akhauriyash/Code-Regression huggingface dataset:
N = int(input())
res = []
for i in range(N):
    name, point = input().split()
    point = int(point)
    res.append((name, point, len(res) + 1))
res = sorted(res, key=lambda x: (x[0], -x[1]))
for name, point, idx in res:
    print(idx)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, H;
  cin>>N>>H;
  vector<ll> a(N), b(N);
  for(int i=0;i<N;++i) cin>>a[i]>>b[i];
  sort(a.begin(), a.end(), greater<ll>());
  sort(b.begin(), b.end(), greater<ll>());
  ll attack = a[0];
  ll nage = 0;
  ll num = 0;
  bool kati = false;
  for(int i=0;i<N;++i) {
    if(attack<b[i]) {
      nage += b[i];
      num++;
      if(nage>=H) {
        kati = true;
        break;
      }
    }
  }
  if(kati) {
    cout<<num<<endl;
    return 0;
  }
  H -= nage;
  if(H%a[0]==0) {
    cout<<H/a[0]+num<<endl;
  }
  else {
    cout<<H/a[0]+1+num<<endl;
  }
}



Measured memory_bytes: 4748
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
c = 0
ans = 0
for i in range(n):
    if s[i]=="W":
        ans += c
    else:
        c += 1
print(ans)

Measured memory_bytes: 65284
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}


#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

int main() {
  int in(N); int in(M);

  vector<queue<int>> A(N, queue<int>());
  rep(i, N) rep(j, M) {
    int in(a);
    A[i].push(a);
  }

  set<int> used;
  int ans = N;
  rep(i, M) {
    map<int, int> count;
    rep(j, N) {
      while (!A[j].empty() && used.find(A[j].front()) != used.end())
        A[j].pop();
      ++count[A[j].front()];
    }
    int max_count = 0, max_num;
    for (const auto& e : count) {
      int num = e.first, count = e.second;
      if (chmax(max_count, count)) max_num = num;
    }
    chmin(ans, max_count);
    used.insert(max_num);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;
import java.io.IOException;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int a = scan.nextInt();
			String str = scan.next();
			int b = scan.nextInt();
			if (str.equals("?")) {
				break;
			}
			switch (str) {
			case "+":
				System.out.println(a + b);
				break;
			case "-":
				System.out.println(a - b);
				break;
			case "*":
				System.out.println(a * b);
				break;
			case "/":
				System.out.println(a / b);
				break;
			}
		}
	}
}

Measured memory_bytes: 26428
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==n){
        cout<<"Yes"<<endl;
        return(0);
      }
    }
  }
  cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
S = input()
n = len(S)-1
ans = 0
for i in range(2**n):
    add = 0
    expr = list(S)
    for j in range(n):
        if ((i >> j) & 1):
            expr.insert(j+1+add, "+")
            add += 1
    ans += eval("".join(expr))
print(ans)


Measured memory_bytes: 3060
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
v = gets.chomp.split.map(&:to_i)

ans = 0
([k+1,n+1].min).times do |l|
  ([k-l+1,n+1].min).times do |r|
    deletable_count = (k-l-r)
    ar = l+r >= n ? v.dup : v.slice(0,l) + v.slice(n-r,r)
    ar.sort!
    [deletable_count, ar.size].min.times do |i|
      break if ar[i].nil? || ar[i] >= 0
      ar[i] = 0
    end
    sum = ar.inject(&:+) || 0
    # p [l,r,deletable_count, ' ', sum]
    ans = sum if ans < sum
  end
end

puts ans


Measured memory_bytes: 2812
/**< 🤣🤣🤣 */
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define deb(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define all(x) x.begin(),x.end()
#define deb1(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << #z << " " << z << endl;
#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)
#define RFOR(I,B,A) for(ll I = (B); I >=(A); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
template<typename T>T gcd(T x, T y){if(y==0)return x;else return gcd(y,x%y);}
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const ll INF = 1e18;
const int mod = 1e9+7;
const int inf = 1e9;
const int mx = 32000;
vector<ll>a1,b1,c1;
map<ll,ll>m1,m2,m3;
bool isPrime[mx];

ll POWER(ll y,ll z){ll res=1;while(z){if(z%2==1){res=(res*y)%mod;}y=(y*y)%mod;z>>=1LL;}return res;}
void sieve(){for(ll i=2; i<=mx; i++)isPrime[i]=true;for(ll i=3; i<=mx; i+=2){if(isPrime[i]==true)
{for(ll J=i*i; J<=mx; J+=i)isPrime[J]=false;}}}

/************************************************/

void Execute()
{
      ll n, nb, val, q, a, b, c, l, r, d, x, y, p, m;
      string s, s1;
      cin >> s >> s1;
      ll con = 0;

      FOR(i,0,s.size()-1)
      {
        if(s[i]!=s1[i]) con++;
      }
      deb(con);

}

int32_t main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("atomm.txt", "r", stdin);
    //#endif

    FAST();
  //  CASES
  //  {
       Execute();
        //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "sec \n";
  //  }
}
/**< 🤣🤣🤣 */


Measured memory_bytes: 3796
/*
 *    author:  Gary Shih
 *    created: 2020-05-04 19:20:13
 */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  vector<vector<long long>> dp(n, vector<long long>(n, INT_MIN));
  for (int i = 0; i < n; ++i) dp[i][i] = ((n & 1) ? a[i] : -a[i]);
  for (int len = 2; len <= n; ++len) {
    for (int i = 0; i < n - len + 1; ++i) {
      int j = i + len - 1;
      if ((n - len) & 1) {
        dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j]);
      } else {
        dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j]);
      }
    }
  }
  cout << dp[0][n - 1] << '\n';
}


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

class mylist {
	struct elem_t {
		int x;
		elem_t* prev;
		elem_t* next;
	};
	elem_t* m_top;

public:
	mylist(): m_top( new elem_t ) {
		m_top->x = 0;
		m_top->prev = m_top;
		m_top->next = m_top;
	}

	~mylist() {
		for( elem_t* p = m_top->next; p != m_top; ) {
			elem_t* t = p;
			p = p->next;

			delete t;
		}

		delete m_top;
	}

	void insert( int x ) {
		elem_t* p = new elem_t;

		p->x = x;
		p->prev = m_top;
		p->next = m_top->next;
		m_top->next->prev = p;
		m_top->next = p;
	}

	void del( int x ) {
		elem_t* p = m_top->next;

		while( p != m_top && p->x != x ) {
			p = p->next;
		}

		if( p != m_top ) {
			p->prev->next = p->next;
			p->next->prev = p->prev;

			delete p;
		}
	}

	void delFirst() {
		elem_t* p = m_top->next;

		m_top->next = p->next;
		p->next->prev = m_top;

		if( p != m_top ) {
			delete p;
		}
	}

	void delLast() {
		elem_t* p = m_top->prev;

		m_top->prev = p->prev;
		p->prev->next = m_top;

		if( p != m_top ) {
			delete p;
		}
	}

	void print() {
		elem_t* p = m_top->next;

		while( p != m_top ) {
			cout << p->x;

			if( p->next != m_top ) {
				cout << ' ';
			}

			p = p->next;
		}

		cout << endl;
	}
};

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	mylist ml;
	string cmd;
	int key;

	for( int i = 0; i < n; ++i ) {
		cin >> cmd;

		if( cmd == "insert" ) {
			cin >> key;
			ml.insert( key );
		}
		else if( cmd == "delete" ) {
			cin >> key;
			ml.del( key );
		}
		else if( cmd == "deleteLast" ) {
			ml.delLast();
		}
		else {
			ml.delFirst();
		}
	}

	ml.print();
}



Measured memory_bytes: 34296
#include<cstdio>

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	if(k > (n-1)*(n-2)/2) {
		printf("-1\n");
	} else {
		int m = n*(n-1)/2-k;
		printf("%d\n", m);
		int u = 1, v = 2;
		while(m > 0) {
			printf("%d %d\n", u, v);
			if(v == n) {
				u++;
				v = u + 1;
			} else {
				v++;
			}
			m--;
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int X[]={2,2,3,3,0,0,1,1,0,1,0,1};
  int Y[]={0,1,0,1,0,1,0,1,2,2,3,3};
  int XX[]={0,1,0,-1};
  int YY[]={1,0,-1,0};
  int h,w,sx,sy,gx,gy,n,a,b,c,d,t,r,i,j,k,nx,ny,x[10000],y[10000];
  while(scanf("%d %d",&w,&h),w||h){
    char m[101][101]={0};
    scanf("%d %d %d %d",&sx,&sy,&gx,&gy);
    scanf("%d",&n);
    while(n--){
      scanf("%d %d %d %d",&a,&b,&c,&d);
      for(i=b*4;i<8+b*4;i++)m[d+Y[i]][c+X[i]]=a;
    }
    /*for(i=0;i<h;i++){
      for(j=0;j<w;j++)printf("%d ",m[i][j]);
      printf("\n");
      }*/
    if(m[sy][sx]!=m[gy][gx])printf("NG\n");
    else {
      x[t=0]=sx;
      y[t]=sy;
      m[sy][sx]=0;
      for(r=1;r-t;t++){
	for(k=0;k<4;k++){
	  nx=x[t]+XX[k];
	  ny=y[t]+YY[k];
	  if(nx<1||w<nx||ny<1||h<ny)continue;
	  if(m[gy][gx]==m[ny][nx]){
	    x[r]=nx;
	    y[r]=ny;
	    m[y[r]][x[r++]]=0;
	    if(nx==gx&&ny==gy)break;
	  }
	}
	if(nx==gx&&ny==gy)break;
      }
      /*for(i=0;i<=h;i++){
	for(j=0;j<=w;j++)printf("%d ",m[i][j]);
	printf("\n");
	}*/
      if(r-t)printf("OK\n");
      else   printf("NG\n");
    }
  }
  return 0;
}
 

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;;
typedef struct node {
    int identifier;
    bool is_parent=false;
    int depth;
    int parent=-1;
    list<int> children;
}Node;

string cnvkind(bool p,bool r){
    if(p&&r)return "root";
    else if(p&&!r)return "internal node";
    else return "leaf";
}

void print(Node n,bool is_root){
    cout<<"node "<<n.identifier<<": parent = "<<n.parent<<", depth = "<<n.depth<<", "+cnvkind(n.is_parent,is_root)<<", [";
    int cnt=0;
    for(auto itr : n.children){
        if(cnt++)cout<<", ";
        cout<<itr;
    }
    cout<<"]"<<endl;
}

int main( ){
    int N;
    cin>>N;
    Node info[N];
    vb is_root(N,true);;
    rep(i,0,N){
        int id;
        cin>>id;
        info[id].identifier=id;
        int k;
        cin>>k;
        if(k||N==1)info[id].is_parent=true;
        rep(j,0,k){
            int c;
            cin>>c;
            info[id].children.push_back(c);
            is_root[c]=false;
            info[c].parent=id;
        }
    }
    int root,depth=0;
    rep(i,0,N)if(is_root[i])root=i;
    queue<pii> q;
    q.emplace(root,depth);
    while(!q.empty()){
        pii tmp=q.front(); q.pop();
        info[tmp.first].depth=tmp.second;
        for(int itr:info[tmp.first].children){
            q.emplace(itr,tmp.second+1);
        }
    }
    rep(i,0,N)print(info[i],is_root[i]);
    return 0;
}





Measured memory_bytes: 12564
import sys
input = sys.stdin.readline
import heapq as hp

AM = 50*50+1
INF = 10**15

N, M, S = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    graph[u-1].append((a, b, v-1))
    graph[v-1].append((a, b, u-1))
C = []
D = []
for _ in range(N):
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)

# dp[n][cost] := cost でいけるnの最短
dp = [[INF]*(AM+1) for _ in range(N)]
dp[0][min(AM, S)] = 0
q = [(0, min(AM, S), 0)]
while q:
    dis, cost, p = hp.heappop(q)
    if dp[p][cost] < dis:
        continue
    if 0 <= cost+C[p] <= AM and dp[p][cost+C[p]] > dp[p][cost]+D[p]:
        dp[p][cost+C[p]] = dp[p][cost] + D[p]
        hp.heappush(q, (dp[p][cost+C[p]], cost+C[p], p))
    for a, b, np in graph[p]:
        if 0 <= cost-a <= AM and dp[np][cost-a] > dp[p][cost] + b:
            dp[np][cost-a] = dp[p][cost]+b
            hp.heappush(q, (dp[np][cost-a], cost-a, np))

for n in range(1, N):
    print(min(dp[n]))

Measured memory_bytes: 95244
ans1 = []
ans2 = []
while line = STDIN.gets
	str = line.chomp!.split(//).map(&:to_s)
	list = []
	count1 =0
	count2 =0
	str.length.times do |i|
		if i< 3
			list << str[i]
		if i==2
			t = list[0].to_s+list[1].to_s+list[2].to_s
			if t== "JOI"
				count1 +=1
			elsif t == "IOI"
				count2 +=1
			end
		end
	else
		list.shift
		list << str[i]
		t = list[0].to_s+list[1].to_s+list[2].to_s
			if t== "JOI"
				count1 +=1
			elsif t == "IOI"
				count2 +=1
			end
		end
	end
	ans1 << count1
	ans2 << count2
	
end

ans1.length.times do
	puts ans1.shift
	puts ans2.shift
end

Measured memory_bytes: 8904
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
string check( string s, string t)
{
	int tmp, j;
	for(int i = 0; i < s.size(); i++)
	{
		for(j = 0; j < s.size(); j++)
		{
			tmp = i+j < s.size() ? i+j : i+j - s.size();
			if( s[j] != t[tmp] )
				break;
		}
		if( j == s.size() )
			return "Yes";
	}
	return "No";
}
int main()
{
	string s, t;
	cin >> s >> t;
	cout << check(s,t);
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] mt = new int[10];
		for(int i = 0; i < 10; i++){
			int h = scan.nextInt();
			mt[i] = h;
		}
		for(int i = 0; i < 10 - 1; i++){
			for(int j = 10 - 1; j > i; j--){
				if(mt[i] < mt[j]){
					int big = mt[j];
					mt[j] = mt[i];
					mt[i] = big;
				}
			}
		}
		for(int i = 0; i < 3; i++){
			System.out.printf("%d\n", mt[i]);
		}
	}
}

Measured memory_bytes: 26156
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int cnt = Integer.parseInt(br.readLine());
		
		int taroPoint = 0;
		int hanakoPoint = 0;
		for (int i = 0; i < cnt; i++) {
			String line = br.readLine();
			String[] arr = line.split(" ");
			String taroHand = arr[0];
			String hanakoHand = arr[1];
			
			if (taroHand.compareTo(hanakoHand) > 0) {
				taroPoint += 3;
			}
			else if (taroHand.compareTo(hanakoHand) < 0) {
				hanakoPoint += 3;
			} else {
				taroPoint++;
				hanakoPoint++;
			}
		}
		System.out.println(taroPoint + " " + hanakoPoint);

		if (br != null) {
			br.close();
			br = null;
		}
	}
}

Measured memory_bytes: 20184
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let A = read![[usize]];

    let mut K = 0;

    for &a in &A {
        if a == K + 1 {
            K += 1;
        }
    }

    if K == 0 {
        println!("-1");
    } else {
        println!("{}", N - K);
    }
}


Measured memory_bytes: 10492
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n) cout<<fixed<<setprecision(n);
#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  double a, b; cin >> a >> b;

  for (int i = 1; i / 10 <= b; i++) {
    if (floor(i * 2 / 25) == a && floor(i / 10) == b) {
      outl(i)
      return 0;
    }
  }
  outl(-1)
}


Measured memory_bytes: 888
a, b = map(int, input().split())
if a*b < 0:
  print("Zero")
elif a > 0:
  print("Positive")
elif a == 0 or b == 0:
  print("Zero")
else:
  if (b-a)%2:
    print("Positive")
  else:
    print("Negative")
  


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

int main(){
    ll n, t, q;
    vector<ll> v;
    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> t;
        v.push_back(t);
    }
    cin >> q;
    for(ll i = 0; i < q; i++){
        cin >> t;
        printf("%lld\n", (int) (lower_bound(v.begin(), v.end(), t) - v.begin()));
    }
    return 0;
}


Measured memory_bytes: 3912
import java.util.*;

public class Main {

	static int n;
	static boolean isFound;
	static char[] answer;
	static char[] arr;
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		n = in.nextInt();
		String s = in.next();
		arr = s.toCharArray();
		
		answer = new char[n];
		
		boolean isDone = false;
		
		answer[0] = 'S';
		answer[1] = 'S';
		fill(1);
		if (isConsistent()) {
			isDone = true;
			for (int i = 0; i < n; i++) {
				System.out.printf("%c", answer[i]);
			}
		}
		
		if (!isDone) {
			answer[0] = 'S';
			answer[1] = 'W';
			fill(1);
			if (isConsistent()) {
				isDone = true;
				for (int i = 0; i < n; i++) {
					System.out.printf("%c", answer[i]);
				}
			}
		}
		
		if (!isDone) {
			answer[0] = 'W';
			answer[1] = 'W';
			fill(1);
			if (isConsistent()) {
				isDone = true;
				for (int i = 0; i < n; i++) {
					System.out.printf("%c", answer[i]);
				}
			}
		}

		if (!isDone) {
			answer[0] = 'W';
			answer[1] = 'S';
			fill(1);
			if (isConsistent()) {
				isDone = true;
				for (int i = 0; i < n; i++) {
					System.out.printf("%c", answer[i]);
				}
			}
		}
		
		if (!isDone) {
			System.out.println(-1);
		}
	}
	
	public static void fill(int index) {
		if (index == n - 1) {
			return;
		}
		if (answer[index] == 'S') {
			if (arr[index] == 'o') {
				answer[index + 1] = answer[index - 1];
			} else if (arr[index] == 'x') {
				answer[index + 1] = answer[index - 1] == 'S' ? 'W' : 'S';
			}
		} else {
			if (arr[index] == 'o') {
				answer[index + 1] = answer[index - 1] == 'S' ? 'W' : 'S';
			} else if (arr[index] == 'x') {
				answer[index + 1] = answer[index - 1];
			}
		}
		
		fill(index + 1);
	}
	
	public static boolean isConsistent() {
		int pre, post;
		for (int i = 0; i < n; i++) {
			pre = i == 0 ? n - 1 : i - 1;
			post = i == n - 1 ? 0 : i + 1;
			// pre and post must match
			if ((answer[i] == 'S' && arr[i] == 'o') || (answer[i] == 'W' && arr[i] == 'x')) {
				if (answer[pre] != answer[post]) return false;
			}
			// pre and post must be different
			if ((answer[i] == 'S' && arr[i] == 'x') || (answer[i] == 'W' && arr[i] == 'o')) {
				if (answer[pre] == answer[post]) return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 66940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;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, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    stack<int> st;
    int ans = 0;
    REP(i, SZ(s)) {
        if (!st.empty() && st.top() != s[i]) {
            ans += 2;
            st.pop();
        } else {
            st.push(s[i]);
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



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

public class Main {
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(br.readLine());
		
		int p500 = x / 500;
		int p5 = (x - 500*p500) / 5;
		
		System.out.println(String.format("%d", p500*1000 + p5*5));
	}

}

Measured memory_bytes: 21716
#pragma region Macros
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    ll N;
    cin >> N;
    vec<ll> a(N);
    cpp_int lc = 1;
    REP(i, N){
        cin >> a[i];
        lc *= a[i];
    }
    lc--;
    cpp_int ans = 0;
    REP(i, N){
        ans += lc % a[i];
    }
    cout << ans << el;
}



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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  vector<vector<int>> a(3,vector<int>(3,0));
  vector<vector<bool>> m(3,vector<bool>(3,false));
  rpv(a){
    rep(i,3){cn(v[i])}
  }
  int n;cn(n)
  rep(i,n){
    int t;cn(t)
    rep(x,3){
      rep(y,3){
        if (a[x][y]==t){
          m[x][y] =true;
        }
      }
    }
  }
  rep(x,3){
    if ( (m[x][0] && m[x][1] && m[x][2]) || (m[0][x] && m[1][x] && m[2][x])){
      co("Yes");
      return 0;
    }
  }
  if ( (m[0][0] && m[1][1] && m[2][2]) || (m[0][2] && m[1][1] && m[2][0] )){
    co("Yes")
  }else{
    co("No")
  }
}

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

int main() {
  int n, m;
  std::cin >> n >> m;

  std::vector<std::vector<int>> a(n, std::vector<int>(m, 0));
  std::vector<int> b(m, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      std::cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    std::cin >> b[i];
  }

  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j < m; j++) {
      sum += b[j] * a[i][j];
    }
    std::cout << sum << std::endl;
  }
}



Measured memory_bytes: 3196
N = int(input())
list1 = []
list1 = list(map(int, input().split()))
Sum = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if list1[i] + list1[j] > list1[k] and list1[j] + list1[k] > list1[i] and list1[k] + list1[i] > list1[j]\
            and list1[i] != list1[j] and list1[j] != list1[k] and list1[k] != list1[i]:
                Sum += 1
print(Sum)

Measured memory_bytes: 9204
{-# LANGUAGE BangPatterns, OverloadedStrings #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import qualified Data.Set as S
import System.IO.Unsafe
import Debug.Trace

unew :: VUM.Unbox a => Int -> VUM.IOVector a
unew !n = accursedUnutterablePerformIO $ VUM.unsafeNew n

uread :: VUM.Unbox a => Int -> VUM.IOVector a -> a
uread !i !v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VUM.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite !i !a !v =
  accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

uthaw :: VUM.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw !v = accursedUnutterablePerformIO $ VU.unsafeThaw v

ufreeze :: VUM.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze !v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

solve :: B.ByteString -> B.ByteString -> String
solve !s !t = walk
 where
  toIndex !i !j = j * succ (B.length s) + i
  fromIndex !n = (n `mod` succ (B.length s), n `div` succ (B.length s))

  dp :: VU.Vector Int
  dp = ufreeze $ foldl'
    ( \(!dp) (!n) ->
      let (!i, !j) = fromIndex n
      in  uwrite
            n
            ( if i == 0 || j == 0
              then 0
              else
                let dpij  = uread (toIndex (i - 1) (j - 1)) dp
                    dpisj = uread (toIndex i (j - 1)) dp
                    dpsij = uread (toIndex (i - 1) j) dp
                    si    = s `B.index` (i - 1)
                    tj    = t `B.index` (j - 1)
                in  if si == tj then dpij + 1 else max dpisj dpsij
            )
            dp
    )
    (unew $ succ (B.length s) * succ (B.length t))
    [0 .. succ (B.length s) * succ (B.length t) - 1]

  walk = fst $ fix
    ( \(!f) (!acc, (!i, !j)) -> if i == 0 || j == 0
      then (acc, (i, j))
      else if s `B.index` (i - 1) == t `B.index` (j - 1)
        then f (s `B.index` (i - 1) : acc, (i - 1, j - 1))
        else if dp VU.! toIndex (i - 1) j < dp VU.! toIndex i (j - 1)
          then f (acc, (i, j - 1))
          else f (acc, (i - 1, j))
    )
    ([], (B.length s, B.length t))

main = do
  s <- B.getLine
  t <- B.getLine
  putStrLn $ solve s t


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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)

int n;
ll k;
ll a[252521];
ll b[252521]; // for za-atu
ll bit[252521]; // for fenwick-tree

// fenwick tree max size is n
ll sum(int x){
  ll ret = 0;
  while(x>0){
    ret += bit[x];
    x -= x&-x;
  }
  return ret;
}
void add(int x,ll v){
  while(x<=n){
    bit[x] += v;
    x += x&-x;
  }
}

int main(){
  scanf("%d%lld",&n,&k);
  REP(i,n)scanf("%lld",a+i+1);
  REP(i,n)a[i+1] += a[i] - k;
  n++;

  // za-atu
  REP(i,n)b[i] = a[i];
  sort(b,b+n);
  int m = unique(b,b+n) - b;
  REP(i,n)a[i] = lower_bound(b,b+n,a[i])-b+1;

  // fenwick tree
  ll ans = 0;
  REP(i,n){
    ans += sum(a[i]);
    add(a[i], 1);
  }
  printf("%lld\n",ans);
  return 0;
}


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

#define lint long long
#define P pair<int, int>

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

    int a[N];
    int lis[9] = {};
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        int tmp = a[i] / 400;
        if(tmp <= 7){
            lis[tmp]++;
        } else {
            lis[8]++;
        }
    }

    int cnt= 0;
    for(int i = 0; i < 8; ++i){
        if(lis[i] > 0){
            cnt++;
        }
    }

    cout << max(1, cnt) << " " << cnt + lis[8] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r * r * pi;
        double len = 2 * r * pi;
        System.out.printf("%f %f", area, len);
    }
}


Measured memory_bytes: 28276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll N;
    cin >> N;

    N %= 10;

    if(N==2||N==4||N==5||N==7||N==9){
        cout << "hon";
    }
    else if (N==0||N==1||N==6||N==8){
        cout << "pon";
    }
    else{
        cout << "bon";
    }
}

Measured memory_bytes: 3652
L = list(input())
count, max_ = 0, 0
for i in L:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    count += 1
  else:
    if count > max_:
      max_ = count
    count = 0
if count > max_:
  max_ = count
print(max_)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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


  ll sum = 0;
  rep1(i, n)  sum += l+i-1;
  if(-(n-1) <= l && l <= 0){}
  else{
    if(abs(l) < abs(l+n-1)) sum -= l;
    else                    sum -= l+n-1;
  }

  cout << sum << endl;



  return 0;
}


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

#define MOD 1000000007
typedef unsigned long long ull;

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	if a+b == 3 {
		fmt.Println("3")
	} else if a+b == 4 {
		fmt.Println("2")
	} else if a+b == 5 {
		fmt.Println("1")
	}
}

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

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
c[1100000],n=1e6;main(i,j){for(i=2;i*i<n;++i)for(j=i;!c[i]&&j<n;c[j+=i]=1);for(i=2;i<n;++i)c[i]=c[i-1]+!c[i];for(;~scanf("%d",&n);printf("%d\n",c[n]));}

Measured memory_bytes: 0
s=str(input())
x=''
list=[]
for i in range(len(s)):
    if s[i]=='1':
        list.append('1')
    elif s[i]=='0':
        list.append('0')
    elif s[i]=='B' and len(list)!=0:
        del list[len(list)-1]

for i in range(len(list)):
    x += list[i]

print(x)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int N;
    scanf("%d", &N);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < N; i++) {
        string tmp = s.substr(i, N - i);
        if (tmp == t.substr(0, N - i)) {
            cout << N + i << endl;
            return 0;
        }
    }
    cout << 2 * N << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <deque>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a,b) (((a)-(b))>0?((a)-(b)):((b)-(a)))

using namespace std;

int main(){
	int N; cin >> N;
	char c[N];
	deque<int> white,red;
	rep(i,0,N){
		cin >> c[i];
		if( c[i]=='W' ) white.push_back(i);
		else red.push_back(i);
	}
	
	if( white.empty() || red.empty() ){
		cout << "0";
		return 0;
	}
	
	int cnt=0;
	rep(i,0,N){
		if( c[i]=='W' ){
			if( white.front() < red.back() ){
				swap( c[white.front()],c[red.back()] );
				white.pop_front();
				red.pop_back();
				cnt++;
			}
			if( white.empty() || red.empty() ){
				break;
			}
		}
	}
	cout << cnt;
	
	return 0;
}

Measured memory_bytes: 4548
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    String[] height = new String[H];
    String[] width = new String[W];
    char[][] grid = new char[H][W];
    boolean[] checkHeight = new boolean[H];
    boolean[] checkWidth = new boolean[W];
    
    for (int i = 0; i < H; i++) {
      height[i] = sc.next();
      if (!height[i].contains("#")) {
        checkHeight[i] = true;
      }
      for (int j = 0; j < W; j++) {
        width[j] += height[i].substring(j, j + 1);
        grid[i][j] = height[i].charAt(j);
      }
    }
    for (int j = 0; j < W; j++) {
      if (!width[j].contains("#")) {
        checkWidth[j] = true;
      }
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (checkHeight[i] || checkWidth[j]) {
          continue;
        }
        System.out.print(grid[i][j]);
      }
      if (checkHeight[i]) {
        continue;
      }
      System.out.println("");
    }
  }
}

Measured memory_bytes: 28884
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string s; cin>>s;
    int a=0;
    int b=1;
    if(s[0]=='A'&&s[1]>=91&&s[1]<=122&&s[s.size()-1]>=91&&s[s.size()-1]<=122){
        int k;
        for(int i=2;i<s.size()-1;i++){
            k=s[i];
            if((k>=97&&k<=122)||k=='C'){
                
            }else{
                b=0;
            }
            if(s[i]=='C'){
                a++;
            }
        }
        if(b==1&&a==1){
            cout<<"AC"<<endl;
            return 0;
        }
    }
    cout<<"WA"<<endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y;
    cin >> X >> Y;
    bool ok = false;
    REP(i, 0, X + 1) {
        if (i * 2 + (X - i) * 4 == Y) {
            ok = true;
            break;
        }
    }
    yesno(ok);
}


Measured memory_bytes: 3652
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, m = LI()
hor = []
ver = []
x_co = {-INF, INF}
y_co = {-INF, INF}
for _ in range(n):
    a, b, c = LI()
    x_co.add(a)
    x_co.add(b)
    y_co.add(c)
    ver += [(a, b, c)]

for _ in range(m):
    d, e, f = LI()
    x_co.add(d)
    y_co.add(e)
    y_co.add(f)
    hor += [(d, e, f)]


x_co = sorted(x_co)
y_co = sorted(y_co)
XD = {val:i for i,val in enumerate(x_co)}
YD = {val:i for i,val in enumerate(y_co)}
x_len = len(x_co) * 2 - 1
y_len = len(y_co) * 2 - 1
grid = [[0] * y_len for _ in range(x_len)]
x_range = [0] * x_len
y_range = [0] * y_len
x_range[0] = x_range[-1] = y_range[0] = y_range[-1] = INF

for i, (x1, x2) in enumerate(zip(x_co, x_co[1:])):
    x_range[i * 2 + 1] = x2 - x1
    if x1 <= 0 <= x2:
        sx = i * 2 + 1

for i, (y1, y2) in enumerate(zip(y_co, y_co[1:])):
    y_range[i * 2 + 1] = y2 - y1
    if y1 <= 0 <= y2:
        sy = i * 2 + 1

for a, b, c in ver:
    yi = YD[c] * 2
    for xi in range(XD[a] * 2,  XD[b] * 2 + 1):
        grid[xi][yi] = 1


for d, e, f in hor:
    xi = XD[d] * 2
    for yi in range(YD[e] * 2,  YD[f] * 2 + 1):
        grid[xi][yi] = 1


ans = x_range[sx] * y_range[sy]
grid[sx][sy] = 1


ans = 0
dq = deque([(sx, sy)])
grid[sx][sy] = 1
diff = ((0, 1), (1, 0), (-1, 0), (0, -1))
ans += x_range[sx] * y_range[sy]
while dq:
    x, y = dq.popleft()
    for dx, dy in diff:
        nx, ny = dx + x, dy + y
        if grid[nx][ny]:
            continue
        nx += dx;
        ny += dy
        if grid[nx][ny]:
            continue
        grid[nx][ny] = 1
        dq.append((nx, ny))
        ans += x_range[nx] * y_range[ny]
        if ans >= INF:
            print("INF")
            exit()

print(ans)






Measured memory_bytes: 435972
n = gets.to_i
ans = 0
min = 1000
n.times do
  s = gets.to_i
  ans += s
  min = s if s % 10 != 0 && s < min
end

if ans % 10 == 0
  if min == 1000
    ans = 0
  else
    ans -= min
  end
end

puts ans



Measured memory_bytes: 3836
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 400100;

int n, l = 0, r = 0, a[N], b[N], q[N];
bool w[N];

void add(int id) {
	if (w[id]) {
		return;
	}
	int pr = (id + n - 1) % n;
	int nx = (id + 1) % n;
	if (b[id] - a[id] < b[pr] + b[nx]) {
		return;
	}
	w[id] = true;
	q[r++] = id;
	r %= N;
}

int main() {

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}

	for (int i = 0; i < n; i++) {
		w[i] = false;
	}

	for (int i = 0; i < n; i++) {
		add(i);
	}

	long long ans = 0;

	while (l != r) {
		int id = q[l++];
		l %= N;
		w[id] = false;
		int pr = (id + n - 1) % n;
		int nx = (id + 1) % n;
		int k = (b[id] - a[id]) / (b[pr] + b[nx]);
		if (k <= 0) {
			continue;
		} 
		ans += k;
		b[id] -= k * (b[pr] + b[nx]);
		add(pr);
		add(nx);
	}

	for (int i = 0; i < n; i++) {
		if (b[i] != a[i]) {
			puts("-1");
			exit(0);
		}
	}

	printf("%lld\n", ans);

	return 0;

}

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

Measured memory_bytes: 256
s=input()
t=input()

num=len(t)
num_2=len(s)-num+1
count_list=[]

for i in range(num_2):
    s_2=s[i:i+num]
    
    count=0
    for j in range(num):
        if t[j]!=s_2[j]:
            count+=1
    count_list.append(count)

print(min(count_list))    
            

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n, k;
  cin >> n >> k;
  vec a(n);
  rep(i,n) {
    cin >> a[i];
  }

  rep(ki,k) {
    vec b(n);
    rep(i,n) {
      int l = max(0, i - a[i]);
      int r = min(n, i + a[i] + 1);
      b[l]++;
      if (r < n) b[r]--;
    }
    bool f = true;
    rep(i,n-1) {
      b[i+1] += b[i];
    }

    if (a == b) break;
    a = b;
  }

  rep(i,n) {
    cout << a[i] << endl;
  }
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[100];
signed main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i <= a[0]; i++) {
    int jobs = 0;
    for (int j = 0; j < N; j++) {
      jobs += a[j];
      jobs -= i;
      if (jobs<0) break;
    }
    if (jobs >= 0) ans = i;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3096