akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>

#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
typedef long long LL;
using namespace std;

class UnionFind
{
    vector<int> data;
    vector<int> scale;
    public:
    UnionFind(int n)
    {
        for(int i=0;i<n;i++)
        {
            data.push_back(i);
            scale.push_back(1);
        }
    }
    int root(int n)
    {
        if(data[n]==n)
            return n;
        else
            return data[n]=root(data[n]);
    }
    void set(int x,int y)
    {
        if(root(x)==root(y))
            return;
        scale[root(y)]+=scale[root(x)];
        scale[root(x)]=0;
        data[root(x)]=data[root(y)];
    }
    int size(int n)
    {
        return scale[root(n)];
    }
};


int N,M;
vector<int> G[100000];
UnionFind U(100000);

int main(void){
    scanf("%d%d",&N,&M);
    REP(i,M){int a,b;scanf("%d%d",&a,&b);a--;b--;G[a].pb(b);G[b].pb(a);}
    deque<int> path;
    path.pb(0);
    while(1){
        int v=path.back();
        int i;
        for(i=0;i<SZ(G[v]);i++){
            if(U.root(0) != U.root(G[v][i])){
                U.set(0,G[v][i]);
                path.pb(G[v][i]);
                break;
            }
        }
        if(i==SZ(G[v]))
            break;
    }
    while(1){
        int v=path.front();
        int i;
        for(i=0;i<SZ(G[v]);i++){
            if(U.root(0) != U.root(G[v][i])){
                U.set(0,G[v][i]);
                path.push_front(G[v][i]);
                break;
            }
        }
        if(i==SZ(G[v]))
            break;
    }
    printf("%d\n",SZ(path));
    REP(i,SZ(path))
        printf("%d ",path[i]+1);
    return 0;
}


Measured memory_bytes: 8308
n = int(input())
sitigosan = []

def dfs(i,siti):
  if i == 9:
    pass
  else:
    dfs(i+1,siti*10+3)
    dfs(i+1,siti*10+5)
    dfs(i+1,siti*10+7)
    sitigosan.extend([siti*10+3,siti*10+5,siti*10+7])
    
dfs(0,0)
ans = 0
for i in sitigosan:
  if i <= n and set(str(i)) == {"3","5","7"}:
    ans += 1
  
print(ans)
    
    

Measured memory_bytes: 4340
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = BigInt(input[0][0]);

  let name = "";
  let n = N;

  while (true) {
    if (n <= 0n) {
      break;
    }

    const num = n % 26n === 0n ? 26n : n % 26n;

    name = `${String.fromCodePoint(96 + Number(num))}${name}`;

    n = (n - num) / 26n;
  }

  return name;
};

console.log(main(read()));


Measured memory_bytes: 29600
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0, j = 0;

        String message = sc.next();
        String re_message = sc.next();
        char[] chmessage = message.toCharArray();
        char[] chre_message = re_message.toCharArray();
        char temp[];
        temp = new char[chre_message.length];

        Arrays.sort(chmessage);
        Arrays.sort(chre_message);
        for (i = 0; chre_message.length > i; i++) {
            temp[chre_message.length - i - 1] = chre_message[i];
        }
        String str1 = String.valueOf(chmessage);
        String str2 = String.valueOf(temp);
        if (str1.compareTo(str2) < 0) {
            System.out.println("Yes");
        }
        if (str1.compareTo(str2) >= 0) {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;//d, v
const int max_n = 5000+10;
const int INF = 1e6;
struct edge{
  int from,to,cost;
};
bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}
ll a,b,c,y,n;
vector<edge> G[max_n];
int dist[max_n];
int dist2[max_n];
edge es[max_n];
ll dp[max_n][max_n];
int main(){
  cin >> n;
  vector<ll>  x(n),xx(n);
  for(int i=0 ; i<n ; i++){
    cin >> x[i];
    xx[i] = x[i];
  }
  sort(x.begin(), x.end());
  for(int i=0 ; i<n ; i++){
    cout << (xx[i]<x[n/2] ? x[n/2] : x[n/2 -1]) << endl;
  }
  return 0;
}


Measured memory_bytes: 5376
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	long long dp[51][51][2501] = {0}, n, a, x[51];

	cin >> n >> a;

	for (int i = 1; i <= n; ++i) {
		cin >> x[i];
		for (int j = i; j <= n; ++j) {
			dp[j][1][x[i]]++;
		}
	}

	for (int i = 2; i <= n; ++i) {
		for (int j = 2; j <= i; ++j) {
			for (int s = 1; s <= 2500; ++s) {
					if(s - x[i] > 0) {
						dp[i][j][s] = dp[i - 1][j - 1][s - x[i]] + dp[i - 1][j][s];
					}
					else {
						dp[i][j][s] = dp[i - 1][j][s];	
					}
			}
		}
	}

	
	long long ans = 0;

	for (int i = 1; i <= n; ++i) {
		ans += dp[n][i][i*a];
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    ll t;
    cin>>t;
    ll lock=0;
    ll a[t+6];
    for(int i=0;i<t;i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
        {
            if((a[i]%5==0 || a[i]%3==0)&& lock==0)
                lock=0;
            else
                lock=1;

        }
    }
    if(lock==1)
        pf("DENIED\n");
    else
        pf("APPROVED\n");

}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<map>

using namespace std;

#define ll long long 

int dist[100001];

int dfs(int node,vector<int> m[]){
    if(m[node].size()==0) dist[node] = 0;     

    if(dist[node]!=-1) return dist[node];
    
    for(auto x:m[node]){
        dist[node] = max(dist[node],1 + dfs(x,m));
    }

    return dist[node];
}

int main(){

    int n,m;
    cin>>n>>m;
    vector<int> m1[100001];
    for(int i=1;i<=n;i++) dist[i] = -1;
    int t1,t2;
    for(int i=0;i<m;i++){
        cin>>t1>>t2;
        m1[t1].push_back(t2);
    }
    int ans = 0;    
    for(int i=1;i<=n;i++) { 
        if(dist[i]!=-1) ans = max(ans,dist[i]); 
        else ans = max(ans,dfs(i,m1));
     }
    cout<<ans;


    return 0;

}

Measured memory_bytes: 11476
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[1000000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>a>>b>>c;
  cout <<max(0LL,a-c)<<' ';
  a=c-a;
  if(a>0){
    cout <<max(0LL,b-a)<<'\n';
  }
  else cout <<b<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll a, b;
    cin >> a >> b;
    if(min(a, b) == 1){
        cout << 1 << endl;
        return 0;
    }
    if(a % 2 == 0 or b % 2 == 0){
        cout << a * b / 2 << endl;
    }else{
        ll ans = 0;
        ans += (a + 1) / 2 * ((b + 1) / 2);
        ans += (a / 2) * (b / 2);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	ll n,x,i;
	cin>>n;
	map<ll,ll> m;
	rep(i,n)
	{
		cin>>x;
		m[x]++;
	}
	if(m.size()==n)
		cout<<"YES";
	else
		cout<<"NO";
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if(b-a == c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  for (int i=0;i<N;i++)cin >> A[i] ;
  
  int sum=0,fg=0;
  for (int i=0;i<N;i++)sum += A[i];
  int i=0;
  int other_g = 0;
  do{
    fg += A[i];
    other_g = sum - fg;
    i++;}while (fg < other_g );
  
  int sg=0;
  i=N-1;
  int Another_g;
  do{
    sg += A[i];
    Another_g = sum -sg;
    --i;} while(sg < Another_g);
  
  int G = fg -other_g;
  int B = sg - Another_g;
  if ( G >= B ) cout << B;
  else cout << G;  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    double a,b,c,d,e,f,x,y;
    double ansx,tmp,ansy;
    double a1,a2,a3,a4,a5,a6,x1,y1;
    
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
        tmp=a,a1=a,a2=b,a3=c,a4=d,a5=e,a6=f,a*=d,b*=d,c*=d;
        d*=tmp,e*=tmp,f*=tmp;
        x=b-e;
        y=c-f; 
        ansx=y/x+0.000499999999;
        
        tmp=a2; 
        a1*=a5,a2*=a5,a3*=a5;
        a4*=tmp,a5*=tmp,a6*=tmp;
        x1=a1-a4; 
        y1=a3-a6;
        ansy=y1/x1+0.000499999999;
        
        printf("%.3f %.3f\n",ansy,ansx);
    } 
    
    return 0; 
    
} 


Measured memory_bytes: 2024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
   string s ;
   cin >> s;
   int num = 0;
   int ans = 0;
   for(int i = 0; i < s.size() ; i++)
   {if (s[i]=='A'||s[i]== 'C'||s[i]=='G'|| s[i]=='T')
   {num++;
    ans = max(ans,num);}
    else num = 0;
   }
  cout << ans<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	//2013
	int N, M;
	cin >> N >> M;

	vector<string> vA(N);
	vector<string> vB(M);
	rep(i, N) cin >> vA[i];
	rep(i, M) cin >> vB[i];

	for (int i = 0; i != N - M + 1; ++i) {
		bool inc = false;
		for (int j = 0; j != N - M + 1; ++j) {
			bool ok = true;
			for (int k = 0; k != M; ++k) {
				const string strA = vA[i + k];
				const string strB = vB[k];
				if (strA.substr(j, M) != strB) {
					ok = false;
					break;
				}
			}
			if (ok) {
				inc = true;
				break;
			}
		}

		if (inc) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

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

int main() {
	int N;
	long long K;
	cin >> N >> K;
	vector<int> Nums(40);
	vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		for (int j = 0; j < 40; j++) {
			if (A[i] & (1ll << j)) Nums[j]++;
		}
	}
	long long ans = 0;
	for (int j = 39; j >= 0; j--) {
		if (Nums[j] * 2 <= N) ans += (1ll << j);
		if (ans > K) ans -= (1ll << j);
	}
	long long sum = 0;
	for (long long a : A) sum += (a ^ ans);
	cout << sum << endl;
}


Measured memory_bytes: 4048
N,M=map(int,input().split())
py=[list(map(int,input().split()))for _ in range(M)]
epy=list(enumerate(py))
P=[[]for _ in range(N+1)]
for x in epy:
    P[x[1][0]].append(x)

i=1
ans=[]
while i<=N:
    L=P[i]
    L.sort(key=lambda x:x[1])
    j=0
    while j<len(L):
        L[j][1][1]=j+1
        ans.append(L[j])
        j+=1
    i+=1
ans.sort()

for e,py in ans:
    p,y=map(str,py)
    p='0'*(6-len(p))+p
    y='0'*(6-len(y))+y
    print(p+y)

Measured memory_bytes: 48664
import sys

N, K = list(map(int, sys.stdin.readline().split()))
A = [None] + list(map(int, sys.stdin.readline().split()))

dist = [None, 0] + [None] * (N-1)
cycle_len = None
i = 0
town = 1

while True:
    next_town = A[town]
    if dist[next_town] is None:
        dist[next_town] = i+1
    elif cycle_len is None:
        cycle_len = i + 1 - dist[next_town]
        K = K % cycle_len
    
    if K <= 0:
        break
    
    town = next_town
    i += 1
    K -= 1

print(town)

Measured memory_bytes: 31440
n = int(input())
a = list(input())
b = list(input())
c = list(input())
cnt = 0

for i in range(n):
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i]:
        cnt += 0
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        cnt += 1
    else:
        cnt += 2

print(cnt)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
const int mod = 1e9+7;

int a[100005];
bool vis[100005];
ll f1[100005], f2[100005];
ll pw(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b%2 == 1) ans = ans*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return ans;
}
ll func(int a, int b){
    if(b > a) return 0;
    return f1[a]*f2[b]%mod*f2[a-b]%mod;
}

int main(){
    int n, l, r;
    scanf("%d", &n);
    f1[0] = f2[0] = 1;
    for(int i=1;i<=n+1;i++){
        f1[i] = f1[i-1]*i%mod;
        f2[i] = pw(f1[i], mod-2);
    }
    for(int i=1;i<=n+1;i++){
        scanf("%d", &a[i]);
        if(vis[a[i]]) r = i;
        vis[a[i]] = 1;
    }
    for(int i=1;i<=n+1;i++){
        if(a[i] == a[r]){
            l = i;
            break;
        }
    }
    for(int i=1;i<=n+1;i++){
        if(i == 1) printf("%d\n", n);
        else if(i == n+1) printf("1\n");
        else{
            ll ans = func(n+1, i);
            ans = (ans - func(n+1-(r-l+1), i-1) + mod)%mod;
            printf("%lld\n", ans);
        }
    }
}

Measured memory_bytes: 5800
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		for(int i = 0; i < S.length(); i++) {
			if(i % 2 == 0) {
				if(S.substring(i, i + 1).equals("L")) {
					System.out.println("No");
					return;
				}
			} else {
				if(S.substring(i, i + 1).equals("R")) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    ll N,M,X,Y; cin >> N >> M >> X >>Y;
    vector<ll> x(N); REP(i,N) cin >> x[i];
    vector<ll> y(M); REP(i,M) cin >> y[i];

    ll max_x = *max_element(x.begin(),x.end());
    ll min_y = *min_element(y.begin(),y.end());
    bool ans = false;
    FOR(Z,X+1,Y){
        if(max_x<Z && min_y>=Z){
            ans = true;
        }
    }

    if(ans) cout << "No War" << endl;
    else cout << "War" << endl;
}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, l, r; cin >>N;
    int ans = 0;
    rep(i, N) {
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        if ("ABC".equals(s)) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}


Measured memory_bytes: 26852
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
public class Main {
	int N,M,s,g,V,P;
	ArrayList<Integer>[] graph;
	int[][] cost;

	private class P implements Comparable<P>{
		int first,second;
		public P(int first,int second){
			this.first = first;
			this.second = second;
		}

		public int compareTo(P p){
			if(this.first == p.first){
				return this.second - p.second;
			}
			return this.first - p.first;
		}

	}

	public int dijkstra(int s,int t){
		int[] dis = new int[N];
		Arrays.fill(dis, (int)1e9 + 7);
		PriorityQueue<P> pq = new PriorityQueue<P>();
		pq.add(new P(0,s));
		dis[s] = 0;
		while(pq.size() > 0){
			P p = pq.poll();
			if(dis[p.second] < p.first)continue;
			dis[p.second] = p.first;
			for(int next : graph[p.second]){
				if(dis[next] > p.first + cost[p.second][next]){
					pq.add(new P(p.first + cost[p.second][next],next));
				}
			}
		}
		return dis[t];
	}

	@SuppressWarnings("unchecked")
	public void solve() {
		N = nextInt();
		M = nextInt();
		cost = new int[N][N];
		graph = new ArrayList[N];
		for(int i = 0;i < N;i++){
			graph[i] = new ArrayList<Integer>();
		}
		for(int i = 0;i < M;i++){
			String[] line = next().split(",");
			int a = Integer.parseInt(line[0]) - 1;
			int b = Integer.parseInt(line[1]) - 1;
			int c = Integer.parseInt(line[2]);
			int d = Integer.parseInt(line[3]);

			cost[a][b] = c;
			cost[b][a] = d;

			graph[a].add(b);
			graph[b].add(a);
		}

		String[] line = next().split(",");
		s = Integer.parseInt(line[0]) - 1;
		g = Integer.parseInt(line[1]) - 1;
		V = Integer.parseInt(line[2]);
		P = Integer.parseInt(line[3]);

		int go = dijkstra(s,g);
		int back = dijkstra(g,s);

		out.println(V - go - back - P);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24220
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-6

int X;
double Rep[1010];

int main()
{
	scanf("%d", &X);
	for (int i=(-120); i<=120; i++) Rep[i + 120] = pow(i, 5);
	for (int i=1; i<=120; i++)
		for (int j=(-120); j<=120; j++)
			if (Rep[i + 120] - Rep[j + 120] == X)
			{ printf("%d %d\n", i, j); return 0; }
}

Measured memory_bytes: 4216
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var A, B int

func main() {
	sc.Split(bufio.ScanWords)

	A, B = nextInt(), nextInt()
	ans := 0
	for i := A; i <= B; i++ {
		s := strconv.Itoa(i)
		if s[0] == s[4] && s[1] == s[3] {
			ans++
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 1152
#include <iostream>
#include <map>
using namespace std;
using ll = unsigned long long;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

ll A[3], D;
map<ll, ll> dp;
ll dfs(ll N) {
  ll ans = D*N;
  ll ps[] = {2, 3, 5};
  if (N == 0) return 0;
  if (N == 1) return D;
  if (dp.count(N) > 0) return dp[N];
  rep(i, 3) {
    ll p = ps[i];
    ans = min(ans,
        min(dfs(N/p)+A[i]+D*(N%p),
          dfs((N+p-1)/p)+A[i]+D*((N+p-1)/p*p-N)));
  }
  return dp[N] = ans;
}

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

  rep(i, t) {
    ll N; cin >> N;
    rep(j, 3) cin >> A[j];
    cin >> D;

    map<ll, ll> dp2;
    swap(dp, dp2);
    cout << dfs(N) << endl;
  }

  return 0;
}


Measured memory_bytes: 5240
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

  vector<int> d(N);

  rep(i,N) cin>>d[i];

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

  int answer = 0;
  if(d[N/2-1] == d[N/2]){
    answer = 0;
  } else {
    answer = d[N/2] - d[N/2-1];
  }

  cout << answer << endl;

  return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
 
int main(void)
{
int N,M,i,hw=0,D;
  int A[10000];
  scanf("%d",&N);
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&A[i]);
    hw+=A[i];
    D=N-hw;
    if(D<0)
    {
      printf("-1\n");
	  break;      
    }
  }
  if(D>=0)
  {
    printf("%d\n",D);
  }
  return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>

#define MAX (999999)

int main(void)
{
	int i, j;
	int p[MAX] = {0};
	// ツェツ素ツ青板表ツ催ャツ青ャツづ可使ツづつスツェ
	int n, ans;
	
	// ツつアツづつゥツづァツ素ツ青板表ツ催ャツ青ャ
	p[0] = 1;
	for (i = 2; i <= (MAX / 2); i++){
		for (j = 2; (i * j) <= MAX; j++){
			if (p[(i * j) - 1] == 0){
				p[(i * j) - 1] = 1;
			}
		}
	}
	// ツつアツつアツづ慊づ！
	
	// ツ本ツ氾板つ「ツづつュツづヲツー
	while (scanf("%d", &n) != EOF){
		ans = 0;
		for (i = 0; i < n; i++){
			if (p[i] == 0){
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 4316
import numpy as np

N, M = map(int, input().split(' '))
input_line = [list(map(int, input().split(' '))) for _ in range(M)]

input_line = list(map(list, set(map(tuple, input_line))))
result = True
conditions = [[] for _ in range(2)]
for x in input_line:
    if x[0] > N or x[0] in conditions[0] or (x[0] == 1 and x[1] == 0 and N > 1):
        result = False
        break
    elif x[0] not in conditions[0]:
        conditions[0].append(x[0])
        conditions[1].append(x[1])

answer = ''
if result:
    for i in range(1, N+1):
        if i in conditions[0]:
            answer +=  str(conditions[1][conditions[0].index(i)])
        elif i == 1 and N != 1:
            answer += '1'
        else:
            answer += '0'
    print(int(answer))
else:
    print(-1)


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

int main(void){

    int n,pair,max_pair=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        pair = 0;
        bool c_list[26]={0};
        for(int j=0;j<=i;j++){
            if(c_list[s[j]-97]){
                continue;
            }else{
                c_list[s[j]-97]=1;
            }
            for(int k=i+1;k<n;k++){
                if(s[j]==s[k]){
                    pair ++;
                    break;
                }
            }
        }
        max_pair = max(max_pair, pair);
    }
    cout<<max_pair<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	char a[55][55] = {};
	int dx[8] = { 1,1,0,-1,-1,-1,0,1 }, dy[8] = { 0,1,1,1,0,-1,-1,-1 }, h, w;
	cin >> h >> w;
	int cnt = 0;
	for (int i = 1; i <= h; i++)for (int j = 1; j <= w; j++)cin >> a[i][j];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (a[i][j] == '.') {
				for (int k = 0; k < 8; k++) {
					if (a[i + dx[k]][j + dy[k]] == '#')cnt++;
				}
				cout << cnt;
				cnt = 0;
			}
			else cout << '#';
		}
		cout << endl;
	}
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ;
  vector<int> v(n) ;
  
  rep(i,n-1){
    int c ;
    cin >> c ;
    c--;
    v.at(c) ++ ;
  }
  
  rep(i,n){
    cout << v.at(i) << endl ;
  }
  
  
  


}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define repo(i,o,n) for(int i=o;i<(int)(n);i++)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,m,c,b[20],a,ans;

main() {
    cin >> n >> m >> c;
    rep(i,m) cin >> b[i];
    rep(i,n) {
        int tmp=c;
        rep(j,m) {
            cin >> a;
            tmp += a*b[j];
        }
        if (tmp > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
   int a, b;
   cin >> a >> b;
   int con = 1;
   int cnt = 0;
   while(con < b){
      cnt++;
      con = con + a - 1;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 256
# input process
inputData = input().split()
N = int(inputData[0])
L = int(inputData[1])

# cal process
aji_min = L + 1 -1
aji_max = L + N -1
if aji_max <= 0:
    print(sum(range(aji_min, aji_max - 1 + 1)))
    exit()
if aji_min >= 0:
    print(sum(range(aji_min + 1, aji_max + 1)))
    exit()
print(sum(range(aji_min, aji_max + 1)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    vector<bool> col(H, false);
    vector<bool> row(W, false);
    rep(0, i, H)
    {
        cin >> S[i];
        rep(0, j, W)
        {
            if (S[i][j] == '#')
            {
                col[i] = true;
                row[j] = true;
            }
        }
    }
    int count;
    rep(0, i, H)
    {
        count = 0;
        rep(0, j, W)
        {
            if (col[i] && row[j])
            {
                cout << S[i][j];
                count++;
            }
        }
        if (count != 0)
        {
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

MOD = 998244353
N = int(input())
#N = 10 ** 7
n = N // 2
ansx = 1
tmp2 = 1
tmpc = 1
for i in range(1, n):
    tmp2 = (tmp2 * 2)%MOD
    tmpc = (tmpc * (2 * n - i + 1) * modinv(i, MOD)) % MOD
    ansx = (ansx + tmp2 * tmpc)%MOD

ans = pow(3, N, MOD)
ans = (ans + 2 * MOD - ansx * 2)%MOD
print(ans)

Measured memory_bytes: 43068
#include<iostream>

using namespace std;

int main(void)
{
  long int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if((a*b)>(c*d)){cout<<a*b<<endl;}
  else if((a*b)<(c*d)){cout<<c*d<<endl;}
  else{cout<<a*b<<endl;}
  
  return 0;
}
  

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int cmpAsc(const void* a, const void* b){
    lld x = *(lld*)a, y = *(lld*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    lld m;
    scanf("%d %lld", &n, &m);
    lld a[n+1];
    a[0] = 0;
    rep(i, 1, n+1){
        scanf("%lld", &a[i]);
    }
    rep(i, 1, n+1){
        a[i] += a[i-1];
        a[i] %= m;
    }
    qsort(a, n+1, sizeof(lld), cmpAsc);
    int cnt = 1;
    lld target = -1;
    lld ans = 0;
    rep(i, 0, n+1){
        if(a[i] == target){
            ans += (lld)cnt;
            cnt++;
        }else{
            target = a[i];
            cnt = 1;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	double x,y,dx,dy,pi,d,rad,prad;
	char camma;
	x=y=0;
	pi=3.14159265359;
	prad=90;
	while(cin>>d>>camma>>rad){
		if(d==0 && rad==0)break;
		dx=d*cos(prad*pi/180);
		dy=d*sin(prad*pi/180);
		x+=dx;
		y+=dy;
		prad=prad-rad;
	}
	cout<<(int)x<<endl;
	cout<<(int)y<<endl;
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, M; cin >> N >> M;
    vec a(N, 1), v(N, 0);
    v[0] = 1;
    rep(i, M){
        int x, y; cin >> x >> y;
        x--; y--;
        a[x]--;
        a[y]++;
        if(v[x] == 1) v[y] = 1;
        if(a[x] == 0) v[x] = 0;
    }
    cout << count(all(v), 1) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
way = [[] for _ in range(n+1)]
for i in range(m):
    a,b = inpm()
    way[a].append(b)
    way[b].append(a)

ans = [0 for i in range(n+1)]
q = queue.Queue()
q.put((1,0))
while not q.empty():
    room,sign = q.get()
    if ans[room] != 0:
        continue
    ans[room] = sign

    for i in way[room]:
        q.put((i,room))

print('Yes')
for i in range(2,n+1):
    print(ans[i])

Measured memory_bytes: 116460
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>

using namespace std;

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;

  if (e - a > k) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = [-a for a in A]

from heapq import heapify, heappop, heappush

heapify(A)

for _ in range(M):
    a = -heappop(A)//2
    heappush(A, -a)
    
print(-sum(A))

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

#define MAXN 110

using namespace std;

vector< int > comp[MAXN];

int main() {
    int n;
    scanf("%d", &n);
    int i, j, k;

    int atual=-1;
    if (n%2==0) {
        for (i=1; i<n-i+1; i++) {
            ++atual;
            comp[atual].push_back(i);
            comp[atual].push_back(n-i+1);
        }
    }
    else {
        ++atual;
        comp[atual].push_back(n);
        for (i=1; i<n-i; i++) {
            ++atual;
            comp[atual].push_back(i);
            comp[atual].push_back(n-i);
            //printf("****** %d %d\n", i, n-i);
        }
    }
    vector< pair<int, int> > res;
    for (i=0; i<atual; i++) {
        for (j=0; j<comp[i].size(); j++) {
            for (k=0; k<comp[i+1].size(); k++) {
                res.push_back(make_pair(comp[i][j], comp[i+1][k]));
            }
        }
    }
    if (n>=5) {
        for (j=0; j<comp[atual].size(); j++) {
            for (k=0; k<comp[0].size(); k++) {
                res.push_back(make_pair(comp[atual][j], comp[0][k]));
            }
        }
    }
    printf("%d\n", res.size());
    for (i=0; i<res.size(); i++) {
        printf("%d %d\n", res[i].first, res[i].second);
    }
    return 0;
}


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

int main(){
  long long N,M,a[50],b[50],c[50];
  cin>>N>>M;
  for(int i=0;i<50;i++)c[i]=0;
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    for(int I=1;I<=50;I++){
      if(a[i]==I)c[I]=1+c[I];
      if(b[i]==I)c[I]=1+c[I];
      
    }
  }
      for(int i=1;i<=N;i++){
	cout<<c[i]<<endl;
      }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	int h[n]; rep(i,n) cin>>h[i];
	vector<bool> c(n,true);
	rep(i,m){
		int a,b; cin>>a>>b; a--; b--;
		if(h[a]>=h[b]) c[b]=false;
		if(h[a]<=h[b]) c[a]=false;
	}
	int ans=0;
	rep(i,n){
		if(c[i]==true) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4056
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a>b?a:b)
int compare(const void *a,  const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(void)
{
    int n, i, idx=100, ave=0, a[100], b[100], min=100;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf("%d",&a[i]);
        ave += a[i];
    }
    for(i=n-1;i>=0;i--) {
        b[i] = abs(a[i]*n - ave);
        if(min>=b[i]) {
            min = b[i];
            idx = i;
        }
    }
    printf("%d",idx);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string a;
  cin >> a;
  int n = a.size();
  set< pair<int, int> > st;
  for(int i = 0; i < n; i++){
    string s = a.substr(0, i);
    string t = a.substr(i);
    if(s.size() != 1 && s[0] == '0') continue;
    if(t.size() != 1 && t[0] == '0') continue;    
    if(i == 0) s = "0";
    int b = stoll(s);
    int c = stoll(t);
    if((c-b)%2 == 1) continue;
    int y = (c-b)/2, x = b + y;
    if(x < 0 || y < 0) continue;
    if(x-y != b || x+y != c) continue;
    st.insert(make_pair(x, y));
  }
  cout << st.size() << endl;
  return 0;
}

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

using namespace std;

int a[20];
int c[20];

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

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
    }
    
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ans += x;
    }

    for (int i = 0; i < n - 1; ++i)
        cin >> c[i];


    
    for (int i = 0; i < n - 1; ++i) {
        if(a[i] + 1 == a[i + 1])
            ans += c[a[i]];
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

    int A = N % 10;

    if (A == 2 || A == 4 || A == 5 || A == 7 || A == 9) {
        cout << "hon" << endl;
    }

    else if (A == 0 || A == 1 || A == 6 || A == 8) {
        cout << "pon" << endl;
    }

    else {
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << "ABC";
    int n; cin >> n;
    cout << n;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)
INF = 1001001001
dp = Array.new(n, INF)
dp[0] = 0
(n-1).times{|i|
  c1 = i>-1 ? dp[i]+(h[i+1]-h[i]).abs : INF
  c2 = i>0 ? dp[i-1]+(h[i+1]-h[i-1]).abs : INF
  dp[i+1] = [c1, c2].min
}
p dp[n-1]


Measured memory_bytes: 11396
N = int(input())
H = list(map(int, input().split()))
H.append(1000000000000000)

ans_m = 0
ans_t = 0

for i in range(N):
    if H[i] >= H[i+1]:
        ans_t += 1
    else:
        ans_m = max(ans_m, ans_t)
        ans_t = 0

print(ans_m)



Measured memory_bytes: 14224
#include<stdio.h>
int main(){
  int n,x,l[100000],i,s=0,a=0;
  scanf("%d %d",&n,&x);
  for(i=1;i<=n;i++){
    scanf("%d",&l[i]);
    s+=l[i];
    if(s>x&&a==0) a=i;
  }
  if(a==0)a=n+1;
  printf("%d",a);
  return 0;
}
     
    


Measured memory_bytes: 128
n = int(input())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a = a[::-1]
b = b[::-1]

ans = 0
for i in range(n):
    t = (a[i] + ans) % b[i]
    if t != 0:
        ans += b[i]-t

print(ans)

Measured memory_bytes: 17632