akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#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;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int ans[3003][3003];
pii pr[3003][3003];
char s[3003], t[3003];

inline string mx (string s, string t) {
   if (sz (s) > sz (t)) return s;
   return t;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> s + 1 >> t + 1;
   int n = strlen (s + 1);
   int m = strlen (t + 1);
   for (int i = 1; i <= n; i ++)
      for (int j = 1; j <= m; j ++) {
         ans[i][j] = max (ans[i - 1][j], ans[i][j - 1]);
         if (max (ans[i - 1][j], ans[i][j - 1]) == ans[i - 1][j]) pr[i][j] = {i - 1, j};
         else pr[i][j] = {i, j - 1};
         if (s[i] == t[j]) {
            if (ans[i][j] < ans[i - 1][j - 1] + 1) {
               ans[i][j] = ans[i - 1][j - 1] + 1;
               pr[i][j] = {i - 1, j - 1};            
            }
         }
      }
   int x = n, y = m;
   string S = "";
   while (x > 0 || y > 0) {
      int new_x = pr[x][y].F, new_y = pr[x][y].S;
      if (ans[x][y] != ans[new_x][new_y]) S += s[x];
      x = new_x, y = new_y;
   }
   reverse (all (S));
   cout << S;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
          

Measured memory_bytes: 105856
#include<cstdio>
#include<cstring>
#include<algorithm>
int main(){
    int h1,h2,m1,m2,k;
    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
    int ans=(h2-h1)*60-m1+m2-k;
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;
int main()
{
	int a, b, t, ans = 0;
	cin >> a >> b >> t;
	for (int i = a; i <= t; i += a) {
		ans += b;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int A, B, res = 0;
    cin >> A >> B;

    if(A < B) swap(A, B);
    res += A;
    A--;
    if(A < B) swap(A, B);
    res += A;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define size(s) s.size()
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int h,n;
ll weight[1111],value[1111];
ll dp[11111];
int main()
{
	cin>>h>>n;
    rep(i,n)
      cin>>weight[i]>>value[i];
    for(int i=1;i<=h;i++)
    	dp[i]=111111111;
    for(int i=1;i<=h;i++)
    {
        rep(j,n)
        {
          if(weight[j]>=i)
          {
          	  dp[i]=min(dp[i],value[j]);
		  }
		  else
		  {
		  	  dp[i]=min(dp[i],dp[i-weight[j]]+value[j]);
		  }
        }
    }
    cout<<dp[h]<<endl;
	return 0;
}


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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<string> a(N + 1, "?");
    string s;
    cout << "0\n";
    cin >> s;
    if (s == "Vacant") return 0;
    a[0] = s;
    a[N] = s;
    int i = 0, l = 0, r = N;
    while (true) {
        i = (l + r) / 2;
        cout << i << "\n";
        cin >> s;
        if (s == "Vacant") return 0;
        a[i] = s;
        if (s == a[l]) {
            if ((i - l) % 2 == 1) r = i;
            else l = i;
        } else {
            if ((i - l) % 2 == 1) l = i;
            else r = i;
        }
    }
}

Measured memory_bytes: 1620
import java.io.*;
import java.util.*;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final int MAX = 100000;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] a = new int[n];
		long sum = 0;
		for(int i=0;i<n;++i) {
			a[i] = sc.nextInt();
			sum+=a[i];
		}
		long ans = 0;
		for(int i=0;i<n;++i) {
			sum-=a[i];
			ans +=a[i]*sum;
		}
		out.print(ans);
	    out.close();
	}
	
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<stdbool.h>
bool same(double a, double b);

int main()
{
    long long int xp0, xp1, xp2, xp3, yp0, yp1, yp3, yp2, diffx0, diffy0, diffx1, diffy1, test;
    int res;
    double m1, m2;
    scanf("%lld", &test);
    while(test--)
    {
        scanf("%lld%lld%lld%lld%lld%lld%lld%lld", &xp0, &yp0, &xp1, &yp1, &xp2, &yp2, &xp3, &yp3);
        diffx0 = xp1 - xp0;
        diffy0 = yp1 - yp0;
        diffx1 = xp3 - xp2;
        diffy1 = yp3 - yp2;
        if(diffx0 == 0)
        {
            if(diffx1 == 0)
            {
                res = 2;
            }
            else if(diffy1 == 0)
            {
                res = 1;
            }
            else    res = 0;
        }
        else if(diffx1 == 0)
        {
            if(diffx0 == 0)
            {
                res = 2;
            }
            else if(diffy0 == 0)
            {
                res = 1;
            }
            else res = 0;
        }
        else
        {
            m1 = (double)diffy0/diffx0;
            m2 = (double)diffy1/diffx1;
            if(m1 == m2)    res = 2;
            else if(same(m1*m2, -1))  res = 1;
            else res = 0;
        }
        printf("%d\n", res);
    }
    return 0;
}
bool same(double a, double b)
{
    return fabs(a - b) < 0.00001;
}


Measured memory_bytes: 2752
n = input()
bars = map(int,raw_input().split(' '))
bars.sort()
h1_cand=0
h2_cand=0
h1=0
h2=0
for i in range(n):
  m = n-1-i
  if h1 > 0:
    if h2_cand == bars[m]:
      h2 = h2_cand
      break
    else:
      h2_cand = bars[m]
  else:
	if h1_cand == bars[m]:
    	  h1 = h1_cand
    	  h1_cand = 0
  	else:
    	  h1_cand = bars[m]
 
print h1*h2

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

int A, B;

int main(){
    cin >> A >> B;

    string ans = "Positive";
    if( A <= 0 && 0 <= B )          ans = "Zero";
    else if( A < 0 && B < 0 ) {
        if( (B - A + 1) % 2 == 0 )  ans = "Positive";
        else                        ans = "Negative";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	// #ifndef ONLINE_JUDGE
	// 	// for getting input from input.txt
	// 	freopen("input.txt", "r", stdin);
	// 	// for writing output to output.txt
	// 	freopen("output.txt", "w", stdout);
	// #endif
	int a,b;
	cin>>a>>b;
	if(a <=5 ) cout<<"0"<<"\n";
	else if(a <=12) cout<<b/2<<"\n";
	else cout<<b<<"\n";
	return 0;
	}	

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

using ll=long long;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
using data=pair<ll,ll>;

int main(){
  ll i,j=0,N,M,ans=0,a,b,x;
  cin>>N>>M;
  vector<data> v(N);
  priority_queue<ll> que;

  rep(i,N){
    cin>>a>>b;
    v[i]=data(a,b);
  }
  vsort(v);

  rep(i,M){
    while(j<N&&v[j].first<i+2)que.push(v[j++].second);

    if(!que.empty()){
      x=que.top();que.pop();
      ans+=x;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll n;
	cin >> n;
	set<ll> answer;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			ll num = n;
			while (num % i == 0) {
				num /= i;
			}
			if (num % i == 1) {
				answer.insert(i);
			}
			num = i;
			while (num % (n / i) == 0) {
				num /= (n / i);
			}
			if (num % (n / i) == 1) {
				answer.insert(n / i);
			}
		}
	}
	answer.insert(n);
	--n;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			answer.insert(i);
			answer.insert(n / i);
		}
	}
	cout << answer.size() - 1 << '\n';
 	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int N=26;
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int data[] =new int[N];
		double t=0;
	
		for(int i=0;i<data.length;i++) {
			data[i]=sc.nextInt();
			
			t += (double)1.0/data[i];
		}
		double ans =( double)1.0/t;
	System.out.println(ans);

		

	}

}

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

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

    int a;
    int minValue = 1000000;
    int maxValue = -1000000;
    long long sum = 0;

    for (int i = 0; i < n; i++) {
        cin >> a;

        minValue = (a < minValue) ? a : minValue;
        maxValue = (a > maxValue) ? a : maxValue;

        sum += a;
    }

    cout << minValue << " " << maxValue << " " << sum << endl;
    return 0;
}



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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
const ll M = 1000000007;
signed main() {
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> f(300000);
    f[0]=1;
    for(ll i=1;i<=f.size();i++)f[i]=i*f[i-1]%M;
    vector<ll> fn(300000);
    fn[0]=n%M;
    for(ll i=1;i<=fn.size();i++)fn[i]=(n-i)*fn[i-1]%M;
    auto Cn=[&](ll r){return fn[r-1]*inv(f[r],M)%M;};
    //cout<<pow(2,n,M)-1<<" "<<Cn(a)<<" "<<Cn(b)<<endl;
    cout<<((pow(2,n,M)-1-Cn(a)-Cn(b))%M+M)%M<<endl;
	return 0;
}


Measured memory_bytes: 4992
var out = function(x) {
  console.log(x);
  return x;
}

var compare = function(argument) {
  if( argument[0] < argument[1] && argument[1] < argument[2] )
  {
    return 'Yes';
  }
  else
  {
    return 'No';
  }

  return 'error!';
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
  var result = compare(input.split(' ').map(Number));

  out(result);
});

Measured memory_bytes: 7648
#include <iostream>
#include <algorithm>
#include <sstream>

using namespace std;

bool is_comprehensible(const string& str){
	istringstream iss(str);
	string word;
	while(iss >> word){
		if(word == "the" || word == "this" || word == "that"){
			return true;
		}
	}
	return false;
}

string shift_string(const string& str, char n){
	string result;
	for(auto& v: str){
		if('a' <= v && v <= 'z'){
			result += (v - 'a' + n) % 26 + 'a';
		}
		else{
			result += v;
		}
	}
	return result;
}

int main(){
	string str;
	while(getline(cin, str)){
		for(int i = 0; i < 26; ++i){
			auto shifted = shift_string(str, i);
			if(is_comprehensible(shifted)){
				cout << shifted << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3048
import collections
import copy

def dfs(i,basho,memo):
    global ans
    #print(i,basho,memo)
    if memo[basho]==1:
        return
    memo[basho]=1
    if i == n:
        if sum(memo)==n:
            ans += 1
        return
    tmp = collections.Counter(graph[basho])
    #print(tmp)
    for next_basho in tmp.keys():
        copy_memo = copy.copy(memo)
        dfs(i+1,next_basho,copy_memo)

n,m = map(int,input().split())
graph = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

memo = [0 for i in range(n+1)]
ans = 0
dfs(1,1,memo)
print(ans)

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1e9+5;
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  long long ans=0;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++){cin>>a[i];}
  for(int i=0;i<n;i++){cin>>b[i];}
  for(int i=0;i<n;i++){cin>>c[i];}
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  for(int i=0;i<n;i++){
    auto ita=upper_bound(a.begin(),a.end(),b[i]-1);
    auto itc=upper_bound(c.begin(),c.end(),b[i]);
    ans+=(ita-a.begin())*(c.end()-itc);
  }
  cout<<ans;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

s = set([])
ans = n
for _ in range(m):
    memo = [0] * (m + 1)
    flag = [0] * (n + 1)
    for j in range(m):
        for i in range(n):
            if flag[i] == 0 and a[i][j] not in s:
                memo[a[i][j]] += 1
                flag[i] = 1
    idx = 0
    mmax = 0
    for i, me in enumerate(memo):
        if me > mmax:
            idx = i
            mmax = me

    ans = min(ans, mmax)
    s.add(idx)

print(ans)





Measured memory_bytes: 43740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        long answer = 0;

        int count = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'W')
            {
                answer += i - count;
                count++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 13216
s=input()
n=len(s)
k=int(input())
l=[]
for i in range(n):
  for j in range(i,i+k+1):
    a=s[i:j+1]
    l.append(a)
l=set(l)
l=list(l)
l.sort()
print(l[k-1])

Measured memory_bytes: 5428
#include <bits/stdc++.h>
using namespace std;
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 long long INF = 1LL << 60;

int main(){
    int N; cin >> N;
    long long int h[100010]; for(int i=0; i<N; i++) cin >> h[i];

    long long int dp[100010]; for(int i=0; i<100010; i++) dp[i] = INF;

    dp[0] = 0;

    for(int i=0; i<N; i++){
        chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
        chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
    }

    cout << dp[N-1] << endl;
}

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

int main(void) {
    int K, A, B;

    cin >> K >> A >> B;

    int cnt = 1000 / K;
    bool result = false;
    for (int i = 0; i <= cnt; i++) {
        int a = K * i;
        if ((A <= a) && (a <= B)) {
            result = true;
            break;
        }
    }

    if (result == false) cout << "NG" << endl;
    if (result == true ) cout << "OK" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    char S;
    cin >> S;
    if (S == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 3624
* test
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  VARN PIC 9(03).
       01  VARM PIC 9(03).
       PROCEDURE DIVISION.
           ACCEPT indata
    *** indataを
           UNSTRING indata DELIMITED BY SPACE INTO VARN VARM.

         IF VARN = VARM THEN
                 DISPLAY "Yes"
         ELSE
                 DISPLAY "No"
         END-IF

       STOP RUN.


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

int main() {
  int N,count=0;
  string S;
  cin >> N >>S;
  for (int i=0;i<N-2; i++){
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      count++;
    }
  }
    cout << count << endl;
}


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

int main(){
    
    // 1. 入力情報.
    double R1, R2;
    scanf("%lf %lf", &R1, &R2);
    
    // 2. 出力.
    printf("%.10f\n", (R1 * R2) / (R1 + R2));
    return 0;
    
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int T; cin >> T;
    REP(i,T){
        ll N,M,A,B; cin >> N >> M >> A >> B;
        cout << floor_sum(N,M,A,B) << endl;
    }
    return 0;
}

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

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

    int n;
    cin >> n;
    int h[n+1], m = 0;
    rep(i, n){
        cin >> h[i];
        m = max(m, h[i]);
    }
    h[n] = 0;
    
    int ans = 0;
    
    for(int i=1; i<=m; i++){
        rep(j, n){
            if(h[j]>=i && h[j+1]<i){
                ans++;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

struct LowestCommonAncester{
    int n,h;
    vector<vector<int>> G,par;
    vector<int> dep;
    LowestCommonAncester(int n):n(n),G(n),dep(n){
        h=1;
        while((1<<h)<=n) ++h;
        par.assign(h,vector<int>(n,-1));
    }
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    void dfs(int v,int p,int d){
        par[0][v]=p;
        dep[v]=d;
        for (auto u:G[v]){
            if (u!=p) dfs(u,v,d+1);
        }
    }
    void build(int r=0){
        dfs(r,-1,0);
        rep(k,h-1){
            rep(v,n){
                if (par[k][v]>=0) par[k+1][v]=par[k][par[k][v]];
            }
        }
    }
    int lca(int u,int v){
        if (dep[u]>dep[v]) swap(u,v);
        rep(k,h){
            if ((dep[v]-dep[u])&1<<k) v=par[k][v];
        }
        if (u==v) return u;
        for (int k=h-1;k>=0;--k){
            if (par[k][u]!=par[k][v]) u=par[k][u],v=par[k][v];
        }
        return par[0][u];
    }
    int distance(int u,int v){
        return dep[u]+dep[v]-dep[lca(u,v)]*2;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,u,v; cin >> N >> u >> v;
    --u,--v;
    LowestCommonAncester LCA(N);
    rep(i,N-1){
        int a,b; cin >> a >> b;
        LCA.add_edge(--a,--b);
    }
    LCA.build();
    int l=LCA.distance(u,v);
    int ans=0;
    rep(i,N){
        int p=LCA.lca(u,i),d1=LCA.distance(u,p),d2=LCA.distance(v,p);
        if (d2<=d1){
            chmax(ans,l/2);
            continue;
        }
        chmax(ans,LCA.distance(v,i)-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 15352
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>s;
    rep(i,Size(s)){
        if(s[i]=='R')tmp++;
        else tmpp++;
    }
    if(tmp>tmpp)Cout("Yes");
    else Cout("No");
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<string>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<set>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	char s[105];
	scanf("%s", s);
	string a(s);
	scanf("%s", s);
	string b(s);
	int k, limit, n;
	for (int i = 0; i < a.length(); i++)
	{
		k = 1;
		n = 0;
		limit = 0;
		if (a[0] == b[i])
		{
			if (i + k < a.length())
			{
				for (;;)
				{
					if (a[k] != b[i + k])break;
					if ((i + k) == a.length() - 1)
					{
						limit = 1;
						k++;
						break;
					}
					k++;
				}
			}
			else limit = 1;
			if (k == a.length())
			{
				printf("Yes");
				return 0;
			}
			if (limit == 1)
			{
				limit = 0;
				for (;;)
				{
					
					if (a[k] != b[n])break;
					if (k == a.length() - 1)
					{
						limit = 1;
						break;
					}
					n++;
					k++;
				}
				if (limit == 1)
				{
					printf("Yes");
					return 0;
				}
				
			}
		}
	}
	printf("No");
	
}

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

int main(){
    string a,b;
    cin >> a >> b;
    a += b;
    int n = stoi(a);
    if((int)sqrt(n)*(int)sqrt(n) == n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
  char suit;
  int num;
  int idx;
} Card;

void BubbleSort(Card C[], int N);
void SelectionSort(Card C[], int N);

int main() {
  int N;
  Card C1[36], C2[36];
  int i;

  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf(" %c%d", &C1[i].suit, &C1[i].num);
    C1[i].idx = i;
    C2[i] = C1[i];
  }

  BubbleSort(C1, N);
  SelectionSort(C2, N);

  return 0;
}

void BubbleSort(Card C[], int N) {
  Card tmp;
  int stable;
  int i, j;
  for(i = 0; i < N-1; ++i) {
    for(j = N-1; j > i; --j) {
      if(C[j].num < C[j-1].num) {
        tmp = C[j];
        C[j] = C[j-1];
        C[j-1] = tmp;
      }
    }
  }
  stable = 1;
  for(i = 0; i < N; ++i) {
    printf("%c%d%c", C[i].suit, C[i].num, " \n"[i==N-1]);
    if(i > 0 && C[i].num == C[i-1].num && C[i].idx < C[i-1].idx) stable = 0;
  }
  puts((stable ? "Stable" : "Not stable"));
}

void SelectionSort(Card C[], int N) {
    Card tmp;
    int minj;
    int stable;
    int i, j;
    for(i = 0; i < N; ++i) {
      minj = i;
      for(j = i; j < N; ++j) {
        if(C[j].num < C[minj].num) minj = j;
      }
      tmp = C[i];
      C[i] = C[minj];
      C[minj] = tmp;
    }
    stable = 1;
    for(i = 0; i < N; ++i) {
      printf("%c%d%c", C[i].suit, C[i].num, " \n"[i==N-1]);
      if(i > 0 && C[i].num == C[i-1].num && C[i].idx < C[i-1].idx) stable = 0;
    }
    puts((stable ? "Stable" : "Not stable"));
}
    


Measured memory_bytes: 2700
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    char s[10];
    ll c;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}
int charcmp( const void *p, const void *q ) {
    return strcmp( ((frequent*)p)->s , ((frequent*)q)->s );}

int main(void){
    ll n,i,m=0;
    scanf("%lld",&n);
    frequent name[n];
    for(i=0;i<n;i++){
        scanf("%s",name[i].s);
        name[i].c=0;
    }
    // printf("\n");
    qsort(name,n,sizeof(frequent),charcmp);
    for(i=0;i<n-1;i++){
        if(strcmp(name[i].s,name[i+1].s) == 0){
            name[i+1].c=name[i].c+1;
            m=max2(name[i+1].c,m);
        }else{   
        }
    }
    // printf("/%lld\n",m);
    for(i=0;i<n;i++){
        // printf("%lld ",name[i].c);
        if(name[i].c==m){
            printf("%s\n",name[i].s);
        }
    }
    return 0;
}


Measured memory_bytes: 9596
h,w=map(int,input().split())
a=[]
for _ in range(h):
    a.append(list(input()))

dp=[[0]*w for _ in range(h)]
dp[0][0]=1
for i in range(h):
    for j in range(w):
        if i+1<h and a[i+1][j]=='.':
            dp[i+1][j]+=dp[i][j]%(10**9+7)
        if j+1<w and a[i][j+1]=='.':
            dp[i][j+1]+=dp[i][j]%(10**9+7)
print(dp[h-1][w-1]%(10**9+7))

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	string s;
	int q;
	cin >> s >> q;

	deque<char> ans;
	for (int i = 0; i < s.length(); ++i)
		ans.push_back(s[i]);

	bool rev = false;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			rev = !rev;
		} else {
			int f;
			char c;
			cin >> f >> c;
			if (rev)
				f = 3 - f;

			if (f == 1)
				ans.push_front(c);
			else
				ans.push_back(c);
		}
	}
	if (!rev) {
		while (!ans.empty()) {
			cout << ans.front();
			ans.pop_front();
		}
	} else {
		while (!ans.empty()) {
			cout << ans.back();
			ans.pop_back();
		}
	}
	cout << '\n';
}


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

int main(){
    int n;
    cin>>n;
    int m=sqrt(n-1);
    int ans=0;
    for(int i=1;i<=m;i++){
        int j=i;
        while(i*j<n){
            ans++;
            j++;
        }
    }
    ans*=2;
    ans-=m;
    cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, a[111], ans = 1e9;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=100;i++){
		int fl = 0;
		for(int j=1;j<=n;j++) fl += (a[j] - i) * (a[j] - i);
		ans = min(ans, fl);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

T, *L = map(int, open(0).read().split())

for a, b, c, d in zip(*[iter(L)] * 4):

    if a < b or d < b:
        flag = False
    elif b < c:
        flag = True
    else:
        g = gcd(b, d)
        flag = (b + a % g - g) <= c

    if flag:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3188
#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 rep11(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 pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

double a,b;

signed main() {
    cin >> a >> b;
    rep(i,10000000) {
        if ((int)(i*0.08) == a && (int)(i*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

// a と b の最大公約数を返す関数
ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

const int MAX = 1000010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long POWN(int x, ll y){
  ll tmp = 1;
  rep(i,y){
    tmp *= x;
    tmp %= MOD;
  }
  return tmp;
}

int main() {
  ll N;
  cin >> N;
  
  COMinit();
  
  ll tmp1=POWN(10,N);
  ll tmp2=POWN(9,N);
  ll tmp3=POWN(8,N);
  ll tmp4=(tmp1+tmp3)%MOD-2*tmp2;
  ll ans=tmp4;
  while(ans<0){
    ans+=MOD;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 27048
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
const ll mod=1e+9+7;
ll N;
ll dp[1000001];
ll ans=0;

int main()
{
	cin>>N;
	dp[0]=1;
	ll sum=1;
	rep1(i,N){
		dp[i]=sum;
		if(i>=2) dp[i]=(dp[i]-dp[i-2])%mod;
		dp[i]=(dp[i]%mod+mod)%mod;
		sum=(sum+dp[i])%mod;
		if(i-N-1>=0) sum=(sum-dp[i-N-1])%mod;
		if(sum<0) sum=sum+mod;
	}
	rep(i,N-1){
		ans=(ans+(dp[i]*(((N-1)*(N-1))%mod))%mod)%mod;
		ans=(ans+(dp[i]*(i+1)%mod))%mod;
	}
	ans=(ans+(dp[N-1]*(N-1))%mod)%mod;
	ans=(ans+dp[N])%mod;
	if(ans<0) ans+=mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int n,m,l,k,a,h;
/*
  n:街の数
  m:再冷凍を行うまでの制限時間
  l:冷凍施設のある街の数
  k:街と街を直接結ぶ道路の数
  a:本国の首都を表す番号
  h:お姫様が搬送された病院のある街の番号
 */

bool reitou[111];
int miti[111][111];
int vis[111];

struct item{
  int now,cost;
    
};

int main(){

  while(cin>>n>>m>>l>>k>>a>>h,n+m+l+k+a+h){
    memset(miti,0,sizeof(miti));
    memset(reitou,0,sizeof(reitou));
    int t;
    for(int i=0;i<l;i++){
      cin>>t;
      reitou[t]=true;
    }
    reitou[a]=true;
    reitou[h]=true;
    int x,y;
    for(int i=0;i<111;i++){
      for(int j=0;j<111;j++){
	miti[i][j]=1e9;
      }
    }
    for(int i=0;i<k;i++){
      cin>>x>>y>>t;
      miti[x][y]=t;
      miti[y][x]=t;
    }

    for(int k=0;k<111;k++){
      for(int i=0;i<111;i++){
	for(int j=0;j<111;j++){
	  if(miti[i][j] > miti[i][k]+miti[k][j]) miti[i][j]=miti[i][k]+miti[k][j];
	}
      }
    }
    for(int i=0;i<111;i++){
      for(int j=0;j<111;j++){
	if(miti[i][j]>m) miti[i][j]=1e9;
	if(reitou[i]==false || reitou[j]==false) miti[i][j]=1e9;
	
      }
    }
    for(int k=0;k<111;k++){
      for(int i=0;i<111;i++){
	for(int j=0;j<111;j++){
	  if(miti[i][j] > miti[i][k]+miti[k][j]) miti[i][j]=miti[i][k]+miti[k][j];
	}
      }
    }
    if(miti[a][h]==1e9) cout<<"Help!"<<endl;
    else cout<<miti[a][h]+max(0,miti[a][h]-m)<<endl;
    
  }
  return 0;
}



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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    rep(i, N) { cin >> P[i]; }
    sort(all(P));

    int ans = 0;
    rep(i, K) { ans += P[i]; }

    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll li, ri;
    ll xmin = 1;
    ll xmax = N;
    for(int i=0;i<M;i++){
        cin >> li >> ri;
        xmin = max(xmin, li);
        xmax = min(xmax, ri);
    }
    if(xmin <= xmax) cout<<(xmax-xmin+1)<<endl;
    else cout<<0<<endl;

    return 0;
}

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

using namespace std;

int main(){
    int k;

    int a[5];


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


    bool result = true;
    for(int  i=0; i<4; i++){
        for(int j=i+1; j<5; j++){
            if( (a[j]-a[i]) > k ) result = false;
        }
    }

    if( result == true ) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N , M;
    cin >> N >> M;
    vector<int> A(N+1, 0);
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        A[a]++;
        A[b]++;
    }

    for (int i = 1; i < N+1; i++) {
        if(A[i] % 2 == 1){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n"); return 0;
}

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

int main() {
  string str;
  cin >> str;
  int ans = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '2') {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
h, w, k = map(int,input().split())
c = []
for i in range(h):
    i = list(input())
    c.append(i)

cnt = 0

for rows in range(2 ** h):
    for cols in range(2 ** w):
        black = 0
        for i in range(h):
            if (rows >> i) & 1:
                continue
            for j in range(w):
                if (cols >> j) & 1:
                    continue
                if c[i][j] == '#':
                    black += 1
        if black == k:
            cnt += 1

print(cnt)

Measured memory_bytes: 9128
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

def divisor(a):
    res = []
    for i in range(1, int(a**0.5)+1):
        if a % i == 0:
            res.append(i)
            res.append(a//i)
    return res
    
div = divisor(M)
div.sort(reverse=True)

for d in div:
    if d * N <= M:
        print(d)
        exit()

Measured memory_bytes: 63880
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll A,P;
  cin >> A >>P;
  print(int(A*3+P)/2);
  

 return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
const int INF = 101010;

string LCS(const string &x, const string &y){
    int X = x.size(), Y = y.size();

    vector<vector<int>> dp(X+1, vector<int>(Y+1,-INF));
    vector<vector<pi>> par(X+1, vector<pi>(Y+1));

    dp[0][0] = 0;
    rep(i,X+1)rep(j,Y+1){
        if(i<X && j<Y && x[i]==y[j]){
            if(dp[i+1][j+1] < dp[i][j]+1){
                dp[i+1][j+1] = dp[i][j]+1;
                par[i+1][j+1] = {-1,-1};
            }
        }
        if(i<X){
            if(dp[i+1][j] < dp[i][j]){
                dp[i+1][j] = dp[i][j];
                par[i+1][j] = {-1,0};
            }
        }
        if(j<Y){
            if(dp[i][j+1] < dp[i][j]){
                dp[i][j+1] = dp[i][j];
                par[i][j+1] = {0,-1};
            }
        }
    }

    string ret = "";
    int px = X, py = Y;
    while(px!=0 || py!=0){
        pi p = par[px][py];
        if(p == pi(-1,-1)) ret += x[px-1];
        px += p.fi;
        py += p.se;
    }
    reverse(all(ret));
    return ret;
}

int main(){
    string s;
    while(cin >>s,(s!="#END")){
        int n = s.size();

        string ans = "";
        for(int i=1; i<n; ++i){
            string F = s.substr(0,i), R = s.substr(i);
            string t = LCS(F,R);
            if(t.size() > ans.size()) ans = t;
        }

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



Measured memory_bytes: 3328
import java.util.Scanner;

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

    int n = sc.nextInt();
      for(int i = 1; i <= n;i++) {

        if(i%3 == 0) {
          System.out.print(" " + i);

        }else{

          int x = i;

          while(x >= 1) {

            if(x%10 == 3) {
              System.out.print(" " + i);
              break;
            }

             x /= 10;

          }

        }

      }

    System.out.println();

    } 
}


Measured memory_bytes: 28576
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

ll n,m,k,mod=998244353;
vecll perm;

ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2==0){
        ll d=modpow(a,b/2);
        return d*d%mod;
    }
    return modpow(a,b-1)*a%mod;
}

void make_perm(ll n){
    perm.resize(n);
    perm[0]=1;
    rep(i,n-1)perm[i+1]=perm[i]*(i+1)%mod;
}

ll divide(ll a,ll b){
    return a*modpow(b,mod-2)%mod;
}

ll comb(ll a,ll b){
    return divide(divide(perm[a],perm[b]),perm[a-b]);
}

int main(){
    n=in();
    m=in();
    k=in();
    ll ans=0;
    make_perm(n+3);
    rep2(i,0,k)ans=(ans+comb(n-1,i)*modpow(m-1,n-i-1))%mod;
    cout<<ans*m%mod<<endl;
}



Measured memory_bytes: 4872
N=int(input())
list_n=[]
for i in range(100001):
    list_n.append(False)
for i in range(N):
    l,r = map(int,input().split())
    for j in range(l-1,r):
        list_n[j]=True
        
ans=0
for i in range(100000):
    if(list_n[i]):
        ans+=1
        
print(ans)

Measured memory_bytes: 3888
s=input()
while True:
    temp = s[:5]
    s = s[5:]
    if temp == 'erase':
        if s[0:1] == 'r':
            s = s[1:]
            continue
        else:
            continue
    elif temp == 'dream':
        if s[:5] == 'erase':
            continue
        elif s[:2] == 'er':
            s = s[2:]
            continue
    elif temp == '':
        print('YES')
        break
    else:
        print('NO')
        break

Measured memory_bytes: 3188