akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);
    	
    	int x=sc.nextInt();
    	int t=sc.nextInt();
    	
    	int result=Math.max(x-t,0);
    	
    	System.out.println(result);
    }
}


Measured memory_bytes: 19796
// Oh boi here we go again
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define pii pair < int, pi >
#define next next123
#define left left123

const int N = 2e5 + 7;
const int INF = 1e9 + 7;

ll n, a, b;

main(){
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0)
        cout << abs(a - b) / 2;
    else {
        ll r1 = min(a, b) + (max(a, b) - min(a, b) - 1) / 2;
        ll r2 = n - max(a, b) + 1 + (n - (min(a, b) + n - max(a, b) + 1)) / 2;
        cout << min(r1, r2);
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, d, a, b, ans = 0;
    ;
    cin >> n >> d;
    while (n--)
    {
        cin >> a >> b;
        if (a * a + b * b <= d * d)
            ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int n, x = 0, maxi = 0;
    string s;
    cin >> n >> s;
    rep(i,n){
        if(s[i] == 'I') x++;
        else x--;
        maxi = max(maxi, x);
    }
    cout << maxi << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
vector<int> used1,used2;
vector<int> dp1,dp2;
priority_queue<pair<int,int>> pq1;
priority_queue<pair<int,int>> pq2;
vector<vector<int>> v;
int main(){
    int n,m;
    int s,t;
    cin>>n>>m>>s>>t;
    s--;
    t--;
    v=vector<vector<int>>(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    used1=vector<int>(n+10,-1);
    used2=vector<int>(n+10,-1);
    pq1.push(make_pair(0,s));
    pq2.push(make_pair(0,t));
    while(pq1.size()){
        auto top=pq1.top();
        pq1.pop();
        if(used1[top.second]>=0) continue;
        used1[top.second]=-top.first;
        for(int x:v[top.second]){
            if(used1[x]>=0) continue;
            pq1.push(make_pair(top.first-1,x));
        }
    }
    while(pq2.size()){
        auto top=pq2.top();
        pq2.pop();
        if(used2[top.second]>=0) continue;
        used2[top.second]=-top.first;
        for(int x:v[top.second]){
            if(used2[x]>=0) continue;
            pq2.push(make_pair(top.first-1,x));
        }
    }
    long long ans=0;
    int dist=used1[t];
    dp1=vector<int>(n+10,0);
    dp2=vector<int>(n+10,0);
    rep(i,n){
        if(0<=used1[i]&&used1[i]<=n) dp1[used1[i]]++;
        if(0<=used2[i]&&used2[i]<=n) dp2[used2[i]]++;
    }
    rep(i,dist-1){
        ans+=(long long)dp1[i]*dp2[dist-2-i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10424
N, Y = [int(i) for i in input().split()]
Y = int(Y/1000)
judge = False
for x in range(N+1):
    if Y-N-9*x < 0 or (Y-N-9*x) % 4 != 0:
        continue
    elif -Y+5*N+5*x < 0 or (-Y+5*N+5*x) % 4 != 0:
        continue
    judge = True
    break
    
if judge == True:
    print(x, int((Y-N-9*x)/4), int((-Y+5*N+5*x)/4))
else:
    print(-1, -1, -1)

Measured memory_bytes: 3064
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int s;
    cin>>s;
    vector<int> vec(s-1);
    rep(i,s-1){
        cin>>vec.at(i);
    }     
    vector<int> veca(s);
    rep(i,s){
        if(i==0||i==1){
            veca.at(i)=vec.at(0);
        }
        else{
            veca.at(i)=-1;
        }
    }  
   
    for(int i=1;i<s-1;i++){
        if(veca.at(i)<=vec.at(i)){
            veca.at(i+1)=vec.at(i);
        }
        else{
            veca.at(i)=vec.at(i);
            veca.at(i+1)=vec.at(i);
        }
    }
    int sum=0;
    rep(i,s){
        sum+=veca.at(i);
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;

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


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <complex>
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
const int N = 310;
int ans[N*N],x[N*N],y[N*N],data[N][N];
int n,m,map[N][N],path[N],flow[N],s,t,vis[N][N];
queue<int> q;
int bfs()
{
	int u,i;
	while(!q.empty())	q.pop();
	memset(path,-1,sizeof(path));
	q.push(s);
	flow[s]=100000;path[s]=0;
	while(!q.empty())
	{
		u=q.front();
		q.pop();
		if(u==t) break;
		for(i=1;i<=n;i++)
			if(path[i]==-1&&map[u][i]==1)
			{
				flow[i]=flow[u]<map[u][i]?flow[u]:map[u][i];
				path[i]=u;
				q.push(i);
			}
	}
	if(path[t]==-1)//
		return -1;
	else
		return flow[t];
}
int EK()
{
	int step,max_flow=0,now,pre;
	while((step=bfs())!=-1)
	{
		max_flow+=step;
		now=t;
		while(now!=s)
		{
			pre=path[now];
			map[pre][now]-=step;
			map[now][pre]+=step;
			now=pre;
		}
	}
	return max_flow;
}
int main()
{
	int i,u,v;
	while(scanf("%d%d",&n,&m)==2)
	{
		memset(map,-1,sizeof(map));
		memset(vis,0,sizeof(vis));
		memset(data,0,sizeof(data));
		for(i=1;i<=m;i++)
		{
			scanf("%d%d",&u,&v);
			x[i]=u;
			y[i]=v;
			data[u][v]=1;
			map[u][v]=map[v][u]=1;
		}
		scanf("%d%d",&s,&t);
		printf("%d\n",EK());
		int r=0;
		for(i=1;i<=m;i++)
		{
			u=x[i];v=y[i];
			if(map[v][u]==0)
				if(data[v][u]^data[u][v])
				ans[r++]=i;
		}
		printf("%d\n",r);
		for(i=0;i<r;i++)
			printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 0
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

maxPow = (1 << (max(A) * 2).bit_length())
cntA = Counter(A)

ans = 0
while maxPow > 0:
    for a in A:
        if maxPow - a == a:
            if cntA[a] >= 2:
                ans += cntA[a] // 2
                cntA[a] %= 2
        elif cntA[a] > 0 and cntA[maxPow - a] > 0:
            ans += 1
            cntA[a] -= 1
            cntA[maxPow - a] -= 1
    maxPow //= 2

print(ans)

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

int main() { 
    int r, g, b;
    cin >> r >> g >> b;

    int a = r * 100 + g * 10 + b;
    if (a % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, d, x, a;
	ll ans = 0;

	cin >> n >> d >> x;

	vector<ll> v;

	REP(i, n) {
		cin >> a;

		v.push_back(a);
	}

	REP(i, n) {
		ans += (d - 1 - ((d - 1) % v[i])) / v[i] + 1;
	}

	cout << ans + x << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
l = []
for i in range(len(a)):
    if a[i] < 0:
        l.append(a[i])
        a[i] = (-1)*a[i]
if len(l) % 2 == 0:
    print(sum(a))
else:
    print(sum(a)-2*min(a))

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

int main(void)
{
    string S;
    cin >> S;
    int evenNumberZero = 0;
    int oddNumberZero = 0;
    // even number
    for (int i = 0; i < S.size(); i += 2) {
        if (S[i] == '0')
            evenNumberZero++;
    }
    // odd number
    for (int i = 1; i < S.size(); i += 2) {
        if (S[i] == '0')
            oddNumberZero++;
    }
    int oddNumberSize = S.size() / 2;
    int evenNumberSize = oddNumberSize;
    if (S.size() % 2 == 1) {
        evenNumberSize++;
    }
    // 0101...
    int ElementChangeNeededFirst = (oddNumberSize - oddNumberZero) + evenNumberZero;
    // 1010...
    int ElementChangeNeededSecond = oddNumberZero + (evenNumberSize - evenNumberZero);
    if (ElementChangeNeededFirst < ElementChangeNeededSecond)
        cout << ElementChangeNeededFirst << endl;
    else
        cout << ElementChangeNeededSecond << endl;
}

Measured memory_bytes: 512
using System;
using System.Linq;

namespace aoj
{
    class Program
    {
        static void Main(string[] args)
        {
            var length = int.Parse(Console.ReadLine());
            int[] array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            selectSort(ref array, length);
        }

        static void selectSort(ref int[] _array, int _length)
        {
            var count = 0;
            for (var i = 0; i < _length; ++i)
            {
                var minIndex = i;

                // iよりindexが大きい要素の中から最小値を探す
                for (var k = i; k < _length; ++k)
                {
                    if (_array[k] < _array[minIndex])
                    {
                        minIndex = k;
                    }
                }

                if (i != minIndex)
                {
                    Swap(ref _array[i], ref _array[minIndex]);
                    ++count;
                }
            }
            
            for (var i = 0; i < _length; ++i)
            {
                Console.Write(_array[i]);
                if (i != _length - 1)
                {
                    Console.Write(" ");
                }
            }
            Console.WriteLine();
            Console.WriteLine(count);
        }

        static void Swap(ref int _a, ref int _b)
        {
            var tmp = _a;
            _a = _b;
            _b = tmp;
        }
    }
}



Measured memory_bytes: 18272
#include<cstring>
#include <cstdio> 
#include <iostream>
#include <cmath>
#include<algorithm>
using namespace std;
#define pi 3.1415926 
#define N 510
int main()
{
	int array[1001]={};
	int n,k,i,sum=0;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>array[i];
	}
	sort(array,array+n);
	for(i=0;i<k;i++)
	{
		sum+=array[i];
//		printf("%d  ",sum);
	}
	printf("%d",sum);
	return 0;
}



Measured memory_bytes: 3688
def main():
    n, k = map(int, input().split())

    temp = 0
    for i in range(1, n + 1):
        x = 1
        while (i < k):
            i *= 2
            x /= 2
        temp += x
    print(temp/n)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define speedhack ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fromfile freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout); 
#define mod int (1e9+7)
#define MAXN int (1e9)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;




int d,e,f,n;
string a, b;

int main() {
    speedhack;
    //fromfile;
    getline(cin, a);
    getline(cin, b);
    b.pop_back();
    for (int k = 0; k<a.size(); k++){
        if (a[k] != b[k]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";




    }

Measured memory_bytes: 3640
from collections import Counter

def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    counter = Counter(A)
    cmb = 0
    for v in counter.values():
        cmb += v*(v-1)//2
    for a in A:
        print(cmb - (counter[a] - 1))

    return 

if __name__ == "__main__":
    resolve()

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	vll color(9,0);
	for(ll i=0;i<n;i++) {
		cin>>p;

		if(p <= 399) color[0] = 1;
		else if(p <= 799) color[1] = 1;
		else if(p <= 1199) color[2] = 1;
		else if(p <= 1599) color[3] = 1;
		else if(p <= 1999) color[4] = 1;
		else if(p <= 2399) color[5] = 1;
		else if(p <= 2799) color[6] = 1;
		else if(p <= 3199) color[7] = 1;
		else color[8]++;
	}

	ll mini = max(min(color[8],1ll),(ll)accumulate(color.begin(),color.begin()+8,0));
	ll maxi = accumulate(color.begin(),color.begin()+8,0) + color[8];
	cout<<mini<<" "<<maxi;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char S[200005];
int V[30];
long long Sol;
int N;
void Read()
{
    cin.getline(S+1,200005);
    N=strlen(S+1);
}

int main()
{
    Read();
    for(int i = 1; i <= N; i++)
        V[S[i] - 'a' + 1]++;
    for(int i = 1; i <= 26; i++)
        for(int j = i + 1; j <= 26; j++)
            Sol += 1LL * V[i] * V[j];
    cout << Sol + 1<< "\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
int n,l[200];
int sum=0;
int main(){
    cin>>n;
    rep(i,n)cin>>l[i];
    sort(l,l+n);
    rep(i,n-1){
        sum+=l[i];
    }
    if(sum>l[n-1])puts("Yes");
    else puts("No");
    return 0;
}

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int n;
    cin >> n;
    set<char> st;
    rep(i, n)
    {
        char tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    map<int, string> mp;
    mp[3] = "Three", mp[4] = "Four";
    cout << mp[st.size()] << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	int N, x; cin >> N >> x;
	if (N == 2) {
		if (x == 2) {
			cout << "Yes" << endl; cout << 1 << endl << 2 << endl << 3 << endl;
		}
		else cout << "No" << endl;
		return 0;
	}
	else {
		if (x <= 1 || x >= 2 * N - 1) {
			cout << "No" << endl; return 0;
		}
		else {
			cout << "Yes" << endl;
			vector<int> ans(2 * N - 1);
			static bool flag[1000010] = {};
			if (x > N) {
				ans[N - 3] = x - 1;
				ans[N - 2] = x;
				ans[N - 1] = 2 * N - 1;
				ans[N] = x - 2;
				flag[x - 1] = flag[x] = flag[2 * N - 1] = flag[x - 2] = true;
				int a = 2 * N - 1;
				rep(i, 0, 2 * N - 1) {
					if (N - 3 <= i&&i <= N)continue;
					while (flag[a])a--;
					ans[i] = a;
					flag[a] = true;
				}
			}
			else {
				ans[N - 3] = x + 1;
				ans[N - 2] = x;
				ans[N - 1] = 1;
				ans[N] = x + 2;
				flag[x + 1] = flag[x] = flag[1] = flag[x + 2] = true;
				int a = 2 * N - 1;
				rep(i, 0, 2 * N - 1) {
					if (N - 3 <= i&&i <= N)continue;
					while (flag[a])a--;
					ans[i] = a;
					flag[a] = true;
				}
			}
			rep(i, 0, 2 * N - 1) {
				cout << ans[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2560
#import sys
#sys.setrecursionlimit(10**9)

H, N = map(int, input().split())
magic = [_ for _ in range(N)]

for k in range(N):
  magic[k] = list(map(int, input().split()))
  magic[k].append(magic[k][0]/magic[k][1])

magic.sort(key = lambda x: x[2], reverse=True)
ans = [0 for _ in range(H+1)]
visited = [0]
anskouho = [float('inf')]
ans2 = float('inf')
"""
def solve(start, power, point, maryoku):
  if start == H:
    print(min(point, min(anskouho)))
    exit()
  elif start > H:
    anskouho.append(point)
    return 0
  elif ans[start] != 0:
    return 0
  else:
    visited.append(start)
    ans[start] = point
    solve(start+power, power, point+maryoku, maryoku)
"""
for k in range(N):
  for item in visited:
    #solve(item+magic[k][0], magic[k][0], ans[item] + magic[k][1], magic[k][1])
    start = item+magic[k][0]
    power = magic[k][0]
    point = ans[item]+ magic[k][1]
    maryoku = magic[k][1]
    for _ in range(10**5):
      if start == H:
        print(min(point, ans2))
        exit()
      elif start > H:
        ans2 = min(ans2, point)
        break
      elif ans[start]!=0:
        break
      else:
        visited.append(start)
        ans[start] = point
        start += power
        point += maryoku
      
print(ans2)

Measured memory_bytes: 9800
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    string s;
    cin>>s;
    string wet[]={"Sunny","Cloudy","Rainy"};
    rep(i,3) if(wet[i]==s) cout<<wet[(i+1)%3]<<endl;
    return 0;
}

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

#define N 100

int main() {
	static char s[N + 1];
	static int kk[26];
	int n, i, yes;

	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i++)
		kk[s[i] - 'a']++;
	yes = 1;
	for (i = 0; i < n; i++)
		if (kk[s[i] - 'a'] % 2)
			yes = 0;
	printf(yes ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	int a=0;
	int b=0;
	int c=0;
	int d=0;
	rep(i,6){
		int x;
		cin >> x;
		if(x==1) a++;
		if(x==2) b++;
		if(x==3) c++;
		if(x==4) d++;
	}
	if(a==1&&b==2&&c==2&&d==1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = -1;
    ll r = 1e18;
    while(r - l > 1) {
        ll m = (r + l) / 2LL;
        ll cnt = 0;
        rep(i, n) {
            if  (a[i] * f[i] > m) {
                cnt += (a[i] * f[i] - m + f[i] - 1) / f[i];
            }
        }
        if (cnt > k) l = m;
        else         r = m;
    }
    cout << r << endl;
    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep (i, h) cin >> v[i];

  bool ans = true;
  int h2[4] = {-1, 1, 0, 0};
  int w2[4] = {0, 0, 1, -1};
  rep (i, h){
    rep (j, w){
      if (v[i][j] == '#'){
        bool f = false;
        rep (k, 4){
          if ((i+h2[k] < 0) || (i+h2[k] >= h)) continue;
          if ((j+w2[k] < 0) || (j+w2[k] >= w)) continue;
          if (v[i+h2[k]][j+w2[k]] == '#') f = true;
        }
        if (f == false) ans = false;
      }
    }
  }
  if (ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // 入力受取
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line1 = input.readLine();

        int N = Integer.parseInt(line1);
        Integer[] A = new Integer[N];
        for(int i=0;i<N;i++) {
            A[i] = Integer.parseInt(input.readLine());
        }

        Integer[] B = new Integer[N];
        System.arraycopy(A,0,B,0,A.length);
        Arrays.sort(B, Collections.reverseOrder());

        for(int i=0;i<N;i++) {
            // 1番目に大きい数と同じなら2番めに大きい数を出力する
            if(A[i]==B[0]) {
                System.out.println(B[1]);
            } else {
                System.out.println(B[0]);
            }
        }

    }
}


Measured memory_bytes: 73900
#include "bits/stdc++.h"

using namespace std;

int main() 
{
	int n;
	cin >> n;
	int a = n / 10;
	if (a == 9)cout << "Yes" << endl;
	else if (n - a * 10 == 9)cout << "Yes" << endl;
	else cout<< "No" << endl;

	return 0;
}

Measured memory_bytes: 256
let
  N, M = map(x -> parse(Int, x), split(readline()))
  maxL = 1
  minR = 10^5
  for i=1:M
    L, R = map(x -> parse(Int, x), split(readline()))
    maxL = max(maxL, L)
    minR = min(minR, R)
    if maxL > minR
      break
    end
  end
  print((maxL > minR) ? 0 : minR - maxL + 1)
end


Measured memory_bytes: 169452
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define INF (2 << 28)
using namespace std;

int main(){
  string s;
  int n,m,cost[301],d[3][301];
  int dp[301];
  
  while(cin >> n >> m){
    
    int maxi = 0;
    for(int i=0;i<n;i++){
      cin.ignore();
      getline(cin,s);
      cin >> cost[i] >> d[0][i] >> d[1][i] >> d[2][i];
    }
    
    /*for(int k = 0;k < 3;k++){
      memset(dp,0,sizeof(dp));
      for(int i = 0;i < n;i++){
	for(int j = m;j > 0;j--){
	  if(j - cost[i] >= 0) dp[j - cost[i]] = max(dp[j] + d[k][i],dp[j - cost[i]]);
	}
	}*/

      for(int k=0;k<3;k++){
memset(dp, 0, sizeof(dp));
	for(int i=0;i<n;i++){
	  for(int j=0;j<m;j++){
	    if(j+cost[i] <= m) dp[j+cost[i]] = max(dp[j+cost[i]], dp[j]+d[k][i]);
	  }
	}

      maxi = max(maxi,*max_element(dp,dp + m + 1));
    }

    cout << maxi << endl;
  }
}

Measured memory_bytes: 1204
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =9e5+100;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int n , m;
int mark[100];

int main(){
    migmig
    for (int i = 0 ; i < 100 ; i ++){
        mark[i] = -1;
    }
    cin >> n >> m;
    for (int i = 0 ; i < m ; i ++){
        int s , c;
        cin >> s >> c;
        s--;
        if(mark[s] == -1){
            mark[s] = c;
        }
        else if(c!=mark[s]){
            dokme(-1);
        }
    }
    if(mark[0] == -1){
        mark[0] = 1;
        if(n == 1){
            mark[0] = 0;
        }
    }
    if(mark[0] == 0 and n > 1){
        dokme(-1);
    }
    for (int i = 0 ; i < n ; i ++){
        if(mark[i] == -1){
            mark[i] = 0;
        }
        cout << mark[i];
    }

    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


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

int main(void){
    int n;
    cin>>n;
    map<int,int> mp[2];
    set<int> st;
    rep(i,n){
        int x;
        cin>>x;
        st.insert(x);
        mp[i&1][x]++;
    }
    using P = pair<int,int>;
    vector<P> vp[2];
    rep(i,2)for(auto itr : mp[i]){
        vp[i].push_back({itr.second, itr.first});
    }
    rep(i,2) sort(vp[i].begin(), vp[i].end(), greater<P>());
    if(vp[0][0].second != vp[1][0].second){
        cout<< n - vp[0][0].first - vp[1][0].first <<endl;
    }else{
        rep(i,2) vp[i].push_back({0, i});
        cout<< n - max(vp[0][1].first + vp[1][0].first, vp[0][0].first + vp[1][1].first)<<endl;;
    }
    return 0;
}


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

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

template<int Modulo = MOD> struct Mint {
	lint val;
	constexpr Mint(lint v = 0) noexcept : val(v % Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		lint a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			lint t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream &operator << (ostream &os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream &is, Mint<Modulo>& x) noexcept {
		lint tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo> &a, lint n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

class Combi {
private:
	vector<mint> fac, inv, finv;

	void init(int N) {
		fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;

		for (int i = 2; i < N; i++) {
			fac[i] = fac[i - 1] * i;
			inv[i] = - inv[MOD%i] * (MOD / i);
			finv[i] = finv[i - 1] * inv[i];
		}
	}

public:
	Combi(int N = 10000) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }

	mint Cmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k]);
	}

	mint Pmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * finv[n - k];
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	Combi C;

	for (int i = 1; i <= K; i++) cout << C.Cmod(N - K + 1, i) * C.Cmod(K - 1, i - 1) << "\n";

	return 0;
}


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

int main(){
	ll n, k;
	cin >> n >> k;

	ll num = n%k;
	cout << min(num, k-num) << endl;

	return 0;
}


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

int main() {
  string s;cin>>s;
 if(s[2]==s[3] && s[4]==s[5])cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin >> n >> m;
    if(n==1&&m==1){
        cout << 1 << endl;
    }
    else if(n==1){
        cout << m-2 << endl;
    }
    else if(m==1){
        cout << n-2 << endl;
    }
    else{
        cout << (n-2)*(m-2) << endl;
    }
}

Measured memory_bytes: 3628
import sys
import numpy as np


def main():
    h, w = map(int, sys.stdin.buffer.readline().split())
    n = int(sys.stdin.buffer.readline())
    a = list(map(int, sys.stdin.buffer.readline().split()))
    ans = np.zeros(w*h, np.int64)
    now = 0
    for i, x in enumerate(a):
        for j in range(x):
            ans[now + j] = i+1
        now += x

    ans = ans.reshape(h, w)
    for i in range(h):
        if i % 2:
            print(*ans[i, ::-1])
        else:
            print(*ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 27292
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, S, T;
  S=0;
  T=0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  S = S + vec.at(i)%2;
  }
  for (int j = 0; S==0; j++) {
  T=T+1;
  for (int i = 0; i < N; i++) {
  vec.at(i) = vec.at(i)/2;
  S= S + vec.at(i)%2;
  }  
  }
  cout << T << endl;
}

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

int main() {
	int a, b, c;
	double rad;
	double PI =  acos(-1);
	scanf("%d %d %d", &a, &b, &c);
	rad = c * PI / 180;

	double S = a * b * sin(rad) / 2;
	double L = a + b + sqrt((a * a) + (b * b) - 2 * a * b * cos(rad));
	double h = b * sin(rad);
	printf("%f\n", S);
	printf("%f\n", L);
	printf("%f\n", h);
	
	return 0;
}


Measured memory_bytes: 2096
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	string s; cin >> s;
    cout << count(s.begin(), s.end(), '1') << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
from collections import defaultdict
d = defaultdict(int)
num_list = list(map(int,input().split()))
for tmp in num_list:
	d[tmp] += 1
    
v_list = sorted(list(d.values()) ,reverse=True)

print(n - sum(v_list[:k]))


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,100)rep(j,100)rep(k,100){
        int f = i*i + j*j + k*k + i*j + j*k + k*i;
        if(f <= n) a[f]++;
    }

    rep(i,n+1){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

#define PI 3.14159265

int main() {
    double a, b, x; cin >> a >> b >> x;
    x /= a;
    double ans;
    if (a*b/2 < x) {
        b = (a*b-x)*2/a;
        ans = atan(b/a)*180/PI;
    } else {
        a = x*2/b;
        ans = atan(b/a)*180/PI;
    }
    printf("%.6lf\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    bool ok1 = true;
    bool ok2 = true;
    for(int i=0; i<S.size(); i++) {
        if(S[i] != S[S.size()-1-i]) ok1 = false;
    }
    for(int i=0; i<S.size()/2; i++) {
        if(S[i] != S[S.size()/2-1-i]) ok2 = false;
    }

    if(ok1 && ok2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.*;
import java.math.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] intArray = Arrays.stream(sc.nextLine().split(" ")) 
                        .mapToInt(Integer::parseInt) 
                        .toArray();                        
                        
                        
        System.out.println(intArray[0] - intArray[1] +1);
    }
}

Measured memory_bytes: 28884
h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
for x in range(h):
    for y in range(w):
        if g[x][y]=="#":
            k=0
            for i,j in [(1,0),(-1,0),(0,1),(0,-1)]:
                nx=x+i
                ny=y+j
                if nx<0 or nx>=h or ny<0 or ny>=w:
                   continue
                if g[nx][ny]==".":
                    k+=1
            if k==4:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> f(n, 1);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int dd;
      cin >> dd;
      dd--;
      f[dd] = 0;
    }
  }
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (f[i]) c++;
  }
  cout << c <<endl;
}

Measured memory_bytes: 3632
n, m, x = map(int, input().split())
ls_a = list(map(int, input().split()))

cst_0 = 0
cst_m = 0

for i in range(m):
    if ls_a[i] < x:
        cst_0 += 1
    elif ls_a[i] > x:
        cst_m += 1

print(min(cst_0, cst_m))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    long long lim=1e18;
    int n;
    cin>>n;
    long long a[n], ans=1;
    for(int i=0; i<n; i++) {
        cin>>a[i];
        if(a[i]==0) ans = 0;
        else if(ans>lim/a[i])ans=-1;
        else if(ans!=-1) ans*=a[i];
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 4396
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;
    if(s.length()%2){
        std::cout << "No";
        return 0;
    }
    for (int i = 0;  i< s.length(); i++) {
        if(i%2&&s[i]=='i')continue;
        if(!(i%2) && s[i]=='h')continue;
        std::cout << "No";
        return 0;
    }
    std::cout << "Yes";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm> // min()
#include <string>
#include <vector>
#include <climits> // INT_MAX
#include <cmath> // ceil()
#define rep(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using ll = long long;
const int INF = INT_MAX;
using Graph = vector<vector<int>>;
using Vi = vector<int>;
using Vpii = vector<pair<int, int>>;
using Pii = pair<int, int>;


int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    auto past_min = h * 60 + m;
    auto theta_m = M_PI * past_min / 30;
    auto theta_h = M_PI * past_min / 360;

    double x = b * sin(theta_m);
    double y = b * cos(theta_m);

    pair<double, double> m_pos = { x, y };

    x = a * sin(theta_h);
    y = a * cos(theta_h);

    pair<double, double> h_pos = { x, y };

    auto dist_x = pow(m_pos.first - h_pos.first, 2);
    auto dist_y = pow(m_pos.second - h_pos.second, 2);

    auto dist = sqrt(dist_x + dist_y);

    printf("%.16lf\n", dist);

}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int diff = (h2 - h1) * 60 + (m2 - m1);
    int ans = max(0, diff - k);
    cout << ans << endl;
}

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

struct st { int x, y, b; }s[200000];
int main() {
	int n, d; scanf("%d%d", &n, &d);
	rep(i, n)scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].b);
	sort(s, s + n, [](st a, st b) {return a.b < b.b; });
	multiset<int>x, y;
	int t = 0;
	ll Max = 0;
	rep(i, n) {
		while (s[i].b - s[t].b > d) {
			x.erase(x.find(s[t].x));y.erase(y.find(s[t].y));
			t++;
		}
		x.insert(s[i].x); y.insert(s[i].y);
		Max = max(Max, ll(*x.rbegin() - *x.begin())*(*y.rbegin() - *y.begin()));
	}
	printf("%lld\n", Max);
}

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

int main()
{
    ll n,ans=0,f=0;
    cin>>n;
    vector<string> song(n);
    vector<ll> duration(n);
    for(ll i=0;i<n;i++)
    {
        string s;
        ll t;
        cin>>s>>t;
        song[i] = s;
        duration[i] = t;
    }
    string x;
    cin>>x;
    for(ll i=0;i<n;i++)
    {
        if(song[i]==x) 
        {
            f=1;
            continue;
        }
        if(f)
        ans += duration[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	if (1 <= n && n <= 104) {
		cout << "0" << endl;
	}
	else if (105 <= n && n <= 134) {
		cout << "1" << endl;
	}
	else if (135 <= n && n <= 164) {
		cout << "2" << endl;
	}
	else  if(165 <= n && n <= 188){
		cout << "3" << endl;
	}
	else if (189 <= n && n <= 194){
		cout << "4" << endl;
	}
	else if (195 <= n && n <= 200){
		cout << "5" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main
{
	public void solve()
	{
		Scanner cin = new Scanner(System.in);
		while(true)
		{
			int n = cin.nextInt();
			if(n == 0)break;
			int m1 = cin.nextInt();
			int[][] a = new int[m1][2];
			int prex1 = 0;
			int prey1 = 0;
			for(int i = 0;i < m1;i++)
			{
				int x = cin.nextInt();
				int y = cin.nextInt();
				if(i != 0)
				{
					if(prex1 < x)
					{
						a[i - 1][0] = 1;
						a[i - 1][1]= Math.abs(x - prex1);
					}else if(prex1 > x)
					{
						a[i - 1][0] = 3;
						a[i - 1][1] = Math.abs(prex1 - x);
					}else if(prey1 < y)
					{
						a[i - 1][0] = 0;
						a[i - 1][1] = Math.abs(y - prey1);
					}else if(prey1 > y)
					{
						a[i - 1][0] = 2;
						a[i - 1][1] = Math.abs(prey1 - y);
					}
				}
				prex1 = x;
				prey1 = y;
			}
			for(int i = 1;i <= n;i++)
			{
				int m2 = cin.nextInt();
				int[][] b = new int[m2][2];
				int prex2 = 0;
				int prey2 = 0;
				for(int j = 0;j < m2;j++)
				{
					int x = cin.nextInt();
					int y = cin.nextInt();
					if(j != 0)
					{
						if(prex2 < x)
						{
							b[j - 1][0] = 1;
							b[j - 1][1] = Math.abs(x - prex2);
						}else if(prex2 > x)
						{
							b[j - 1][0] = 3;
							b[j - 1][1] = Math.abs(prex2 - x);
						}else if(prey2 < y)
						{
							b[j - 1][0] = 0;
							b[j - 1][1] = Math.abs(y - prey2);
						}else if(prey2 > y)
						{
							b[j - 1][0] = 2;
							b[j - 1][1] = Math.abs(prey2 - y);
						}else
						{
							break;
						}
					}
					prex2 = x;
					prey2 = y;
				}
				if(m2 != m1)continue;
				boolean ok = false;
				for(int k = 0;k < 4;k++)
				{
					boolean ook = true;
					for(int l = 0;l < m2 - 1;l++)
					{
						if(a[l][0] == (b[l][0] + k) % 4 && a[l][1]  == b[l][1])continue;
						ook = false;
						break;
					}
					if(ook)
					{
						ok = true;
						break;
					}
					ook = true;
					for(int l = 0;l < m2 - 1;l++)
					{
						if(a[m2 - 2 - l][0] == (b[l][0] + k) % 4 && a[m2 - 2 - l][1] == b[l][1])continue;
						ook = false;
						break;
					}
					
					if(ook)
					{
						ok = true;
						break;
					}
				}
				if(ok)
				{
					System.out.println(i);
				}
			}
			System.out.println("+++++");
		}
	}
	public static void main(String[] args)
	{
		new Main().solve();
	}
}

Measured memory_bytes: 37980
#include<stdio.h>
#include<stdlib.h>

int main(){
  int N;
  scanf("%d", &N);
  int *A;
  A = (int *)malloc(sizeof(int)*N);
  for(int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }

  int l=0, r=0;
  int s, x;
  long long cnt=0;
  for(l=0; l<N; l++){

    if(l==0){
      s=x=0;
    }else{
      s -= A[l-1]+A[r];
      x = s;
    }
    
    for(; r<N; r++){
      s += A[r];
      x = x^A[r];
      if(s != x) break;
    }

    cnt+=r-l;
  }

  
  printf("%lld\n", cnt);
  
  return 0;
}

Measured memory_bytes: 896
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= 100000; i++)
    {
        if (i * i <= n)
            chmax(ans, i * i);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 5010
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int n,an,bn,na[N],nb[N],a[N],b[N],ansn=1e9;
char ch;
int add(int x,int y){
	int sum=0;
	for (int i=1-x,j=1-y;i<=an||j<=bn;i++,j++){
		if (i<1)sum+=nb[j];
		if (j<1)sum+=na[i];
		if (i>an)sum+=n-nb[j];
		if (j>bn)sum+=n-na[i];
		if (i>=1&&j>=1&&i<=an&&j<=bn)sum+=abs(na[i]-nb[j]);
	}
	return sum;
}
int main(){
	read(n);
	for (int i=1;i<=n;i++){ch=getchar();while (ch!='0'&&ch!='1')ch=getchar();a[i]=ch-'0';}
	for (int i=1;i<=n;i++){ch=getchar();while (ch!='0'&&ch!='1')ch=getchar();b[i]=ch-'0';}
	for (int i=1;i<=n;)if (a[i+1]!=a[i]||i==n){na[++an]=i;i++;}else{na[++an]=i+1;i+=2;}
	for (int i=1;i<=n;)if (b[i+1]!=b[i]||i==n){nb[++bn]=i;i++;}else{nb[++bn]=i+1;i+=2;}
	if (a[1]==b[1]){
		for (int i=0;i<=bn;i+=2)ansn=min(ansn,add(0,i));
		for (int i=0;i<=an;i+=2)ansn=min(ansn,add(i,0));
	}else{
		for (int i=1;i<=bn;i+=2)ansn=min(ansn,add(0,i));
		for (int i=1;i<=an;i+=2)ansn=min(ansn,add(i,0));
	}
	cout<<ansn<<endl;
	return 0;
}

Measured memory_bytes: 384
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
ans = 0
for z in range(X+1,Y+1):
    if max(x) < z and min(y) >= z:
        ans = 1
    if ans == 1:
        j = z
        break
if ans == 0:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

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

int main()
{
    IOS;
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<pair<ll,ll>>v;
    v.pb({-1,-1});
    for(int i=0;i<s.size();i++)
    {
        int j=i;
        if(s[i]=='0')
        {
            while(j<s.size()&&s[i]==s[j])
            {
                j++;
            }
            v.pb({i,j-1});
            i=j-1;
        }
    }
    v.pb({n,n});
    if(v.size()<=k+2)
    {
        cout<<n<<endl;
        return 0;
    }
    // for(int i=0;i<v.size();i++)
    // {
    //     cout<<v[i].ff<<" "<<v[i].ss<<endl;
    // } 
    ll mx=0;
    for(int i=1;i<v.size()-k;i++)
    {
        mx=max(mx,v[i+k].ff-v[i-1].ss-1);
    }
    cout<<mx<<endl;
}

Measured memory_bytes: 1528