akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
int N,X;
vector<int> m;
cin>>N>>X;
int tmp;
int rest=X;
for(int i=0;i<N;i++){
    cin>>tmp;
    rest-=tmp;
    m.push_back(tmp);
}

sort(m.begin(),m.end());

int cnt=N;
while(true){
    rest-=m[0];
    if(rest<0) break;
    cnt++;
}
cout<<cnt<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	char b;
	cin>>b;
	if(b=='A')
	{
		cout<<"T";
	}
	if(b=='T')
	{
		cout<<"A";
	}
	if(b=='C')
	{
		cout<<"G";
	}
	if(b=='G')
	{
		cout<<"C";
	}
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()


def check(subs):
    start = 0
    for x in subs:
        index = S.find(x, start)
        if index == -1:
            return False
        start = index + 1
    return True


ans = 0
for i in range(1000):
    s = '0' * (3 - len(str(i))) + str(i)
    if check(s):
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>

typedef long long ll;

using namespace std;

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

	vector<int> rev(N);
	for (int i = 0; i < N; i++) {
		rev[A[i]-1]=i+1;
	}

	for (int i = 0; i < N; i++) {
		cout << rev[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline

from collections import deque
N,Q = (int(x) for x in input().split())
S = list(input())
d = deque(S)
cum = [0] * N
count = 0
t1 = d.popleft()
for i in range(1,N):
    t2 = d.popleft()
    if t1 == 'A' and t2 == 'C':
        count += 1
    cum[i] = count
    t1 = t2
for i in range(Q):
    l,r = (int(x) for x in input().split())
    print(cum[r-1]-cum[l-1])

Measured memory_bytes: 79544
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#define mp(x,y) make_pair(x,y)
using namespace std;

typedef pair<int,int> pi;

const int N=100005;

int n,f[N];
set<int> se[N];
map<pi,int> ma;
queue<pi> que;

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

int find(int x)
{
	if (f[x]==x) return x;
	else return f[x]=find(f[x]);
}

int main()
{
	n=read();
	for (int i=1;i<=n*2-2;i++)
	{
		int x=read(),y=read();
		se[x].insert(y);se[y].insert(x);
		ma[mp(x,y)]++;ma[mp(y,x)]++;
		if (ma[mp(x,y)]==2) que.push(mp(x,y));
	}
	for (int i=1;i<=n;i++) f[i]=i;
	set<int>::iterator it;
	while (!que.empty())
	{
		int x=que.front().first,y=que.front().second;que.pop();
		x=find(x);y=find(y);
		se[x].erase(y);se[y].erase(x);
		if (se[x].size()<se[y].size()) swap(x,y);
		for (it=se[y].begin();it!=se[y].end();it++)
		{
			int to=(*it);
			ma[mp(to,y)]=ma[mp(y,to)]=0;
			se[to].erase(y);se[to].insert(x);
			ma[mp(to,x)]++;ma[mp(x,to)]++;
			if (ma[mp(to,x)]==2) que.push(mp(to,x));
			se[x].insert(to);
		}
		f[y]=x;
		se[y].clear();
	}
	int s=0;
	for (int i=1;i<=n;i++) s+=f[i]==i;
	if (s==1) puts("YES");
	else puts("NO");
	return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a>b){
    for(int i=0;i<a;i++){
      cout<<b;
    }
  }
  else{
    for(int i=0;i<b;i++){
      cout<<a;
    }
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long res = 0l;
		int[][] q = new int[m][2];
		PriorityQueue<Integer> pq = new PriorityQueue<>();
		
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			pq.offer(a);
			res += a;
		}
		
		for (int i = 0; i < m; i++) {
			q[i][0] = sc.nextInt();
			q[i][1] = sc.nextInt();
		}
		Arrays.sort(q, (a, b) -> (b[1] - a[1]));
		
		for (int i = 0; i < m; i++) {
			int b = q[i][0];
			int c = q[i][1];
			int min = pq.peek();
			if (c < min) { break;}
			
			while (b > 0) {
				min = pq.poll();
				if (c > min) {
					pq.offer(c);
					res = res - min + c;
				} else {
					pq.offer(min);
					break;
				}
				b--;
			}
		}
			
		
		
		/*while (!pq.isEmpty()) {
			res += pq.poll();
		}*/
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    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());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 49268
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()

a.sort(reverse=True)
ans=1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21648
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 300005

int main()
{
    int N;
    read(N);
    REP(i, 50001) {
        if(int(float(i) * 1.08) == N) {
            print(i);
            return 0;
        }
    }
    print(":(");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    while (true) {
        bool ok = true;
        for (int i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            break;
        }
        x++;
    }
    cout << x << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
    res = 0
    for b in range(k+1, n+1):
        q, r = divmod(n, b)
        res += q * (b - k) + max(0, r - (max(k, 1) - 1))
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
PROGRAM november30
      IMPLICIT NONE
      integer :: a(2),b(2)
      
      read*,a
      read*,b
      
      if( a(1)/=b(1) )then
        print'(i0)',1
      else
        print'(i0)',0
      end if
      
      
      
      
      
      
      END PROGRAM

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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

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

	vector<int> p(n);
	REP(i, n){
		cin >> p[i];
	}

	if(n == k){
		cout << 1 << endl;
		return 0;
	}

	int ans = n-k+1;
	int cnt = 0, sum = 0;
	REP(i, n-1){
		if(p[i] < p[i+1]) cnt++;
		else cnt = 0;
		if(cnt == k-1) sum++;
	}
	if(sum > 1) ans -= sum-1;

	set<int> st;
	REP(i, n){
		st.insert(p[i]);
		if(i >= k){
			if(p[i] == *st.rbegin() && p[i-k] == *st.begin()) ans--;
			st.erase(p[i-k]);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
ll x,y;
ll used[200005];
char s[305][305];
ll ans=0;
ll v=-1,w;

int main(){
	int n,m;
	int x,y;
	cin>>n>>m;
	int a[55];
	re(i,0,n){
		a[i]=0;
	}
	re(i,0,m-1){
		cin>>x>>y;
		a[x]+=1;
		a[y]+=1;
	}
	re(i,1,n){
		pe(a[i]);
	}
	p("");
	return 0;
}

Measured memory_bytes: 4992
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* ]]] */

int main(){
  string s;
  cin >> s;
  string t;
  each(c, s){
    if (c == 'T' && t.size() > 0 && t.back() == 'S') t.pop_back();
    else t += c;
  }
  cout << t.size() << endl;
}



Measured memory_bytes: 916
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


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

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

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

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,h,m;

	cin >> a >> b >> h >>m;

	long double rad = 2.0 * M_PI * ((double long)h / 12.0 + (double long)m / 60.0 / 12.0 - (double long)m / 60.0);

	double long length = (double long)(a * a + b * b) - (double long)(2.0 * a * b) * cos(rad);
	cout << fixed << setprecision(12);
	cout << sqrtl(length);
	
	
	

	
		
	



}
	

Measured memory_bytes: 4116
#include<stdio.h>
 
int main(){
 int n,x,i;
 int y,l=0; 
  int count = 1;
  scanf("%d %d",&n,&x);

  for(i=0;i<n;i++){
  	scanf("%d",&y);
    //  printf("%d\n",y);
  	l += y;
    if(l<=x){
    count++;
    }
	else
      break;
  }
printf("%d\n",count);
}

Measured memory_bytes: 128
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<string> ans(n);
  vector<string> s(n);

  REP(i, n) { cin >> s[i]; }
  REP(i, n) {
    if (s[i] == "AB") {
      if (a == b && i < n - 1) {
        int j = i + 1;
        if (s[j] == "AB") {
          a++;
          b--;
          ans[i] = "A";
        } else if (s[j] == "AC") {
          a++;
          b--;
          ans[i] = "A";
        } else if (s[j] == "BC") {
          a--;
          b++;
          ans[i] = "B";
        }

      } else if (a < b) {
        a++;
        b--;
        ans[i] = "A";
      } else {
        a--;
        b++;
        ans[i] = "B";
      }
    } else if (s[i] == "BC") {
      if (b == c && i < n - 1) {
        int j = i + 1;
        if (s[j] == "AB") {
          b++;
          c--;
          ans[i] = "B";
        } else if (s[j] == "AC") {
          b--;
          c++;
          ans[i] = "C";
        } else if (s[j] == "BC") {
          b++;
          c--;
          ans[i] = "B";
        }
      } else if (b < c) {
        b++;
        c--;
        ans[i] = "B";
      } else {
        b--;
        c++;
        ans[i] = "C";
      }
    } else if (s[i] == "AC") {
      if (a == c && i < n - 1) {
        int j = i + 1;
        if (s[j] == "AB") {
          a++;
          c--;
          ans[i] = "A";
        } else if (s[j] == "AC") {
          a++;
          c--;
          ans[i] = "A";
        } else if (s[j] == "BC") {
          a--;
          c++;
          ans[i] = "C";
        }
      } else if (a < c) {
        a++;
        c--;
        ans[i] = "A";
      } else {
        a--;
        c++;
        ans[i] = "C";
      }
    }

    if (a < 0 || b < 0 || c < 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  REP(i, n) { cout << ans[i] << "\n"; }
  return 0;
}


Measured memory_bytes: 9516
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

S = sys.stdin.buffer.readline().decode().rstrip()


def ok1():
    N = len(S)
    s = S[:(N - 1) // 2]
    return s == s[::-1]


def ok2():
    N = len(S)
    s = S[(N + 3) // 2 - 1:]
    return s == s[::-1]


ok = True
ok &= S == S[::-1]
ok &= ok1()
ok &= ok2()
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 24908
#include<stdio.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(int);
void visit(int);

int V,u,a[101][101],d[101],f[101],time,color[101];

int main(){
  int i,j,v,k;

  scanf("%d",&V);
  for(i=1;i<=V;i++){
     for(j=1;j<=V;j++){
       a[i][j]=0;
     }
  }
  for(i=1;i<=V;i++){
    scanf("%d%d",&u,&k);
    color[u]=WHITE;
    if(k!=0){
      for(j=1;j<=k;j++){
	scanf("%d",&v);
	a[i][v]=1;
      }
    }
  }
  for(i=1;i<=V;i++){
  dfs(i);
  }
  for(i=1;i<=V;i++){
    printf("%d %d ",i,d[i]);
    printf("%d\n",f[i]);
    }
  
  return 0;
}

void dfs(int u){
  for(u=1;u<=V;u++){
    color[u]=WHITE;
  }
  time=0;
  for(u=1;u<=V;u++){
    if(color[u]==WHITE){
      visit(u);
    }
  }
}

void visit(int u){
  int i;
  color[u]=GRAY;
  d[u] = ++time;
  for(i=1;i<=V;i++){
    if(a[u][i]==1 && color[i]==WHITE){
      visit(i);
    }
  }
  color[u]=BLACK;
  f[u] = ++time;
}
  



Measured memory_bytes: 2052
s = list(input())
lis = ["A","T","G","C"]
ans = []
for i in range(len(s)):
    cnt = 0
    for j in range(len(s)-i):
        if s[i+j] in lis:
            cnt +=1
        else:
            ans.append(cnt)
            break
    else:ans.append(cnt)
print(max(ans))


Measured memory_bytes: 3060
a, b = map(int, raw_input().split())

def gcd(a,b):
	c = a%b
	if c==0:
		return b
	elif c == 1:
		return c
	else:
		return gcd(b, c)

if a > b:
	print gcd(a, b)
elif a < b:
	print gcd(b, a)
else:
	print a

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

int main(){
    int n,m,x;
    cin >>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
        }
    }

    int ans=12345678;
    rep(tmp, (1<<n)){
        vector<int> level(m);
        int cnt=0;
        rep(i, n){
            if((tmp>>i)&1){
                cnt += c[i];
                rep(j, m){
                    level[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        rep(j, m){
            if(level[j]<x)
                ok=false;
        }
        if(ok) ans = min(ans,cnt);
    }
    if(ans==12345678) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3620
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    a, b = map(str, input().split())
    a = int(a)
    b = int(b[0] + b[2:])
    print((a * b) // 100)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

void Main()
{
  ll n; cin >> n;
  vector<P> a(n);
  rep(i,n) cin >> a[i].second >> a[i].first;
  sort(a.begin(), a.end());
  ll time = 0;
  rep(i,n) {
    time += a[i].second;
    if (time > a[i].first) {
      cout << "No" << endl; return;
    }
  }
  cout << "Yes" << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 6348
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int judge=0;
  for(int i=0;i<s.size();i++){
    if(s[i]==t[i]){
      judge++;
    }
  }
  if(judge==s.size()) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3624
ll =  list('1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', '))

k = int(input())

print(ll[k - 1])

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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,a;
    int mem[300000]={0};
    cin>>n;

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

    for (int i=1; i<n; i++) {
        cout<<mem[i]<<endl;
    }
    cout<<0<<endl;
}



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

using namespace std;

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

	vector<pair<pair<string, int>, int>> list(N);

	for (int i = 0; i < N; i++)
	{
		string s;
		int p;
		cin >> s >> p;
		list[i] = make_pair(make_pair(s, p), i + 1);
	}

	sort(list.begin(), list.end(),
		[](const pair<pair<string, int>, int>& x, const pair<pair<string, int>, int>& y)
		{
			if (x.first.first == y.first.first) {
				return x.first.second > y.first.second;
			}
			else {
				return x.first.first < y.first.first;
			}
		});

	for (auto i : list) {
		cout << i.second << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#!python3

LI = lambda: list(map(int, input().split()))

# input
A, V = LI()
B, W = LI()
T = int(input())


def main():
    if V <= W:
        ans = "NO"
    else:
        x = (V - W) * T
        if abs(A - B) > x:
            ans = "NO"
        else:
            ans = "YES"
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  int n , m;
cin >> n >> m;
  vector<int> g[n];
  for(int i = 0; i < m; i++){
int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
  }
  double ans=1e9;
  for(int u = 0; u < n; u++){
vector<double> dp(n);
  for(int i = n-1; i >= 0; i--){
    double s = 0 ,m = 0;
     int c = 0;
    for(int j: g[i]){
c++;
      s += dp[j]; 
      m  = max(m, dp[j]);
}
    if(!c){
dp [i]  = 0;
      continue;
    }
    
    if(u == i){
if(c > 1){
c--;
  s -= m;
}
}
dp[i] = s / c + 1;
}
      ans = min( ans, dp[0]);
  }
  printf("%.10lf\n", ans);
}

Measured memory_bytes: 1408
N, K = map(int, input().split())
A = list(map(int, input().split()))
e = [False] * (N+1)
idx = 1
move = []
while True:
  if e[idx]:
    break
  move.append(idx)
  e[idx] = True
  idx = A[idx-1]
m = move.index(idx)
c = len(move) - m

if K <= m:
    print(move[K])
else:
    print(move[m+(K-m) % c])


Measured memory_bytes: 32380
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
map<char,int> cnt;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        cnt[s[0]]++;
    }
    
}

int solve(){
    ll ans = 0;
    vector<char> MARCH;
    MARCH = {'M','A','R','C','H'};
    vector<bool> choice(5,false);
    for (int i = 0; i < 3; i++) choice[i] = true;
    do
    {
        ll tmp = 1;
        for (int i = 0; i < 5; i++)
        {
            if(choice[i]) tmp *= cnt[MARCH[i]];
        }
        ans += tmp;
        
    } while (prev_permutation(choice.begin(),choice.end()));
    cout << ans << endl;

    return 0;
}   

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


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

using namespace std;

struct edge {
  int to;
  string cost;
  edge(int to = -1, string cost = ""):to(to), cost(cost){}
};

using Graph = vector<vector<edge>>;

int n, a, s, g;
Graph graph;

struct State {
  int now;
  string str;
  State(int now = -1, string str = ""):now(now), str(str){}
  bool operator < (const State& st) const {
    return str > st.str;
  }
};

string mincost[44][444];
string dijkstra() {
  fill(mincost[0], mincost[44], "~");
  priority_queue<State> que;
  que.emplace(s, "");
  mincost[s][0] = "";
  while(!que.empty()) {
    State st = que.top(); que.pop();
    if(mincost[st.now][st.str.size()] < st.str) continue;
    for(edge& e : graph[st.now]) {
      string ns = st.str + e.cost;
      if(ns.size() >= 444) continue;
      if(mincost[e.to][ns.size()] > ns) {
	que.emplace(e.to, ns);
	mincost[e.to][ns.size()] = ns;
      }
    }
  }
  string res = "~";
  for(int i = 0; i < 444; i++) {
    if(res > mincost[g][i]) {
      res = mincost[g][i];
      if(i > 400) return "NO";
    }
  }
  return res == "~" ? "NO" : res;
}

int main() {
  while(cin >> n >> a >> s >> g, n || a || s || g) {
    graph.clear();
    graph.resize(n);
    for(int i = 0; i < a; i++) {
      int x, y;
      string lab;
      cin >> x >> y >> lab;
      graph[x].emplace_back(y, lab);
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

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

void sort( int* a, int n )
{
    for( int i = 0; i < n - 1; i++ )
        for( int j = i + 1; j < n; j++ )
        {
            if( a[i] > a[j] )
            {
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
}

int main()
{
    int n, m;

    cin >> n >> m;

    int w[m], l[m], cnt = 0;
    for( int i = 0; i < m; i++ )
    {
        cin >> w[i] >> l[m];
        if( w[i] >= n )
            cnt++;
    }

    sort( w, m );

    int i = m - 1, sum = 0;
    while( cnt < m - 1 )
    {
        if( w[i] < n )
        {
            sum += n - w[i];
            cnt++;
        }
        i--;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b, c, d;
    
    scanf("%d%d%d%d",&a,&b,&c,&d);
    
    while((a>0)&&(c>0)){
        c=c-b;
        if(c<=0){
            printf("Yes\n");
            return 0;
        }
        a=a-d;
        if(a<=0){
            printf("No\n");
            return 0;
        }
    }
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<string> S(N);
    cin >> S;

    auto check = [&]() {
        bool ok = true;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (S[i][j] != S[j][i]) ok = false;
            }
        }
        return ok;
    };
    int ans = 0;

    for (int i = 0; i < N; i++) {
        if (check()) ++ans;

        for (int j = 0; j < N; j++) {
            S[j] = S[j].substr(1) + S[j][0];
        }
    }
    cout << ans * N << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] member = new int[n];
    for(int i = 1; i <= n; i++) {
      member[Integer.parseInt(sc.next())-1] = i;
    }
    StringBuilder sb = new StringBuilder();
    sb.append(member[0]);
    for(int i = 1; i < n; i++) sb.append(" " + member[i]);
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 46884
_=input()
S=input()
numc=0
numw=0
numcmin=0
for s in S:
    if s == '#':
        numc += 1
    else:
        numw += 1
        numc -= 1
        if numc < numcmin:
            numcmin = numc
print(numcmin+numw)

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

int main(){

int h,w;
h=0,w=0;

while(true){
    cin >> h >> w; 
        rep(i,h){
            rep(j,w){
                if(i == 0 || i == h-1 || j == 0 || j == w-1 ) 
                    cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
  if (h == 0 && w == 0) break;
    cout << endl;
}
}


Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define ceil(a,b) (((a)+(b)-1)/(b))
#define dist(a,b) max((a)-(b),(b)-(a))
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}



int main(){
  int n,k; cin >>n >>k;
  vector<int> v(n); rep(i,n) cin >>v[i];
  int f=0;
  rep(i,k){
    if(f)break;
    vector<int> d(n,0);
    rep(j,n){
      int a,b;
      a=max(0,j-v[j]);
      b=j+v[j]+1;
      d[a]++;
      if(b<n)d[b]--;
    }
    int tmp=0;
    f=1;
    rep(j,n){
      tmp+=d[j];
      v[j]=tmp;
      if(v[j]!=n)f=0;
    }
    if(df)print(v);
  }
  print(v);
}





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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	ll n,m;
	cin>>n>>m;
	vll x(n+2,0);
	for(ll i=0;i<m;i++) {
		cin>>y;
		x[y]+=1;
		cin>>y;
		x[y+1]-=1;
	}
	for(ll i=2;i<=n;i++) {
		x[i] += x[i-1];
	} 
	ll cnt = 0;
	for(ll i=1;i<=n;i++) {
		if(x[i] >= m) cnt++; 
	}
	cout<<cnt;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3952
using System;
using System.Linq;

namespace ABC125D
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long N = ConsoleInput.Long();
            long[] A = ConsoleInput.LongArray();

            long ans = 0;
            long absmin = Int32.MaxValue;
            long minusCount = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] < 0)
                {
                    minusCount++;
                }
                ans += Math.Abs(A[i]);
                absmin = Math.Min(Math.Abs(A[i]), absmin);
            }

            if (minusCount % 2 == 1)
            {
                ans -= 2 * absmin;
            }
            
            Console.WriteLine(ans);
        }
    }
    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 33372
#include <bits/stdc++.h>
 
using namespace std;
 
int digit(int n)
{
  set<int> s;
  while(n!=0)
  {
    s.insert(n%10);
    n/=10;
  }
  
  if(s.size()==1)
      return 1;
  
  else
     return 0;
}
int main()
{
   int i,n;
   cin>>n;
  
   for(i=n;;++i)
   {
       if(digit(i))
           break;
     
   }
  
  cout<<i;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
int main(){
  int n,q,i,j,l=0,r,mid,count=0;
  int S[MAX],T[MAX];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    r=n;
    l=0;
    scanf("%d",&T[i]);
    while(l<r){
      mid=(l+r)/2;
      //printf("\nmid = %d key = %d\n",mid,T[i]);
      if(S[mid]==T[i]){
	count+=1;
	break;
      }
      else if(S[mid]<T[i]){
	l=mid+1;
      }
      else{
	r=mid;
      }
      
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define fr(x,y) for(int x=0; x<(y); ++x)
#define fr2(x,z,y) for(int x=z; x<(y); ++x)
#define Rabee_Adel          file();
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y){if (y == 0)return 1;if (y == 1)return x;ll r = power(x, y / 2) % mod;return r%mod*r%mod*power(x, y % 2) % mod;}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int main()
{

	Rabee_Adel
		int n, m, x = 0; cin >> n >> m;
	ll sum = 0;
	fr(i, m)
	{
		cin >> x;
		sum += x;
	}
	if (sum > n)cout << "-1";
	else cout << n-sum;
	 
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
const int maxn = 11;
char g[maxn][maxn];
int cnt = 0, n, m;
void dfs(int i, int j){
	cnt++;
	if(i == n && j == m) return;
	if(g[i + 1][j] == '#'){
		dfs(i + 1, j);
		return;
	}
	if(g[i][j + 1] == '#'){
		dfs(i, j + 1);
		return;
	}
}
int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> g[i + 1][j + 1];
	int need = 0;
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) if(g[i][j] == '#') need++;
	if(g[1][1] == '#')dfs(1, 1);
	if(need == cnt) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<vector>
#include<string>
using namespace std;

signed main() {
	string k; cin >> k;
	int a = k[0] - '0', b = k[1] - '0', c = k[2] - '0', d = k[3] - '0';
	if (a + b + c + d == 7) {
		printf("%d+%d+%d+%d=7\n", a, b, c, d);
	}
	else if (a + b + c - d == 7) {
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
	}
	else if (a + b - c + d == 7) {
		printf("%d+%d-%d+%d=7\n", a, b, c, d);
	}
	else if (a + b - c - d == 7) {
		printf("%d+%d-%d-%d=7\n", a, b, c, d);
	}
	else if (a - b + c + d == 7) {
		printf("%d-%d+%d+%d=7\n", a, b, c, d);
	}
	else if (a - b + c - d == 7) {
		printf("%d-%d+%d-%d=7\n", a, b, c, d);
	}
	else if (a - b - c + d == 7) {
		printf("%d-%d-%d+%d=7\n", a, b, c, d);
	}
	else {
		printf("%d-%d-%d-%d=7\n", a, b, c, d);
	}
}

Measured memory_bytes: 256
import numpy as np
n,m,c = map(int,input().split())
count = 0
t = np.zeros(n,dtype=int)
b = list(map(int,input().split()))
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(m):
        t[i]+=a[j]*b[j]
    if t[i] + c > 0:
        count+=1
print(count)

Measured memory_bytes: 12396
#include <iostream>

using namespace std;

int main() {
  int N = 0;
  cin >> N;
  int Hmax = 0; 
  int H = 0;
  int count = 0;
  for(int i=0;i<N;i++) {
    cin >> H;
    if (H >= Hmax) {
      	count++;
      	Hmax = H;
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 256
// ref: https://img.atcoder.jp/arc092/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

vector<int> mask(const vector<int>& vB, const int k){
    int m=1; for(int i=0; i<k; ++i){ m<<=1; m+=1; }
    vector<int> v_ret=vB; for(uint i=0; i<v_ret.size(); ++i){ v_ret[i]&=m; }
    return v_ret;
}

int cnt_range(const vector<int>& v, const int a, const int b){ // [a, b)
    int lo = lower_bound(v.begin(), v.end(), a) - v.begin();
    int hi = lower_bound(v.begin(), v.end(), b) - v.begin() - 1;
    return hi-lo;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int digs=28+1;
    int N; cin >> N;
    vector<int> vA(N); for(int i=0; i<N; ++i){ cin >> vA[i]; }
    vector<int> vB(N); for(int i=0; i<N; ++i){ cin >> vB[i]; }
    
    int ans=0;
    for(int k=digs-1; k>=0; --k){
        ans <<= 1;
        vector<int> vA_m = mask(vA, k);
        vector<int> vB_m = mask(vB, k);
        sort(vB_m.begin(), vB_m.end());
        vB_m.push_back( INT_MAX );
        
        int cnt = 0;
        int T=1<<k; // pow(2, k)
        for(int i=0; i<N; ++i){
            cnt += cnt_range(vB_m, 1*T-vA_m[i], 2*T-vA_m[i]); // [ T, 2T)
            cnt += cnt_range(vB_m, 3*T-vA_m[i], 4*T-vA_m[i]); // [3T, 4T)
        }
        if(cnt & 1){ ans+=1; }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int a[100];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	int alice = 0;
	int bob = 0;
	for (int i = 0; i < n; ++i)
	{
		if(i % 2 == 0)
			alice = alice + a[i];
		else
			bob = bob + a[i];
	}
	cout << alice - bob;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

struct RLAQ{
  int sst[1<<18];
  int adt[1<<18];
  RLAQ(){
    fill(sst,sst+(1<<18),0);
    fill(adt,adt+(1<<18),0);
  }
  void add(int p, int q, int x, int k=0, int l=0, int r=(1<<17)){
    if(r <= p || q <= l) return;
    if(p <= l && r <= q){
      adt[k] += x;
      return;
    }
    add(p, q, x, 2*k+1, l, (l+r)/2);
    add(p, q, x, 2*k+2, (l+r)/2, r);
    sst[k]=min(sst[2*k+1]+adt[2*k+1],sst[2*k+2]+adt[2*k+2]);
  }
  int find(int p, int q, int k=0, int l=0, int r=(1<<17)){
    if(r <= p || q <= l) return INT_MAX;
    if(p <= l && r <= q) return sst[k]+adt[k];
    int m1, m2;
    m1 = find(p,q,2*k+1,l,(l+r)/2);
    m2 = find(p,q,2*k+2,(l+r)/2,r);
    return min(m1,m2)+adt[k];
  }
};

signed main(){
  int n,m,s=0,ans=0;
  cin>>n>>m;
  priority_queue<P>q;
  vector<P>v;
  r(i,n){
    int a,b;
    cin>>a>>b;
    q.push(P(b,a));
  }
  r(i,m){
    int a,b;
    cin>>a>>b;
    v.push_back(P(a,b));
  }
  v.push_back(P(-1,1000000));
  sort(v.begin(),v.end());
  RLAQ R;
  r(i,m+1){
    R.add(i,i+1,v[i].se);
    //cout<<v[i].se<<endl;
  }
  //r(i,4)cout<<R.find(0,i+1)<<endl;
  while(!q.empty()){
    P p=q.top();q.pop();
    int r=p.first;
    int l=p.second;
    int x=upper_bound(v.begin(),v.end(),P(l,1000000009))-v.begin();
    //cout<<x<<endl;
    int Q=R.find(0,x);
    //cout<<Q<<endl;
    if(Q>1){
      R.add(0,x,-1);
      ans+=r;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10208
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9
using namespace std;

inline void up(int &x,const int &y){if(x<y)x=y;}
inline void down(int &x,const int &y){if(x>y)x=y;}
const int maxn = 11000;

int n;
char s1[maxn],s2[maxn];
int pre1[maxn],pre2[maxn],topre[maxn],nex[maxn];

int cal(const int x,const int y)
{
	if(x<y) return pre2[x]+pre2[n]-pre2[y-1];
	else return pre2[x]-pre2[y-1];
}
int find_pre(const int x)
{
	if(topre[x]) return x-topre[x];
	else return x+n-topre[n];
}
int find_nex(const int x)
{
	if(nex[x]!=n+1) return nex[x]-x;
	else return nex[1]+n-x;
}
struct node{int left,right;}t[maxn]; int tp,mx[maxn];
inline bool cmp(const node x,const node y){return x.left<y.left;}
int solve()
{
	int re=inf;
	for(int i=0;i<n;i++)
	{
		int now=0; tp=0;
		for(int j=1;j<=n;j++)
		{
			int r=j-i<=0?j-i+n:j-i;
			if(s1[j]!=s2[r]) 
			{
				now++;
				if(s1[j]=='0') continue;
				if(cal(j,r)==0)	t[++tp]=(node){find_pre(r),find_nex(j)};
			}
		}
		sort(t+1,t+tp+1,cmp);
		int cost; mx[tp+1]=0;
		for(int j=tp;j>=1;j--) mx[j]=max(mx[j+1],t[j].right);
		cost=mx[1]*2;
		for(int j=1;j<=tp;j++)
		{
			int k=j+1;for(;k<=tp&&t[k].left==t[j].left;k++);k--;
			down(cost,2*(t[j].left+mx[k+1]));
			j=k;
		}
		down(cost,n);
		if(!tp) cost=0;
		down(re,now+cost+i);
	}
	return re;
}

int main()
{
	scanf("%s",s1+1); scanf("%s",s2+1); n=strlen(s1+1);
	for(int i=1;i<=n;i++)
		pre1[i]=pre1[i-1]+(s1[i]-'0'),
		pre2[i]=pre2[i-1]+(s2[i]-'0');
	for(int las=0,i=1;i<=n;i++)
	{
		if(s2[i]=='1') las=i;
		topre[i]=las;
	}
	for(int las=n+1,i=n;i>=1;i--)
	{
		if(s2[i]=='1') las=i;
		nex[i]=las;
	}
	if(pre1[n]&&!pre2[n]) {puts("-1");return 0;}
	
	int ans=solve();
	
	for(int i=1;i*2<=n;i++)
		swap(s1[i],s1[n-i+1]),
		swap(s2[i],s2[n-i+1]);
	for(int i=1;i<=n;i++)
		pre1[i]=pre1[i-1]+(s1[i]-'0'),
		pre2[i]=pre2[i-1]+(s2[i]-'0');
	for(int las=0,i=1;i<=n;i++)
	{
		if(s2[i]=='1') las=i;
		topre[i]=las;
	}
	for(int las=n+1,i=n;i>=1;i--)
	{
		if(s2[i]=='1') las=i;
		nex[i]=las;
	}
	down(ans,solve());
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 384