akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left
from collections import defaultdict

S = input()
T = input()
a = 97

grid = defaultdict(list)
for idx, s in enumerate(S + S):
    grid[s].append(idx)

ans = 0
cur = 0
lenS = len(S)
for t in T:
    if t in grid:
        tList = grid[t]
        ncur = tList[bisect_left(tList, cur)]
        ans += ncur - cur + 1
        cur = (ncur + 1) % lenS
    else:
        ans = -1
        break

print(ans)


Measured memory_bytes: 53228
X=int(input())

n = 0

big = 0
small=0

#print(10**9)

while True:

   if (n**5 - (n-1)**5) > 10**9 :
     break
   big=n
   n += 1

n=0
while True:
   if (n**5 - (n-1)**5) > 10**9 :
     break
   small=n
   n -= 1

a = list(range(0, big,   1))+list(range(-1, small-1, -1))
b = list(range(0, big-1, 1))+list(range(-1, small-2, -1))

stopFlag = False
for ia in a:
   if stopFlag :
      break
   for ib in b:

     if (ia**5) - (ib**5) == X:
        print(ia, ib)
        stopFlag = True
        break


Measured memory_bytes: 9216
import java.io.*;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line1 = br.readLine();
		String[] spl = line1.split(" ");
		int r = Integer.parseInt(spl[0]);
		int c = Integer.parseInt(spl[1]);
		int[][] a = new int[r+1][c+1];
		for (int i = 0 ; i<r ; i++ ) {
			String line = br.readLine();
			String[] str = line.split(" ");
			for (int j = 0; j<c ; j++ ) {
				a[i][j] = Integer.parseInt(str[j]);
				a[i][c] += Integer.parseInt(str[j]);
				a[r][j] += Integer.parseInt(str[j]);
				a[r][c] += Integer.parseInt(str[j]);
			}	
		}
		for (int i = 0; i<r+1 ;i++ ) {
			for (int j = 0; j<c ;j++ ) {
				System.out.print(a[i][j]+" ");
			}
			System.out.println(a[i][c]);
		}
		
		
	}
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(),p.end());
    int ans = 0;
    rep(i,k) ans+=p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
int W,H,x,y,r;

scanf("%d", &W);
scanf("%d", &H);
scanf("%d", &x);
scanf("%d", &y);
scanf("%d", &r);

if((H-y)>=r&&(W-x)>=r&&x>=r&&y>=r){
printf("Yes\n");
}else{
printf("No\n");

}
  
return 0;
}

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

#define ll long long
int main() {
  ll N, x;
  cin >> N >> x;
  
  vector<ll> a(100010);
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  } 
  
  ll ans = 0;
  
  if (a[0] > x) {
    ans += a[0] - x;
    a[0] = x;    
  }
  
  for (int i = 0; i < N-1; i++) {
    if (a[i] + a[i+1] <= x) continue;
    
    ans += a[i] + a[i+1] - x;
    a[i+1] =  x - a[i];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3964
import numpy as np
from collections import deque

H, W = list(map(int, input().split()))
s_y, s_x = 0, 0
g_y, g_x = H - 1, W - 1

visited = np.full((H, W), False)
board = np.zeros((H, W))
for i in range(H):
    row = input()
    for j, r in enumerate(row):
        if r == '.':
            board[i][j] = 1

direction = [[0, 1], [0, -1], [1, 0], [-1, 0]]
queue = deque()
queue.append(((s_y, s_x), 0))  # (pos, dist)

found = False
while len(queue) > 0:
    (y, x), dist = queue.popleft()
    if x == g_x and y == g_y:
        found = True
        break

    for dx, dy in direction:
        new_y, new_x = y + dy, x + dx
        if new_y < 0 or new_y >= H or new_x < 0 or new_x >= W:
            continue
        if board[new_y][new_x] == 0:
            continue
        if visited[new_y][new_x]:
            continue
        queue.append(((new_y, new_x), dist + 1))
        visited[new_y][new_x] = True
if found:
    print(int(np.sum(board)) - (dist + 1))
else:
    print(-1)


Measured memory_bytes: 12512
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N int
	fmt.Scan(&N)
	S := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sum := 0
	for i := 0; i < N; i++ {
		S[i] = nextInt(sc)
		sum += S[i]
	}
	if sum%10 != 0 {
		fmt.Println(sum)
	} else {
		sort.Ints(S)
		for i := 0; i < len(S); i++ {
			if S[i]%10 != 0 {
				fmt.Println(sum - S[i])
				return
			}
		}
		fmt.Println(0)
	}
}


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

const int N = 8 + 7;

int n, m;
char c[N][N];
bool mrk[N][N];

void dfs(int x, int y) {
	mrk[x][y] = 1;
	if (x < n && c[x + 1][y] == '#' && !mrk[x + 1][y])
		dfs(x + 1, y);
	if (y < m && c[x][y + 1] == '#' && !mrk[x][y + 1])
		dfs(x, y + 1);
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> c[i][j];
	dfs(1, 1);

	for (int i = 1; i <= n; i++)
   		for (int j = 1; j <= m; j++)
			if (c[i][j] == '#' && !mrk[i][j]) {
				cout << "Impossible";
				return 0;
			}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (c[i][j] == '#') 
				for (int x = 1; x <= n; x++)
					for (int y = 1; y <= m; y++)
						if (c[x][y] == '#')
							if ((i > x && j < y) || (i < x && j > y)) {
								cout << "Impossible";
								return 0;
							}
	cout << "Possible";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
typedef long long LL;
int a[N], fa[N];
LL rmn[N];
vector<int> adj[N];
int main() {
	int n;
	cin >> n;
	for(int i(1); i <= n; i++) 
		cin >> a[i];
	if(n == 1) {
		printf("YES\n");
		return 0;
	}else if(n == 2) {
		printf("%s\n", a[1] == a[2] ? "YES" : "NO");
		return 0;
	}
	for(int i(0); i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int rt;
	for(int i(1); i <= n; i++) {
		if(adj[i].size() >= 2) {
			rt = i;
			break;
		}
	}
	vector<int> q;
	q.push_back(rt);
	for(int i(0); i < (int)q.size(); i++) {
		int v(q[i]);
		for(int p(0); p < (int)adj[v].size(); p++) {
			int y(adj[v][p]);
			if(y != fa[v]) {
				fa[y] = v;
				//cout << v << ' ' << y << endl;
				q.push_back(y);
			}
		}
	}
	for(int i(n - 1); i >= 0; i--) {
		int v(q[i]);
		vector<LL> vec;
		LL tot(0), mx(0);
		for(int p(0); p < (int)adj[v].size(); p++) {
			int y(adj[v][p]);
			if(y != fa[v]) {
				vec.push_back(rmn[y]);
				tot += rmn[y];
				mx = max(mx, rmn[y]);
			}
		}
		if(vec.empty()) {
			rmn[v] = a[v];
		}else {
			
			LL lim(min(tot / 2, (tot - mx)));
			//cout << tot << ' ' << mx << endl;
			if(a[v] >= tot - lim && a[v] <= tot) {
				//a+2*b=tot
				//a+b=a[v]
				rmn[v] = -tot + a[v] * 2;
			}else {
				printf("NO\n");
				return 0;
			}
		}
		//cout << v << ' ' << rmn[v] << endl;
	}
	printf("%s\n", rmn[rt] == 0 ? "YES" : "NO");
}


Measured memory_bytes: 8184
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);

  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int c = 0;
    for (int j = 1; j <= n; j++)
      c += !(i % j);
    ans += (c == 8);
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			int point0 = 0;
			int point1 = 0;
			for(int i = 0; i < n; i++) {
				int a = stdIn.nextInt();
				int b = stdIn.nextInt();
				
				if(a == b) {
					point0 += a;
					point1 += b;
				}
				else if(a > b) {
					point0 += a + b;
				}
				else if(a < b) {
					point1 += a + b;
				}
			}
			System.out.println(point0 + " " + point1);
		}
	}
}

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

int main() {
int n,k;
cin >>n >>k;
vector<int>a(n);
int ans =0;
for(int i=0;i<n;i++){
    cin >>a.at(i);
    if(a.at(i)>=k)ans++;
}
cout << ans <<endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n,m,q; cin >> n >> m >> q;
    vvl v(n+1);
    rep(i,m){
        ll a,b; cin >> a >> b;
        rep(j,a+1){
            v[j].push_back(b);
        }
    }
    rep(i,n) sort(all(v[i]));
    rep(i,q){
        ll p,q; cin >> p >> q;
        auto itr = upper_bound(all(v[p]),q);
        cout << distance(v[p].begin(),itr) << endl;
    }
}

Measured memory_bytes: 289036
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;

ll W, H, x, y;
int main(void){
    cout << setprecision(10);
    cin >> W >> H >> x >> y;
    cout << double(W*H)/2 << " ";

    if(W%2==0 and x==W/2 and H%2==0 and y==H/2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}



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

struct Card{
	char suit;
	char value;
};

void trace(struct Card A[], int len)
{
	for(int i = 0; i < len; i++)
	{
		printf("%c%c", A[i].suit, A[i].value);
		if(i < len-1)
		{
			printf(" ");
		}
	}
	printf("\n");
}

void BubbleSort(struct Card C[], int N){
	for (int i = 0; i < N; i++) {
		for (int j = N-1; j > i; j--) {
			if (C[j].value < C[j-1].value) {
				Card d = C[j];
				C[j] = C[j-1];
				C[j-1] = d;
			}
		}
	}
	trace(C, N);
}

void SelectSort(struct Card C[], int N){
	for (int i = 0; i < N; i++) {
		int mini = i;
		for (int j = i; j < N; j++) {
			if (C[j].value < C[mini].value) {
				mini = j;
			}
		}
		Card t = C[i];
		C[i] = C[mini];
		C[mini] = t;
	}
	trace(C, N);
}


int main(int argc, char *argv[]) {
	int n;
	struct Card C1[40], C2[40];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> C1[i].suit;
		cin >> C1[i].value;
		C2[i] = C1[i];
	}
	
	BubbleSort(C1, n);
	printf("Stable\n");
	SelectSort(C2, n);
	int flag = 1;
	for (int i = 0; i < n; i++) {
		if (C2[i].suit != C1[i].suit) {
			flag = 0;
			break;
		}
	}
	if (flag == 1) {
		printf("Stable\n");
	}else {
		printf("Not stable\n");
	}
	return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int n;
char mas[1001][1001];
int dp[1001][1001];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> n, n) {
    rep(i, n) rep(j, n) cin >> mas[i][j];

    int ans = 0;
    rep(i, n) rep(j, n) {
      if(mas[i][j] == '*') dp[i][j] = 0;
      else if(!i || !j) dp[i][j] = 1;
      else dp[i][j] = min({dp[i-1][j-1], dp[i-1][j], dp[i][j-1]}) + 1;
      ans = max(ans, dp[i][j]);
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 11900
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}
//ll n;
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}
vector < vector <ll > > dp(101, vector <ll> (100005,-1));
vector <ll> w(101);
vector <ll> v(101);
ll n;
ll ww;

ll solve(ll i,ll j){
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(i==0){
		if(w[i]<=j)
			return v[i];
		else
			return 0LL;
	}
	if(w[i]<=j)
		dp[i][j]=max(v[i]+solve(i-1,j-w[i]),solve(i-1,j));
	else
		dp[i][j]=solve(i-1,j);
	return dp[i][j];
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>ww;
	for(ll i=0;i<n;i++)
		cin>>w[i]>>v[i];
	
	ll ans=solve(n-1,ww);
	cout<<ans<<"\n";
	
}

Measured memory_bytes: 82980
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  long long n,cnt=0,num;
  vector<int> a;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> num;
    a.push_back(num);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i+=2){
    if((a[i]==a[i+1]&&a[i]==i+1)){
      if(i==0) cnt=2;
      else cnt=(cnt*2)%(1000000000+7);
      }else if(n%2==1&&i==0&&a[i]==0){
        cnt=1;
        i=-1;
      }else{
        cnt=0;
        break;
      }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
#define Int int64_t
#define pb push_back
using namespace std;

int main()
{
  Int N;cin>>N;
  vector<Int> A(N);
  set<Int> s;
  for(auto &x:A) cin>>x,s.insert(x);
  
  Int largest=-1;int find=1;bool found=false;
  int i=0,j=0;
  while(i<N){
      if(A[i]==find){
          ++find;
          found=true;
      }
      i++;
  }
  cout<<(!found ? -1:N-find+1)<<"\n";
  
  
   
   
}

Measured memory_bytes: 14348
n = int(input())
s_list = []
for _ in range(n):
    s_list.append(input())

ans = 0
head_b = 0
tail_a = 0
headAndTail = 0

for s in s_list:
    ans += s.count('AB')

    if s.startswith('B') and s.endswith('A'):
       headAndTail += 1
    elif s.startswith('B'):
        head_b += 1
    elif s.endswith('A'):
        tail_a += 1

ans += min([head_b, tail_a])

if head_b == 0 and tail_a == 0:
    ans += max([0,headAndTail-1])
else:
    ans += headAndTail

print(ans)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

bool binary_search(vector<int> v, int kay, bool is_sorted){
    if (!is_sorted) sort(ALL(v));

    int left = 0;
    int right = SZ(v);
    int mid;
    while(left < right){
        mid = (left + right)/2;
        if (v[mid] == kay) return true;
        else if (kay < v[mid]) right = mid;
        else left = mid+1; 
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> v;
    int t;
    REP(_, n){cin >> t; v.PB(t);}

    cin >> n;
    int count = 0;
    REP(_, n){
        cin >> t;
        if (binary_search(v, t, true)) count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;
std::vector<P>v[100010];

int main() {
	bool flag = true;
	ll n, m, ans = 1;
	std::cin >> n >> m;
	if (n > m)flag = false;
	else if (n == m) {
		ans *= 2;
		flag = false;
	}
	if (abs(n - m) != 0 && abs(n - m) != 1)std::cout << 0 << std::endl;
	else {
		for (ll i = std::max(n, m);i >= 1 && m >= 1 && n >= 1;i--) {
			ans *=i;
			ans %= mod;
			if (!flag) {
				ans *= m;
				m--;
			}
			else {
				ans *= n;
				n--;
			}
			ans %= mod;
		}
		std::cout << ans%mod << std::endl;
	}
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <stack>
#include <string>
#include <set>
#include <queue>
#include <functional>
#include <deque>
 
using namespace std;
 
#define forn(i,n) for(int i = 0; i < n; i++)
#define forr(i,n) for(int i = n-1; i >= 0; i++)
#define ALL(x) x.begin(),x.end()
#define mp(x,y) make_pair(x,y);
#define lson x*2, l, m
#define rson x*2+1, m+1, r
 
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;
typedef vector<int> vint;
typedef vector<int64> vint64;
template <typename T> istream& operator >> (istream& in, vector<T>& t) { for (int i = 0;i < t.size();i++) in >> t[i]; return in; }
template <typename T> ostream& operator << (ostream& out, vector<T>& t) { for (int i = 0;i < t.size();i++) out << t[i] << " "; return out; }
 
struct Node
{
	vector<int> to;
};
vector<Node> g;
int n, m;
 
void go(int x, int p = -1, int h = 0)
{
	if (h == 2)
	{
		if (x == n - 1)
		{
			puts("POSSIBLE");
			exit(0);
		}
		else return;
	}
	for (int i = 0;i < g[x].to.size();i++)
	{
		if (g[x].to[i] == p) continue;
		go(g[x].to[i], x, h + 1);
	}
}
 
int main()
{
#ifdef _SANYA
	freopen("abc.txt", "r", stdin);
#else
#define T "permutation"
	//freopen(T ".in", "r", stdin);
	//freopen(T ".out", "w", stdout);
#endif
	cin >> n >> m;
	g.resize(n);
	for (int i = 0;i < m;i++)
	{
		int l, r; cin >> l >> r; l--;r--;
		g[l].to.push_back(r);
		g[r].to.push_back(r);
	}
	go(0);
	puts("IMPOSSIBLE");
	exit(0);
}

Measured memory_bytes: 12016
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;
}


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

int main() {
    vector< vector<int> > c(4, vector<int>(4));
    int sum = 0;
    for(int i=1; i<4; i++){
        for(int j=1; j<4; j++){
            cin >> c[i][j];
            sum += c[i][j];
        }
    }

    if(sum%3!=0){
        cout << "No" << endl;
        return 0;
    }

    int sum1 = c[1][1]+c[2][2]+c[3][3];
    int sum2 = c[1][1]+c[2][3]+c[3][2];
    int sum3 = c[1][2]+c[2][1]+c[3][3];
    int sum4 = c[1][2]+c[2][3]+c[3][1];
    int sum5 = c[1][3]+c[2][2]+c[3][1];
    int sum6 = c[1][3]+c[2][1]+c[3][2];

    if(sum != 3*sum1 || sum != 3*sum2 || sum != 3*sum3 || sum != 3*sum4 || sum != 3*sum5 || sum != 3*sum6){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
N,C=map(int, input().split())
#Aは時計回り
A,B=[],[]
allv=0
for i in range(N):
  a,b=map(int, input().split())
  A.append([a,b])
  B.append([C-a,b])
  allv+=b
A,B=sorted(A),sorted(B)
OA,OB,AS,BS=[],[],[],[]
ax,av,bx,bv=0,0,0,0
for i in range(N):
  ax,bx=A[i][0],B[i][0]
  av+=A[i][1]
  bv+=B[i][1]
  OA.append((ax,av))
  OB.append((bx,bv))
  AS.append(av-ax)
  BS.append(bv-bx)
#OA→AO→OBといくとき
d=BS[0]
e=AS[0]
BSma,ASma=[-10000]*N,[-10000]*N
for i in range(N):
  BSma[i]=max(d,BS[i])
  d=BSma[i]
  ASma[i]=max(e,AS[i])
  e=ASma[i]
  
ansa=0
for i in range(N-1):
  #iまで行く
  bma=N-i
  oa=OA[i][1]-OA[i][0]
  ao=-OA[i][0]
  ob=BSma[-2-i]
  d=max(oa,oa+ao+ob)
  ansa=max(ansa,d)
ansb=0
for i in range(N-1):
  #iまで行く
  ama=N-i
  ob=OB[i][1]-OB[i][0]
  bo=-OB[i][0]
  oa=ASma[-2-i]
  d=max(ob,ob+bo+oa)
  ansb=max(ansb,d)
print(max(ansa,ansb,allv-(C-max(OA[0][0],OB[0][0]))))


Measured memory_bytes: 70816
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;
const int maxn = 312;

double dp[maxn][maxn][maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int> cnt(4);
	for(int i = 0; i < n; ++ i) {
		int x;
		cin >> x;
		cnt[x] ++;
	}
	for(int k = 0; k < maxn - 1; ++ k) {
		for(int j = 0; j < maxn - 1; ++ j) {
			for(int i = 0; i < maxn - 1; ++ i) {
				if(!i && !j && !k) continue;
				double non_empty = i + j + k;
				dp[i][j][k] = n / non_empty;
				if(i) dp[i][j][k] += dp[i - 1][j][k] * i / non_empty;
				if(j) dp[i][j][k] += dp[i + 1][j - 1][k] * j / non_empty;
				if(k) dp[i][j][k] += dp[i][j + 1][k - 1] * k / non_empty;
			}
		}
	}
	cout << fixed << setprecision(10) << dp[cnt[1]][cnt[2]][cnt[3]] << '\n';
}


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

const int N = 1e5+9;
int n, m, k, a, b, p[N], ans[N], num[N];
//num：i里点数量
vector<int> vf[N], vb[N];

int fl(int x){
    return x == p[x] ? x : p[x] = fl(p[x]);
}

int main(){
    scanf("%d%d%d", &n, &m, &k);
    for(int i = 1; i <= n; i++) p[i] = i, num[i] = 1;
    for(int i = 1; i <= m; i++){
        scanf("%d%d", &a, &b);
        vf[a].push_back(b), vf[b].push_back(a);
        if(fl(a) != fl(b)){
            num[fl(b)] += num[fl(a)];
            p[fl(a)] = fl(b);
        }
    }
    for(int i = 1; i <= k; i++){
        scanf("%d%d", &a, &b);
        vb[a].push_back(b), vb[b].push_back(a);
    }
    for(int i = 1; i <= n; i++){
        ans[i] = num[fl(i)]-1;
        ans[i] -= vf[i].size();
        for(vector<int>::iterator it = vb[i].begin(); it != vb[i].end(); it++)
            ans[i] -= (fl(i) == fl(*it));
    }
    for(int i = 1; i <= n; i++) cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 13560
package main

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

func main(){
    s := bufio.NewScanner(os.Stdin)
    s.Split(bufio.ScanWords)
    s.Scan()
    n, _ := strconv.Atoi(s.Text())
    s.Scan()
    m, _ := strconv.Atoi(s.Text())
    s.Scan()
    x, _ := strconv.Atoi(s.Text())
    s.Scan()
    y, _ := strconv.Atoi(s.Text())
    
    xs := make([]int, n)
    for i := 0; i < n; i++ {
        s.Scan()
        d, _ := strconv.Atoi(s.Text())
        xs[i] = d
    }
    ys := make([]int, m)
    for i := 0; i < m; i++ {
        s.Scan()
        d, _ := strconv.Atoi(s.Text())
        ys[i] = d
    }
    
    sort.Ints(xs)
    sort.Ints(ys)
    
    if xs[n-1] < ys[0] && x < ys[0] && ys[0] <= y {
        fmt.Println("No War")
    } else {
        fmt.Println("War")
    }
}


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

public class Main {
	static String s;
	static int len;
	static int index;
	
	public static long x[];
	
	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		index = 0;
		s = br.readLine();
		
		len = s.length();
		int n = (int) Math.pow(2, len-1);
		x = new long[n];
		long result = 0;
		
		for(int i=0; i<= s.length(); i++){
			f(i, 0, s);
		}
		
		for(int i=0; i<n; i++){
			result += x[i];
		}
		
		System.out.println(result);
	}
	
	static void f(int plus, long sum, String str){
		if(plus != 0){
			for(int i=1; i<str.length()-plus+1; i++){
				f(plus-1, Long.parseLong(str.substring(0, i))+sum, str.substring(i, str.length()));
			}
		}else{
			x[index++] = sum + Long.parseLong(str);
		}
	}
}


Measured memory_bytes: 8788
#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 rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n, m;
  cin >> n >> m;
  vi p(m), y(m);
  vi yd[n+1];
  rep(i,m) {
    cin >> p[i] >> y[i];
    yd[p[i]].pb(y[i]);
  }
  rep(i,n) sort(yd[i+1].begin(), yd[i+1].end());
  rep(i,m) printf("%06d%06d\n", p[i], lower_bound(rng(yd[p[i]]), y[i]) - yd[p[i]].begin() + 1);
  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

map<ll, ll> D;

int main()
{
    ll N, M;
    cin >> N;
    REP(i, N)
    {
        ll d;
        cin >> d;
        D[d]++;
    }
    cin >> M;
    string ans = "YES";
    REP(i, M)
    {
        ll t;
        cin >> t;
        D[t]--;
        if (D[t] < 0)
            ans = "NO";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#include <set>
#include <cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(auto s=t.begin(),S=s;s!=t.end();s++)for(S=s;++S!=t.end();v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=1;i<=n/2;i++)printf("%d\n",v[i]);}}

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

using namespace std;

int main()
{
  int N, M, T, A[100];

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

  int ret = A[0] - M;
  for(int i = 1; i < N; i++) {
    ret += max(A[i] - A[i - 1] - M * 2, 0);
  }
  ret += max(T - A[N - 1] - M, 0);

  cout << ret << endl;
}

Measured memory_bytes: 3104
import java.util.*;

import javax.xml.crypto.Data;

import java.math.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] listA = new int[n];
		for(int i = 0; i < n; i++) {
			listA[i] = sc.nextInt() * 3600 + sc.nextInt() * 60;
		}
		int m = sc.nextInt();
		int[] listB = new int[m];
		for(int i = 0; i < m; i++) {
			listB[i] = sc.nextInt() * 3600 + sc.nextInt() * 60;
		}
		int[] list = new int[n + m];
		for(int i = 0; i < n; i++) {
			list[i] = listA[i];
		}
		for(int i = 0; i < m; i++) {
			list[i + n] = listB[i];
		}
		
		Arrays.sort(list);
		int pre = list[0];
		show(pre);
		for(int i = 1; i < n+m; i++) {
			if(list[i] == pre) continue;
			System.out.print(" ");
			show(list[i]);
			pre = list[i];
		}
		System.out.println();
		
	}
	
	static void show(int a) {
		int h = a / 3600;
		System.out.print(h + ":");
		
		a -= h * 3600;
		a /= 60;
		if(a < 10) {
			System.out.print("0");
		}
		System.out.print(a);
	}
	
}

Measured memory_bytes: 20736
<?php
fscanf(STDIN,"%d",$n);
for($i=0;$i<$n;$i++){
	fscanf(STDIN,"%s %d",$s,$p);
	$a[]=array($s, -$p, $i);
}
sort($a);
for($i=0;$i<$n;$i++)
echo $a[$i][2]+1 ."\n";

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int n,ans[200009];
vector<int>g[200009],mod[3],tp[2];
void dfs(int u,int p,bool c) {
	tp[c].push_back(u);
	for(int i=0;i<g[u].size();i++)
		if(g[u][i]!=p)
			dfs(g[u][i],u,!c);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;i++) {
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=1;i<=n;i++) mod[i%3].push_back(i);
	dfs(1,0,0);
	if(tp[0].size()<tp[1].size()) swap(tp[0],tp[1]);
	if(tp[0].size()>=mod[1].size()+mod[2].size()) {
		while(mod[1].size()) {
			ans[tp[0].back()]=mod[1].back();
			tp[0].pop_back();
			mod[1].pop_back();
		}
		while(mod[2].size()) {
			ans[tp[0].back()]=mod[2].back();
			tp[0].pop_back();
			mod[2].pop_back();
		}
		for(int i=1;i<=n;i++)
			if(!ans[i]) {
				ans[i]=mod[0].back();
				mod[0].pop_back();
			}
	}
	else {
		while(mod[1].size()) {
			ans[tp[0].back()]=mod[1].back();
			tp[0].pop_back();
			mod[1].pop_back();
		}
		while(mod[2].size()) {
			ans[tp[1].back()]=mod[2].back();
			tp[1].pop_back();
			mod[2].pop_back();
		}
		for(int i=1;i<=n;i++)
			if(!ans[i]) {
				ans[i]=mod[0].back();
				mod[0].pop_back();
			}
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<' ';
	return 0;
}

Measured memory_bytes: 19864
#include <vector>
#include <iostream>
#include <algorithm>
int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	int N;
	std::cin >> N;
	std::vector<int> A(N);
	for(int i = 0; i < N; ++i) {
		std::cin >> A[i];
	}
	int ptr = 0;
	for(int i = 0; i < N - 1; ++i) {
		if(A[i] <= A[N - 1]) {
			std::swap(A[i], A[ptr++]);
		}
	}
	std::swap(A[ptr], A[N - 1]);
	for(int i = 0; i < N; ++i) {
		if(i == ptr) std::cout << '[';
		std::cout << A[i];
		if(i == ptr) std::cout << ']';
		std::cout << (i != N - 1 ? ' ' : '\n');
	}
	return 0;
}


Measured memory_bytes: 3232
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    
    string symbol;
    
    if(a > b){
        symbol = " > ";
    }
    else if(a < b){
        symbol = " < ";
    }
    else{
        symbol = " == ";
    }

    cout << "a" << symbol << "b" << endl;
    
    return 0;
}


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

ll n,k,m,a,b;
string s;

int main() {
  cin >> s;
  int ans=0;
  for(auto c:s)if(c=='2') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2000 + 10;
int N, M, Q;
int A[MAXN][MAXN];
int f[MAXN][MAXN], g[MAXN][MAXN], h[MAXN][MAXN];

int main() {
	register int i, j; int x1, y1, x2, y2;
	scanf("%d%d%d", &N, &M, &Q);
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
			scanf("%01d", A[i] + j);
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
			f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + A[i][j],
			g[i][j] = g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1] + (A[i][j] == 1 && A[i][j - 1] == 1),
			h[i][j] = h[i - 1][j] + h[i][j - 1] - h[i - 1][j - 1] + (A[i][j] == 1 && A[i - 1][j] == 1);
	while(Q--) {
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int x = f[x2][y2] - f[x1 - 1][y2] - f[x2][y1 - 1] + f[x1 - 1][y1 - 1];
		int y = g[x2][y2] - g[x1 - 1][y2] - g[x2][y1] + g[x1 - 1][y1];
		int z = h[x2][y2] - h[x1][y2] - h[x2][y1 - 1] + h[x1][y1 - 1];
		printf("%d\n", x - y - z);
	}
	return 0;
}

Measured memory_bytes: 64768
a, b, c, n = list(map(int, input().split()))

cnt = 0
for i in range(n//a+1):
  an = n - a * i
  if an >= 0:
    for j in range(an//b+1):
      num = an - b * j
      if num >= 0 and num % c == 0:
        cnt+=1
        
print(cnt)
    

Measured memory_bytes: 2940
n, m = gets.chomp.split(" ").map(&:to_i)
arr = Array.new(n,0)
huseikai = Array.new(n,0)
count = 0
m.times do
    i, item = gets.chomp.split(" ")
    i = i.to_i
    if item == "WA" && huseikai[i-1] <= 1000000
        huseikai[i-1] += 1
    end
    if item == "AC" && huseikai[i-1] <= 1000000
        arr[i-1] += huseikai[i-1]
        count += 1
        huseikai[i-1] += 10000000
    end
    # p arr
    # p huseikai
end
arr_goukei = arr.inject(:+)
print count
print " "
print arr_goukei

Measured memory_bytes: 15708
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin >> n;
  map<ll,int> mp;
  repi(i,0,n){
    ll d;cin >> d;
    if(mp.find(d) == mp.end()){
      mp[d] = 1;
    } else {
      mp[d] += 1;
    }
  }
  int m; cin >> m;
  bool possible = true;
  repi(i,0,m){
    ll t;cin >> t;
    if(mp.find(t) == mp.end()){
      possible = false;
      break;
    } else {
      if(mp[t] > 0){
        mp[t] -= 1;
      } else {
        possible = false;
        break;
      }
    }
  }

  if(possible){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll X,Y;
  cin>>X>>Y;
  bool flag=false;
  rep(i,X+1){
    if(i*2+(X-i)*4==Y){
      flag=true;
    }
       }

       if(flag){
         cout<<"Yes"<<endl;
       }
       else{
         cout<<"No"<<endl;
       }
       }

  


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

int main(void){
	int N;
	std::vector<int> problems;
	std::cin>>N;
	for(int i=0;i<N;i++){
		int t;
		std::cin>>t;
		problems.push_back(t);
	}

	int sum = std::accumulate(problems.begin(),problems.end(),0l);

	int M;
	std::cin>>M;
	for(int i=0;i<M;i++){
		int p,x;
		std::cin>>p>>x;
		int ans = sum - problems.at(p-1) + x;
		std::cout<<ans<<std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	int N;
	cin >> N;

	VS names( N );
	VI costs( N );
	REP( i, N )
	{
		cin >> names[i] >> costs[i];
	}

	map< string, int > name2idx;
	{
		int idx = 0;
		FOR( name, names )
		{
			if ( !EXIST( name2idx, name ) )
			{
				name2idx[ name ] = idx++;
			}
		}
	}

	VI res( N );
	priority_queue< PII, VPII, greater< PII > > que;
	REP( i, N )
	{
		const int u = name2idx[ names[i] ];
		res[u] = costs[i];
		que.EM( costs[i], u );
	}

	int M;
	cin >> M;
	VVI G( N );
	REP( i, M )
	{
		string s, t;
		cin >> s >> t;
		const int u = name2idx[ s ], v = name2idx[ t ];

		G[u].PB( v );
		G[v].PB( u );
	}

	while ( !que.empty() )
	{
		const int c = que.top().fst;
		const int u = que.top().snd;
		que.pop();

		if ( res[u] < c )
		{
			continue;
		}

		FOR( v, G[u] )
		{
			if ( res[u] < res[v] )
			{
				que.EM( res[v] = res[u], v );
			}
		}
	}

	cout << accumulate( ALL( res ), 0 ) << endl;

	return 0;
}

Measured memory_bytes: 2056
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    int count = 0,max = 0;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        count += A;
        if (A == 0){
            if (max < count) max = count;
            count = 0;
        }
    }
         if (max < count) max = count;
         count = 0;
         
         cout << max+1 << endl;
         
    
    
    return 0;
}


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

#define ll long long

using namespace std;



int main(){
    ll number = 1;
    ll count = 0;
    ll N ;
    cin >> N;
    vector<ll> a(N);
    vector<ll> ans;
    for(ll i = 0;i < N; i++){
        cin >> a[i];
        if(a[i] == number){
            ans.push_back(a[i]);
            number++;
        } 
        else count++;
    }
    if(ans.empty()) cout << -1 << endl;
    else cout << count << endl;


}

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    ll x,a,b;
    cin>>x>>a>>b;
    if(b<=a) cout<<"delicious"<<endl;
    else if(b-a<=x) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
 
} 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
namespace io
{
#define SIZ (1 << 21 | 1)
#define gc() (io::iS == io::iT ? (io::iT= (io::iS= io::ibuff) + fread(io::ibuff, 1, SIZ, stdin), (io::iS == io::iT ? EOF : *io::iS++)) : *io::iS++)
#define putc(x) (io::oS == io::oT ? (fwrite(io::obuff, 1, io::oS - io::obuff, stdout), io::oS= io::obuff, (*io::oS++= x)) : *io::oS++= x)
#define exit                                          \
	fwrite(io::obuff, 1, io::oS - io::obuff, stdout); \
	return 0;
	char *iS, *iT, ibuff[SIZ], obuff[SIZ], *oS= obuff, *oT= oS + SIZ - 1, fu[110], c;
	int fr;
	template <class Type>
	inline void read(Type &x)
	{
		x= 0;
		Type y= 1;
		for(c= gc(); (c > '9' || c < '0') && c != '-'; c= gc())
			;
		c == '-' ? y= -1 : x= (c & 15);
		for(c= gc(); c >= '0' && c <= '9'; c= gc()) x= x * 10 + (c & 15);
		x*= y;
	}
	inline void reads(char *x)
	{
		for(c= gc(); c == ' ' || c == '\n'; c= gc())
			;
		for(; c != ' ' && c != '\n' && c != EOF; *x= c, c= gc(), ++x)
			;
	}
	template <class Type>
	inline void print(Type x, char text= '\n')
	{
		if(x < 0) putc('-'), x*= -1;
		if(x == 0) putc('0');
		while(x) fu[++fr]= x % 10 + '0', x/= 10;
		while(fr) putc(fu[fr--]);
		putc(text);
	}
	inline void prints(char *x, char *y= NULL, char text= '\n')
	{
		for(; *x && x != y; ++x) putc(*x);
		putc(text);
	}
}  // namespace io
using io::print;
using io::prints;
using io::read;
using io::reads;
#define N 201
int n, a[N], ans;
signed main()
{
	read(n);
	n<<= 1;
	for(int i= 1; i <= n; i++) read(a[i]);
	sort(a + 1, a + n + 1);
	for(int i= 1; i <= n; i+= 2) ans+= a[i];
	print(ans);
	exit;
}

Measured memory_bytes: 2304
mod = 2019
L,R = [int(x) for x in input().split()]
if(R-L>=2018):
    print(0)
else:
    l = L%mod
    r = R%mod
    if(r<l):
        print(0)
    elif(l<=3 and r>=673):
        print(0)
    else:
        ans = 2020
        for i in range(l,r):
            for j in range(i+1,r+1):
                ans = min(ans,(i*j)%mod)
        print(ans)


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

#define MAX 205
#define MAXLEN 1000000;
int  C[11][11];
int A[MAX][MAX];
int h,w;

int main()
{


    cin>>h>>w;
    int ans=0;
    for(int i=0;i<=9;++i)
        for(int j=0;j<=9;++j)
            cin>>C[i][j];


    

    for(int k=0;k<=9;++k)
    {
        for(int i=0;i<=9;++i)
        {
            for(int j=0;j<=9;++j)
            {
                // if(k==i||k==j)
                //     continue;
                if(C[i][j]>C[i][k]+C[k][j])
                    C[i][j]=C[i][k]+C[k][j];
            }
        }
    }


    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
        {
            cin>>A[i][j];
            if(A[i][j]==-1 || A[i][j]==1)
                continue;
            ans+=C[A[i][j]][1];
        }
    }

    cout<<ans;

}
        

Measured memory_bytes: 384
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    a=0
    for i in s:
        a+=int(i)
    print(a)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;
const double PI = 3.14159265358979323846;

signed main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double r_short = h * 30 + m * 0.5;
  double r_long = m * 6;

  double c =
      sqrt(a * a + b * b - 2 * a * b * cos(M_PI * (r_long - r_short) / 180));
  cout << fixed << setprecision(20);

  cout << c;
  return 0;
}


Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(D: int, T: int, S: int):

    if D <= T*S:
        return print('Yes')
    else:
        return print('No')



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(D, T, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator*(double a) { return Point(a*x, a*y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
	Point operator+(Point p) { return Point(x + p.x, y + p.y); }
	double norm() { return x*x + y*y; }
};
typedef vector<Point>Polygon;
struct Segment {
	Point p1, p2;
};
double cross(Point a, Point b) {
	return a.x*b.y - a.y*b.x;
}
double dot(Point a, Point b) {
	return a.x*b.x + a.y*b.y;
}
bool isPrallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
int contains(Polygon g, Point p) {
	int n = g.size();
	bool x = false;
	rep(i, n) {
		Point a = g[i] - p, b = g[(i + 1) % n] - p;
		if (abs(cross(a, b)) < EPS&&dot(a, b) < EPS)return 1;
		if (a.y > b.y)swap(a, b);
		if (a.y < EPS&&EPS<b.y&&cross(a, b)>EPS)x = !x;
	}
	return x ? 2 : 0;
}
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0;
	Point b = p2 - p0;
	if (cross(a, b) > EPS)return 1;
	if (cross(a, b) < -EPS)return -1;
	if (dot(a, b) < -EPS)return 2;
	if (a.norm() < b.norm())return -2;
	return 0;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 &&
		ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
Point project(Segment s, Point p) {
	Point base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base*r;
}
Point reflect(Segment s, Point p) {
	return p + (project(s, p) - p)*2.0;
}
bool isconvex(Polygon g) {
	int back = 3;
	rep(i, g.size()) {
		int d = ccw(g[(i + g.size() - 1) % g.size()], g[i], g[(i + 1) % g.size()]);
		if (back != 3 && d != back)
			return false;
		else back = d;
	}
	return true;
}
double area(Polygon g) {
	double cnt = 0;
	rep(i, g.size())
		cnt += g[i].x*g[(i + 1) % g.size()].y - g[(i + 1) % g.size()].x*g[i].y;
	return abs(cnt) / 2;
}
int main() {
	Polygon g;
	double x, y;
	while (~scanf("%lf,%lf", &x, &y)) {
		g.push_back({ x,y });
	}
	printf("%.6lf\n", area(g));
}

Measured memory_bytes: 3164
n, m = map(int, input().split())

a = set()
for i in range(m):
    a_tmp = int(input())
    a.add(a_tmp)

# a = [int(input()) for i in range(m)]

dp = [0] * (n + 1)
for i in range(n + 1):
    if i in a:
        dp[i] = 0
    else:
        if i == 0:
            dp[i] = 1
        elif i == 1:
            dp[i] = 1
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])

Measured memory_bytes: 11884