akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(S: str):
    ## 1の位からi+1文字のうち13で割ったもののあまりがjであるものの数
    N = len(S)
    dp = [[0]*13 for _ in range(N+1)]
    dp[0][0]=1
    list10 = range(0,10)
    list13 = range(0,13)
    keta =1
    for i in range(1,N+1):
        if S[N-i]=="?":
            for j in list10:
                addmod = j*keta%13
                for k in list13:
                    modmod = (k+addmod)%13
                    dp[i][modmod] += dp[i-1][k]%MOD
        else:
            addmod = (int(S[N-i])*keta)%13
            for k in list13:
                modmod = (k+addmod)%13
                dp[i][modmod] = dp[i-1][k]%MOD
        keta*=10
        keta%=13
    print(dp[N][5]%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

using namespace std;

void solve() {
    int n, m; cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
for i in range(n):
    ans *= a[i]
    if ans > 1e18:
        print(-1)
        exit()
if ans > 1e18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 21688
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
VI G[100011];
VI X[100011];

int par[100011];
VI ord;
int U[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }

    ord.reserve(N);
    ord.push_back(0);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) if (*e != par[v]) {
	    par[*e] = v;
	    ord.push_back(*e);
	}
    }

    VI buf; buf.reserve(N+2);
    
    REP (i_, N) {
	int v = ord[N-1-i_];
	int ma = -1;
	EACH (e, G[v]) if (*e != par[v]) {
	    amax(ma, X[*e].back());
	}

	if (ma == -1) {
	    U[v] = 0;
	    X[v].push_back(0);
	} else {
	    buf.resize(ma+2);
	    fill(buf.begin(), buf.end(), 0);
	    EACH (e, G[v]) if (*e != par[v]) {
		EACH (f, X[*e]) buf[*f]++;
	    }
	    int at_least = 0;
	    REP (i, ma+2) if (buf[i] >= 2) at_least = i+1;
	    REP (i, ma+2) {
		if (i < at_least || buf[i]) {
		    buf[i] = 0;
		} else {
		    U[v] = i;
		    buf[i] = 1;
		    break;
		}
	    }
	    REP (i, ma+2) if (buf[i]) X[v].push_back(i);
	}
    }

    int ma = *max_element(U, U+N);
    //rprintf("%d", U, U+N);
    printf("%d\n", ma);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 14976
#include<iostream>
#include<queue>
#include<cstring>

using namespace std;

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

typedef vector<int> Dice;
enum {TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};
#define rotate_swap(x, a, b, c, d) swap(x[a], x[b]); swap(x[b], x[c]); swap(x[c], x[d]);

void rotate_r(Dice &dice) {rotate_swap(dice, TOP, LEFT, BOTTOM, RIGHT);}
void rotate_l(Dice &dice) {rotate_swap(dice, TOP, RIGHT, BOTTOM, LEFT);}
void rotate_f(Dice &dice) {rotate_swap(dice, TOP, BACK, BOTTOM, FRONT);}
void rotate_b(Dice &dice) {rotate_swap(dice, TOP, FRONT, BOTTOM, BACK);}

struct Status {
  int x, y, cost;
  Dice d;
  bool operator<(const Status &s) const {return cost > s.cost;}
};

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0) break;
    int board[h][w];
    rep (i, h) rep (j, w) cin >> board[i][j];
    int x1, y1, x2, y2;
    cin >> y1 >> x1 >> y2 >> x2;
    int dis[h][w][6][6][6];
    memset(dis, -1, sizeof(dis));
    priority_queue<Status> que;
    Dice d(6);
    rep (i, 6) d[i] = i + 1;
    que.push((Status){x1, y1, 0, d});
    while (!que.empty()) {
      Status now = que.top();
      que.pop();
      if (now.y == y2 && now.x == x2) {
	cout << now.cost << endl;
	break;
      }
      if (now.x < 0 || w <= now.x || now.y < 0 || h <= now.y) continue;
      if (dis[now.y][now.x][now.d[TOP]][now.d[FRONT]][now.d[RIGHT]] != -1) continue;
      dis[now.y][now.x][now.d[TOP]][now.d[FRONT]][now.d[RIGHT]] = now.cost;
      Dice d1 = now.d, d2 = now.d, d3 = now.d, d4 = now.d;
      rotate_r(d1);
      rotate_l(d2);
      rotate_f(d3);
      rotate_b(d4);
      if (now.x < w - 1) que.push((Status){now.x + 1, now.y, now.cost + d1[BOTTOM] * board[now.y][now.x + 1], d1});
      if (0 < now.x) que.push((Status){now.x - 1, now.y, now.cost + d2[BOTTOM] * board[now.y][now.x - 1], d2});
      if (now.y < h - 1) que.push((Status){now.x, now.y + 1, now.cost + d3[BOTTOM] * board[now.y + 1][now.x], d3});
      if (0 < now.y) que.push((Status){now.x, now.y - 1, now.cost + d4[BOTTOM] * board[now.y - 1][now.x], d4});
    }
  }
}

Measured memory_bytes: 1448
object Main {
  def main(args: Array[String]): Unit = {
    val str    = scala.io.StdIn.readLine
    val answer = scala.io.StdIn.readLine
    var flg    = false

    var check_str = str
    for(i <- 0 until str.length) {
      check_str = check_str.tail + check_str.head
      if(check_str == answer) flg = true
    }

    if(flg) {
      println("Yes")
    }
    else {
      println("No")
    }

  }
}

Measured memory_bytes: 27332
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<string> w(n);
	rep(i, 0, n - 1)cin >> w[i];
	bool ok = true;
	rep(i, 1, n - 1)
	{
		if (w[i - 1].back() != w[i][0])
		{
			ok = false;
		}
	}
	sort(all(w));
	int len1, len2;
	len1 = w.size();
	w.erase((unique(all(w))), w.end());
	len2 = w.size();
	if (len1 != len2)
	{
		cout << "No" << endl;
		return 0;
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define INF 1000000000001
#define se second
#define mod 1000000007
int main()
{
	ll a[5],ans;
	for(ll i=0;i<5;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		ans=i+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
using namespace std;
char zfc[10001];
int main()
{
	int cp=999999,fp=-1;
	cin>>zfc;
	for(int i=0;i<strlen(zfc);i++)
	{
		if(zfc[i]=='C')
		{
			cp=i;
			break;
		}
	}
	for(int i=strlen(zfc)-1;i>=0;i--)
	{
		if(zfc[i]=='F')
		{
			fp=i;
			break;
		}
	}
	if(cp<fp)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <functional>
using namespace std;
int N, W;
int w[105],v[105];
map< pair<int,int>,int> m;
int rec(int i, int j) {
    int res;
    pair<int,int> p = make_pair(i, j);
    if (m.find(p) != m.end())
        return m[p];
    if (i == N)
        res = 0;
    else if (j < w[i])
        res = rec(i + 1, j);
    else
        res = max(rec(i + 1, j),rec(i + 1, j - w[i]) + v[i]);
    m[make_pair(i, j)] = res;
    return res;
}


int main(){
    cin >> N >> W;
    for (int i = 0; i < N; i++){
        int tw, tv;
        cin >>w[i]>>v[i];
    }
    cout << rec(0, W) << endl;
    return 0;
}


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

char s[6][6] = {
	"abcde",
	"fghij",
	"klmno",
	"pqrst",
	"uvwxy",
	"z.?! "
};

int main(void){
	string str;

	while(cin>>str){
		if(str.length() % 2 == 1){
			cout<<"NA\n";
			continue;
		}
		string ans = "";
		bool flg = false;
		for(int i=0;i<str.length();i+=2){
			if('1' > str[i] || str[i] >= '7' || '1' > str[i+1] || str[i+1] >= '6'){
				cout<<"NA\n";
				flg = true;
				break;
			}
			int a = str[i] - '1';
			int b = str[i+1] - '1';
			ans += s[a][b];
		}
		if(flg) continue;
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ans = "";
        String a = sc.next();
        String b = sc.next();
        if(a.compareTo(b)<0){
            for(int i=0;i<Integer.parseInt(b);i++)ans+=a;
        }else{
            for(int i=0;i<Integer.parseInt(a);i++)ans+=b;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define v vector
#define vi vector< int >
#define vpi vector< pair< int,int > >
#define forl(a) for(int i = 0;i < a;i ++)
using namespace std;
ll modF=1e7;

void solve(){
	int a;
	cin>>a;
	cout<<(a+a*a+a*a*a)<<"\n";
}

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

Measured memory_bytes: 3612
const lines=readlines()
const N,M,P=map(x->parse(Int,x),split(shift!(lines)))
const A=Tuple{Int,Int,Int}[]
for s=lines
	a,b,c=map(x->parse(Int,x),split(s))
	push!(A,(a,b,c-P))
end
const d=ones(Int,N)*-(10^18)
d[1]=0
function f()
	for _=1:N
		for (a,b,c)=A
			d[b]=max(d[b],d[a]+c)
		end
	end
end
f()
ans=d[N]
f()
println(ans<d[N]?-1:ans<0?0:ans)


Measured memory_bytes: 166820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD=1e9+7;

int main(void){
    long long n,d;
    cin>>n>>d;
    long long dd=d*d;
    int ans=0;
    rep(i,n){
        long long x,y;
        cin>>x>>y;
        long long z=x*x+y*y;
        if(z<=dd) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s ;
  cin >> s ;
  int check = 0 ;
  for(int i=0;i<3;i++){
    if(s[i]=='7') check = 1 ;
  }
  if(check){
    cout << "Yes" ;
    return 0 ;
  }
  cout << "No" ;
  return 0 ;
}

Measured memory_bytes: 3612
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    x, a, b = list(map(int, input().split()))

    print('A') if abs(x - a) < abs(x - b) else print('B')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10448
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=998244353;
const ll INF=9e18;
const long double PI = acos(-1.0);
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll sum[110000];

int main(){cout<<fixed<<setprecision(20);
		   ll n,m,x;
           cin>>n>>x>>m;
           ll loopsize=-1;
           ll start=-1;
           ll loopval=-1;
           map<ll,ll> cnt;
           ll a=x;
           bool ok=false;
           rep(i,1,n+1){
             sum[i]=sum[i-1];
             if(cnt[a]!=0){
               loopsize=i-cnt[a];
               start=cnt[a];
               loopval=sum[i]-sum[start-1];
               break;
             }
             else{
             sum[i]+=a;
             cnt[a]=i;
             a=a*a%m;
             }
             if(i==n){
              ok=true; 
             }
           }
           if(ok){
            cout<<sum[n]<<endl;
             return 0;
           }
           
           ll ans=sum[start-1];
           ll times=(n-start+1)/loopsize;
           ans+=times*loopval;
           ll R=(n-start+1)%loopsize;
           rep(i,0,R){
            ans+=sum[start+i]-sum[start-1+i]; 
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 6988
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int a,b;
  cin >> a >> b;
  if((a*b)%2 == 0) {
    cout << "Even";
  }
  else {
    cout << "Odd";
  }
  
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
mod = 10 ** 9 + 7

dp = [[1] * (n + 1)] + [[1] + [0] * n for _ in range(m)]

arr_s = [0] + list(map(int, input().split()))
arr_t = [0] + list(map(int, input().split()))

for r in range(1, m + 1):
    for c in range(1, n + 1):
        if arr_s[c] == arr_t[r]:
            dp[r][c] = dp[r-1][c] + dp[r][c-1]
        else:
            dp[r][c] = dp[r-1][c] + dp[r][c-1] - dp[r-1][c-1]
        dp[r][c] %= mod

print(dp[m][n])


Measured memory_bytes: 77276
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		try{
          
          Scanner sc = new Scanner(System.in);

			int n = sc.nextInt();
			String a = sc.next();
			String b = sc.next();
			String c = sc.next();
			
			int r = 0;
			
			for (int i = 0; i < n ; i++) {
				String a2 = a.substring(i, i+1);
				String b2 = b.substring(i, i+1);
				String c2 = c.substring(i, i+1);
				
				r = r + replace(a2, b2, c2);
			}
			System.out.println(r);
			
		}catch (Exception e) {
			e.printStackTrace();
		}
		
//		System.out.println(replace("1", "2", "3"));
		
	}
	
	private static int replace(String a, String b ,String c){
		int result = 0;
		
		if(!a.equals(b)){
			result++;
		}
		if(!b.equals(c)){
			result++;
		}
		if(!c.equals(a)){
			result++;
		}
		
		if(result>0){
			result--;
		}
		
		return result;
	}

}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
long long acm (long long x) {
  if (!x) return 0;
  long long ret = 0;
  if (!(x & 1)) {
    ret = x;
    x--;
  }
  ret ^= !(((x - 1) >> 1) & 1);
  return ret;
}
int main() {
  long long a, b;
  cin >> a >> b;
  long long ret = acm(a - 1) ^ acm(b);
  cout << ret << endl;
  return 0;
}

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

int main()
{
  string S ;
  int n , answer ;
  answer = 1 ;
  cin >> S ;
  
  for(int i=0; i<S.size(); i++)
  {
    if(i%2 == 0)
      if(S.at(i)=='L')
      {
        answer = 0 ;
        break ;
      }
    if(i%2 == 1)
      if(S.at(i)=='R')
      {
        answer = 0 ;
        break ;
      }
  }
  
  if(answer == 1)
    cout << "Yes" << endl ;
  else
    cout << "No" << endl ;
}

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

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

	int f=0;
	int i=0;
	while(4*i <= n)
	{
		if((n-4*i)%7==0) f++;
		i++;
	}

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

Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
r = g = b = rg = rb = gb = 0

for c in S:
    if c=="B":
        ans += rg
        rb += r
        gb += g
        b += 1
    elif c=="G":
        ans += rb
        rg += r
        gb += b
        g += 1
    else:
        ans += gb
        rg += g
        rb += b
        r += 1
for j in range(1, N):
    Sj = S[j]
    for Si, Sk in zip(S[j-1::-1], S[j+1:]):
        if len({Si, Sj, Sk}) == 3:
            ans -= 1
print(ans)


Measured memory_bytes: 9220
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007

using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	ll n,i,ans=0;
	cin>>n;
	vll a(n);
	rep(i,n)
		cin>>a[i];
	ll cnt=1;
	for(i=0;i<n;i++)
	{
		if(a[i]==cnt)
		{
			ans++;
			cnt++;
		}
	}
	if(ans==0)
		cout<<"-1";
	else
		cout<<n-ans;
}

Measured memory_bytes: 1792
class SegmentTree:
    """Segment Tree (Point Update & Range Query)
    Query
        1. update(i, val): update i-th value to val
        2. query(low, high): find f(value) in [low, high)
    Complexity
        time complexity: O(log n)
        space complexity: O(n)
    """

    def __init__(self, N, f, default):
        self.N = 1 << (N - 1).bit_length()
        self.default = default
        self.f = f
        self.segtree = [self.default] * ((self.N << 1) - 1)

    @classmethod
    def create_from_array(cls, arr, f, default):
        N = len(arr)
        self = cls(N, f, default)
        for i in range(N):
            self.segtree[self.N - 1 + i] = arr[i]

        for i in reversed(range(self.N - 1)):
            self.segtree[i] = self.f(
                self.segtree[(i << 1) + 1], self.segtree[(i << 1) + 2]
            )
        return self

    def update(self, i, val):
        i += self.N - 1
        self.segtree[i] = val
        while i > 0:
            i = (i - 1) >> 1
            self.segtree[i] = self.f(
                self.segtree[(i << 1) + 1], self.segtree[(i << 1) + 2]
            )

    def __getitem__(self, k):
        return self.segtree[self.N - 1 + k]

    def query(self, low, high):
        # query [l, r)
        low, high = low + self.N, high + self.N
        left_ret, right_ret = self.default, self.default
        while low < high:
            if low & 1:
                left_ret = self.f(left_ret, self.segtree[low - 1])
                low += 1
            if high & 1:
                high -= 1
                right_ret = self.f(self.segtree[high - 1], right_ret)
            low, high = low >> 1, high >> 1
        return self.f(left_ret, right_ret)


def main() -> None:
    N, K, C = map(int, input().split())
    S = [1 if s == "o" else 0 for s in input()]
    left, right = [-1] * N, [-1] * N
    max_v = -1
    for i in range(N):
        if i - C - 1 >= 0:
            max_v = max(max_v, left[i - C - 1])
        if S[i] == 1:
            left[i] = max_v + 1
    max_v = -1
    for i in reversed(range(N)):
        if i + C + 1 <= N - 1:
            max_v = max(max_v, right[i + C + 1])
        if S[i] == 1:
            right[i] = max_v + 1
    work_day = [max(0, left[i] + right[i] + 1) for i in range(N)]
    #print(work_day)
    if max(work_day) > K:
        return
    segt = SegmentTree.create_from_array(work_day, max, 0)
    ans = []
    for i in range(N):
        if work_day[i] < K:
            continue
        m = max(segt.query(max(0, i - C), i), segt.query(i+1, min(i + 1 + C, N)))
        if m >= K:
            continue
        # m = max(segt.query(0, max(0, i - C)), segt.query(min(N, i + 1 + C), N))
        # if m >= K + 1:
        #     continue
        ans.append(i + 1)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int n,m,k;
cin>>n>>m>>k;
rep(i,n+1){
  rep(j,m+1){
    int black=i*m+j*n-2*i*j;
    if(black==k){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
}

cout<<"No"<<endl;
  return 0;
}


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

int main(){
    int n,i;
    cin>>n;
    ll pow[33];
    pow[0]=1;
    for(i=1;i<33;i++){
        pow[i]=pow[i-1]*2;
    }

    ll z[n],w[n];
    int flag=-1;

    for(i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        z[i]=x+y;
        if(flag==-1) flag=(3000000000+z[i])%2;
        else if(flag!=(3000000000+z[i])%2) {
            cout<<-1<<endl;
            return 0;
        }
        w[i]=x-y;
    }

    int add=0;
    if(flag==0) add=1;
    cout<<32+add<<endl;
    if(add){
        cout<<1<<" ";
    }
    cout<<pow[0];
    for(i=1;i<32;i++){
        cout<<" "<<pow[i];
    }
    cout<<endl;

    if(add){
        for(i=0;i<n;i++){
            z[i]-=1;
            w[i]-=1;
        }
    }

    for(i=0;i<n;i++){
        if(add) cout<<'R';
        z[i]=z[i]+pow[32]-1;
        w[i]=w[i]+pow[32]-1;
        z[i]/=2;
        w[i]/=2;
        bool zz,ww;
        for(int j=0;j<32;j++){
            zz=z[i]&1;
            ww=w[i]&1;
            if(zz&ww) cout<<'R';
            if(!zz&ww) cout<<'D';
            if(zz&!ww) cout<<'U';
            if(!zz&!ww) cout<<'L';
            z[i]=z[i]/2;
            w[i]=w[i]/2;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func solution(s string) string {
	if s[2] == s[3] && s[4] == s[5] {
		return "Yes"
	}
	return "No"
}

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(solution(s))
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <climits>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define INFMAX                   LLONG_MAX
#define INFMIN                   LLONG_MIN
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef list<ll> li;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int BUFF_MAX = 1024;
    char buf[BUFF_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

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

vector<vector<int> > list(100);
vector<vector<int> > timed(100);
int times;
void dfs(int now){
	if(!timed[now].empty())	return;
	timed[now].push_back(times++);
	for(int i=0;i<(int)list[now].size();i++){
		dfs(list[now][i]);
	}
	timed[now].push_back(times++);
}

int main(){
	int n;	cin>>n;
	int id,num,ne;
	for(int i=0;i<n;i++){
		cin>>id>>num;
		id--;
		for(int j=0;j<num;j++){
			cin>>ne;
			list[id].push_back(ne-1);
		}
	}
	times=1;
	for(int i=0;i<n;i++){
		if(timed[i].empty())	dfs(i);
	}
	for(int i=0;i<n;i++){
		cout<<i+1;
		for(int j=0;j<(int)timed[i].size();j++){
			cout<<" "<<timed[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m,ans;
int main(){
	in(n);in(m);
    while(n){
        n/=m;
        ans++;
    }
    cout<<ans<<endl;
	return 0;
}


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

int main(){
    string s,t;cin >>s >>t;
    bool table[26][26];
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 26; j++){
            table[i][j]=false;
        }
    }
    for (int i = 0; i < s.size(); i++)
    {
        table[s[i]-'a'][t[i]-'a']=true;
    }
    bool ret=true;
    
    for (int i = 0; i < 26; i++){
        int cnt1=0,cnt2=0;
        for (int j = 0; j < 26; j++){
            if(table[i][j])cnt1++;
            if(table[j][i])cnt2++;
        }
        if(cnt1>1 ||cnt2>1)ret=false;
    }
    if(ret)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
}

Measured memory_bytes: 776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = in.nextInt();
            }
            int[] dp = new int[n];
            dp[n - 1] = 1;
            for (int i = n - 2; i >= 0; i--) {
                if (ar[i] >= ar[i + 1]) {
                    dp[i] = dp[i + 1] + 1;
                } else {
                    dp[i] = 1;
                }
            }
            int max = 0;
            for (int el : dp) {
                max = Math.max(max, el);
            }
            out.println(max - 1);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n;
  cin >> n;
  int ans = 0;
  vector<int> div(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      div[j]++;
    }
  }
  for (int i = 1; i <= n; i++) ans += i * div[i];
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 81380
n = int(input())

l = []


def f(n):
    return chr(n+ord("a"))


def search(s: str, cnt: int) -> str:
    if len(s) == n:
        return s
    cnt = len(set(list(s)))
    for i in range(0, min(cnt, len(s)) + 1):
        g = search("".join([s, f(i)]), cnt + max(0, i - len(s) + 1))
        if g is not None:
            l.append(g)


search("", 1)

l.sort()

for s in l:
    print(s)


Measured memory_bytes: 12660
n = int(input())
w_list = list(map(int, input().split()))

min = 100000000000
for t in range(n):
    if abs(sum(w_list[:t+1]) - sum(w_list[t+1:])) < min:
        min = abs(sum(w_list[:t+1]) - sum(w_list[t+1:]))

print(min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int n, a[102];
ll sum;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    cin >> n;
    REP (i, n) {
        cin >> a[i];
    }

    REP (i, n) {
        REP (j, i) {
            sum += a[i] * a[j];
        }
    }

    cout << sum << endl;
    return 0;
}


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

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

            Set<Integer> set = new HashSet<>();

            for (int i = 0; i < N; i++) {
                if (set.contains(A[i])) {
                    System.out.println("NO");
                    return;
                }

                set.add(A[i]);
            }

            System.out.println("YES");
        }
    }

}


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

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        if(mp.count(s)) {
            mp.at(s)++;
        }
        else {
            mp[s] = 1;
        }
    }
    
    vector<P> vt;
    for(auto p : mp) {
        P vi = make_pair(p.second, p.first);
        vt.push_back(vi);
    }
    sort(vt.begin(), vt.end());
    reverse(vt.begin(), vt.end());
    int i = 0;
    int m = vt.at(i).first;
    vector<string> ans;
    while(i < vt.size() && vt.at(i).first == m) {
        ans.push_back(vt.at(i).second);
        i++;
    }
    reverse(ans.begin(), ans.end());
    for(string s : ans) {
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 41120
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B, C, sp = 0;

  std::cin >> A >> B >> C;

  sp = std::max(10 * A + B + C, sp);
  sp = std::max(10 * B + A + C, sp);
  sp = std::max(10 * C + A + B, sp);

  std::cout << sp << std::endl;
  
  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

using P = pair<string, string>;

int n;
string s;
map<P, int> mp;

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

   for (int S = 0; S < (1<<n); S++) {
      string A, B;
      for (int i = 0; i < n; i++) {
         if ((S >> i) & 1) {
            A += s[i];
         }
      }
      for (int i = n-1; i >= 0; i--) {
         if (!((S >> i) & 1)) {
            B += s[i];
         }
      }
      mp[P(A, B)]++;
   }

   ll ret = 0;
   for (int S = 0; S < (1<<n); S++) {
      string A, B;
      rep (i, n) {
         if (S>>i&1) A += s[n+i];
      }
      for (int i = n-1; i >= 0; i--) {
         if (!(S>>i&1)) B += s[n+i];
      }
      ret += mp[P(B, A)];
   }

   cout << ret << endl;

   return 0;
}

Measured memory_bytes: 91904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
typedef pair<int, ll> pii;
ll sumL, sumR, sumb, tot;
multiset<int> L, R;
void insert(int a)
{
	if(R.empty() || a < *R.begin())
	{
		L.insert(a);
		sumL += a;
	}
	else
	{
		R.insert(a);
		sumR += a;
	}
	if(L.size() == R.size() + 2)
	{
		auto it = L.rbegin();
		int rmid = *it;
		R.insert(rmid);
		L.erase((++it).base());
		sumR += rmid;
		sumL -= rmid;
	}
	if(R.size() == L.size() + 1)
	{
		int mid = *R.begin();
		L.insert(mid);
		R.erase(R.begin());
		sumL += mid;
		sumR -= mid;
	}
}
pii query()
{
	int mid = *L.rbegin();
	return mp(mid, (sumR - 1ll * R.size() * mid) + (1ll * L.size() * mid - sumL));
}
int main()
{
	int q;
	scanf("%d", &q);
	for(int cas = 1; cas <= q; ++cas)
	{
		int op, a, b;
		scanf("%d", &op);
		if(op == 1)
		{
			scanf("%d%d", &a, &b);
			insert(a);
			sumb += b;
			++tot;
		}
		else
		{
			auto ret = query();
			printf("%d %lld\n", ret.first, ret.second + sumb);
		}
	}
	return 0;
}
	

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

#define RATIO acos(-1) / 180

void area(int a, int b, int c)
{
    double hb = a * sin(c * RATIO);
    double ha = hb * b / a;
    double a1 = a * cos(c * RATIO);
    double cc = sqrt(pow(hb, 2.0) + pow(b - a1, 2.0));
    printf("%f\n%f\n%f\n", hb * b / 2, a + b + cc, ha);
}

int main()
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    area(a, b, c);

    return 0;
}

Measured memory_bytes: 2100
//  Created by conan1024hao on 2019/11/26.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
//まだ理解してない
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    ll n;cin>>n;
    vector<string>s(n);
    for(int i=0;i<n;i++)
        cin>>s[i];
    int m=0,a=0,r=0,c=0,h=0;
    for(int i=0;i<n;i++){
        if(s[i][0]=='M')
            m++;
        if(s[i][0]=='A')
            a++;
        if(s[i][0]=='R')
            r++;
        if(s[i][0]=='C')
            c++;
        if(s[i][0]=='H')
            h++;
    }
    int cnt=0;
    if(m)
    cnt++;
    if(a)
    cnt++;
    if(r)
    cnt++;
    if(c)
    cnt++;
    if(h)
    cnt++;
    ll D[5];
    D[0]=m;D[1]=a;D[2]=r;D[3]=c;D[4]=h;
    ll ans=0;
    for(int i=0;i<5;i++)
        for(int j=i+1;j<5;j++)
            for(int z=j+1;z<5;z++)
                ans+=D[i]*D[j]*D[z];
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e2 + 2;

multiset < int > S;
multiset < int > :: iterator it;
vector < int > V[N],U[N];
int n,i,j,x,y,ans;

signed main(){
    cin >> n;
    for(i=1;i<=n;i++) { cin >> x >> y; V[x].pb(y); }
    for(i=1;i<=n;i++) { cin >> x >> y; U[x].pb(y); }

    for(i=0;i<N;i++){
        for(j=0;j<U[i].size();j++){
            it = S.lower_bound(U[i][j]);
            if(it == S.begin()) continue;
            ans++;
            S.erase(--it);
        }
        for(j=0;j<V[i].size();j++)
            S.insert(V[i][j]);
    }
    
    cout << ans;
}

Measured memory_bytes: 256
def solve():
  N, K = map(int, input().split())
  s = input()
  S = []
  b = s[0]
  cnt = 0

  if s[0] == '0': S.append(0)
  for c in s:
    if b == c: cnt = cnt + 1
    else:
      b = c
      S.append(cnt)
      cnt = 1
  S.append(cnt)
  if s[-1] == '0': S.append(0)

  num = min(len(S), 2 * K + 1)
  part = sum(S[0:num])
  ans = part

  for i in range(0, len(S) - num, 2):
    part = part - sum(S[i:i+2]) + sum(S[i + num:i + num + 2])
    ans = max(ans, part)

  return ans

print(solve())


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 405, M = 1e5 + 10;
int n, m, a[M], b[M], mark[N], ans;
bitset<N> s[N];

int main() {
    cin >> n >> m;
    rep(i, 1, m) scanf("%d%d", &a[i], &b[i]);
    rep(i, 1, n) {
        s[i][i] = 1;
        for (int j = m; j; --j) {
            if (s[i][a[j]] && s[i][b[j]]) { mark[i] = 1; break; }
            if (!s[i][a[j]] && !s[i][b[j]]) continue;
            s[i][a[j]] = s[i][b[j]] = 1;
        }
    }
    rep(i, 1, n)
        rep(j, i + 1, n)
            ans += (!mark[i] && !mark[j] && (s[i] & s[j]).none());
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4564