akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

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

	cin >> a >> b >> c;

	ans = min(b, c) * 2;

	if (b < c) {
		c -= b;
		ans += min(c, a + 1);
	}
	else if(b>c){
		b -= c;
		ans += b;
	}
	
	cout << ans;

	return 0;
}

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

void solve() {
    int h, w, n;
    cin >> h >> w >> n;
    cout << (n + max(h, w) - 1) / max(h, w) << EOL;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n, i, j, k, b, c;
    i = 0;
    j = 0;
    scanf("%d\n", &n);
    int a[n] = {};
    if (n >= 2){
        while (i <= n - 2) {
            scanf("%d ", &b);
            a[n - i - 1] = b;
            i += 1;
        }
        scanf("%d", &c);
        a[0] = c;
        while (j <= n - 2){
            printf("%d ", a[j]);
            j += 1;
        }
        printf("%d\n", a[n - 1]);
    } else if (n == 1) {
        scanf("%d", &b);
        printf("%d\n", b);
    }
    
}


Measured memory_bytes: 2616
// kotae maru utsushi
#include <iostream>
using namespace std;


int main(){
	string s;
	cin >> s;
	if(s.size()%2 == 0){
		if(s[0] == s[s.size()-1]){
			cout << "First" << endl;
		}else{
			cout << "Second" << endl;
		}
	}else{
		if(s[0] == s[s.size()-1]){
			cout << "Second" << endl;
		}else{
			cout << "First" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll n;
    cin>>n;
    ll l0=2,l1=1;
    FOR(i,2,n+2){
        if(i%2==0) l0=l1+l0;
        else l1=l1+l0;
    }
    if(n%2==0) cout<<l0<<endl;
    else cout<<l1<<endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        string[] input = ReadLine().Split(' ');
//        long n = long.Parse(input[0]);
//        long m = long.Parse(input[1]);

        int count = 0;
        for(int i=0;i<kazu;i++){
            int temp = int.Parse(input[i]);
            while(temp%2==0){
                temp/=2;
                count++;
            }
        }
        WriteLine(count);
    }
}

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

int main(void)
{
    int A;
    std::cin >> A;

    int B;
    std::cin >> B;
    
    std::vector<int> buf(3);
    buf[0] = A + B;
    buf[1] = A - B;
    buf[2] = A * B;

    int max = *std::max_element(buf.begin(), buf.end());

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

Measured memory_bytes: 256
#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;

string  formula;
int idx;

map<char, int> mp;

int solve(int pri)
{
  static int len = formula.size();
  if(idx >= len) return 0;
  int ret = 0; char c = formula[idx];
  if(c == '(') idx++, ret = solve(0), idx++;
  else if(c == ')') idx++;
  else while(idx < len && isdigit(formula[idx]))
	 ret = ret*10 + (formula[idx++]-'0');
  while(idx < len && mp.count(formula[idx]) && mp[formula[idx]] > pri) {
    char op = formula[idx++];
    if(op == '+') ret += solve(mp[op]);
    else if(op == '-') ret -= solve(mp[op]);
    else if(op == '*') ret *= solve(mp[op]);
  }
  return ret;
}


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

  cin >> formula;
  int ans = LLONG_MIN;
  rep(i, 3) rep(j, 3) rep(k, 3) {
    mp['+'] = i+1, mp['-'] = j+1, mp['*'] = k+1;
    idx = 0; ans = max(ans, solve(0));
  }
  cout << ans << endl;

  return 0;
}

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

int solve(int a,int b,int n){
    int count=0;
    int all=0;

    if(a>=b)
        a %= b;
    if(a==0){
        return 0;
    }
    for(int i=0; i<n; i++){
        all += a*10/b;
        a=a*10%b;
    }
    return all;
}

int main()
{
    int a,b,n;
    while(cin>>a>>b>>n,!cin.eof()){
        cout<<solve(a,b,n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys
 
input = sys.stdin.readline
 
def comb(n, r):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod
 
mod = 998244353
N, M, K = map(int, input().split())
 
fact = [1] * (N + 1)
for i in range(1, N + 1):
    fact[i] = (fact[i-1] * i) % mod #n!を計算
# print('fact:{}'.format(fact))
revfact = [1] * (N + 1) #逆元を定義
revfact[N] = pow(fact[N], mod - 2, mod) #n!のmod-2乗を計算
# print('revfact:{}'.format(revfact))
for i in reversed(range(1, N)): #N-1から1まで
    revfact[i] = ((i + 1) * revfact[i + 1]) % mod
# print('revfact:{}'.format(revfact))
 
ans = 0
for k in range(K + 1):
    ans += (M * pow(M - 1, N - 1 - k, mod) * comb(N - 1, k)) % mod
    ans %= mod
print(ans)

Measured memory_bytes: 24684
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    ll cnt = 0;
    ll tmp = 1000000005;
    rep(i,n){
        cin >> a[i];
        if(a[i]<0){
            cnt++;
        }
        sum += abs(a[i]);
        tmp = min(tmp, abs(a[i]));
    }
    if(cnt %2==0){
        cout << sum << endl;
        return 0;
    }
    cout << (sum - 2*tmp) << endl;
    


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int i;
    string s, ans="";
    cin >> s;
    for(i=0;i<s.size();i++){
        if(s[i]=='B' && !ans.empty()) ans.pop_back();
        else if(s[i]!='B') ans+=s[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#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){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  
  bool flag=true;
  while(A!=0&&B!=0){
    if(flag){
      C-=B;
      flag=false;
    }
else{
A-=D;
  flag=true;
}

    if(A<=0){
cout<<"No"<<endl;
      break;
    }
    else if(C<=0){
cout<<"Yes"<<endl;
      break;
    }
  }
}

    

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

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,K = MI()
	n = N
	ans = 1
	while N >= K:
		N //= K
		ans += 1
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
signed main(){
	int n;cin>>n;
	cout<<"ABC"<<n<<endl;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 303;
int n , u[N] , d[N] , l[N] , r[N];
int dir[N][N];

void match() {
  vector<pii> remain;
  rep(i,0,n) {
    int s = u[i] + d[i];
    if(s > n) {
      puts("NO");
      exit(0);
    }
    remain.pb(mp(-(n - s) , i));
  }
  sort(all(remain));
  rep(i,0,n) {
    int s = l[i] + r[i];
    if(s > n) {
      puts("NO");
      exit(0);
    }
    rep(j,0,s) {
      remain[j].fi++;
      if(remain[j].fi > 0) {
        puts("NO");
        exit(0);
      }
      dir[i][remain[j].se] = 1;
    }
    inplace_merge(remain.begin() , remain.begin() + s , remain.end());
  }
  rep(i,0,n) rep(j,0,n) {
    dir[i][j] = dir[i][j] ? (--l[i] >= 0 ? 0 : 2) : (--u[j] >= 0 ? 1 : 3);
  }
  //rep(i,0,n) rep(j,0,n)
    //printf("%d%c",dir[i][j]," \n"[j == n - 1]);
}

int used[N][N] , instack[N][N];
int dx[4] = {0 , -1 , 0 , 1};
int dy[4] = {-1 , 0 , 1 , 0};
bool dfs(int i,int j) {
  if(used[i][j]) return false;
  if(instack[i][j]) {
    instack[i][j] = false;
    return true;
  }
  instack[i][j] = true;
  int d = dir[i][j];
  for(int ni=i+dx[d],nj=j+dy[d];;ni+=dx[d],nj+=dy[d]) {
    if(ni < 0 || ni >= n || nj < 0 || nj >= n)
      break;
    if(dfs(ni , nj)) {
      dir[ni][nj] = d;
      if(instack[i][j]) {
        instack[i][j] = false;
        return true;
      } else {
        return dfs(i , j);
      }
    }
  }
  used[i][j] = true;
  instack[i][j] = false;
  printf("%c%d\n","LURD"[dir[i][j]],(dir[i][j] & 1 ? j : i) + 1);
  return false;
}

int main(){
  scanf("%d",&n);
  rep(i,0,n) scanf("%d",u+i);
  rep(i,0,n) scanf("%d",d+i);
  rep(i,0,n) scanf("%d",l+i);
  rep(i,0,n) scanf("%d",r+i);
  match();
  rep(i,0,n) rep(j,0,n)
    dfs(i,j);
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int main(){
	string c[105];
	int i,j,n,m;
	cin>>n>>c[0];
	for(i=1;i<n;i++){
		cin>>c[i];
		m=c[i-1].size();
		if(c[i-1][m-1]!=c[i][0]){
				cout<<"No";
				return 0;
			}
		for(j=i-1;j>=0;j--)
			if(c[i]==c[j]){
				cout<<"No";
				return 0;
			}
	}
	cout<<"Yes";
	return 0; 
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        n: usize,
    }
    for i in 0..(n/4)+2 {
        for j in 0..(n/7)+2 {
            let v = 4*i + 7*j;
            if n == v {
                println!("{}", "Yes");
                return;
            }
        }
    }
    println!("{}", "No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int dp[22][1<<21];
int main()
{
    int N; cin >> N;
    vector<vector<int>> pair(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int a; cin >> a;
            if (a) pair[i].push_back(1 << j);
        }
    }
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int b : pair[i-1]) {
            for (int k = 0, m = 1 << N; k < m; k++) {
                if ((k & b) == 0) {
                    (dp[i][k | b] += dp[i-1][k]) %= MOD;
                }
            }
        }
    }
    cout << dp[N][(1 << N) - 1] << endl;
    return 0;
}

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

bool arr[201];

int main(void) {
    int n,k;
    scanf("%d %d\n",&n,&k);
    for(int i=0;i<k;i++) {
        int d;
        scanf("%d\n",&d);
        for(int j=0;j<d;j++) {
            int x;
            scanf("%d",&x);
            arr[x]=true;
        }
    }
    int ret=0;
    for(int i=1;i<=n;i++) {
        if (!arr[i]) {
            ret++;
        }
    }
    printf("%d",ret);
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
const int INF = 1e9;
typedef long long ll;
typedef pair<ll, ll> P;

auto cmn=[](auto&x,auto y){if(x>y){x=y;return true;}return false;};
//return TRUE; はその関数が正常に終了（期待した結果）することを示し、return FALSE; は関数が失敗（期待しなかった結果）
//trueやfalseなどを返すのは多くの場合「関数の実行が成功/失敗した」といったことを呼び出し側に知らせるために使います。ですので、エラー終了などの場合はfalse、正常終了の場合はtrueです。

int main() {
    ll a,b,n;
    cin >> a >> b >>n;
    cmn(n,b-1);
    cout << a*n/b <<endl;
}

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

using namespace std;
 
 #define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define fill(a,b) memset(a, b, sizeof(a))
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long int
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define L(x) ('a'<=x && x<='z')
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int Maxn  =  200*1000 + 1;
const ld  pi   =  acos(-1);
const int mod =  1000000007;
const double epsilon = 1e-9; 
 
 
template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,unordered_set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}

int binpow(int a,int b) {
    a=a%mod;
   
    int res = 1;
while (b > 0) {
        if (b & 1)res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
}
return (res+mod)%mod;
}



 int32_t main(){
    IOS;
 
   int t;
   //cin>>t;
       t=1;
   while(t--){

    int n;
    cin>>n;

    vector<int>p(n),m(n),p2(n),m2(n);

    fr(i,0,n){
       int x,y;
       cin>>x>>y;

       p[i]=x+y;
       p2[i]= -x+y;
       m[i]=x-y;
       m2[i]= -x-y;
    }

    sort(all(p));
    sort(all(m));
    sort(all(p2));
    sort(all(m2));

    int x= max(p[n-1]-p[0],m[n-1]-m[0]);

    x=max(x,p2[n-1]-p2[0]);
    x=max(x,m2[n-1]-m2[0]);

    cout<<x<<endl;

    
   }
}
 

Measured memory_bytes: 9532
from math import sin, pi
def calc(n):
    s = a = 0
    V = []
    for i in range(n-1):
        v = int(input())
        s += v
        a += sin(v*pi/180)
        V.append(v)
    V.append(360-s)
    a += sin((360-s)*pi/180)
    return a, sorted(V)
while 1:
    m = int(input())
    if m == 0:
        break
    a1, V1 = calc(m)
    n = int(input())
    a2, V2 = calc(n)
    if V1 == V2 or a1 == a2:
        print(0)
    elif a1 < a2:
        print(2)
    else:
        print(1)

Measured memory_bytes: 7720
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception, std.typecons, std.container;

  int h, w; rd(h, w);
  auto c=new char[][](h, w);
  foreach(i; 0..h) c[i]=readln.chomp.to!(char[]);

  auto n=h*w;
  alias E=Tuple!(int, "to", int, "cost");
  auto g=new E[][](n);
  auto dir=[[1, 0], [-1, 0], [0, 1], [0, -1]];
  foreach(i; 0..h)foreach(j; 0..w){
    if(c[i][j]=='#') continue;
    foreach(dd; dir){
      auto ai=i+dd[0], aj=j+dd[1];
      if(ai<0 || ai>=h || aj<0 || aj>=w) continue;
      if(c[ai][aj]=='.'){
        g[i*w+j]~=E(ai*w+aj, 1);
        g[ai*w+aj]~=E(i*w+j, 1);
      }
    }
  }
  auto d=new int[](n);
  const int inf=1e9.to!(int);
  fill(d, inf);
  alias P=Tuple!(int, "v", int, "dist");
  auto Q=new RedBlackTree!(P, "a.dist<b.dist", true);
  d[0]=0; Q.insert(P(0, 0));
  while(Q.length>0){
    auto cur=Q.front; Q.removeFront;
    foreach(e; g[cur.v]){
      if(d[e.to]<=d[cur.v]+e.cost) continue;
      d[e.to]=d[cur.v]+e.cost;
      Q.insert(P(e.to, d[e.to]));
    }
  }
  if(d[n-1]==inf){writeln(-1); return;}

  int bk=0;
  foreach(i; 0..h) bk+=count(c[i], '#');
  auto res=n-bk-(d[n-1]+1);
  enforce(res>=0);
  writeln(res);
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 2812
#include<stdio.h> 

int main() {
	int n, k, a[100];
	scanf("%d %d",&n,&k);
	for(int i = 0;i < 100;i ++) {
		a[i] = 0;
	}
	for(int i = 0;i < k;i ++) {
		int d;
		scanf("%d",&d);
		for(int j = 0;j < d;j ++) {
			int t;
			scanf("%d",&t);
			if(a[t - 1] == 0) {
				a[t - 1] = 1;
			}
		}
	}
	int sum = 0;
	for(int i = 0;i < n;i ++) {
		if(a[i] == 0) {
			sum ++;
		}
	}
	printf("%d",sum);
}

Measured memory_bytes: 1736
n = int(input())
s = input()
x = 0
point = [0] * (n + 1)
for i in range(n) :
    if s[i] == "I" :
        point[i+1] = point[i] + 1
    if s[i] == "D" :
        point[i+1] = point[i] - 1
print(max(point))


Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;
static const int INF = 999999;
struct SEdge
{
	int To;
	int Cost;
};
int V, E;
vector<int> mincost;
vector< vector<SEdge> > G;
bool used[128];

int Prim()
{
	fill(used, used + V, false);
	fill(mincost.begin(), mincost.end(), INF);
	mincost[0] = 0;
	priority_queue<P, vector<P>, greater<P> > PQue;
	PQue.push(P(0, 0));
	int res = 0;
	while(!PQue.empty())
	{
		P p = PQue.top();
		PQue.pop();
		int v = p.second;
		if(mincost[v] < p.first || used[v])
		{
			continue;
		}
		used[v] = true;
		res += p.first;
		for(int i = 0; i < G[v].size(); ++i)
		{
			SEdge e = G[v][i];
			if(mincost[e.To] > e.Cost)
			{
				mincost[e.To] = e.Cost;
				PQue.push(P(mincost[e.To], e.To));
			}
		}
	}
	return(res);
}

void solve()
{
	while(cin >> V, V)
	{
		for(int i = 0; i < G.size(); ++i)
		{
			G[i].clear();
		}
		G.clear();
		cin >> E;
		mincost.resize(V);
		G.resize(V);
		for(int i = 0; i < E; ++i)
		{
			int From, To, Cost;
			scanf("%d,%d,%d", &From, &To, &Cost);
			SEdge e1, e2;
			e1.To = To;
			e2.To = From;
			e1.Cost = e2.Cost = Cost / 100 - 1;
			G[From].push_back(e1);
			G[To].push_back(e2);
		}
		cout << Prim() << endl;
	}
}

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

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int k,s;
int main(void){
  cin >> k >> s;
  int ans = 0;
  for(int i = 0; i <= k; i++)
    for(int j = 0; j <= k; j++)
      if(0 <= s-i-j && s-i-j <= k)
	ans++;
  cout << ans << endl;
}


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

int main(){
  ll n;
  cin >> n;
  n--;
  ll a = 26;
  int b = 1;
  while(true) {
    if(n - a < 0) break;
    n -= a;
    a *= 26;
    b++;
  }
  string s = "";
  rep(i,b) {
    a /= 26;
    ll d = n / a;
    n -= (d*a);
    s += (char)('a'+d); 
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3640
from itertools import combinations
n = int(input())
s = list(map(lambda s:s[0], [input() for _ in range(n)]))
marchn = [s.count(c) for c in list("MARCH")]
ans = 0
for li in combinations(marchn, 3):
    ans += li[0] * li[1] * li[2]
print(ans)

Measured memory_bytes: 10540
N,T=gets.split.map &:to_i
ts=gets.split.map &:to_i
cnt=0
for i in 0..N-2
    cnt+=ts[i+1]-ts[i] if ts[i+1]-ts[i]<T
    cnt+=T if ts[i+1]-ts[i]>=T
end
cnt+=T
puts cnt


Measured memory_bytes: 16004
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    vector<int> a(N);
    for(int i=0; i<N; i++)
        a[i] = L + i;

    int min_val=99999, min_idx=0;
    for(int i=0; i<N; i++) {
        if(min_val > abs(a[i])) {
            min_idx = i;
            min_val = abs(a[i]);
        }
    }
            

    cout << accumulate(a.begin(), a.end(), 0) - a[min_idx] << endl;

    return 0;
}

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

int main() {
  int A, B; cin >> A >> B;
  if (A <= B) { cout << "Impossible" << '\n'; exit(0); }
  stack<int> s;
  for (int i = 0; i < A+B; i++) {
    if (s.empty()) { s.push(i); continue; }
    cout << '?' << ' ' << s.top() << ' ' << i << '\n' << flush;
    char c; cin >> c;
    if (c == 'N') s.pop();
    else s.push(i);
  }
  string ans;
  for (int i = 0; i < A+B; i++) {
    cout << '?' << ' ' << s.top() << ' ' << i << '\n' << flush;
    char c; cin >> c;
    if (c == 'Y') ans += '1';
    else ans += '0';
  }
  cout << '!' << ' ' << ans << '\n';
  exit(0);
}

Measured memory_bytes: 848
#include<stdio.h>
#include<string.h>

int main(){

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

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

  int count = 0;
  for(int i = 0; i <n ; ++i){
    while( a[i] % 2 == 0 ){
      a[i] /= 2;
      ++count;
    }
  }

  printf("%d",count);
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
vi H(N);
rep(i,N) cin >> H[i];

int M = 0;
int cnt = 0;
rep(i,N) {
    if(H[i] >= M) cnt++;
    M = max(M,H[i]);
}

cout << cnt << endl;

return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int S[100010];

int main(int argc, char *argv[])
{
  int N, ans = 0, a;
  cin >> N;

  for (int i = 0; i < 100010; i++) S[i] = 0;
  for (int i = 0; i < N; i++) {
    cin >> a;
    S[a]++;
  }

  for (int i = 0; i < 100010; i++) {
    ans = max(ans, S[i] + S[i + 1] + S[i + 2]);
  }

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


Measured memory_bytes: 640
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    using namespace std ;
    int main(){
        int A,B,C,D;
        cin>>A>>B>>C>>D;
        if(A+B>C+D)cout<<"Left"<<endl;
        if(A+B==C+D)cout<<"Balanced"<<endl;
        if(A+B<C+D)cout<<"Right"<<endl;
        return 0 ;
    }

Measured memory_bytes: 256
//此程序使用了qt专属名称，请勿模仿。侵权必究！！！
//我真是太菜了…… 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define i_i pair<int,int>
const int N=1e5+10;
int n,m,t=0,b[N<<1],w[N];
bool v[N];
priority_queue< i_i,vector<i_i>,greater<i_i> > q;
struct tq
{
	int y;
	int next;
}a[N<<1];
inline void in(int x,int y)
{
	a[++t].next=b[x];
	b[x]=t;
	a[t].y=y;
	return;
}
inline int read()
{
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<n;++i)
	{
		int x=read(),y=read();
		in(x,y);
		in(y,x);
	}
	m=read();
	for(int i=1;i<=m;++i)
	{
		int x=read();
		w[x]=read();
		v[x]=1;
		q.push(i_i(w[x],x));
	}
	while(!q.empty())
	{
		int x=q.top().second;
		q.pop();
		for(int i=b[x];i;i=a[i].next)
		{
			int y=a[i].y;
			if(v[y])
			{
				if(abs(w[x]-w[y])!=1)
				{
					puts("No");
					return 0;
				}
			}
			else
			{
				w[y]=w[x]+1;
				q.push(i_i(w[y],y));
				v[y]=1;
			}
		}
	} 
	puts("Yes");
	for(int i=1;i<=n;++i)
	{
		printf("%d\n",w[i]);
	}
	return 0;
}

Measured memory_bytes: 4212
from operator import itemgetter
n, m = map(int, input().split())
yobo = []
for _ in range(m):
    a, b = map(int, input().split())
    yobo.append((a, b))

yobo = sorted(yobo, key=itemgetter(1))
ans = 0
rem = -1

for i in range(m):
    if rem < yobo[i][0]:
        rem = yobo[i][1] - 1
        ans += 1

print(ans)


Measured memory_bytes: 18992
import itertools
from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))

p = [(p[i] + 1) / 2 for i in range(n)]

csum = [0] + list(accumulate(p))

def range_sum(l, r):
    return csum[r] - csum[l]

ret = 0
for i in range(n - k + 1):
    ret = max(ret, range_sum(i, i + k))
print(ret)

Measured memory_bytes: 25148
h, w = map(int, input().split())
grid = [['#' for i in range(w+2)]]
for i in range(h):
  grid.append(['#'] + [s for s in str(input())] + ['#'])
grid.append(['#' for i in range(w+2)])

U = [[0 for j in range(w+2)] for i in range(h+2)]
D = [[0 for j in range(w+2)] for i in range(h+2)]
L = [[0 for j in range(w+2)] for i in range(h+2)]
R = [[0 for j in range(w+2)] for i in range(h+2)]

for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    U[i][j] = U[i-1][j] + 1
    L[i][j] = L[i][j-1] + 1
for i in range(h, 0, -1):
  for j in range(w, 0, -1):
    if grid[i][j] == '#': continue
    D[i][j] = D[i+1][j] + 1
    R[i][j] = R[i][j+1] + 1

ans = 0
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    cnt = U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3
    ans = max(ans, cnt)
    #print(i, j, cnt)
print(ans)

Measured memory_bytes: 315656
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(){
    int i;
    int n;
    char s[100001][8];
    int ac, wa, tle, re;
    ac = wa = tle = re = 0;

    scanf("%d", &n);
    for(i = 0;i < n;i++) scanf("%s", s[i]);

    for(i = 0;i < n;i++){
        switch(s[i][0]){
            case 'A':
                ac++;
                break;
            case 'W':
                wa++;
                break;
            case 'T':
                tle++;
                break;
            case 'R':
                re++;
                break;
        }
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac, wa, tle, re);

    return 0;
}


Measured memory_bytes: 2512
import sys
import os

def main():
    for s in sys.stdin:
        s = float(s)
        if s  <= 48.0:
            print('light fly')
        elif s <= 51.0:
            print('fly')
        elif s <= 54.0:
            print('bantam')
        elif s <= 57.0:
            print('feather')
        elif s <= 60.0:
            print('light')
        elif s <= 64.0:
            print('light welter')
        elif s <= 69.0:
            print('welter')
        elif s <= 75.0:
            print('light middle')
        elif s <= 81.0:
            print('middle')
        elif s <= 91.0:
            print('light heavy')
        else:
            print('heavy')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 5576
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	var sum float64
	for _, a := range as {
		sum += 1.0 / float64(a)
	}

	fmt.Println(1.0 / sum)
}


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;

int n, k, x, y;

int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }

  //  string str;
    cin >> n >> k >> x;// >> y;
 //   cin >> str;
 //   vector<int> cnt(26, 0);


    cout << (double)(n + k) * x / 2 << endl;
    return 0;
}


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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  vector<string> g(n);
  for (int i = 0; i < n; i++) {
    cin >> g[i];
  }

  vector<vector<bool>> visit(n, vector<bool>(m));
  struct Node {
    int x, y, d;
  };
  queue<Node> q;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == '#') {
        q.push({i, j, 0});
        visit[i][j] = true;
      }
    }
  }
  
  auto inside = [&](int x, int y) {
    return 0 <= x && x < n && 0 <= y && y < m;
  };
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};

  int ans = 0;
  while (q.size()) {
    auto v = q.front(); q.pop();
    for (int i = 0; i < 4; i++) {
      int x = v.x + dx[i];
      int y = v.y + dy[i];
      if (inside(x, y) && !visit[x][y]) {
        visit[x][y] = true;
        q.push({x, y, v.d + 1});
        ans = max(ans, v.d + 1);
      }
    }
  }
  
  cout << ans << '\n';
  return 0;
}

  


Measured memory_bytes: 16584
#include<cstdio>
#include<algorithm>
using namespace std;
int A,B,C,x,y,tmp,ans;
int main() {
	scanf("%d%d%d%d%d",&A,&B,&C,&x,&y);
	ans=2e9;
	for (int i=0;i<=max(x*2,y*2);i++) {
		tmp=i*C;
		if (i<x*2) tmp+=(x-i/2)*A;
		if (i<y*2) tmp+=(y-i/2)*B;
		ans=min(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 128
#include<stdio.h>

int main (void)
{
        int d;
        scanf("%d",&d);
        if (d==25)     printf("Christmas\n");
        else if(d==24) printf("Christmas Eve\n");
        else if(d==23) printf("Christmas Eve Eve\n");
        else if(d==22) printf("Christmas Eve Eve Eve\n");
        return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;

int main(void){

    string N;
    cin>>N;
    int M;
    M=N.size();
    
    int T;
    T=0;
    
    for(int i=0;i<M;i++){

        T=T+N[i]-'0';
        
    }
    
    int n;
    n=stoi(N);
    
    
   
    
    if(n%T==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    } 
    
}

Measured memory_bytes: 256
import fractions
 
N, M = [int(i) for i in raw_input().split(" ")]
S = raw_input()
T = raw_input()
 
def solve():
    gcd = fractions.gcd(N, M)
    for i in range(1, gcd + 1):
        if S[-int(N / gcd) * i] != T[-int(M / gcd) * i]:
            return -1
    return int(N * M / gcd)
 
print(solve())

Measured memory_bytes: 4776
import java.io.*;
import java.util.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        while(true){
            StringTokenizer st=new StringTokenizer(br.readLine());
            int x=Integer.parseInt(st.nextToken());
            int y=Integer.parseInt(st.nextToken());
            if(x==0&&y==0) break;
            System.out.println(Math.min(x,y)+" "+Math.max(x,y));
        }
    }
}

Measured memory_bytes: 26736
# https://atcoder.jp/contests/abc126/tasks/abc126_d

import heapq
from collections import defaultdict

class Dijkstra:
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
        return list(reversed(path))

n = int(input())
route_map = [dict() for _ in range(n)]
for i in range(n - 1):
    u, v, wi = map(int, input().split())
    u, v = u - 1, v - 1
    route_map[u][v] = wi
    route_map[v][u] = wi

d = Dijkstra(route_map, 0).execute()
for k in range(n):
    if d[k] % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 105248
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int a, b; cin >> a >> b;
	if (b < a)cout << a - 1 << endl;
	else cout << a << endl;
}

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

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

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

    ll ans = 0;
    for(int i = 1; i<=n; i++) {
        if(i%3==0) {
        }else if(i%5 == 0) {
        }else if(i%3 == 0 && i%5 == 0) {
        }else{
            ans += i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> A(n), P(n), Q(n);
  REP(i, n) cin >> P[i]; REP(i, n) cin >> Q[i];
  iota(A.begin(), A.end(), 1);
  int a = -1, b = -1;
  int i = 1;
  do {
    if (A == P) a = i;
    if (A == Q) b = i;
    if (a != -1 && b != -1) break;
    i++;
  } while (next_permutation(A.begin(), A.end()));
  int ans = a - b;
  ans = abs(ans);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

int main() {
  int N;
  cin >>N;
  vector<int> a(N),b(N);
  for(int i=0; i<N; i++){
    cin >>a[i];
    b[i]=a[i];
  }
  sort(b.begin(), b.end());
  for(int i=0; i<N; i++){
    if(a[i] != b[N-1])
      cout <<b[N-1] <<endl;
    else
      cout <<b[N-2] <<endl;
  }
}

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

using namespace std;
typedef long long ll;
const int mxN=101,mxW=100100;
int wt[mxN],val[mxN];
ll dp[mxN][mxW];
int maxx;

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,w; cin>>n>>w;
    for(int i=1;i<=n;i++) {
        cin>>wt[i]>>val[i];
        maxx=max(maxx,wt[i]);
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=w;j++) {
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            if(wt[i]<=j) dp[i][j]=max(dp[i][j],val[i]+dp[i-1][j-wt[i]]);
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int a,b;
    cin>>a>>b;
    cout<<a*b-(a+b)+1<<endl;

}


Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	int x;
	cin >> x;
	if (x >= 400 and x <= 599)
		cout << "8";
	if (x >= 600 and x <= 799)
		cout << "7";
	if (x >= 800 and x <= 999)
		cout << "6";
	if (x >= 1000 and x <= 1199)
		cout << "5";
	if (x >= 1200 and x <= 1399)
		cout << "4";
	if (x >= 1400 and x <= 1599)
		cout << "3";
	if (x >= 1600 and x <= 1799)
		cout << "2";
	if (x >= 1800 and x <= 1999)
		cout << "1";
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    if(N==1)cout<<"Hello World"<<endl;
    else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


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

int main(void)
{   
    int counter = 0;
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == '1')   counter++;
    }

    cout << counter << endl;
    

    return 0;
}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fl '\n'
#define vi vector<int>
#define sz size
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

multiset<char>st;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    string s;
    cin>>s;
    for(int i=0;i<s.sz();i++){
        st.insert(s[i]);
    }
    bool flg=true;
    for(auto it:st){
        if(st.count(it)&1){flg=false;break;}
    }
    if(flg)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    string s;
    cin >> s;

    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
        if (s[i] == 'o')
            cnt++;

    cnt += 15 - s.length();
    if (cnt >= 8)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

int main(){
    int N,K; cin >> N >> K;
    vector <int> P(N);
    rep(i,N) cin >> P[i];
    rep(i,N) P[i]++;
    int mx=0;
    int s=0;
    
    queue<int> Q;
    rep(i,N){
        s+=P[i];
        Q.push(P[i]);
        if (Q.size() > K){
            s-=Q.front(); Q.pop();
        }
        if (Q.size() == K){
            mx=max(mx,s);
        }
    }
    double ans=mx;
    ans/=2;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 1792