akhauriyash/Code-Regression huggingface dataset:
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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



const int N = 100005;
int n;
ll arr[N], diff[N], A, B, sparse[20][N], DP[N], suffix_DP[N];


ll rmq(int l, int r){
    int k = log2(r-l+1);
    return min(sparse[k][l], sparse[k][r-(1<<k)+1]);
}


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n>>A>>B;
    if(A < B)   swap(A, B);
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        if(i == 1)  diff[i] = (ll)1e18+1;
        else    diff[i] = arr[i]-arr[i-1];
        sparse[0][i] = diff[i];
    }

    for(int j=1;(1<<j)<=n;j++)
        for(int i=1;i+(1<<j)-1<=n;i++)
            sparse[j][i] = min(sparse[j-1][i], sparse[j-1][i+(1<<(j-1))]);

    DP[n] = suffix_DP[n] = 1;
    for(int i=n-1;i>=1;i--){

        int lo = lower_bound(arr+i, arr+n+1, arr[i]+A) - arr;
        DP[i] = 1;
        if(i+2 <= n && rmq(i+2, n) < B)
            DP[i] = 0;
        int temp = lo;

// cout<<"at i = "<<i<<endl;
// cout<<"got lo = "<<lo<<" and originally "<<DP[i]<<endl;
        
        if(lo == n+1){
            suffix_DP[i] = (suffix_DP[i+1] + DP[i]) % MOD;
            continue;
        }

        int right = -1, hi = n;
        while(lo <= hi){
            
            int mid = (lo+hi)/2;
            bool ok = true;
            if(i+2 < mid && rmq(i+2, mid-1) < B)
                ok = false;

            if(mid-1 > i && mid+1 <= n && arr[mid+1]-arr[mid-1] < B)
                ok = false;

            if(ok){
                right = max(right, mid);
                lo = mid+1;
            }
            else{
                hi = mid-1;
            }
        }


// cout<<"right = "<<right<<endl;

        if(right != -1){
            DP[i] += suffix_DP[temp] - suffix_DP[right+1];
// cout<<"added "<<suffix_DP[temp] - suffix_DP[right+1]<<" to "<<DP[i]<<endl;
            DP[i] %= MOD;
            DP[i] += MOD;
            DP[i] %= MOD;
        }
        suffix_DP[i] = (suffix_DP[i+1] + DP[i]) % MOD;
    }

// cout<<"DP: ";for(int i=1;i<=n;i++)  cout<<DP[i]<<" ";cout<<endl;
// cout<<"suffix_DP: ";for(int i=1;i<=n;i++)  cout<<suffix_DP[i]<<" ";cout<<endl;

    ll ans = DP[1];
    if(rmq(1, n) >= B)
        ans = (ans + 1) % MOD;
    arr[n+1] = (ll)2e18;
    for(int i=2;i<=n;i++){

        if(i-1 >= 2 && rmq(2, i-1) < B)
            break;
        if(arr[i+1]-arr[i-1] >= B)
            ans = (ans + DP[i]) % MOD;
    }

    cout<<ans;
    return 0;
}




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

int n;
int a[110];

int main()
{
    cin>>n;

    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    int max_diff = 0;
    
    for (int i = 0; i < n-1; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            max_diff = max(max_diff, abs(a[i] - a[j]));
        }
            
    }
            
    cout << max_diff << endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    int n; cin>>n;
    int l; cin>>l;
string s[n];
rep(i,n){
    cin>>s[i];
}
sort(s,s+n);
rep(i,n){
    cout<<s[i];
}
return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

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

		int n2 = (int) Math.sqrt(n);
		for (int a = n2; a > 0; a--) {
			if (n % a == 0) {
				System.out.println(a - 1 + n/a - 1);
				return;
			}
		}
	}
}


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

int main(){
	int N;
	cin>>N;
	int max;
	int L[N];
	int l;
	int sum = 0;
	for(int i=0;i<N;i++){
		cin>>l;
		L[i]=l;
		sum += l;
		if(i==0){
			max = l;
			continue;
		}
		if(l>max){	
			max=l;
		}
	}

	int remnant = sum - max;
	if(remnant<=max){
		cout<<"No";
	}	else{
		cout<<"Yes";
	}
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
K = {i: 0 for i in range(1, M+1)}

for i in range(N):
    row = list(map(int, input().split()))
    for j in range(1, row[0]+1):
        K[row[j]] += 1

print(list(K.values()).count(N))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
vector<string>in;
int n,m,co;
int dx[]={0,0,1,-1,1,-1,-1,1};
int dy[]={1,-1,0,0,1,-1,1,-1};
void f(int a,int b,char c,char d){
	in[a][b]=d;
	rep(i,8){
		int nx=a+dx[i];
		int ny=b+dy[i];
		if(nx<0||ny<0||nx>=n||ny>=m)continue;
		if(in[nx][ny]==c)f(nx,ny,c,d);
	}
}
int main(){
	int w=0;
	while(cin>>n,n){
		in=vector<string>(n);
		getline(cin,in[0]);
		rep(i,n){
			getline(cin,in[i]);
		}
		rep(i,n)m=max(m,co=(in[i].size()));
		rep(i,n)while(in[i].size()!=m)in[i]+=" ";
		map<int,int>ma;
		rep(i,n)rep(j,m)if(in[i][j]=='*'){
			co=0;
			f(i,j,'*','!');
//			rep(q,n)cout<<in[q]<<endl;
			rep(q,n){
				int r=1,l=0;
				rep(k,m)if(in[q][k]=='!'){
					r=k;break;
				}
				for(int k=m-1;k>=0;k--)if(in[q][k]=='!'){
					l=k;break;
				}
				co+=l-r+1;
			}
			ma[co]++;
			f(i,j,'!',' ');
		}
		if(w)cout<<"----------"<<endl;
		for(map<int,int>::iterator it=ma.begin();it!=ma.end();it++){
			cout<<(it->first)<<" "<<(it->second)<<endl;
		}
		w++;
	}
}

Measured memory_bytes: 1272
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N+1];
		for(int i = 1; i < N+1; i++) {
			a[i] = sc.nextInt();
		}

		int nextPosition = a[1];
		int count = 0;
		while(true) {
			count++;
			if(count == N || nextPosition == 2) {
				break;
			}
			nextPosition = a[nextPosition];
		}
		if(count == N) {
			System.out.println("-1");
		} else {
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 50812
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll int
#define int long long
#define ld long double
#define ff first
#define ss string 
#define se second
#define endl "\n"
#define alt(v) v.begin(),v.end()
#define ralt(v) v.rbegin(),v.rend()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(int i=(a);i<(b);i++)
#define fba(i,a,b) for(int i=(b);i>=(a);i--)
int mod=1000000007;
// int mod=998244353;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
int dx1[]={-2,-2,-2,-2,-2,2,2,2,2,2,-1,-1,-1,-1,1,1,1,1,0,0};
int dy1[]={0,-1,-2,1,2,0,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-2,2};
 
bool test  = 0;
const int N = 1e3+5;
const int inf = 1e9;
int h,w,m;
void solve()
{
    
    cin>>h>>w>>m;
    map<int,int>row,col;
    vector<pair<int,int>>v;
    for(int i = 1,x,y;i<=m;++i)
    {
        cin >>x>>y;
        x--;
        y--;
        row[x]++;
        col[y]++;
        v.pb(mp(x,y));
    }
    int mxrow = 0;
    set<int>r,c;
    for(auto it : row)
        mxrow = max(mxrow,it.se);
    for(auto it : row)
    {
        if(it.se == mxrow)
            r.insert(it.ff);
    }
    int mxcol = 0;
    for(auto it :col)
        mxcol = max(mxcol,it.se);
 
    int ans = mxrow + mxcol;
    
    for(auto it : col)
    {
        if(it.se == mxcol)
            c.insert(it.ff);
    }
 
    int cnt = 0;
    for(auto it :v)
    {
        int x = it.ff;
        int y = it.se;
        if(r.find(x)!=r.end() and c.find(y)!=c.end())
            cnt++;
    }
    int tot = (int)r.size()*(int)c.size();
 
    bool ok = false;
    if(cnt < tot)
        ok = true;
    if(!ok)
        ans--;
    cout<<ans;
 
    
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 73456
n = int(input())
H = list(map(int, input().split()))
cost = [None]*n
h1 = [None]*(n-1)
h2 = [None]*(n-2) 
one_ago = H[1]
two_ago = H[0]
h1[0] = abs(two_ago-one_ago)
for i in range(2, n):
    new = H[i]
    h1[i-1] = abs(one_ago-new)
    h2[i-2] = abs(two_ago-new)
    two_ago, one_ago = one_ago, new
cost[0], cost[1] = 0, h1[0]
for i in range(2, n):
    cost[i] = min(cost[i-2]+h2[i-2], cost[i-1]+h1[i-1])
print(cost[n-1])

Measured memory_bytes: 18884
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  rep(i,365){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		TreeSet<Integer> set = new TreeSet<>();
		int sCount = 0;
		boolean first = true;
		for (int i = 0; i < k; i++) {
			set.add(arr[i]);
			if (i != k - 1 && arr[i] > arr[i + 1]) {
				first = false;
			}
		}
		if (first) {
			sCount++;
		}
		int count = 1;
		for (int i = k; i < n; i++) {
			if (set.first() == arr[i - k] && set.last() < arr[i]) {
				
			} else {
				boolean flag = true;
				for (int j = i - k + 1; j < i; j++) {
					if (arr[j] > arr[j + 1]) {
						flag = false;
						break;
					}
				}
				if (flag) {
					sCount++;
				}
				count++;
			}
			set.remove(arr[i - k]);
			set.add(arr[i]);
		}
		if (sCount > 1) {
			count = count - sCount + 1;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 90620
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	char tavolo[h][w];
	vector<int> damenaH;
	vector<int> damenaW;
	for( int i = 0; i < h; ++i ){
		bool flag = true;
		for( int j = 0; j < w; ++j ){
			char temp;
			cin >> temp;
			if( temp == '#' ) flag = false;
			tavolo[i][j] = temp;
		}
		if( flag ) damenaH.push_back(i);
	}
	for( int i = 0; i < w; ++i ){
		bool flag = true;
		for( int j = 0; j < h; ++j ){
			if( tavolo[j][i] == '#' ) flag = false;
		}
		if( flag ) damenaW.push_back(i);
	}
	for( int i = 0; i < h; ++i ){
		if( find( damenaH.begin(), damenaH.end(), i ) != damenaH.end() ) continue;
		for( int j = 0; j < w; ++j ){
			if( find( damenaW.begin(), damenaW.end(), j ) != damenaW.end() ) continue;
			cout << tavolo[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//解説既読....
int main() {
int n;
cin>>n;
map<ll,int> M;
ll ans=0;
rep(i,n)
{int a;cin>>a;
 ans+=M[i-a];
 M[i+a]++;
}
cout<<ans<<endl;
}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/


Measured memory_bytes: 26248
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();

    }
 
    
    public void input(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int min = 10000000;
        for(int i = 0; i < n; i++){
            int m = sc.nextInt();
            x -= m;
            if(min > m){
                min = m;
            }
        }
        int ans = n + (x/min);
        sc.close();
        System.out.println(ans);
    }

}

Measured memory_bytes: 23636
i = input()
N, M, X = i.split()
A = input()
array = A.split()
ind = 0
for n in array:
    array[ind] = int(n)
    ind = ind+1

X = int(X)
bef = [cost < X for cost in array]
aft = [cost > X for cost in array]

be = sum(bef)
af = sum(aft)

if be <= af:
    print(be)
else:
    print(af)


Measured memory_bytes: 3060
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('hex', 0, bytesRead).split('0a'); // hexでreadしたら早い？
main();
 
function main(){
  // 26と互いに素の値
  var multiply = new Int8Array([1,3,5,7,9,11,15,17,19,21,23,25]);
  var alphabets = new Int8Array(26);
  var convertTable = new Int8Array(123);
  for(var init = 123; init--;)
    convertTable[init] = init;

FIRST:for(var i = 1, leni = input.length - 1; i < leni; i++){
    var inp = input[i];
    var c = inp.split('20');
  
    for(var j = 0, lenj = multiply.length; j < lenj; j++){
      var alpha = multiply[j];
      for(var beta = 26; beta--;){
        for(var conv = 26; conv--;){ // a-zの変換表作成
          alphabets[conv] = (conv * alpha + beta) % 26 + 97;
        }
        
        var thatIs = alphabets[19].toString(16) + alphabets[7].toString(16) + alphabets[0].toString(16) + alphabets[19].toString(16);
        var thisIs = alphabets[19].toString(16) + alphabets[7].toString(16) + alphabets[8].toString(16) + alphabets[18].toString(16);

        if(new RegExp("(" + thatIs + "|" + thisIs + ")").test(inp)){
          for(var conv = 26; conv--;){
            var fromCode = alphabets[conv];
            convertTable[fromCode] = conv + 97; // key-valueの入れ替え
          }
          
          var result = "";
          for(var k = 0; k < inp.length; k+=2){
            result += String.fromCharCode(convertTable[parseInt(inp[k] + inp[k+1], 16)]);
          }
          console.log(result);
          continue FIRST;
        }
        
      }
    }
  
  }
}

Measured memory_bytes: 10540
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans;
    //----------------------------------------------------------------------
    #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock()/CLOCKS_PER_SEC << "s.\n";
    #endif
}
/*

*/


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    vector<int> A(N);
    for_(i,0,N) cin >> A[i];

    for_(i,K,N) {
        int a = A[i - K];
        int b = A[i];
        puts(a < b ? "Yes" : "No");
    }
}

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

using namespace std;
#define ll long long

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

    string str;
    cin>>str;

    int a = str.size();
    for(int i=0;i<min(n,a);i++)
        cout<<str[i];
        
    if(str.size()>n)
    {
        cout<<"..."<<endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0) cout << 0.5 << endl;
    else cout << double(double(n / 2 + 1) / n)<< endl;

    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
int i,a;
long long n,min=1000000,max=-1000000,sum=0;
scanf("%d",&n);
for (i=0;i<n;i++){
    scanf("%d",&a);
    if(a<min)
    min=a;
    if(a>max)
    max=a;
    sum=sum+a;
    }

printf("%lld %lld %lld\n",min,max,sum);

return 0;
}

Measured memory_bytes: 1796
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = 1e9+7;

const int NODE_SIZE = 100010;

struct node{
    int p,num;
}a[100007];
int find(int x)
{
    if(a[x].p==x&&a[x].num==0){
        return x;
    }
    else
    {
        int t=find(a[x].p);
        a[x].num=a[a[x].p].num+a[x].num;
        a[x].p=t;
        return t;
    }
}
int main()
{
    int n,m,i;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        a[i].p=i;a[i].num=0;
    }

    for(i=1;i<=m;i++)
    {
        int l,r,x;
        cin>>l>>r>>x;
        int pl=find(l),pr=find(r);
        if(pl!=pr)
        {
            if(pl>pr)
            {
                a[pl].p=pr;
                a[pl].num=-(a[l].num-a[r].num+x);
            }
            else
            {
                a[pr].p=pl;
                a[pr].num=a[l].num-a[r].num+x;
            }
        }
        else{
            if(a[r].num-a[l].num!=x)
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  rep(i,N) cin>>h[i];
  sort(h.begin(),h.end());
  int ans=pow(10,9);
  rep(i,N-K+1) {
    ans=min(ans,h[i+K-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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


    ll ans;

    if(n > k) {
         ll fac = n / k; 
         n = n - fac * k;  
         ll tmp = k - n;
        ans = min(tmp,n);
        cout << ans << endl;
        return 0;
    }

    if(n <= k) {
        ll tmp = k - n;
        ans = min(tmp,n);
        cout << ans << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,i,j;

int main(){
  while(1){
    cin>>n>>i>>j;
    if(n==0)break;
    i--; j--;
    string res="";
    while(n>0){
      if(i%2==j%2) res+="L";
      else res+="R";
      if(i<(1LL<<(n-1)))i=(1LL<<(n-1))-1LL-i;
      else i-=(1LL<<(n-1));
      j/=2;
      n--;
    }
    reverse(all(res));
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 3048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int a = ia[0];
		int b = ia[1];
		int c = ia[2];
		int x = ia[3];
		int y = ia[4];
		int c2 = c * 2;
		int m = min(x, y);
		int ans = 0;
		if (c2 < a + b) {
			ans += c2 * m;
			x -= m;
			y -= m;
		}
		if (x > 0) {
			if (a > c2) {
				ans += c2 * x;
			} else {
				ans += a * x;
			}
		}
		if (y > 0) {
			if (b > c2) {
				ans += c2 * y;
			} else {
				ans += b * y;
			}
		}
		pln(ans);
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 22100
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    max_num = 10**5
    n = int(input())
    a_list = list(map(int, input().split()))
    q = int(input())
    
    query = [map(int, input().split()) for _ in range(q)]
    num = [0 for _ in range(max_num+1)]
    for i in a_list:
        num[i] += 1

    ans = sum(a_list)

    for b,c in query:
        n = num[b]
        num[b] = 0
        num[c] += n
        ans += (c-b)*n
        print(ans)

    
if __name__ == "__main__":
    main()

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

a = sum(inpm())
if(a >= 22):
    print('bust')
else:
    print('win')


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if(b-a<2*k){
        for(int i=a;i<=b;i++) cout<<i<<endl;
    }else{
        for(int i=a;i<=b;i++){
            cout<<i<<endl;
            if(i==a+k-1) i=b-k;
        }
    }
    return 0;
}

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


/* 2017/01/20 問題 ----- ABC048 D /Link http://abc048.contest.atcoder.jp/tasks/arc064_b */
/* -----解説等-----
問題: 長さ 3 以上の文字列 s があります。 s の中に同一の文字が隣り合う箇所はありません。

高橋君と青木君がゲームで勝負します。 二人は交互に次の操作を行います。 高橋君が先手です。

s から両端以外の文字をひとつ取り除く。 ただし、その文字を取り除くことで、s の中に同一の文字が隣り合う箇所ができる場合、その文字を取り除くことはできない。
先に操作を行えなくなった人が負けです。 二人が最適に行動したとき、どちらが勝つかを判定してください。

制約
3≦|s|≦105
s は英小文字のみからなる。
s の中に同一の文字が隣り合う箇所はない。

膠着状態はabababのような二文字の繰り返しとなるもの
abababcabababaであればacaまで削減可能(11こ)=>２人目の負け
ababcabcabababaであればacacaまで削減可能(10こ)=>1人目の負け
ababxyabab=>ab(8)=>1
ababxyaba=>aya(6)=>1

ababxabab=>ab(7)=>2
ababxaba=>axa(5)=>2
文字列の両端が一緒 　=> {偶数、奇数} => {2負け、1負け}
文字列の両端が異なる => {偶数、奇数} => {1負け、2負け}

判定可能であるが正当性が示せない...！


*/

string S; int slen;
int p;
string ans;

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

    cin >> S;
    slen = S.size();
    if (S[0] == S[slen - 1] && slen % 2 == 1 || S[0] != S[slen - 1] && slen % 2 == 0)p = 2;
    else p = 1;

    if (p == 1)ans = "First";
    else ans = "Second";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
n,m,x=map(int,input().split())
cc=[list(map(int,input().split())) for _ in range(n)]
ans=float('inf')
for b in range(1<<n):
    a=[0]*(m+1)
    for i in range(n):
        if b&(1<<i)==0:
            continue
        for k,l in enumerate(cc[i]):
            a[k]+=l
        if min(a[1:])>=x:
            ans=min(ans,a[0])
    a=[0]*(m+1)
if ans==float('inf'):
    print(-1)
else:
    print(ans)
        


Measured memory_bytes: 9216
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  for (;;) {
    char s[16], r[16];
    r[8] = '.';
    r[13] = '\0';
    fill(s, s+16, 0);
    scanf("%s", s);
    if (s[0] == '-') return 0;
    int a, b, d = 0;
    while (s[d] && s[d] != '.') d++;
    if (!s[d]) {
      sscanf(s, "%d", &a);
      if (a >= 1 << 9) {
        puts("NA");
        continue;
      }
      r[9] = r[10] = r[11] = r[12] = '0';
      goto print_a;
    }
    for (int i = 1; i <= 4; i++)
      if (!s[d+i])
        s[d+i] = '0';
    sscanf(s, "%d.%d", &a, &b);
    if (a >= 1 << 9) {
      puts("NA");
      continue;
    }
    for (int i = 1; i <= 4; i++) {
      int x = 10000 / (1 << i);
      if (b >= x) {
        b -= x;
        r[8+i] = '1';
      } else
        r[8+i] = '0';
    }
    if (b) {
      puts("NA");
      continue;
    }
print_a:
    for (int i = 0; i < 8; i++)
      if ((a >> i) & 1)
        r[7-i] = '1';
      else
        r[7-i] = '0';
    puts(r);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
int i[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  cin >>a>>b;
  b+=a*3;
  cout <<b/2<<'\n';
  return (0);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	string a, b, s;
	int c;
	REP(i,0, N) s+= to_string(i+1);
	
	REP(i, 0, N){
		cin >> c;
		a+= to_string(c);
	}
	REP(i, 0, N){
		cin >> c;
		b+= to_string(c);
	}
	int indexa= (a==s?1:-1), indexb = (b==s?1:-1);
	c = 2;
	while(indexa == -1 || indexb == -1){
		next_permutation(s.begin(), s.end());
		if(a == s) indexa = c;
		if(b == s) indexb = c;
		++c;
	}
	cout << abs(indexa -indexb );

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
vector<int>edge[100005];
int n,k;
ll ans = 1;
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll choose(ll a,ll b){
    ll ret = 1;
	for(ll i=a;i>=a-b+1;i--) ret = ret*i%mod;
	return ret;
}
void dfs(int v,int u){
	int cnt = 0;
	rep(i,edge[v].size()){
		if(edge[v][i] == u) continue;
		dfs(edge[v][i],v); cnt++;
	}
	//cout << cnt << endl;
	if(u == -1){
		if(k-1 < cnt) ans = 0;
		else ans = ans*choose(k-1,cnt)%mod;
	}
	else{
		if(k-2 < cnt) ans = 0;
		else ans = ans*choose(k-2,cnt)%mod;
	}
}
int main(){
	cin >> n >> k;
	rep(i,n-1){
		int a,b; cin >> a >> b; edge[a].pb(b); edge[b].pb(a);
	}
	ans = k;
	dfs(1,-1);
	cout << (ans%mod+mod)%mod << endl;
}

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

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret *= ret;
    if(b % 2 == 1) ret *= a;
    return ret;
}

int main() {
    while(true) {
        ll n, a, b;
        cin >> n >> a >> b;
        if(n == 0 && a == 0 && b == 0) break;
        ll SIZE = beki(2, n);
        a = SIZE - a + 1;
        //cerr << a << endl;
        string ans = "";
        for(int time = 1; time <= n; time++) {
            //cerr << time << " " << SIZE << " " << b << " ";
            bool upper = false;
            ll copy = a + beki(2, time + 1) - beki(2, time - 1) - 1;
            if((copy % beki(2, time + 1)) < beki(2, time)) upper = true;
            if(upper) {
                if(b <= SIZE / 2) {
                    ans += "L";
                    SIZE /= 2;
                    b = SIZE - b + 1;
                    //cerr << "one" << endl;
                } else {
                    ans += "R";
                    b = SIZE - b + 1;
                    SIZE /= 2;
                    //cerr << "two" << endl;
                }
            } else {
                if(b <= SIZE / 2) {
                    ans += "R";
                    SIZE /= 2;
                    //cerr << "three" << endl;
                } else {
                    ans += "L";
                    SIZE /= 2;
                    b -= SIZE;
                    //cerr << "four" << endl;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  int n, m, c; cin >> n >> m >> c;
  
  vector<int> bm(m);
  for (int i = 0; i < m; i++) cin >> bm[i];
  
  vector<vector<int>> am(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> am[i][j];
    }
  }
  
  int answer = 0;
  
  for (int i = 0; i < n; i++) {
    long long sum = c;
    for (int j = 0; j < m; j++) {
      sum += bm[j] * am[i][j];
    }
    if (sum > 0) answer++;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 110000;

int n;
int a[maxn];
int f[maxn];

int main()
{
	scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	
	f[0]=0;
	int t1=1,t0=1; f[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(a[i-1]>a[i]) t1=i;
		if(a[i-1]<a[i]) t0=i;
		f[i]=f[min(t1,t0)-1]+1;
	}
	printf("%d\n",f[n]);
	
	return 0;
}


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

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//namespaces
using namespace __gnu_pbds; 
using namespace std;

//MACROS
#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long 
#define For(i,s,e) for (int i=(s); i<(e); i++)
#define Fod(i,s,e) for (int i=(s); i>=(e); i--)
#define pii pair<ll,ll>
#define f first
#define s second
#define endl "\n"
#define all(container) container.begin(), container.end()
#define mp make_pair
#define int ll

//debug
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//Templates
template <typename T>
using ordered_set =tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

//globals
ll const prime1 = 304933;
ll const prime2 = 15486277;
ll const mod = 1e9+7;
ll const inf = 1e18;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE

signed main(){
    IOS
    string a,b;cin >> a >> b;
    cout << b +a << endl;
    return 0;
}


Measured memory_bytes: 256
n = input()

if len(n) == 1:
  print(int(n))

elif len(n) == 2:
  print(9)

elif len(n) == 3:
  print(9 + int(n) - 99)
  
elif len(n) == 4:
  print(9 + 900)
  
elif len(n) == 5:
  print(9 + 900 + int(n) - 9999)

else:
  print(9 + 900 + 90000)
  

Measured memory_bytes: 3060
X, Y = input().split()
X = int(X)
Y = int(Y)

if X*2>Y or Y>X*4:
  print('No')
elif not Y%2==0:
  print('No')
elif 50 < X:
  print('No')
a = X
b = 0
for i in range(X+1):
  if Y == a*2 + b*4:
    print('Yes')
    break
  else:
    a -= 1
    b += 1

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

#define MOJI_LEN 101
#define ALPHA 26

int main(void){
	int i;
	int len;
	char moji[MOJI_LEN+1];
	char alp[ALPHA+1]={0};
	scanf("%s",moji);

	len=strlen(moji);
	for(i=0;i<len;i++){
		alp[moji[i]-'a']++;
	}
	for(i=0;i<ALPHA;i++){
		if(alp[i]%2!=0){
			printf("No\n");
			break;
		}if( (i>=ALPHA-1) && (alp[i]%2==0) ){
			printf("Yes\n");
			break;
		}
	}

	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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; }

ll conv3(ll x){
  return x * (x-1) * (x-2) / (6);
}

ll conv2(ll x){
  return x * (x-1) / (2);
}

int main() {

  int c[3][3] = {0};
  REP(i, 3)REP(j, 3)cin >> c[i][j];

  if(c[0][1]-c[0][0] == c[1][1]-c[1][0] && c[1][1]-c[1][0] == c[2][1]-c[2][0]){
    if(c[0][2]-c[0][1] == c[1][2]-c[1][1] && c[1][2]-c[1][1] == c[2][2]-c[2][1]){
      cout << "Yes" << endl;
      return 0;
    } 
  }
  cout << "No" << endl;
  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int N;
	cin >> N;
	int ans = 0;
	FOR(i,1,N+1){
		int cnt = 0;
		for(int j = 1;j * j <= i;++j){
			if(i % j)continue;
			++cnt;
			if(i / j != j)++cnt;
		}
		if(cnt == 8 && i & 1)++ans;
	}
	out(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			int tmp = a + b;

			if (tmp % 2 != 0) {
				System.out.println("IMPOSSIBLE");
			} else {
				System.out.println(tmp / 2);
			}
		}
	}
}


Measured memory_bytes: 24020
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long long int N;
    cin >> N;
    vector<pair<long long int, long long int>> tasks(N);
    for(int i=0;i<N;i++){
        long long int A,B;
        cin >> A >> B;
        tasks[i] = make_pair(B,A);
    }


    // first DEADLINE
    // second 

    // for(int i=0;i<N;i++){
    //     cout << tasks[i].second << " " << tasks[i].first << endl; 
    // }
    sort(tasks.begin(), tasks.end());
    // cout << "\n";
    // for(int i=0;i<N;i++){
    //     cout << tasks[i].second << " " << tasks[i].first << endl; 
    // }
    int total_time=0;
    for(int i=0;i<N;i++){
        total_time += tasks[i].second;
        if(total_time > tasks[i].first){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    




}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX=5e5+5;
bool a[MAX];


int main()
{
        LL n,m;
        cin>>n>>m;
        LL a[MAX]={0};
        for(int i=0;i<m;i++)
        {
                LL L,R;
                cin>>L>>R;
                a[L]+=1;
                if(R+1<=n)
                {
                        a[R+1]-=1;
                }
        }
        LL ans=0;
        for(int i=2;i<=n;i++)
        {
                a[i]+=a[i-1];
        }
        for(int i=1;i<=n;i++)
        {
                //cout<<a[i]<<" ";
                if(a[i]==m) ans++;
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x, c, d;
  cin >> n;
  d = 100;
  for (int i = 0; i < n; i++) {
    cin >> x;
    c = 0;
    while (x % 2 == 0){
      x /= 2;
      c++;
    }
    if (d > c){
      d = c;
    }
   }
  cout << d << endl;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
mod = 998244353
s = m - 1
S = 1
ans = 0
fact = [1] * (n + 1)
fact_inv = [0] * (n + 1)
for i in range(1, n + 1):
	fact[i] = (fact[i - 1] * i) % mod
	fact_inv[i] = pow(fact[i], mod - 2, mod)
fact_inv[0] = fact_inv[1]

#k += 1
for t in range(n):
	if t >= n - k - 1:
		b = fact[n - 1] * fact_inv[t] * fact_inv[n - t - 1]
		ans += (S * b) % mod
		#print(t, S, b % mod)
	S = (S * s) % mod
	
print((m * ans) % mod)

Measured memory_bytes: 24656
#include<cctype>
#include<stdio.h>
using namespace std;

int main( ){
  char s;
  while(1){
    scanf("%c",&s);
    if(isalpha(s)){
      if(islower(s)){
	printf("%c",toupper(s));
      }
      else printf("%c",tolower(s));
    }else printf("%c",s);
    if( s=='\n')break;
  }
  return 0;
}

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


Measured memory_bytes: 22612
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define Q int tt,qq; cin>>tt ;for(qq=1;qq<=tt;qq++)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
    double w,h,x,y,a,b;
    cin>>w>>h>>x>>y;
    double area1,area2,area3;
    area1=(double)(w*h)/2;
   // area2=(float)(h-x)*w;
   // area3=(float)h*(w-x);
   // int c=0;
   // if(area1==area2)
   //     c++;
   // if(area1==area3)
   //     c++;
   // if((float)w/2==(float)x && (float)h/2==(float)y)
   //     c++;
   bool ans=false;
   if((double)w/2==(double)x &&(double)h/2==(double)y)
      ans=true;

    cout<<fixed<<setprecision(10)<<area1<<" "<<(1?ans:0)<<endl;
    //cout<<area1;
}

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

// vector<int> dp(100000, 1e9);

int main()
{
    ll n,k, t;
    ll dp[100005];
    int h[100005];
    scanf("%lld%lld", &n,&k);
    // std::vector<int> h;
    // rep(i, n)
    // {
    //     scanf("%lld", &t);
    //     h.push_back(t);
    // }
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    rep2(i,1,k)
    dp[i] = 0;
    rep2(i, 2, n + 1)
    {
        //     dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        // if (i - k >= 1){
        //     dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
        // }
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        rep2(j, 2, k + 1) if (i - j >= 1) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
    printf("%lld\n", dp[n]);
    // printf("OK");

    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

using P = pair<int, int>;

const ll MOD = 1e9 + 7;

template <class T>
struct fenwick_tree {
  vector<T> x;
  fenwick_tree(int n) : x(n + 1) {}
  void add(int k, T a) {
    for (++k; k < x.size(); k += k & -k) (x[k] += a) %= MOD;
  }
  T sum(int k) {
    T s = 0;
    for (; k > 0; k &= k - 1) (s += x[k]) %= MOD;
    return s;
  }
};

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<int> x(N), y(M);
    for (int i = 0; i < N; i++) cin >> x[i];
    for (int i = 0; i < M; i++) cin >> y[i];
    vector<P> ps;
    for (int i = 0, j = 0; i < N; i++) {
      while (j < M && y[j] < x[i]) ++j;
      if (j < M && j > 0) {
        ps.emplace_back(x[i] - y[j - 1], y[j] - x[i]);
      }
    }
    vector<int> ys;
    for (auto& p : ps) {
      ys.push_back(p.snd);
    }
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    for (auto& p : ps) {
      p.snd = distance(ys.begin(), lower_bound(ys.begin(), ys.end(), p.snd));
    }
    sort(ps.begin(), ps.end(), [&](auto& a, auto& b) {
      if (a.fst != b.fst) return a.fst < b.fst;
      return a.snd > b.snd;
    });
    ps.erase(unique(ps.begin(), ps.end()), ps.end());
    fenwick_tree<ll> bit(ys.size() + 1);
    bit.add(0, 1);
    for (auto& p : ps) {
      ll ways = bit.sum(p.snd + 1);
      bit.add(p.snd + 1, ways);
    }
    ll res = bit.sum(ys.size() + 1);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3064