akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;

  vector<ll> pa(a + b + c);
  rep(i, a) { cin >> pa[i]; }

  sort(all(pa), greater<ll>());

  vector<ll> paa(a + b + c);

  rep(i, x) {
    paa[i] = pa[i];
    debug(paa[i]);
  }

  vector<ll> pb(a + b + c);
  rep(i, b) { cin >> pb[i]; }
  sort(all(pb), greater<ll>());

  vector<ll> pc(a + b + c);
  rep(i, c) { cin >> pc[i]; }
  sort(all(pc), greater<ll>());
  vector<ll> pbb(a + b + c);

  rep(i, y) {
    pbb[i] = pb[i];
  }

  vector<ll> sai(a + b + c);

  std::copy(paa.begin(), paa.end(), std::back_inserter(sai));
  std::copy(all(pbb), std::back_inserter(sai));
  std::copy(all(pc), std::back_inserter(sai));

  sort(all(sai), greater<ll>());

  ll ans = 0;

  rep(i, x + y) {
    ans += sai[i];
    debug(sai[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 23384
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   int n;
   cin>>n;
   vi a(n);
   set<int> s;
   lp(0,n){
       cin>>a[i];
   }
   int ans=0;
   sort(a.begin(), a.end());
   n = a.size();
   lp(0,n){
       
       for(int j=i+1; j<n; j++){
           
           for(int k=j+1; k<n; k++){
               
               if(a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i] and a[i]+a[j]>a[k] and a[j]+a[k]>a[i] and a[k]+a[i]>a[j]){
                //   cout<<i<<" "<<j<<" "<<k<<endl;
                   ans++;
               }
           }
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define ll long long
#define ld long double

int main() {
	int c;
	for (int i = 1; i < 6; i++) {
		cin >> c;
		if (c == 0) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>

int main(void){
  std::string str;
  char c1='s',c2='s';
  int i1 = 0,i2 = 0;
  std::cin >> str;
  c1 = str[0];
  i1++;
  for(int i = 1; i < 4; i++){
    if(str[i] == c1)
      i1++;
    else if(c2 == 's'){
      c2 = str[i];
      i2++;
    }
    else if(str[i] == c2){
      i2++;
    }else{
      std::cout << "No";
      return 0;
    }
  }
  if(i1 == 2 && i2 == 2){
    std::cout << "Yes";
  }else
    std::cout << "No";
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    bool ok = false;
    for (int i = 0; i < 2; i++) {
        if (S[i] != S[i+1]) ok = true;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  int n,d,a;
  cin>>n>>d>>a;
  PII bomb[n];
  int ans=0;
  rep(i,n){
    cin>>bomb[i].F>>bomb[i].S;
    bomb[i].S=(bomb[i].S+a-1)/a;
  }
  sort(bomb,bomb+n);
  
  deque<PII> wall;
  rep(i,n){
    //cout<<"A"<<endl;
    if(!wall.empty() && bomb[i].F > wall[0].F + (d*2)){
      int num=wall.size();
      int damage=0;
      queue<PII> qq;
      rep(j,num){
	PII p=wall.front();
	wall.pop_front();
	//cout<<p.F<<" "<<i<<"pb"<<endl;
	if(p.F < bomb[i].F-(d*2)){
	  damage=max(damage,p.S);
	  // cout<<"A"<<endl;
	}
	qq.push(p);
      }
      ans+=damage;
      int aaaaa=qq.size();
      rep(i,aaaaa){
	PII p=qq.front();
	qq.pop();
	p.S-=damage;
	if(p.S>0) wall.push_back(p);
      }
    }
    wall.push_back(bomb[i]);
     rep(i,wall.size() ){
       // cout<<"("<<wall[i].F<<" "<<wall[i].S<<") ";
     }
     //cout<<endl;
    //cout<<ans<<endl;
  }
 
  int numm=0;
  
  rep(i,wall.size() ){
    
    numm=max(numm,wall[i].S);
  }
  ans+=numm;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(!n)break;
		int a[n];
		rep(i,n){
			cin>>a[i];
		}
		int ans=0;
		rep(i,n-1){
			REP(j,i+1,n-1){
				if(a[i]+a[j]<=m&&ans<a[i]+a[j])
					ans=a[i]+a[j];
			}
		}
		if(ans)cout<<ans<<endl;
		else puts("NONE");
	}
	return 0;
}


Measured memory_bytes: 3016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		String s = sc.next();
		System.out.println(s.equals("ABC")?"ARC":"ABC");

	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

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

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

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

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

bool Comp(pair<int,int>a,pair<int,int>b)
{
   return a.second > b.second;
}
int main()
{
   int N;
   cin >> N;
   vector<pair<int,int>>A(N);
   vector<pair<int,int>>C(N);
   rep(i,0,N)
   {
       cin >> A[i].first >> A[i].second;
   }
   rep(i,0,N)
   {
       cin >> C[i].first >> C[i].second;
   }
   sort(C.begin(),C.end());
   vector<pair<int,int>>less;
   vector<bool>sel(N,false);
   ll ans=0;

   rep(i,0,N)
   {
       rep(j,0,N){
           if(!sel[j]&&(C[i].first>A[j].first)){
               sel[j]=true;
               less.push_back(A[j]);
           }
       }

       sort(less.begin(),less.end(),Comp);

       /*cout << C[i].first << endl;
       rep(i,0,less.size()){
           cout << less[i].first << "," << less[i].second << endl;
       }*/

       rep(j,0,less.size()){
           if(less[j].second<C[i].second){
               ans++;
               less.erase(less.begin()+j);
               break;
           }
       }
   }

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

Measured memory_bytes: 384
from collections import defaultdict

N, M = map(int, input().split())
years = defaultdict(list)
Q = []
for i in range(M):
    P, Y = map(int, input().split())
    years[P].append(Y)
    Q.append((P, Y))

rev_list = {}
for P, Y in years.items():
    Y.sort()
    rev_list[P] = {}
    for i in range(len(Y)):
        rev_list[P][Y[i]] = i + 1

for q in Q:
    print('{:06}{:06}'.format(q[0], rev_list[q[0]][q[1]]))


Measured memory_bytes: 71220
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
int main(){
  int h,w;
  scanf("%d %d",&h,&w);
  char *w_dot=(char *)malloc(sizeof(char)*w);
  for(int i=0;i<h;i++){
    scanf("%s\n",w_dot);
    printf("%s\n%s\n",w_dot,w_dot);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mod=1000000007;
long long dp[3002][3002],n;
string s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>s;


	dp[1][1]=1;
	for(int i=2;i<=n;i++){
		char ch=s[i-2];
		for(int j=1;j<=i;j++){
			if(ch=='<'){
				dp[i][j]=(dp[i-1][j-1]+dp[i][j-1]);
				if(dp[i][j]>=mod)dp[i][j]-=mod;
			}
			else{
				dp[i][j]=dp[i-1][i-1]-dp[i-1][j-1];
				if(dp[i][j]<0)dp[i][j]+=mod;
				dp[i][j]+=dp[i][j-1];
				if(dp[i][j]>=mod)dp[i][j]-=mod;
			}
		}
	}
	cout<<dp[n][n]<<endl;
	return 0;
}

Measured memory_bytes: 68992
<?php
 fscanf(STDIN,"%d%d",$n,$m);
$citys = array();
 for($i=0;$i<$m;$i++){
   $p_y = explode(" ",trim(fgets(STDIN)));
   $pref[$p_y[0]][] = $p_y[1];
   $py_li[] = $p_y;
 }
 

//昇順にする
$p_y_key_li = array_keys($pref);
for($i=0;$i<count($p_y_key_li);$i++){
  sort($pref[$p_y_key_li[$i]]);
}

$memo = array();

//print_r($pref);
foreach($pref as $c){
  foreach($c as $x => $year){
    $memo[$year] = $x;
  }
}

//print_r($memo);
  


foreach($py_li as $py){
  $x = $memo[$py[1]]+1;
  for($i=0;$i<6-strlen($py[0]);$i++){
    echo "0";
  }
  echo $py[0];
   for($i=0;$i<6-strlen($x);$i++){
    echo "0";
  }
  echo ($x)."\n";
}
//print_r($pref);

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

#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]))
#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 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    string s; cin >>s;
    rep(i,s.length()) {
        if (s[i] == '1')
            s[i] = '9';
        else if (s[i] == '9')
            s[i] = '1';
    }
    ANS(s);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    ll X;
    cin >> X;
    ll happy = 0;
    happy += X / 500 * 1000;
    happy += (X - X / 500 * 500) / 5 * 5;
    cout << happy << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
#define max 2000000

int n,a[max];

void maxHeapify(int i){
  int l,r,largest,c;
  
  l=2*i;
  r=2*i+1;
  if(l<=n && a[l]>a[i]) largest=l;
  else largest=i;
  if(r<=n && a[r]>a[largest]) largest=r;
  if(largest!=i){
    c=a[i];
    a[i]=a[largest];
    a[largest]=c;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&a[i]);
    for(i=n/2;i>=1;i--) maxHeapify(i);

  for(i=1;i<=n;i++) printf(" %d",a[i]);
  printf("\n");
   
  return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>a>>b>>c;
    cout<<YN[(b*10+c)%4==0]<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()

ll lcs(string X,string Y){
    ll c[1001][1001];
    ll m=X.size();
    ll n=Y.size();
    ll maxl=0;
    X=' '+X;
    Y=' '+Y;
    for (int i = 0; i <=m ; ++i)c[i][0]=0;
    for (int j = 0; j <=n ; ++j)c[0][j]=0;

    for(int i=1;i<=m;i++){
        for(int j=1; j<=n;j++){
        if(X[i]==Y[j]){
            c[i][j]=c[i-1][j-1]+1;
        }else{
            c[i][j]=max(c[i-1][j],c[i][j-1]);
        }
        maxl=max(maxl,c[i][j]);
        }
    }
    return maxl;
}

int main() {
string s1,s2;
ll n;cin>>n;
rep(i,n){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
}
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> cnt(5, 0);
ll ans = 0;

// 組み合わせを全探索し，使われるindexの集合を返す
void search(ll n, ll k, vector<ll> v){
    if (v.size() == k){
        ll tmp = 1;
        for (auto a: v){
            tmp *= cnt[a];
        }
        ans += tmp;
    } else {
        ll start = (v.size() > 0) ? v.at(v.size() - 1) + 1 : 0; // 重複はNGなので+1
        rep2(i, start, n){
            vector<ll> new_v(v);
            new_v.push_back(i);
            search(n, k, new_v);
        }
    }
}

void Main() {
    ll N; cin >> N;
    rep(i, N){
        string s; cin >> s;
        if (s[0] == 'M'){cnt.at(0) += 1;}
        else if (s[0] == 'A'){cnt.at(1) += 1;}
        else if (s[0] == 'R'){cnt.at(2) += 1;}
        else if (s[0] == 'C'){cnt.at(3) += 1;}
        else if (s[0] == 'H'){cnt.at(4) += 1;}
    }
    vector<ll> v(0);
    search(5, 3, v);
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);

        var dic = new DefaultDectionary<int, int>(0);

        for(int i=0; i<n; i++) {
            dic[aa[i]] += 1;
        }

        long sum = 0;
        foreach (var x in dic) {
            sum += (long)x.Key * (long)x.Value;
        }

        var sb = new StringBuilder();

        var q = int.Parse(input.ReadLine());
        for(int i=0; i<q; i++) {
            var spl = input.ReadLine().Split(' ');
            var b = int.Parse(spl[0]);
            var c = int.Parse(spl[1]);

            if (dic.ContainsKey(b)) {
                sum -= (long)b * (long)dic[b];
                sum += (long)c * (long)dic[b];

                dic[c] += dic[b];
                dic[b] = 0;
            }

            sb.AppendLine(sum.ToString());
        }
        return sb;
    }

    class DefaultDectionary<Tkey, TValue> : Dictionary<Tkey, TValue>
    {
        TValue DefaultValue;
        public DefaultDectionary(TValue defaultvalue) {
            this.DefaultValue = defaultvalue;
        }
        public new TValue this[Tkey key] {
            get {
                if (this.ContainsKey(key)) return base[key];
                else return DefaultValue;
            }
            set {
                base[key] = value;
            }
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        if(n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 51060
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

ll cnt(ll a){
    string s=to_string(a);
    ll n=s.size();
    ll res=0;
    rep(i,0,n-1){
        res+=s[i]-'0';
    }
    return res;
}

int main(){fastio
    ll n,a,b;cin>>n>>a>>b;
    ll ans=0;
    rep(i,1,n){
        ll c=cnt(i);
        if(a<=c&&c<=b)ans+=i;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	string s;
	int c = 0;
	cin >> s;
	REP(i, s.size()) {
		if (c == 0 && s[i] == 'C') ++c;
		else if (c == 1 && s[i] == 'F'){
			++c;
			break;
		}
	}

	cout << (c == 2 ? "Yes" : "No") << endl;



	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

struct Node
{
    int par,left,right;
};

Node G[26];

void dfs(int n, int i)
{
    if(i == 0)printf(" %d", n);
    if(G[n].left != -1){
        dfs(G[n].left, i);    
    }
    if(i == 1)printf(" %d", n);
    if(G[n].right != -1){
        dfs(G[n].right, i);
    }
    if(i == 2)printf(" %d", n);
}

int main()
{
    int n,id,left,right;
    scanf("%d", &n);
    
    for(int i = 0; i < n; ++i){
        G[i].par = -1;
    }
    
    for(int i = 0; i < n; ++i){
        scanf("%d%d%d", &id, &left, &right);
        G[id].left = left;
        G[id].right = right;
        if(left != -1)G[left].par = id;
        if(right != -1)G[right].par = id;
    }
    
    int root;
    for(int i = 0; i < n; ++i){
        if(G[i].par == -1){
            root = i;
            break;
        }
    }
    puts("Preorder");
    dfs(root, 0);
    puts("");
    
    puts("Inorder");
    dfs(root, 1);
    puts("");
    
    puts("Postorder");
    dfs(root, 2);
    puts("");
}



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

using namespace std;

int ante[5] = {0};
int k = 0;

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

    for(int i=0;i<5;i++)
    {
        cin >> ante[i];
    }
    cin >> k;

    if(ante[4] - ante[0] > k)
    {
        cout << ":(";
    }
    else
    {
        cout << "Yay!";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}
int main() {
    int till,i,same=0,c=0;
    scanf("%d",&till);
    int num[till],d_num[till];
    for (int i = 0; i < till; i++)
    {
        scanf("%d",&num[i]);    
        d_num[i]=num[i];
    }
    qsort(num, till, sizeof(int), cmpfunc);
    for (int i = 0; i < till; i++)
    {
        //printf("%d %d",num[i],d_num[i]);
        if(num[i]!=d_num[i])
        c++;
    }
        if(c==0||c==2){
        printf("YES\n");    
        }
        else{
        printf("NO\n");                
        }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++)
      a[i]=sc.nextInt();
    int wrong=0;
    for(int i=0;i<n;i++)
      if(a[i]!=(i+1))
        wrong++;
    if(wrong==0||wrong==2)
      System.out.print("YES");
    else
      System.out.print("NO");
  }
}

Measured memory_bytes: 21716
import java.io.*;
import java.util.Scanner;

public class Main{

	static long n,k;
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 k= sc.nextLong();

			 long x=n%k;
			 long min=x;

			 if(min>Math.abs(x-k)){
			 	min=Math.abs(x-k);
			 }
			 System.out.print(min);
			}
		}



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

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



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

int main() {
  vector<char> vec(3);
  for (int i = 0;i < 3;i++) {
    cin >> vec.at(i);
  }
  
  string s1{vec.at(0)};
  string s2{vec.at(1)};
  string s3{vec.at(2)};
  
  if (s1 == "A" && s2 == "A" && s3 == "A") {
    cout << "No" << endl;
  } else if (s1 == "B" && s2 == "B" && s3 == "B") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    ll cnt[N]{};
    // i < j
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            int i_j = j - i;
            int i_X_Y_j = abs(X - i) + 1 + abs(Y - j);
            cnt[min(i_j, i_X_Y_j)]++;
        }
    }
    for (int i = 1; i < N; i++) {
        cout << cnt[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main()
{
    int A[N],j,flag=1,n,a,count=0;
    scanf("%d",&n);
    for(j=0;j<n;j++){
        scanf("%d",&A[j]);
    }
    
    while(flag!=0){
        flag=0;
        for(j=n-1;j>=1;j--){
            if(A[j]<A[j-1]){
                a=A[j];
                A[j]=A[j-1];
                A[j-1]=a;
                flag=1;
                count++;
            }
        }
    }
    for(j=0;j<n-1;j++){
        printf("%d ",A[j]);
    }
     printf("%d\n",A[n-1]);
    printf("%d\n",count);
    return 0;
    
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef pair<D,int> pdi;
 
const D EPS = 1e-8;
 
inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}
 
inline D seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}
 
int main(){
  int w,n,m,x,y;
  while(scanf("%d%d",&w,&n)){
    if(w==0)return 0;
 
    vector< vector<L> > l(n);
    rep(i,n){
      scanf("%d",&m);
      vector<P> p(m);
      rep(j,m){
	scanf("%d%d",&x,&y);
	p[j] = P(x,y);
      }
      rep(j,m)l[i].push_back(L(p[j],p[(j+1)%m]));
    }
 
    int v = n+2;
    vector< vector<pdi> > g(v);
    g[v-2].pb(pdi(w,v-1));
    L ls = L(P(0,0),P(0,1e4)), lt = L(P(w,0),P(w,1e4));
    rep(i,n){
      D dis = w;
      for(L a : l[i])dis = min(dis, seg_p_dis(ls,a.fs));
      g[v-2].pb(pdi(dis, i));
      dis = w;
      for(L a : l[i])dis = min(dis, seg_p_dis(lt,a.fs));
      g[i].pb(pdi(dis,v-1));
      rep(j,i){
	dis = w;
	for(L a : l[i])for(L b : l[j]){
	  dis = min(dis, seg_p_dis(a,b.fs));
	  dis = min(dis, seg_p_dis(b,a.fs));
	}
	g[i].pb(pdi(dis,j)); g[j].pb(pdi(dis,i));
      }
    }

    vector<D> d(v,1e9);
    d[v-2] = 0;
    bool use[220];
    memset(use,0,sizeof(use));
 
    for(;;){
      int u = -1;
      rep(i,v){
	if(!use[i] && (u<0 || d[u] > d[i]+EPS) )u = i;
      }
      if(u<0 || u==v-1)break;
      use[u] = true;
       
      for(pdi nxt : g[u]){
	D ncost = d[u] + nxt.fs;
	if(!use[nxt.sc] && d[nxt.sc] > ncost +EPS)d[nxt.sc] = ncost;
      }
    }
    printf("%.9lf\n",d[v-1]);
  }
}

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

int main(){
    int a, b, total, avg;
    cin >> a >> b;
    total = a + b;
    avg = total / 2;
    if (total % 2 == 0){
        cout << avg  << endl;
    } else {
        cout << avg + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);

    int iquotient = a / b;
    int remainder = a % b;
    double fquotient = (double)a / b;

    printf("%d %d %.5f\n", iquotient, remainder, fquotient);
}

Measured memory_bytes: 1068
# coding: UTF-8
#@document_it
from collections import deque
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    s = deque(A)
    alice =0
    bob = 0
    for i in range(N):
        if i % 2 == 0:
            alice += s.pop()
        else:
            bob += s.pop()
    print(alice-bob)

if __name__ == '__main__':
    exe()

Measured memory_bytes: 3316
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: Chars,
    }
    let mut sum = 0usize;
    for &c in &n {
        sum += c as usize - '0' as usize;
    }
    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 3012
# input
N, M = map(int, input().split())

if N >= 2 and M >= 2:
    print((N - 2) * (M - 2))
if N == 1 and M == 1:
    print(1)
if N == 1 and M >= 2:
    print(M - 2)
if N >= 2 and M == 1:
    print(N - 2)


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

const int mod=1000000007;
int d[1001];
bool is_prime[1001];
int prime[1001];
int sieve(int n){
    int p=0;
    rep(i,n+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    FOR(i,2,n+1){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}
int main(){
    int n;
    cin>>n;
    ll ans=1;
    int p=sieve(n);
    FOR(i,1,n+1){
        rep(j,p){
            for(int k=prime[j];k<=i;k*=prime[j]){
                if(i%k==0)++d[j];
            }
        }
    }
    rep(i,p){
        ans=(ans*(d[i]+1))%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_d
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,W;
    cin>>n>>W;
    vector<ll> w(n);
    vector<ll> v(n);
    for(ll i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    for(ll j=1;j<=W;j++){
        for(ll i=1;i<=n;i++){
            if(w[i-1]<=j){
                dp[i][j] = max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            }
            else{
                dp[i][j] = dp[i-1][j];   
            }
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    // cout<<"------------------------"<<endl;
    cout<<dp[n][W]<<endl;    
    return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>
int main()
{
  int min=1000000,i;
  char a[10];
  scanf("%s",a);
  for(i=0; i<strlen(a)-2; i++){
    if(min>abs(100*(a[i]-'0')+10*(a[i+1]-'0')+(a[i+2]-'0')-753)){
      min=abs(100*(a[i]-'0')+10*(a[i+1]-'0')+(a[i+2]-'0')-753);
    }
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long k = sc.nextLong();
		long ans = n;
		long num = n % k;
		long num2 = 0;

		while(true) {
			num2 = Math.abs(num);
			ans = Math.min(ans, num2);
			if(num < 0) {
				break;
			}
			num = num -k;
		}
		
		System.out.println(ans);

	}
}


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

int main(){
 int n,k;
 cin >>n>>k;
 int h[n+1];
 vector<int>cost(n+1); 
 rep(i,n){
 cin >>h[i+1];
 }
  
 cost[2]= abs(h[2]-h[1]);
 for(int i=3;i<=n;i++){
   cost[i]=cost[i-1]+abs(h[i]-h[i-1]);
   for(int j=2;j<=k;j++){
     if(i>j){ 
   	 cost[i]=min(cost[i],cost[i-j]+abs(h[i]-h[i-j])); 	
     } 
   } 
 }
 cout<<cost[n]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

string s;
int dp[114514][2];
signed main() {
	cin >> s;
	dp[1][0] = 2; dp[1][1] = 1;
	REP(i, s.size()) {
		if (s[i] == '1') {
			dp[i + 1][0] = dp[i][0] * 2;
			dp[i + 1][1] = dp[i][1] * 3 + dp[i][0];
		}
		else {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] = dp[i][1] * 3;
		}
		dp[i + 1][0] %= mod; dp[i + 1][1] %= mod;
	}
	cout << (dp[s.size()][0] + dp[s.size()][1]) % mod << endl;
}

Measured memory_bytes: 2048
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb
 
N,K = map(int, input().split())
 
# 複数個の数値を、intの配列として取得
X = list(map(int, input().split()))
 
ans = 10**18
for i in range(N-K+1):
    if X[i]*X[i+K-1] >= 0:
        ans = min(ans,max(abs(X[i]),abs(X[i+K-1])))
    else:
        ans = min(ans, 2*abs(X[i])+abs(X[i+K-1]), abs(X[i])+2*abs(X[i+K-1]))
 
print(ans)

Measured memory_bytes: 23080
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
ll gcd(ll a, ll b){
    if(b==0) return a;
    else return gcd(b, a%b);
}

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


int main(void){
    ll n, m;
    cin>>n>>m;
    string s, t;
    cin>>s>>t;
    bool ok = true;
    rep(i, n){
        if(((ll)i*m)%n == 0) {
            ll j = ((ll)i*m)/n;
            if(s[(int)i] != t[(int)j]) {
                ok = false;
                break;
            }
        }
    }
    if(ok){
        cout<<lcm(n, m)<<endl;
    }
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>

using namespace std;

char s[1000001] = {0};
char sout[1000001] = {0};
char t[1000001] = {0};
char tout[1000001] = {0};


void normalize(char* str, char* strout){
  char d[300] = {0};
  char current = 'a';
  for(int i=0; str[i] != '\0'; i++){
    if(d[str[i]] == 0){
      d[str[i]] = current;
      current++;
    }
    strout[i] = d[str[i]];
  }
}

int main(){
  scanf("%s\n", s);
  scanf("%s\n", t);
  normalize(s, sout);
  normalize(t, tout);
  // printf("%s\n", s);
  // printf("%s\n", t);
  // printf("%s\n", sout);
  // printf("%s\n", tout);
  if(strcmp(sout, tout) == 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 896
n=int(input())
a=list(map(int,input().split()))
f=True
for x in range(n):
    if x+1==n:break
    if a[x+1]-a[x]==-1:a[x+1]+=1
    elif a[x+1]-a[x]<-1:
        f=False
        break
if f:print("Yes")
else:print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int s1 = H * W;
    int s2 = H * w;
    int s3 = W * h;
    int s4 = w * h;
    cout << s1 + s4 - s2 - s3 << endl;
}

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

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

const ll INF = 1LL << 60;
int N;
ll h[100001];
ll dp[100001];

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    
    for(int i = 0; i < 100001; ++i) dp[i] = INF;

    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }
    dp[1] = 0;
    
    for(int i = 2; i <= N; ++i){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 2) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    
    /*
    for (int i = 1; i <= N; i++) {
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    */
    cout << dp[N] << endl;
    

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int a[5],k;
    
    for(int i=0; i<5; i++)
        scanf("%d",&a[i]);
    scanf("%d",&k);
    
    if(a[4]-a[0]<=k)
        printf("Yay!");
    else
        printf(":(");
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int N, x = 0, max = 0;
  char ID;
  scanf("%d\n", &N); //N:試行回数
  for (int i = 0; i < N; i++){
      scanf("%c", & ID);
      if (ID == 'I'){
        x +=  1;//Increment
        if(x > max){max = x;}
      }else{x -= 1;}//Decrement
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++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; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};


ll dp[100100][3];

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    vector<ll> a(N);
    vector<ll> b(N);
    vector<ll> c(N);
    rep(i,N) cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    rep(i,N-1){
      dp[i+1][0] = max(dp[i][1] + a[i+1], dp[i][2] + a[i+1]);
      dp[i+1][1] = max(dp[i][0] + b[i+1], dp[i][2] + b[i+1]);
      dp[i+1][2] = max(dp[i][0] + c[i+1], dp[i][1] + c[i+1]);
    }
    ll ans = 0;
    rep(i,3) chmax(ans, dp[N-1][i]);
    print(ans);
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x[n];
    int y[n];
    for(int i=0;i<n;i++){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y,y+n);
    for(int i=0;i<n;i++){
        if(x[i]<=y[n/2-1])cout << y[n/2] << endl;
        else cout << y[n/2-1] << endl;
    }
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>


using namespace std;
using ll = long long;



int main()
{
	string N;
	cin >> N;
	for (int i = 0; i < 3; i++) {
		if (N[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

const int MAX_N = int(1e6) + 10;


struct fenwick{
  int lim;
  int *tree;
  fenwick(int _lim){
      lim=_lim;
      tree=new int[lim];
  }
  void init(){
    for(int i=0;i<lim;i++){
      tree[i]=0;
    }
  }
  void update(int x){
    while(x<lim){
      tree[x]+=1;
      x+=x&(-x);
    }
  }
  int query(int x){
    int ans=0;
    while(x>0){
      ans+=tree[x];
      x-=x&(-x);
    }
    return ans;
  }
  int _query(int k){
    int low=1;
    int high=500000;
    int ans=0;int x=k;
    while(low<=high){
      int mid=low+(high-low)/2;
      if(query(mid)>=x){
        ans=mid;
        high=mid-1;
      }else{
        low=mid+1;
      }
    }
    return ans;
  }
};

int main() {

  int a,b;
  cin>>a>>b;
  if(b==1)cout<<0<<endl;
  else{
    int av=1;
    int ans=0;
    while(av<b){
      av+=a-1;
      ans+=1;
    }
    cout<<ans<<endl;
  }
  return 0;
}
   


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
typedef pair<ll,ll> P;
vector<P> g[N];
int n,m,k,q;
int fes[N];
ll d[N],s[N],t[N],l[N],r[N];
P suf[N];
class UnionFind{
private:
    int p[N];
    int Par(int x){
	int a=x,t;
	while(a!=p[a])a=p[a];
	while(x!=a)t=p[x],p[x]=a,x=t;
	return x;
    }
    void Unite(int a,int b){
	a=Par(a),b=Par(b);
	p[a]=b;
    }
public:
    void Init(){
	lol(i,N)p[i]=i;
    }
    void Add(int x){
	for(auto to:g[x]){
	    int y=to.first;
	    if(d[y]>=d[x])Unite(x,to.first);
	}
    }
    bool Same(int a,int b){
	return (Par(a)==Par(b));
    }
};
void Dijkstra(){
    lol(i,n)d[i]=(ll)mod*(ll)mod;
    priority_queue<P,vector<P>,greater<P> >Q;
    lol(i,k)Q.push(make_pair(0,fes[i]));
    while(!Q.empty()){
	ll cost=Q.top().first;
	ll x=Q.top().second;
	Q.pop();
	if(d[x]<=cost)continue;
	d[x]=cost;
	for(auto to:g[x]){
	    ll y=to.first;
	    ll len=to.second;
	    Q.push(make_pair(cost+len,y));
	}
    }
}
int main(){
    cin>>n>>m>>k>>q;
    lol(i,m){
	ll a,b,c;cin>>a>>b>>c;a--,b--;
	g[a].push_back(make_pair(b,c));
	g[b].push_back(make_pair(a,c));
    }
    lol(i,k){cin>>fes[i];fes[i]--;}
    Dijkstra();
    lol(i,n)suf[i]=make_pair(d[i],i);
    sort(suf,suf+n,greater<P>());
    lol(i,q){
	cin>>s[i]>>t[i];s[i]--,t[i]--;
	l[i]=0,r[i]=mod;
    }
    #define BNScnt 40
    lol(u,BNScnt){
	UnionFind uf;uf.Init();
	vector<P> v;
	lol(i,q)v.push_back(make_pair((l[i]+r[i])/2,i));
	sort(v.begin(),v.end(),greater<P>());
	int last=0;
	lol(i,q){
	    ll mid=v[i].first,ind=v[i].second;
	    while(last<n){
		if(suf[last].first<mid)break;
		uf.Add(suf[last].second);
		last++;
	    }
	    if(uf.Same(s[ind],t[ind]))l[ind]=mid;
	    else r[ind]=mid;
	}
    }
    lol(i,q)cout<<l[i]<<endl;
    return 0;
}



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

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
//int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			//depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

#define int long long //change int main to int32_t main

const int N = 1e5 + 5;

int dp[105][N];

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

	fr(j, 1, n + 1)
	{
		int x, y; cin >> x >> y;
		fr0(i, fw + 1)
		{
			if (i - x >= 0)
				dp[j][i] = max(dp[j - 1][i], dp[j - 1][i - x] + y);
			else
				dp[j][i] = dp[j - 1][i];
		}
	}
	cout << dp[n][fw] << nl;

}





int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 81632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100000;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
#define fi first
#define se second
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
struct edge{ll from,to,cost;};
vector<edge> edges;
ll d[10000];
int main(){
    for(int i=0;i<10000;i++){
        d[i]=-inf;
    }
    int v,m;
    cin>>v>>m;
    for(int i=0;i<m;i++){
            ll a,b,c;
            cin>>a>>b>>c;
            a--;b--;
            edges.push_back(edge{a,b,c});
    }
    d[0]=0;
    for(int i=0;i<v;i++){
       for(int j=0;j<m;j++){
           edge e=edges.at(j);
           if(d[e.to]<d[e.from]+e.cost){
               d[e.to]=d[e.from]+e.cost;
           }
       }
    } 
ll ans=d[v-1];
for(int i=0;i<v;i++){
       for(int j=0;j<m;j++){
           edge e=edges.at(j);
           if(d[e.to]<d[e.from]+e.cost){
               d[e.to]=d[e.from]+e.cost;
           }
       }
    } 
    if(ans<d[v-1])cout<<"inf"<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 384