akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    int ans;
    scanf("%d%d%d",&a,&b,&c);
    ans=a-b;
    ans=c-ans;
    if(ans<0)
    {
        ans=0;
    }
    printf("%d",ans);
}


Measured memory_bytes: 128
import Data.List

main :: IO ()
main = do
  getLine
  vs <- getInts
  print $ solve vs

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: [Int] -> Int
solve vs = calc (count o) (count e)
  where (o,e) = sp vs

sp :: [Int] -> ([Int],[Int])
sp [] = ([],[])
sp (o:e:res) = let (o1,e1) = sp res in (o:o1,e:e1)

count :: [Int] -> [(Int,Int)]
count = map (\x -> (head x,length x)) . group . sort

calc :: [(Int,Int)] -> [(Int,Int)] -> Int
calc [] _ = 0
calc _ [] = 0
calc xs ys | o /= e = f os + f es
           | otherwise = min (m + calc xs es) (n + calc os ys)
  where
    f = sum . map snd
    (o,n,os) = select xs
    (e,m,es) = select ys

select :: [(Int,Int)] -> (Int,Int,[(Int,Int)])
select ((x0,n0):xs) = foldl' (\(x,n,xs) (y,m) -> if n > m then (x,n,(y,m):xs) else (y,m,(x,n):xs)) (x0,n0,[]) xs


Measured memory_bytes: 43388
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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 inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll n;
    cin >> n;
    auto cnt = [](ll i) {
        int ret = 0;
        while(i > 0) {
            ret++;
            i /= 10;
        }
        return ret;
    };
    int ans = inf;
    for(int i = 1; (ll)i*i <= n; i++) {
        if(n%i != 0) continue;
        chmin(ans,cnt(n/i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>

using namespace std;

int main(){
	int n,m;
	int ans,tmp;


	cin >> n>>m;
	ans = n;
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		ans -= tmp;
	}
	if (ans < 0) {
		ans = -1;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

int main() {
	ll A, B, C;
	cin >> A >> B >> C;
	ll ans = 0;
	ll t = min(A, C);
	C -= t;
	ans += t;
	t = min(B, C);
	C -= t;
	if (C > 0) ans++;
	ans += t;
	ans += B;
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using Mat = vector<vector<int>>;

int main(){
    int n, m;
    cin >> n >> m;
    vi a(m),b(m);
    rep(i, m) cin >> a[i] >> b[i];

    vi node(n);
    for(int i=1; i<=n; ++i) node[i-1] = i;
    int ans = 0;

    do{
        bool can = false;
        rep(i,n-1){
            can = false;
            rep(j,m){
                if((node[i]==a[j] && node[i+1]==b[j]) || (node[i]==b[j] && node[i+1]==a[j])){
                    can = true;
                    break;
                }
            }
            if(can==false) break;
        }
        if(can && node[0]==1) ans += 1; 
    }
    while(next_permutation(all(node)));

    cout(ans);
    
    return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n,m,x;
    cin>>n>>m>>x;
    Vi c(n);
    VVi a(n,Vi(m));
    REP(i,0,n){
        cin>>c[i];
        REP(j,0,m){
            cin>>a[i][j];
        }
    }

    int ans=INF;
    for(int mask=0; mask<(1<<n); mask++){
        Vi ability(m);
        int cost=0;
        REP(i,0,n){
            if(mask&(1<<i)){
                cost+=c[i];
                REP(j,0,m){
                    ability[j]+=a[i][j];
                }
            }
        }
        bool check=true;
        REP(i,0,m){
            if(ability[i]<x) check=false;
        }
        if(check) chmin(ans,cost);
    }
    cout<<(ans==INF?-1:ans)<<endl;
}

Measured memory_bytes: 3616
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(1, N-1):
  if P[i-1] < P[i] < P[i+1]:
    ans += 1
  elif P[i+1] < P[i] < P[i-1]:
    ans += 1
print(ans)    

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

int main(){
   int k, n;
   cin >> k >> n;
   vector<int> a(n);
   for(int i = 0; i < n; i++) {
      cin >> a[i];
   }
   a.push_back(a[0]+k);
   int M = 0;
   //折り返す必要はない
   for(int i = 0; i < n; i++){
      M = max(M, a[i+1]-a[i]);
   }
   int ans = k-M;
   cout << ans << endl;
   return 0;
}
 

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

int main(){
	ll a,b,k; cin >> a >> b >> k;
	if(a > k)cout << a - k <<" "<< b << endl;
	else if(a <= k && a + b > k)cout << 0 <<" " << a + b - k << endl;
	else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		while(true)
		{
			int n = sc.nextInt();
			
			if(n == 0)break;
			
			int min = 99999;
			int max = -99999;
			int sum = 0;
			
			for(int i = 0; i < n; i++)
			{
				int in = sc.nextInt();
				sum += in;
				
				min = Math.min(in, min);
				max = Math.max(in, max);
			}
			
			sum = sum - min - max;
			sum /= n-2;
			
			System.out.println(sum);
		}
	}

}



Measured memory_bytes: 29408
#include<cstdio>

using namespace std;

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int p[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &p[i]);
    }
    int sm = 0;
    int s = 0;
    for(int i = 0; i < k; i++){
        s += p[i] + 1;
    }
    sm = s;
    // printf("%d\n", s);
    for(int i = k; i < n; i++){
        s -= (p[i-k] + 1);
        s += (p[i] + 1);
        if (s > sm) sm = s;
        // printf("%d\n", s);
    }
    double mx;
    mx = (double)sm;
    mx = mx / 2;
    printf("%.16f\n", mx);

}

Measured memory_bytes: 896
import copy
import sys
import math

def main():
	a,b,c = map(int,input().split())
	ca = a
	cb = b
	cc = c
	count = 0
	if(ca%2==1  or cb%2==1 or cc%2==1):
		print(count)
		sys.exit()
	ca,cb,cc = int((cb+cc)/2),int((ca+cc)/2),int((cb+ca)/2)
	
	count+=1
	while a != ca or b !=  cb or c !=  cc:
		if(ca%2==1  or cb%2==1 or cc%2==1):
			print(count)
			sys.exit()
		ca,cb,cc = int((cb+cc)/2),int((ca+cc)/2),int((cb+ca)/2)
		count+=1
	print(-1)


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define pii pair<ll int, ll int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define repi(i, n) for(ll i=0; i<n; i++)
#define rep(i, a, b) for(ll i=a; i<=b; i++)
#define M 1000000007
#define INF 1e10

using namespace std;

void dfs(vector <vector<ll>> &adj, vector <ll> &dp, vector <bool> &vis, ll root){
    vis[root] = true;
    ll ans = 0;
    for(auto x: adj[root]){
        if(dp[x] == -1) dfs(adj, dp, vis, x);
        ans = max(ans, 1+dp[x]);
    }
    dp[root] = ans;
}

int main() {
    ios
    ll n, m;
    cin>>n>>m;
    vector <vector<ll>> adj(n+1, vector<ll>(0));
    vector <ll> dp(n+1, -1);
    vector <bool> vis(n+1, false);
    repi(i, m){
        ll u, v;
        cin>>u>>v;
        adj[u].pb(v);
    }
    ll ans = 0;
    rep(i, 1, n){
        if(!vis[i]){
            dfs(adj, dp, vis,  i);
            ans = max(ans, dp[i]);
        }
    }
    cout<<ans;
    return 0;
}

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


public class Main {
    public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    }

    private static boolean bmStringSearch(String word, String key){
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    }


}

Measured memory_bytes: 24444
w, h, n = [int(i) for i in input().split()]
area = [0, w, 0, h]
for i in range(n):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        area[0] = max(area[0], x)
    if a == 2:
        area[1] = min(area[1], x)
    if a == 3:
        area[2] = max(area[2], y)
    if a == 4:
        area[3] = min(area[3], y)
print(max(area[1] - area[0], 0) * max(area[3] - area[2], 0))

Measured memory_bytes: 3064
n=10**5
p=[0,0]+[1]*~-n
for i in range(2,int(n**0.5)+1):
  if not p[i]:continue
  for j in range(i*2,n+1,i):p[j]=0
c=[0]
for i in range(1,n+1):
  c.append(c[-1]+(i%2and p[i]and p[-~i//2]))
for _ in range(int(input())):
  l,r=map(int,input().split())
  print(c[r]-c[l-1])

Measured memory_bytes: 7908
#include <stdio.h>
#include <iostream>

#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main() {
  int N;
  char S[100];

  scanf("%d", &N);
  scanf("%s", S);

  int ans = 0;
  for(int i = 0; i < N; i++){
    int tmp_ans = 0;
    map<char, int> mp;
    for(int a = 0; a <= i; a++){
      char test = S[a];
      for(int b = 0; b < N - i; b++){
        if(test == S[N - b]){
          if(mp.find(test) == mp.end()){
            mp[test] = 1;
            tmp_ans++;
          }
        }
      }
    }
    if(tmp_ans > ans){
      ans = tmp_ans;
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        int N;
        long K;
        int[] A;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            N = in.Int();
            K = in.Long();
            A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.Int() - 1;
            }

            int[] current = IntStream.rangeClosed(0, N - 1).toArray();
            int[] next = Arrays.copyOf(A, N);
            int ans = 0;
            while (K > 0) {
                if ((K & 1) == 1) {
                    ans = next[ans];
                }
                current = Arrays.copyOf(next, N);
                for (int i = 0; i < N; i++) {
                    next[i] = current[next[i]];
                }
                K >>= 1;
            }
            out.println(ans + 1);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

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

        public long Long() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 58784
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
ll a[200005],b[200005];
int main()
{
    int n,x;
    
    cin>>n;
    for(int i=1;i<200005;i++)
    {
    	a[i]=0;
    	b[i]=0;
	}
    for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		b[a[i]]++;
	}
	ll ans=0;
	for(int i=1;i<200005;i++)
	{
		if(b[i]<=1)
			continue;
		ll t=b[i];
		ans+=t*(t-1)/2;
	}
    for(int i=0;i<n;i++)
    {
    	if(b[a[i]]==1)
    	{
    		printf("%lld\n",ans);
		}
		else
		{
			ll t=b[a[i]];
			printf("%lld\n",ans-t*(t-1)/2+(t-1)*(t-2)/2);
		}
			
    	
	}
    return 0;
}

Measured memory_bytes: 5760
import math
a,b,n = map(int, input().split())
if (n >= b-1):
    ans = math.floor(a*(b-1)/b) - a*(math.floor((b-1)/b))
    print(ans)
else:
    x = n
    ans = math.floor(a*(x)/b) - a*(math.floor((x)/b))
    print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,x;
  cin>>N>>x;
  long long A[N];
  for(long long i=0;i<N;i++){
    cin>>A[i];
  }
  long long ans=0;
  if(A[0]>x){
    ans+=A[0]-x;
    A[0]=x;
  }
  long long temp=0;
  for(long long i=1;i<N;i++){
    if(A[i-1]+A[i]>x){
      temp=A[i-1]+A[i]-x;
      ans+=temp;
      A[i]-=temp;
    }
  }
  cout<<setprecision(18)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4328
n = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(n-2):
    if p[i] < p[i+1] < p[i+2]:
        ans+=1
    if p[i] > p[i+1] > p[i+2]:
        ans+=1
print(ans)

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

int main(){
	int N,Z,W;
	cin>>N>>Z>>W;
	int a[2000];
	for(int i=0;i<N;i++){cin>>a[i];}
	int L=a[N-1];
	//N=1は例外？
	if(N==1){cout<<abs(W-L);}
	else{
		int Lx=a[N-2];
		if(abs(W-L)>abs(Lx-L)){
			cout<<abs(W-L);
		}
		else{
			cout<<abs(Lx-L);
		}
		//Wとラス前のスコアを比較して大きい方
	}	
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    main2();
  }

  private static void main1() {
    Scanner scanner = new Scanner(System.in);
    String line = scanner.next();
    String seikai = "CODEFESTIVAL2016";
    int count = 0;
    for (int i = 0; i < line.length(); i++) {
      if (line.charAt(i) != seikai.charAt(i))
        count++;
    }
    System.out.println(count);
    scanner.close();
  }

  private static void main2() {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    String s = scanner.next();
    int all = 0;
    int overSea = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'a') {
        if (all < (a + b)) {
          System.out.println("Yes");
          all++;
        } else
          System.out.println("No");
      } else if (s.charAt(i) == 'b') {
        if ((all < (a + b)) && overSea < b) {
          System.out.println("Yes");
          all++;
          overSea++;
        } else
          System.out.println("No");
      } else {
        System.out.println("No");
      }

    }
    // N A B
    // S
    scanner.close();
  }

  private static void main3() {
    Scanner scanner = new Scanner(System.in);
    String line = scanner.next();
    scanner.close();
  }

  private static void main4() {
    Scanner scanner = new Scanner(System.in);
    String line = scanner.next();
    scanner.close();
  }

}

Measured memory_bytes: 23088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<ll> a;
    vector<ll> b;
    for(int i=0;i<n;i++){
        ll k;
        cin>>k;
        a.pb(k);
        b.pb(k);
    }
    ll evenans=0; // even +ve 0index
    ll oddans=0; // odd +ve

    for(int i=0;i<n;i+=2){
        if(a[i]<0){
            evenans-=a[i];
            a[i]=0;
        }
    }
    for(int i=1;i<n;i+=2){
        if(a[i]>0){
            evenans+=a[i];
            a[i]=0;
        }
    }
    ll count=0;
    for(int i=0;i<=n-1;i++){
        count+=a[i];
        if((i&1)==0){
            if(count<=0){
                evenans=evenans-count+1;
                count=1;
            }
        }
        else{
            if(count>=0){
                evenans=evenans+count+1;
                count=-1;
            }
        }
    }



    for(int i=0;i<n;i+=2){
        if(b[i]>0){
            oddans+=b[i];
            b[i]=0;
        }
    }
    for(int i=1;i<n;i+=2){
        if(b[i]<0){
            oddans-=b[i];
            b[i]=0;
        }
    }
    count=0;
    for(int i=0;i<=n-1;i++){
        count+=b[i];
        if((i&1)==1){
            if(count<=0){
                oddans=oddans-count+1;
                count=1;
            }
        }
        else{
            if(count>=0){
                oddans=oddans+count+1;
                count=-1;
            }
        }
    }
    //cout<<oddans<<' '<<evenans<<endl;
    cout<<min(oddans,evenans)<<endl;
    return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    ll n, ans = 0;
    cin>>n;
    vi v(n);
    map<ll,  ll>cnt;
    for(int i = 0; i < n; i++){
        cin>>v[i];
        cnt[v[i]]++;
    }   
    for(auto it:cnt){
        ans+=cnt[it.f]*(cnt[it.f]-1)/2;
    }
    for(int i = 0; i < n; i++){
        ans-=1ll*cnt[v[i]]*(cnt[v[i]]-1)/2;
        cout<<ans+(1ll*(cnt[v[i]]-1)*(cnt[v[i]]-2)/2)<<"\n";
        ans+=cnt[v[i]]*(cnt[v[i]]-1)/2;
    }
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 10368
#include<cstdio>
#include<cstring>
#include<iostream>

using namespace std;

int main()
{
	int m,n;
	cin >> n >> m;
	int a[10005];
	for(int i = 0; i < m; i ++){
		cin >> a[i];
	}
	int sum = 0;
	for(int i = 0; i < m; i++){
		sum += a[i];
	}
//	cout << sum << endl;
	if(sum > n){
		cout << "-1" << endl;
	}
	if(sum <= n){
		int num = n-sum;
		cout << num << endl;
	}
	return 0;
}
	

Measured memory_bytes: 3584
str = gets.chomp
n = gets.chomp.to_i
n.times{
    line =gets.chomp.split
    s = line[1].to_i
    e = line[2].to_i

    case line[0]
    when "print"
        puts str[s .. e]
    when "reverse"
        str[s .. e] = str[s .. e].reverse
    when "replace"
        str[s .. e] = line[3]
    end
}

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

int main() {
  string s;
  cin >> s;
  int ans=0, count=0;
  for(int i = 0; i < s.length(); i++){
    if((s[i]=='A')||(s[i]=='C')||(s[i]=='G')||(s[i]=='T')) count++;
    else count = 0;
    ans = max(ans,count);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(){
    char s[12]; cin >> s;
    bool cptl = false, flag = true;

    if(s[0] != 'A') flag = false;
    else{
        for(int i = 1; i < strlen(s); i++){
            if(s[i] < 'a' || s[i] > 'z'){
                if(cptl){
                    flag = false; break;
                } else if(s[i] != 'C'){
                    flag = false; break;
                } else {
                    if(i == 1 || i == (strlen(s)-1)) break;
                    cptl = true;
                }
            }
        }
    }

    cout << (flag && cptl ? "AC" : "WA") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int i;
	char str[21];

	scanf("%s", str);

	for (i = 0; i < strlen(str) / 2; i++) {
		char tmp = str[i];
		str[i] = str[strlen(str) - i - 1];
		str[strlen(str) - i - 1] = tmp;
	} 

	printf("%s\n", str);

 	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll H,W;
    cin >> H >> W;
    vector<string> data;
    vector<vector<ll>> migi;
    vector<vector<ll>> hidari;
    vector<vector<ll>> ue;
    vector<vector<ll>> shita;

    for(int i = 0;i<H;i++){
        string s;
        cin >> s;
        data.push_back(s);
    }

    for(int i = 0;i<H;i++){
        ll left  = -1;
        vector<ll> migi_row;
        for(int j = 0;j<W;j++){
            if(data[i][j] == '#'){
                left = j;
            }
            migi_row.push_back(left);
        }
        migi.push_back(migi_row);
    }

    for(int i = 0;i<H;i++){
        ll right  = W;
        vector<ll> hidari_row;
        for(int j = W - 1;j>=0;j--){
            if(data[i][j] == '#'){
                right = j;
            }
            hidari_row.push_back(right);
        }
        reverse(hidari_row.begin(),hidari_row.end());
        hidari.push_back(hidari_row);
    }

    for(int i = 0;i<H;i++){
        vector<ll> ue_row;
        ue.push_back(ue_row);
    }
    for(int j = 0;j<W;j++){
        ll up = -1;
        for(int i = 0;i<H;i++){
            if(data[i][j] == '#'){
                up = i;
            }
            ue[i].push_back(up);
        }
    }

    for(int i = 0;i<H;i++){
        vector<ll> shita_row;
        shita.push_back(shita_row);
    }
    for(int j = 0;j<W;j++){
        ll down = H;
        for(int i = H -1;i>=0;i--){
            if(data[i][j] == '#'){
                down = i;
            }
            shita[i].push_back(down);
        }
    }

    ll max_s = 0;
//     cout << "ue" << endl;
//     for(int i = 0;i<H;i++){
//         for(int j = 0;j<W;j++){
//             cout << ue[i][j];
//         }
//         cout << endl;
//     }
// cout << "shita" << endl;
//     for(int i = 0;i<H;i++){
//         for(int j = 0;j<W;j++){
//             cout << shita[i][j];
//         }
//         cout << endl;
//     }
//     cout << "migi" << endl;
//     for(int i = 0;i<H;i++){
//         for(int j = 0;j<W;j++){
//             cout << migi[i][j];
//         }
//         cout << endl;
//     }
//     cout << "hidari" << endl;
//     for(int i = 0;i<H;i++){
//         for(int j = 0;j<W;j++){
//             cout << hidari[i][j];
//         }
//         cout << endl;
//     }

// cout << "score" << endl;
    for(int i = 0;i<H;i++){
        for(int j = 0;j<W;j++){
            // cout << shita[i][j];
            ll hikatteru = (shita[i][j] - ue[i][j] - 1) + (- migi[i][j] + hidari[i][j] - 1) - 1;
            max_s = max(max_s,hikatteru);
            // cout << hikatteru << ",";
        }
        // cout << endl;
    }

    cout << max_s << endl;
    return 0;

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll MOD = 1000000007;

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

    vector<ll> sum(200002, 0);
    for (ll i = 1; i <= 200001; ++i) {
        sum[i] = sum[i - 1] + i;
    }
    ll ans = 0LL;
    for (int i = k; i <= (n + 1); ++i) {
        ll mn = sum[i - 1];
        ll mx = sum[n] - sum[max(0, n - i)];
        ans = ans + (mx - mn + 1);
        ans %= MOD;
    }
    cout << ans % MOD << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t;
    // cin >> t;

    // while (t--)
    solve();

    return 0;
}


Measured memory_bytes: 4784
#include<iostream>
//#include<string>
int main(){
    long long a,b,c;
    std::cin>>a>>b>>c;
    for(int i=0;i<100000;i++){
        if((a*i+c)%b==0){
            std::cout<<"YES\n";
            return 0;
        }
    }
    std::cout<<"NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> sc(M);
    REP(i, M) cin >> sc[i].first >> sc[i].second;
    REP(i, 1000){
        string str = to_string(i);
        if(str.size() != N) continue;
        bool ok = true;
        REP(j, M){
            int s = sc[j].first;
            int c = sc[j].second;
            if(str[s-1] != '0' + c)
                ok = false;
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Max_N=5*1e3,Max_M=2*1e2;
int N,M,top=0,l[Max_N+10]={},r[Max_N+10]={},stk[Max_N+10]={};
long long Ans=0,A[Max_N+10]={},B[Max_N+10][Max_M+10]={},C[Max_N+10][Max_N+10]={};
int main(){
	scanf("%d%d",&N,&M);
	for(int i=2;i<=N;i++) scanf("%lld",&A[i]),A[i]+=A[i-1];
	for(int i=1;i<=N;i++)
	 for(int j=1;j<=M;j++) 
	  scanf("%lld",&B[i][j]);
	for(int i=1;i<=M;i++){
		top=0;
		for(int j=1;j<=N;j++){
			for(;top&&B[stk[top]][i]<=B[j][i];--top);
			l[j]=stk[top];  stk[++top]=j; 
		}
		top=0;
		for(int j=N;j>=1;j--){
			for(;top&&B[stk[top]][i]<B[j][i];--top);
			r[j]=top?stk[top]:N+1; stk[++top]=j;
		}
		for(int j=1;j<=N;j++){
			int x=l[j]+1,y=j,X=j,Y=r[j]-1;
		 	C[x][y]+=B[j][i]; C[X+1][Y+1]+=B[j][i];
		 	C[x][Y+1]-=B[j][i];
		 	C[X+1][y]-=B[j][i];
	    }
    }
    for(int i=1;i<=N;i++)
     for(int j=1;j<=N;j++)
      C[i][j]+=C[i-1][j]+C[i][j-1]-C[i-1][j-1];
    for(int i=1;i<=N;i++)
     for(int j=i;j<=N;j++)
      Ans=max(Ans,C[i][j]-(A[j]-A[i]));
    printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 204544
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int n;
char str[300100];

int mat(char c) {
    if (c=='R') return 0;
    if (c=='G') return 1;
    return 2;
}

int chk[300100];
vector<int> cand;
void calc(int r = 0) {
    int rem[3] = {0,0,0};
    for (int i=0;i<3*n;i++) {
        int c = mat(str[i]);
        if (rem[c]) {
            rem[c]--;
            continue;
        }
        else {
            chk[r?3*n-1-i:i] = r+1;
            for (int j=0;j<3;j++) if (c!=j) rem[j]++;
        }
    }
}

int cnt[3] = {0,0,0};
int main() {
    scanf("%d",&n);
    scanf("%s",str);
    calc();
    reverse(str,str+3*n);
    calc(1);
    reverse(str,str+3*n);
    ll ans = 1;
    for (int i=0;i<3*n;i++) {
        if (chk[i]==1) {
            cnt[mat(str[i])]++;
        }
        else if (chk[i]==0) {
            for (int j=0;j<3;j++) {
                if (mat(str[i])!=j&&cnt[j]) {
                    ans = ans*cnt[j]%MOD;
                    cnt[j]--;
                }
            }
        }
    }
    for (int i=3*n-1;i>=0;i--) {
        if (chk[i]==2) cnt[mat(str[i])]++;
        else if (chk[i]==0) {
            for (int j=0;j<3;j++) {
                if (mat(str[i])!=j&&cnt[j]) {
                    ans = ans*cnt[j]%MOD;
                    cnt[j]--;
                }
            }
        }
    }
    for (int i=1;i<=n;i++) ans = ans*i%MOD;
    printf("%lld\n",ans);

    return 0;
}


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

typedef long long ll;

#define MOD 1000000007
#define N 1001
int m, n;
char a[N][N];
ll dp[N][N];

signed main() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

        cin >> m >> n;
        for (int i = 1; i <= m; i++)
                for (int j = 1; j <= n; j++)
                        cin >> a[i][j];

        for (int i = 1; i <= m; i++)
                for (int j = 1; j <= n; j++)
                        if (i == 1 && j == 1 && a[i][j] == '.')
                                dp[i][j] = 1;
                        else if (a[i][j] == '.')
                                dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
        cout << dp[m][n] % MOD << '\n';

        return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>
int main(void)
{
  char a[12], b[12], c[12];
  scanf("%s %s %s", a, b, c);

  if(a[strlen(a)-1] == b[0] && b[strlen(b)-1] == c[0])
    printf("YES\n");
  else 
    printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
res=min(a)+min(b)
for i in range(M):
    x,y,c=map(int,input().split())
    res=min(res,a[x-1]+b[y-1]-c)
print(res)

Measured memory_bytes: 18608
n = int(input())
A = list(range(1,n+1))
S = sum (A)

a = n//3
b = sum(list(range(1,a+1)))
c = n//5
d = sum(list(range(1,c+1)))
e = n//15
f = sum(list(range(1,e+1)))

print(S-3*b-5*d+15*f)

Measured memory_bytes: 61484
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, K;
    cin >> N >> K;
    ll i;
    P s[MAX];
    ll clr[MAX]={};
    
    for(i=0; i<N; i++) cin >> s[i].sc >> s[i].ft;
    sort(s, s+N);
    reverse(s, s+N);
    
    priority_queue<P> q;
    ll ans=0;
    ll t=0;
    ll kind=0;
    
    for(i=0; i<K; i++) {
        q.push(P(-s[i].ft, s[i].sc));
        t+=s[i].ft;
        clr[s[i].sc]++;
        if(clr[s[i].sc]==1) kind++;
    }
    chmax(ans, t+kind*kind);

    for(i=K; i<N; i++) {
        P u=q.top();
        
        while(q.size() && clr[u.sc]==1) {
            q.pop();
            
            if(q.empty()) {
                pt(ans);
                return 0;
            }
            
            u=q.top();
        }
        
        if(clr[s[i].sc]==0) {
            q.pop();
            clr[u.sc]--;
            q.push(P(-s[i].ft, s[i].sc));
            t+=u.ft; t+=s[i].ft;
            clr[s[i].sc]++; kind++;
            chmax(ans, t+kind*kind);
        }
        
    }

    pt(ans);
}




Measured memory_bytes: 4724
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

// weakly decreasing sequence

int main() {
  int n;
  scan(n);
  vi a(n);
  scan(a);
  reverse(all(a));

  vi lis(n+1, INT_MAX);
  lis[0] = -1;
  rep (i, n) {
    int lb = upper_bound(all(lis), a[i]) - begin(lis);
    assert(lb <= n);
    if (lis[lb] > a[i]) {
      lis[lb] = a[i];
    }
  }
  int ans = 0;
  for (int i = n; i > 0; --i) {
    if (lis[i] != INT_MAX) {
      ans = i;
      break;
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b;
   cin>>a>>b;
   cout<<(6-a-b)<<endl;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}


int main(void){
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vector<int> res(n, 0);
  REP(i, k){
    int d;
    cin >> d;
    vector<int> a(d);
    REP(j, d){
      int tmp;
      cin >> tmp;
      res[tmp-1] = 1;
    }
  }
  int ans = 0;
  REP(i, n){
    if (res[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
long long on[64] = {};
long long off[64] = {};
int main(){
	long long n, k;
	cin >> n >> k;
	REP(i, n) {
		long long a;
		cin >> a;
		for (int i = 0;i < 64; ++i) {
			if (a % 2 == 0) {
				off[i]++;
			}
			else {
				on[i]++;
			}
			a /= 2;
		}
	}
	long long ans = 0;
	for (long long i = 60; i >= 0; --i) {
		long long bo = 1;
		REP(q, i) {
			bo *= 2;
		}
		if (k >= bo) {
			if (off[i] > on[i]) {
				k -= bo;
				ans += bo * off[i];
				continue;
			}
		}
		ans += bo * on[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    string S;
    cin >> S;

    int L = S.size();

    if(S[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    int A=-1;
    for(int i=1;i<L;i++){
        if(S[i]=='C'){
            if(i>=2&&i<L-1){
                if(A!=-1){
                    cout<<"WA"<<endl;
                    return 0;
                }
                else{
                    A=i;
                }
            }
            else{
                cout<<"WA"<<endl;
                return 0;

            }
        }
        else if(!((int)S[i]>=97&&(int)S[i]<=122)){
            cout<<"WA"<<endl;
            return 0;
        }
    }

    if(A==-1){
        cout<<"WA"<<endl;
        return 0;
    }

    cout<<"AC"<<endl;
    return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1e7
int dp[1<<20];
int t[20][20];
int n;
int main(){
  while(cin>>n && n){
    for(int i=0;i<n;i++)
      for(int j=0;j<=n;j++)
        cin>>t[i][j];
    for(int i=0;i<(1<<n);i++)
      dp[i]=INF;
    dp[0]=0; 
    for(int s=0;s<(1<<n);s++)
      for(int v=0;v<n;v++){
        if((s>>v)&1) continue;
        int co=t[v][0];
        for(int k=0;k<n;k++)
          if((s>>k)&1) co = min(co,t[v][k+1]);
        dp[(s|(1<<v))] = min(dp[(s|(1<<v))],dp[s]+co);
      }
    cout<<dp[(1<<n)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << ((abs(b-a) <= d && abs(c-b) <= d)||abs(c-a) <= d ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
    int k,x;
    scanf("%d %d",&k,&x);
    if(k*500>=x)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    vector <ll> a(n);
    ll sum = 0;
    rep(i,0,n) {
        cin >> a[i];
    }

    rep(i,1,n) {
        if (a[i] < a[i-1]) {
            sum += a[i-1] - a[i];
            a[i] += a[i-1] - a[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4352