akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

int N, M;
vector<ll> x, y;
vector<ll> xc, yc;

void init()
{
	cin >> N >> M;
	x.RS(N-1);
	y.RS(M-1);
	vector<ll> tx, ty;
	CINV(tx, N);
	CINV(ty, M);
	xc.RS(N-1);
	yc.RS(M-1);
	rep(i, N-1) {
		x[i] = tx[i+1] - tx[i];
	}
	rep(i, M-1) {
		y[i] = ty[i+1] - ty[i];
	}
	rep(i, N-1) {
		xc[i] = (ll) (i + 1) * (N - i - 1);
	}
	rep(i, M-1) {
		yc[i] = (ll) (i + 1) * (M - i - 1);
	}
}

void solve()
{
	ll H = 0;
	rep(i, M-1) {
		H += y[i] * yc[i];
		H %= MOD;
	}
	ll W = 0;
	rep(i, N-1) {
		W += x[i] * xc[i];
		W %= MOD;
	}
	cout << H * W % MOD << endl;
}



Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline int read()
{
    int x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-') t=-1,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return x*t;
}
int n,d;
int main ()
{
	n=read(),d=read();
	int ans=2*d+1;
	printf("%d\n",(n+ans-1)/ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int x;
    cin>>x;
    For(i,1,361){
        if(i*x%360==0){
            cout<<i<<endl;
            return;
        }
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

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

    bool ans = false;
    xrep(i,1,10){
        if(N % i == 0 && N / i <= 9){
            ans = true;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3600
import Control.Monad

power :: Int -> Int
power 0 = 1
power n = 2 * power (n - 1)

main = do
    [a, b, c] <- map (read::String->Int) . words <$> getLine
    k <- readLn
    let m = maximum [a, b, c]
    let s = sum [a, b, c]
    let k' = power k
    let ret = m * k' + s - m
    print ret



Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

void solve(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		if(i%2==0&&x%2==1) ans++;
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 3628
N, K = gets.split.map(&:to_i)

if K == 0
  puts N ** 2
else
  counter = 0
  ((K+1)..N).each do |i|
    one_loop_count = i - K
    counter += (N / i) * one_loop_count
    piece_count = (N - (N / i) * i + 1) - (i - one_loop_count)
    counter += piece_count if piece_count >= 1
  end
  puts counter
end

Measured memory_bytes: 1788
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scanner = new Scanner (System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
if (a < b){
System.out.println("a < b");
} else if (a > b){
System.out.println("a > b");
} else {
System.out.println("a == b");
}
}
}


Measured memory_bytes: 26228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string AT_coder;
	int i,kkksc03;
	bool chen_zhe=false;
	cin>>AT_coder;
	kkksc03=AT_coder.size();
	for (i=0;i<kkksc03;i++)
	{
		if (AT_coder[i]=='C')
			chen_zhe=true;
		if (AT_coder[i]=='F'&&chen_zhe==true)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < n; i++) {
			int x = sc.nextInt();
			array[x-1]++;
		}
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 0; i < array.length; i++){
			if(array[i] == 0) continue;
			map.put(i, array[i]);
		}
		int sum = 0;
		List<Integer> list = map.entrySet().stream().sorted((e1, e2) -> e2.getValue() - e1.getValue()).map(e -> e.getValue()).collect(Collectors.toList());
		for(int i = 0; i < list.size(); i++){
			if(i < k) continue;
			sum += list.get(i);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 66340
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 本文
        String s = sc.next();
      	int sL=s.length();

        // 部分
        String t = sc.next();
     	int tL=t.length();
      	
      	//何文字あっているか
      	int[] point=new int[sL-tL+1];
      
      	int maxPoint=0;

		for(int i=0;i<(sL-tL+1);i++){
          for(int j=0;j<tL;j++){
            if(s.charAt(i+j)==t.charAt(j)){
              point[i]+=1;
            }
          }
          if(maxPoint<=point[i]){
            maxPoint=point[i];
          }
        }
      
      	System.out.println(tL-maxPoint);
      
      
      
      
    }
}

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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1,0), minCost(n+1,INT_MAX);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    minCost[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=i-1;j>=i-k;j--)
        minCost[i]=min(minCost[i],minCost[max(1,j)]+abs(h[i]-h[max(1,j)]));
    }
   
    cout<<minCost[n];
	return 0;
}

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

int climb_dp(int* h, int n)
{
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]), 
                    dp[i-2]+abs(h[i] - h[i-2]));
    }

    return dp[n-1];

}

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

    int h[n];
    for(int i=0; i<n; i++)
    {
        cin >> h[i];
    }

    cout << climb_dp(h, n);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
 
int main()
{
    int n;cin >> n ;

    map<long long int,long long int> m;
    int ans=0;
    for(int i=0;i<n;i++){
        long long int tmp;cin >> tmp;
        if(m[tmp]==0){
            m[tmp]=1;
            ans++;
        } else {
            m[tmp]=0;
            ans--;
        }
    }
    p(ans)
}

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

using namespace std;

using int64 = long long;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


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


vector< pair<lli, lli> > value;
lli dp[10010][1010];


lli funcion(lli peso, lli indice)
{
	
	if(indice==value.size())
	{
		return 0;
	}
	if (peso<0)
	{
		return -100000;
	}
	if (dp[peso][indice]!=-1)
	{
		return dp[peso][indice];
	}
	
	lli	si=funcion(peso-value[indice].second, indice) + value[indice].first;
	lli	no=funcion(peso, indice+1);	
	dp[peso][indice]= max(si,no);
	return dp[peso][indice];
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	memset(dp, -1, sizeof(dp));
	lli n,w, aux1, aux2;
	cin>>n>>w;
	for(lli i=0; i<n; i++)
	{
		cin>>aux1>>aux2;
		value.push_back (make_pair(aux1,aux2));
	}
	cout<<funcion(w,0)<<endl;
	
	return 0;
}


Measured memory_bytes: 82632
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class Main{

	static int[] p;
	static	int N ;
	static	int M ;


	public static void main(String[] args) {


		Scanner scanner = new Scanner(System.in);
		//N = scanner.nextInt();
		//M = scanner.nextInt();

		String s = scanner.next();
		String t = scanner.next();

		ArrayList<String> slist = new ArrayList<String>();
		ArrayList<String> tlist = new ArrayList<String>();

		for(int i = 0;i < s.length();i++){
			slist.add(s.substring(i, i+1));
		}
		for(int i = 0;i < t.length();i++){
			tlist.add(t.substring(i, i+1));
		}
		Collections.sort(slist);
		Collections.sort(tlist,Comparator.reverseOrder());

		StringBuilder sbs = new StringBuilder();
		for(int i = 0;i < s.length();i++){
			sbs.append(slist.get(i));
		}
		s = sbs.toString();
		
		StringBuilder sbt = new StringBuilder();
		for(int i = 0;i < t.length();i++){
			sbt.append(tlist.get(i));
		}
		t =sbt.toString();
		
		boolean flags = true;
		boolean flagt = true;

		for(int i = 0;i < s.length()-1;i++){
			if(flags){
				if(!(s.substring(i,i+1).equals(s.substring(i+1,i+2)))){
					flags = false;
				}
			}
		}
		for(int i = 0;i < t.length()-1;i++){
			if(flagt){
				if(!(t.substring(i,i+1).equals(t.substring(i+1,i+2)))){
					flagt = false;
				}
			}
		}


		


		if(s.substring(0,1).equals(t.substring(0,1)) &&  flags && flagt){

			if(s.length() >= t.length()){
				System.out.println("No");
			}else{
				System.out.println("Yes");

			}
			return;
		}




		if(t.compareTo(s) >= 1){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}

	}


}

class Pair implements Comparable{
	int from;
	int middle;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 21844
from math import pow
S = input()
S = list(S)
S.reverse()
l = len(S)
dp =[ [0] * 13 for _ in range(l + 1)]
dp[0][0] = 1
MOD = 10 ** 9 + 7
keta = 1
for k,c in enumerate(S):
    if c == "?":
        for i in range(0,10): # ? に入る候補達
            for amari in range(0, 13):
                next_amari = (amari + i * keta ) % 13
                dp[k + 1][next_amari] += (dp[k][amari] )
                dp[k + 1][next_amari] %= MOD
    else:
        i = int(c)
        for amari in range(0,13):
            next_amari = (amari + i * keta ) % 13
            dp[k + 1][ next_amari] += (dp[k][amari])
            dp[k + 1][next_amari] %= MOD

    keta *= 10
    keta %= 13

print(dp[l][5])


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

typedef long long int ll;
ll x;

int main() {
    cin >> x;
    ll p = 100, res = 0;
    while(p < x) {
        p += p/100;
        res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main() {
    int n,k;
    cin >> n >> k;
    if(n % 2 != 0) {
        if ((n / 2) + 1 >= k) {
            cout << "YES";
        } else {
            cout << "NO";
        }
    } else {
        if ((n / 2) >= k) {
            cout << "YES";
        } else {
            cout << "NO";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vii;
typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
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 n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    vll x(n), y(n), ax, ay;
    rep(i, 0, n) {
      cin >> x[i] >> y[i];
      ax.pb(x[i]); 
      ay.pb(y[i]);
    }
    sort(ALL(ax)); sort(ALL(ay));
    ll ans = (ax[n-1] - ax[0]) * (ay[n-1] - ay[0]);
    rep(xi, 0, n) {
      rep(xj, xi + 1, n) {
        rep(yi, 0, n) {
          rep(yj, yi + 1, n) {
            int cnt = 0;
            ll lx = ax[xi], rx = ax[xj];
            ll ly = ay[yi], uy = ay[yj];
            rep(i, 0, n) {
              if (lx <= x[i] && x[i] <= rx && ly <= y[i] && y[i] <= uy) 
                  cnt++;
            }
            if (cnt >= k) ans = min(ans, (rx - lx) * (uy - ly));
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    As = list(map(int, input().split()))
    q = int(input())
    Ms = list(map(int, input().split()))

    ans_set = set()
    for bit in range(0, 2**N):
        """bit全探索
        計算量はO(2**N) = O(1048576)
        """
        total = 0
        for i in range(N):
            total += As[i]*(bit>>i&1)

        ans_set.add(total)


    for m in Ms:
        if m in ans_set:
            print("yes")
        else:
            print("no")


def solve2():
    N = int(input())
    As = list(map(int, input().split()))
    q = int(input())
    Ms = list(map(int, input().split()))

    # dp[i][j] := i個まで使って、jを作れるかどうか
    dp = [[False for _ in range(N*2000+1)] for __ in range(N+1)]
    for i in range(N+1):
        dp[i][0] = True

    """dpを使って解く。
    計算量はO(N* N * 2000) = O(400 * 2000) = O(800000)
    """

    for i in range(1, N+1):
        for j in range(N*2000+1):
            if dp[i-1][j]:
                dp[i][j] = True
            if j+As[i-1] <= N*2000:
                dp[i][j+As[i-1]] = dp[i-1][j]

    ans_set = set()
    for j in range(N*2000+1):
        if dp[N][j]:
            ans_set.add(j)

    for m in Ms:
        if m in ans_set:
            print("yes")
        else:
            print("no")



if __name__ == "__main__":
    solve2()



Measured memory_bytes: 12260
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+9;
int n;
int a[maxn],b[maxn];
int main(){
    cin>>n;
    for(int i=1;i<=n+1;++i)cin>>a[i];
    for(int i=1;i<=n;++i)cin>>b[i];
    long long ans=0;
    for(int i=1;i<=n;++i){
        int t=min(b[i],a[i]);
        ans+=t;
        b[i]-=t;a[i]-=t;
        if(b[i]>0){
            t=min(b[i],a[i+1]);
            ans+=t;
            b[i]-=t;a[i+1]-=t;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    string str;
    cin>>str;
    if(str[2]==str[3]&&str[4]==str[5])
        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 vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int cnt=1,k;
void solve(string str,int len,int i){
	if(i==len){
		//cout<<str<<" "<<cnt<<endl;
		if(cnt==k){
			cout<<str<<endl;
			exit(0);
		}
		cnt++;
		return;
	}
	for(int j=-1;j<2;++j){
		string temp=str;
		char ch=str[i-1];
		ch+=j;
		if(ch<'0'||ch>'9')
			continue;
		temp+=ch;
		solve(temp,len,i+1);
	}

}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin>>k;
	int len=1;
	while(true){
		for(int i=1;i<=9;++i){
			string str;
			char ch='0'+i;
			str+=ch;
			solve(str,len,1);
		}
		len++;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long long int n;
	scanf("%lld",&n);
	long long int num[n]={};
	long long int res=1;
	long long int temp;
	for (int i=0;i<n;i++){
		scanf("%lld",&num[i]);
	}
	for(int i=0;i<n;i++){
	
		if (num[i]==0){
			printf("0\n");
			return 0;
		}
		}
	for (int i=0;i<n;i++){
		if(num[i]<=1000000000000000000/res){
			res*=num[i];
		}
		else{
			printf("-1\n");
			return 0;
		}
	}	
		printf("%lld",res);
		return 0;
	}
	

Measured memory_bytes: 2484
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int n,k,q,a;
    int num[100005];
    memset(num,0,sizeof(num));
    scanf("%d%d%d",&n,&k,&q);
    for(int i=0;i<q;i++)
    {
        scanf("%d",&a);
        num[a]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(k-q+num[i]>0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b<c+d){
    cout << "Right" << endl;
  }else if(a+b == c + d){
    cout << "Balanced" << endl;
  }else {
    cout << "Left" << endl;
  }



  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> vec[200001];
int sum[200001];
bool visited[200001];
struct position{
	int pos;
	int sum;
};
int main(){
	int i;
	int n, q;
	int u, v, toAdd;
	scanf("%d%d", &n, &q);
	for(i=0; i<n-1; i++){
		scanf("%d%d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	for(i=0; i<q; i++){
		scanf("%d%d", &u, &toAdd);
		sum[u]+=toAdd;
	}
	queue<position> positions;
	positions.push({1, sum[1]});
	sum[1]=0;
	position aPos;
	while(!positions.empty()){
		aPos=positions.front();
		positions.pop();
		sum[aPos.pos]+=aPos.sum;
		aPos.sum=sum[aPos.pos];
		visited[aPos.pos]=true;
		for(i=0; i<vec[aPos.pos].size(); i++){
			if(!visited[vec[aPos.pos][i]]){
				positions.push({vec[aPos.pos][i], aPos.sum});
			}
		}
	}
	for(i=1; i<=n; i++){
		printf("%d ", sum[i]);
	}
	printf("\n");
}


Measured memory_bytes: 16500
/* b */
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    long long ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0)
            continue;
        if (i % 5 == 0)
            continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  map<string, int> cnt;
  rep(i, N) {
    string S;
    cin >> S;
    ++cnt[S];
  }
  cout << "AC x " << cnt["AC"] << '\n';
  cout << "WA x " << cnt["WA"] << '\n';
  cout << "TLE x " << cnt["TLE"] << '\n';
  cout << "RE x " << cnt["RE"] << '\n';
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector <int> a(n+1),b(n+1),c(n+1);
    int i;
    for(i=1;i<=n;++i)cin>>a[i];
    for(i=1;i<=n;++i)cin>>b[i];
    for(i=1;i<n;++i)cin>>c[i];
    int ans;
    ans=b[a[1]];
    for(i=1;i<n;++i){
        int j=i+1;
        ans+=b[a[j]];
        if(a[j]==a[i]+1)
            ans+=c[a[i]];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
left = ((n - 1) // 2) - 1
s1 = s[0 : left + 1]
right = ((n + 3) // 2) - 1
s2 = s[right : ]

s1rev = s1[::-1]
s2rev = s2[::-1]
srev = s[::-1]

if ((s1 == s1rev) and (s2 == s2rev) and s == srev):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
//#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int fun(int n){
	int ans=0;
	rep(i,n){
		if(n%(i+1)==0){
			ans++;
		}
	}
	return ans;
}
		


int main(){
	string s;
	ll k;
	cin>>s>>k;
	if(s[0]-'0' > 1){
		cout<<s[0]-'0'<<endl;
		return 0;
	}
	int i=0;
	while(1){
		k--;
		int x = s[i]-'0';
		if(k==0 || x>1){
			cout<<x<<endl;
			return 0;
		}
		i++;

	}

}


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

int main(){
    ll N,M;
    cin >> N >> M;
    ll ans = 0;
    if(M>=N*2){
        ans = N;
        M -= N*2;
        ans += M/4;
    }else{
        ans = M/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ll d[100],dp[100][100];

int main(){
  cin >> n >> m;
  if(n + m < 10)print(n+m);
  else puts("error");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b) {
  int t;
  if (a < b) {
    t = a;
    a = b;
    b = t;
  }
  while (b != 0) {
    t = b;
    b = a % b;
    a = t;
  }
  return a;
}
int lcm2(int a, int b) {
  return a * b / gcd(a, b);
}
int lcm(vector<int> a) {
  int res = lcm2(a[0], a[1]);
  for (int i = 2; i < a.size(); i++) {
    res = lcm2(res, a[i]);
  }
  return res;
}
int main() {
  int n, t;
  vector<int> a;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    a.push_back(t);
  }
  cout << lcm(a) << endl;

  return 0;
}

Measured memory_bytes: 3160
import math

A, B, H, M = map(int, input().split())

if H >= 5 * M:
    theta = 30 * H - 5.5 * M
else:
    theta = 5.5 * M - 30 * H

if theta > 180:
    theta = 360 - theta

cos_theta = math.cos(math.radians(theta))

a = A ** 2 + B ** 2 - 2 * A * B * cos_theta

print(math.sqrt(a))


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

using namespace std;

using grid = vector<vector<char>>;

int search(grid &g, int i, int j)
{
    if (i < 0 || i >= g.size() || j < 0 || j >= g[0].size() || (g[i][j] <= '9' && g[i][j] >= '0'))
        return 0;
    if (g[i][j] == '#')
        return 1;
    g[i][j] = '0';
    g[i][j] += search(g, i - 1, j) +
               search(g, i - 1, j - 1) +
               search(g, i - 1, j + 1) +
               search(g, i, j - 1) +
               search(g, i, j + 1) +
               search(g, i + 1, j - 1) +
               search(g, i + 1, j) +
               search(g, i + 1, j + 1);
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    char t;
    cin >> h >> w;
    grid g(h);

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> t;
            g[i].emplace_back(t);
        }
    }
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (g[i][j] == '.')
                search(g, i, j);
    for (auto i : g)
    {
        for (auto j : i)
            cout << j;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 888
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    edge = [-1] * (N-1)
    for i in range(N-1):
        a, b = (int(i)-1 for i in input().split())
        G[a].append((b, i))
        G[b].append((a, i))

    max_deg = max(len(G[i]) for i in range(N))

    from collections import deque

    def bfs(s):
        que = deque([])
        par = [-1]*N
        color = [-1]*N
        que.append(s)
        c = 1
        while que:
            pos = que.popleft()
            for (v, i) in G[pos]:
                if par[pos] == v:
                    continue
                if color[pos] == c:
                    c += 1
                    if max_deg < c:
                        c = 1
                par[v] = pos
                edge[i] = c
                color[v] = c
                c += 1
                if max_deg < c:
                    c = 1
                que.append(v)

    bfs(0)

    print(max_deg)
    for i in range(N-1):
        print(edge[i])


if __name__ == '__main__':
    main()


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

int main(){
  int H,W,i,j;

  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    
  for(i = 0; i < H; i++){
    for(j = 0;j < W; j++){

      cout << "#";

    }
    cout << endl;//??????
  }
  cout << endl;
  }






  return 0;
}

Measured memory_bytes: 1152
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
cnt = [0]
def dfs(V, s):
    V[s] = 1
    if sum(V) == N:
        cnt[0] += 1                    
    else:
        for adj in G[s]:
            if V[adj] == 0:             
                dfs(V[:adj] + [1] + V[adj + 1:], adj)
dfs([0] * N, 0)
print(cnt[0])

Measured memory_bytes: 3064
using System;

public class Class1
{
		
		
	public static void Main()
	{   	
		int[,,] house=new int[4,3,10];//?£????????????¨?±?
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<3;j++)
			{
				for(int k=0;k<10;k++)
				{
					house[i,j,k]=0;
				}
			}
		}

		int b,f,r,v;//?£????????????¨?±?????????°
		int n=int.Parse(Console.ReadLine());
		for(int i=0;i<n;i++)
		{
			string dataSet=Console.ReadLine();
			string[] data=dataSet.Split();
			b=int.Parse(data[0])-1;
			f=int.Parse(data[1])-1;
			r=int.Parse(data[2])-1;
			v=int.Parse(data[3]);
			house[b,f,r]+=v;
			
		}
		for(int i=0;i<4;i++)
		{
			for(int j=0;j<3;j++)
			{
				for(int k=0;k<10;k++)
				{
					Console.Write(" {0}",house[i,j,k]);					     
				}
				Console.Write("\r\n");
				
			}
			
			if(i!=3)Console.WriteLine("####################");
							
		}
		
	}
}
				

Measured memory_bytes: 9100
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

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

    if(s.size()%2 == 0){
        if(s[0] != s[s.size()-1]){
            cout << "Second" << endl;
        }else cout << "First" << endl;
    }else{
        if(s[0] == s[s.size()-1]){
            cout << "Second" << endl;
        }else cout << "First" << endl;
    }

    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args){
		try{
			BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
			int[] num = new int[10];
			for(int i=0;i<10;i++){
				num[i] = Integer.parseInt(stdReader.readLine());
			}
			Arrays.sort(num);
			System.out.println(num[9]);
			System.out.println(num[8]);
			System.out.println(num[7]);
		}catch(Exception e){
			}
		}
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int r; cin >> r;
  cout << r*r << endl;
  return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int a, b;
int main() {
    std::cin >> a >> b;
    std::cout << ((a*b % 2 == 0) ? "Even" : "Odd") << std::endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,k,a[200010],b[200010],ans;

int main()
{
	cin>>n>>k;
	repn(i,n) a[i]=a[i-1]+i;
	for(int i=n;i>=0;i--) b[i]=b[i+1]+i;
	for(int i=k;i<=n+1;i++) ans=(ans+b[n-i+1]-a[i-1]+1)%MOD;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    long long N; cin >> N;
    vector<long long>A(N);
    long long ans = 0;
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i);
        while (A.at(i) % 2 == 0) {
            ans++;
            A.at(i) /= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#include<string>
int main(){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<"";
  }
  else if(s=="ARC"){
    cout<<"ABC"<<"";
  }
  else{
    return 0;
  }
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define debug(x) cerr << #x << ": " << x << "\n"
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}


int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
    
    while(1){
    int n; cin>>n;
    vector<int> s(n);
   

    rep(i,n)cin>>s.at(i);
    if(n==0)break;

    int sum=0;
    rep(i,n) sum +=s.at(i);

    double m =1.0*sum/n;

    
    double cnt=0.0;
    rep(i,n){
        cnt +=(s.at(i)-m)*(s.at(i)-m);

    }
  


    

    cout<<fixed<<setprecision(8);
    cout<<sqrt(cnt/n)<<endl;
}

}


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

int main() {
    int a,b,n,cnt=0,flag=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a==b)cnt++;
        else cnt=0;
        if(cnt==3)flag=1;
    }
    if(flag)
    cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3588
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 200010;
const ll inf = 0x3f3f3f3f;
const ll mod = 1e9+7;
ll a[N],b[N];

int main() 
{
	ll i,n,ans;
	cin>>n;
	for(i = 1; i <= n; i++) {
		cin>>a[i];
		if(ans < a[i])
			ans = a[i];
		b[a[i]]++;
	}
	for(i = 1;i <= n;i++) {
		b[a[i]]--;
		for(ll j = ans;~j; j--) {
			if(b[j]) {
				cout<<j<<endl;
				break;
			}
		}
		b[a[i]]++;
	}
	return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n, k; cin >> n >> k;

    vector<pair<ll, ll>> p(n);

    for (ll i = 0; i < n; ++i) {
        ll a, b; cin >> a >> b;

        p[i] = make_pair(a, b);
    }

    sort(p.begin(), p.end());

    ll cnt = 0;

    for (ll i = 0; i < n; ++i) {
        cnt += p[i].second;

        if (k <= cnt) {
            cout << p[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
import math
A, B, H, M = map(int, input().split())
thetaA = math.pi * (0.5*(H*60 + M)) / 180
thetaB = math.pi * 6.0*M / 180
theta = min(2*math.pi-abs(thetaA-thetaB), abs(thetaA-thetaB))
cosC = math.cos(theta)
ans = math.sqrt(A**2+B**2-2*A*B*cosC)
print(ans)

Measured memory_bytes: 9480
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
	string s;
	cin>>s;
	int32_t year=stoi(s.substr(0,4));
	int32_t month=stoi(s.substr(5,2));
	int32_t day=stoi(s.substr(8,9));
	if(year>=2020){
		cout<<"TBD"<<endl;
	}else if(year<=2018){
		cout<<"Heisei"<<endl;
	}else{
		if(month<=4){
			cout<<"Heisei"<<endl;
		}else{
			cout<<"TBD"<<endl;
		}
	}


}


Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
# import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().decode('utf8').rstrip()

lis = []

for m in S:
    if m != 'B':
        lis.append(m)
    else:
        if len(lis):
            lis.pop()

print(*lis, sep='')


Measured memory_bytes: 3060
using System;

namespace A___Coffee
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            if (s[2] == s[3] && s[4] == s[5])
                Console.WriteLine ("Yes");

            else
                Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int a, b;
int ansa = 0;
int ansb = 0;
void update(int aa,int ab) {
	if (ansa + ansb > aa + ab) {
		ansa = aa;
		ansb = ab;
		return;
	}
	if (ansa + ansb == aa + ab) {
		if (ansa*a + ansb*b > aa*a + ab*b) {
			ansa = aa;
			ansb = ab;
			return;
	}
	}
}
int main() {
	int d;
	while (cin>>a>>b>>d,a|b|d) {
		vi amal(d + 1,-1);
		vi bmal(d + 1,-1);
		ansa = 100000;
		ansb = 100000;
		for (int i = 0;i <= d;i += a) {
			if ((d - i) % b == 0)
				update(i / a, (d - i) / b);
		}
		for (int i = 0;i < 100000;i++) {
			if ((d + i*a) % b == 0)
				update(i, (d + i*a) / b);
		}
		for (int i = 0;i < 100000;i++) {
			if ((d + i*b) % a == 0)
				update((d + i*b) / a, i);
		}
		
		cout << ansa << ' ' << ansb << endl;
	}
}

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

int main() {
  string s;
  	cin>>s;
  int n=s.size();
  vector<int>vec(n);
  int sum=0;
  for(int i=0;i<n;i++){
	if(s.at(i)=='0'){
      sum+=1;
    }
    else{
      sum-=1;
    }
  }
 int m=min(sum,-sum);
  cout<<n+m<<endl; 
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  int cnt = 0;
  string S;
  cin >> S;
  REP(i, 7){
    if(s[i] == S){
      cnt = i;
    }
  }
  cout << 7 - cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }                                                                                                     
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

ll get(ll n) {
	int res = 0;
	while(n) {
		res += (n % 10);
		n /= 10;		
	} 
	return res;
}

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    string s;
    cin >> s;
    ll ans = 0;
    ll mx = s[0] - 48;
    for (int i = 0; i < s.size(); i++) {
    	if (s[i] != '0')
    	mx = max(mx, ans + (s[i] - 48 - 1) + ((ll)s.size() - i - 1) * 9ll);
    	ans += (s[i] - 48);
    }
    mx = max(mx, ans);
    cout << mx;    
    return 0;
}

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

using event = pair<int, pair<int,int>>;

signed main() {
  int n,q;
  cin >> n >> q;

  vector<event> queries;
  rep(i,n) {
    int s, t, x;
    cin >> s >> t >> x;

    event insert = {s - x, {1, x}};
    event erase = {t - x, {-1, x}};

    queries.push_back(insert);
    queries.push_back(erase);
  }

  sort(queries.begin(),queries.end());
  set<int> points;

  vector<int> d(q), answer(q);
  rep(i,q) cin >> d[i];

  int j = 0;
  for (int i = 0; i < q; i++) {
    while(j < queries.size() && queries[j].first <= d[i]) {
      event query = queries[j];
      if(query.second.first == 1) points.insert(query.second.second);
      else if(query.second.first == -1) points.erase(query.second.second);
      j++;
    }
    if(points.empty()) answer[i] = -1;
    else answer[i] = *points.begin();
  }

  for (auto it : answer) cout << it << '\n';
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int L[100000], R[100000], table[100010] = {0};
    for (int i = 0; i < m; i++)
    {
        cin >> L[i] >> R[i];
        table[L[i]-1]++;
        table[R[i]]--;
    }
    for (int i = 1; i <= n; i++)
    {
        table[i] += table[i - 1];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (table[i] == m)
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10000000)

N = int(input())
ashiba = [int(s) for s in input().split()]

l = [float('inf')] * N
l[0] = 0
l[1] = abs(ashiba[1] - ashiba[0])

for i in range(2,N):
	l[i] = min(abs(ashiba[i] - ashiba[i - 1]) + l[i - 1], abs(ashiba[i] - ashiba[i - 2]) + l[i - 2])

print(l[N - 1])

Measured memory_bytes: 13976
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  double d = 0, t = 0, s = 0;

  cin >> d >> t >> s;

  if(d / s <= t) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}
/*

*/


Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define ll long long
const int inf = 1e8;
const ll INF = 1e18;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-9;
const long double pi = acos(-1.0);
using namespace std;

int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1 -1};


void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length() - 1; i++){
        if (s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return;
        }
        if (i + 2 <= s.length() - 1){
            if (s[i] == s[i + 2]){
                cout << i + 1 << " " << i + 3 << endl;
                return;
            }
        }
    }

    cout << - 1 << " " << - 1 << endl;
    return;
}



int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(40);
    //freopen("inevit.in", "r", stdin);
    //freopen("inevit.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++)
        solve();


}


Measured memory_bytes: 3744
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  string ans="Three";
  char a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)
    if(a[i]=='Y')ans="Four";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
W,H,N = map(int,input().split())
w=h=0
for _ in[0]*N:
    x,y,a = map(int,input().split())
    if a == 1:
        w = max(w,x)
    elif a == 2:
        W = min(W,x)
    elif a == 3:
        h = max(h,y)
    else:
        H = min(H,y)
print((W-w)*(H-h)*(W>w)*(H>h))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    while(n>0){
        if(n%10==9){
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
    
}

Measured memory_bytes: 256