akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using  namespace std;
double f(double n, double k, double n2){
    if(n2>=k){
        return 1/n;
    }
    return f(n, k ,n2*2)/2;
}
int main(){
    double n, k, ans=0;
    cin >> n >> k;
    for(int i=1;i<=n;i++){
       ans += f(n, k, i);
    }
  	cout << fixed;
    cout << setprecision(12) << ans << endl;
    return 0;
 
}


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(i % 2 == 0 && a % 2 == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<unordered_map>
using namespace std;

struct a {
	int b, c;
};
bool operator <(a d ,a e) {
	if (d.b*d.b + d.c*d.c != e.b*e.b + e.c*e.c)return d.b*d.b + d.c*d.c < e.b*e.b + e.c*e.c;
	return d.b < e.b;
}
int main() {
	vector<a>d;
	for (int e = 1; e < 150; e++) {
		for (int f = e+1; f < 150; f++) {
			a g;
			g.b = e; g.c = f;
			d.push_back(g);
		}
	}
	sort(d.begin(), d.end());
	int e, f;
	while (cin >> e >> f, e | f) {
		for (int g = 0; g < d.size(); g++) {
			if (d[g].b == e&&d[g].c == f) {
				cout << d[g + 1].b << " " << d[g + 1].c << endl;
			}
		}
	}
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


bool check(vint a) {
    int sz = a.size();
    int p = a[0];
    srep(i, 1, sz) {
        if (abs(p-a[i]) > 1) return false;
        p = a[i];
    }
    return true;
}

void update(vint& a) {
    int sz = a.size();
    int id = 0;
    while (1) {
        while (1) {
            if (a[id] < 9) {
                a[id]++;
                break;
            }
            else {
                id++;
                if (id >= sz) {
                    a = {};
                    rep(i, sz) a.push_back(0);
                    a.push_back(1);
                    return;
                }
            }
            
        }
        rrep(i, id) {
                a[i] = max(a[id]-(id-i), 0);
        }
        if (check(a)) return;
    }
}

int main() {
    int k;
    cin >> k;
    vint a = {1};
    rep(i, k-1) update(a);
    ll ans = 0, d = 1;
    for (int ai : a) {
        ans += ai*d;
        d *= 10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ull unsigned long long
#define ll long long
#define pb push_back
#define f first
#define se second
#define mp make_pair
#define Speedforce boost();

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const int inf = 1e9 + 7;

int a, b;

int main() {
    Speedforce
    cin >> a >> b;
    if(a > 0 && b > 0){
        cout << "Positive";
        return 0;
    }
    if(0 >= a && 0 <= b){
        cout << "Zero";
        return 0;
    }
    if((abs(a) - abs(b) + 1) & 1){
        cout << "Negative";
    }
    else{
        cout << "Positive";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#define ll long long int 
using namespace std;
ll n;
ll fak(){
	ll ans = 1e15;
	ll sampe = sqrt(n);
	ll i = 1;
	while(i<=sampe){
		if(n%i == 0){
			ans = min(ans, (i-1)+(n/i)-1);
		}
		i++;
	}
	return ans;
}


int main(){
	cin>>n;
	cout<<fak()<<"\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var n = inputLongArray[0];
            var k = inputLongArray[1];

            var a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            //var denkyuuList = new List<denkyuu>();
            //for (int i = 0; i < a.Length; i++)
            //{
            //    var denkyuu = new denkyuu();
            //    denkyuu.x = i;
            //    denkyuu.d = a[i];

            //    denkyuuList.Add(denkyuu);
            //}

            //long sum = 0;
            //for (int i = 0; i < k; i++)
            //{
            //    var denkyuuList_new = new List<denkyuu>();
            //    foreach (var item in denkyuuList)
            //    {
            //        denkyuuList_new.Add(new denkyuu(item));
            //    }

            //    foreach (var item in denkyuuList)
            //    {
            //        item.d = denkyuuList_new.Count(x => item.x >= x.lightrange_min
            //                                            && item.x <= x.lightrange_max);
            //    }
            //    var sum2 = (long)denkyuuList.Sum(x => x.d);
            //    if (sum == sum2)
            //    {
            //        break;
            //    }
            //    sum = sum2;
            //}

            //string result = "";
            //for (int i = 0; i < denkyuuList.Count; i++)
            //{
            //    result += (i == 0 ? "" : " ") + denkyuuList[i].d.ToString();
            //}]

            var ans = a;
            for (int i = 0; i < k; i++)
            {
                var tmp = new int[n + 1];
                for (int j = 0; j < ans.Length; j++)
                {
                    tmp[Math.Max(0, j - ans[j])]++;
                    tmp[Math.Min(n, j + ans[j] + 1)]--;
                }

                for (int j = 0; j < ans.Length; j++)
                {
                    ans[j] = (j == 0 ? 0 : ans[j -1]) + tmp[j];
                }
                if (!ans.Any(x => x != n))
                {
                    break;
                }
            }

            Console.WriteLine(string.Join(" ",ans));
            Console.Out.Flush();
        }
        //public class denkyuu
        //{
        //    public denkyuu()
        //    {}
        //    public denkyuu(denkyuu _d)
        //    {
        //        x = _d.x;
        //        d = _d.d;
        //    }
        //    public int x { get; set; }
        //    public int d { get; set; }
        //    public int lightrange_min
        //    {
        //        get { return x - d; }
        //    }
        //    public int lightrange_max
        //    {
        //        get { return x + d; }
        //    }
        //}
    }
}


Measured memory_bytes: 61216
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;




int main() {
	
	int w,h,n;
	cin>>w>>h>>n;
	int xl=0,xr=w,yd=0,yu=h;
	for(int i=0;i<n;i++){
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1)xl=max(xl,x);
		if(a==2)xr=min(xr,x);
		if(a==3)yd=max(yd,y);
		if(a==4)yu=min(yu,y);

	}
	if(xr<=xl||yu<=yd)cout<<0;
	else cout<<(xr-xl)*(yu-yd)<<endl;
	

	return 0;
}

	

Measured memory_bytes: 256
from fractions import gcd
import collections

def lcm(x, y):
  return (x*y)//gcd(x, y)
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(10**6)]
mod=10**9+7
for i in range(n):
  x=factorize(a[i])
  for j in range(len(x)):
    l[x[j][0]]=max(l[x[j][0]],x[j][1])
lcm=1
for i in range(2,10**6):
  lcm*=(i**l[i])
  lcm%=mod
ans=0
for i in range(n):
  ans+=lcm*mod_inv(a[i],mod)
  ans%=mod
print(ans)

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

#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 998244353


int solve()
{
  int n;
  cin>>n;
  int k;
  cin>>k;
  vector<pii> yu(k);
  for(int i=0;i<k;i++)
  {
    cin>>yu[i].fr>>yu[i].sc;
  }
  int temp=0;
  ll f[n+1][2];
  ll a[n+1];
  
  for(int i=0;i<=n;i++)
  {
    f[i][0]=0;
    f[i][1]=0;
  }
  memset(a,0,sizeof(a));
  a[n]=1;
  for(int i=n;i>0;i--)
  {
    temp+=f[i][1];
    temp%=M;
    a[i]+=temp;
    a[i]%=M;
    temp-=f[i][0];
    temp+=M;
    temp%=M;
    //cout<<"a[i]="<<a[i]<<", for i="<<i<<endl;
    for(auto it:yu)
    {
      if(i-it.fr<1)
        continue;
      int right=i-it.fr;
      int left=max(0,i-it.sc);
      f[left][0]+=a[i];
      f[left][0]%=M;
      f[right][1]+=a[i];
      f[right][1]%=M;
    }
    
  }
  cout<<a[1]<<endl;
  
  return 0;
}


int main() {
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);       

  int t=1;
  //cin>>t;
  while(t--)
  { 
    solve();
  }
  return 0;
}




Measured memory_bytes: 8304
def solve():
    [N, M] = [int(x) for x in input().split()]
    X = sorted([int(x) for x in input().split()])

    delta = sorted([X[i]-X[i-1] for i in range(1, M)], reverse=True)

    return sum(delta[N-1:])


def main():
    print(solve())


if __name__ == '__main__':
    main()

Measured memory_bytes: 13832
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#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...); }

const int N = 100001;

bool b[N];
int dp[N];

int main()
{
	fio;
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++)
	{
		int a;
		cin >> a;
		b[a] = true;
	}
	dp[0] = 1;
	dp[1] = (b[1] ? 0 : 1);
	for(int i=2; i<=n; i++)
		dp[i] = (b[i] ? 0 : (dp[i-1] + dp[i-2]) % MOD);
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 768
from itertools import product

n = int(input())
data = []
for i in range(n):
    for j in range(int(input())):
        x, y = map(int, input().split())
        data.append((i, x-1, y))

ans = 0
for i in product([1, 0], repeat=n):
    s = True
    for j in data:
        if i[j[0]] == 1 and i[j[1]] != j[2]:
            s = False
            break
    if s:
        ans = max(ans, sum(i))
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <queue>
#include <string>

using namespace std;

struct Task {
    string t_name;
    int t_time;
};

int
main(int argc, const char *argv[])
{
    int n, q;
    int time_count = 0;
    cin >> n >> q;
    queue<Task> qt;
    while (n--) {
        Task t;
        cin >> t.t_name >> t.t_time;
        qt.push(t);
    }
    while (!qt.empty()) {
        Task f = qt.front();
        qt.pop();
        if (f.t_time > q) {
            f.t_time -= q;
            qt.push(f);
            time_count += q;
        } else {
            cout << f.t_name << " " << f.t_time + time_count << endl;
            time_count += f.t_time;
        }
    }

    return 0;
}

Measured memory_bytes: 6168
#include <stdio.h>
#include <math.h>
int main(void){
  int n,k,h[100001],dp[100001];
  dp[0]=0;
  scanf("%d",&n);
  int i,j;
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  for(i=1;i<n;i++) dp[i]=1E9;
  for(i=0;i<n;i++){
    dp[i+1]=fmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    dp[i+2]=fmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }
  printf("%d",dp[n-1]);
  return 0;
}

Measured memory_bytes: 896
// https://atcoder.jp/contests/abc151/tasks/abc151_a
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    char c,d;
    cin>>c;
    d=c+1;
    cout<<d<<"\n";
    return 0;
}

Measured memory_bytes: 3628
import numpy as np

def main():
    N, L = map(int, input().split())
    aji = [L+i-1 for i in range(1, N+1)]
    absaji = list(map(abs, aji))

    i = np.argmin(absaji)

    print(sum(aji) - aji[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 21420
#include<iostream>
#include<vector>
using namespace std;
struct tri{
    int a;
    int b;
    int c;
    int r;
};
int main(){
    int k = 0;
    vector<int>ans;
    while(1){
        int a,b,c,n;
        cin >> a >> b >> c;
        if(a == 0 && b == 0 && c == 0)break;
        cin >> n;
        vector<tri>t(n);
        for(int i = 0;i < n;i++){
            cin >> t[i].a >> t[i].b >> t[i].c >> t[i].r;
        }
        int s = a + b + c + 1;
        vector<int>check(s);
        //0故障　1正常 2不明
        for(int i = 0;i < s;i++){
            check[i] = 2;
        }
        for(int i = 0;i < n;i++){
            if(t[i].r == 1){
                check[t[i].a] = 1;
                check[t[i].b] = 1;
                check[t[i].c] = 1;
            }
        }
        for(int i = 0;i < n;i++){
            if(t[i].r == 0){
                if(check[t[i].a] == 1 && check[t[i].b] == 1){
                    check[t[i].c] = 0;
                }
                else if(check[t[i].a] == 1 && check[t[i].c] == 1){
                    check[t[i].b] = 0;
                }  
                else if(check[t[i].c] == 1 && check[t[i].b] == 1){
                    check[t[i].a] = 0;
                }
                     
            }
        }
        for(int i = 1;i < s;i++)ans.push_back(check[i]);
    }
    for(int i = 0;i < ans.size();i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main() {
  int n; cin >> n;
  int l; cin >> l;
  vector<int> arr(n);
  int sum_apple = 0;
  for (int i = 0; i < n; ++i) {
    arr[i] = l + i;
    sum_apple += arr[i];
  }
  if (arr[0] > 0) {
    cout << sum_apple - arr[0] << endl;
  } else if (arr[n - 1] < 0) {
    cout << sum_apple - arr[n - 1] << endl;
  } else {
    cout << sum_apple << endl;
  }
}

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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &v[i]);
    }
    sort(v.begin(), v.end());
    int result = v[v.size()/2] - v[v.size()/2-1];
    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int a=0,b=0,c=0,n,x,y,m;
  cin>>n;
  int aa[n];
  rep(i,0,n) cin>>aa[i];
  rep(i,0,n){
    a=aa[i]-1;
    if(aa[a]==i+1) c++;
  }
  co(c/2);
  
  
  return 0;
}

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

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

    string s;
    cin >> s;

    int w[n];
    int e[n];
    int change[n];
    for(int i = 0; i < n; i++){
        w[i] = 0;
        e[i] = 0;
        change[i] = 0;
    }

    for(int i = 1; i < n; i++){
        if(s[i - 1] == 'W'){
            w[i] = w[i - 1] + 1;
        }else{
            w[i] = w[i - 1];
        }
    }

    for(int i = n - 2; i >= 0; i--){
        if(s[i + 1] == 'E'){
            e[i] = e[i + 1] + 1;
        }else{
            e[i] = e[i + 1];
        }
    }

    int ans = -1;
    for(int i = 0; i < n; i++){
        change[i] = w[i] + e[i];
        if(ans == -1){
            ans = change[i];
        }else{
            if(ans >= change[i]){
                ans = change[i];
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int C = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'R') {
      C++;
    }
  }
  int CL = 0;
  for (int i = 0; i < C; i++) {
    if (S.at(i) == 'R') {
      CL++;
    }
  }  
  cout << C - CL << endl;
}


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

int main() {
    long long H; cin >> H;
    long long res = 0;
    for(int i=0; i<50; ++i) {
        if(H == 0) break;
        H /= 2;
        res += (1LL << i);
    }
    cout << res << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;
using ll = long long;

ll n;

void input(){
  cin >> n;
}

void solve(){
  ll ans = 0;
  ll cnt = 0;
  ll a = pow(5, cnt);
  while(a <= n){
    ll b = pow(5, cnt + 1);
    if(b <= n){
      cnt++;
      a = pow(5, cnt);
      //cout << a << endl;
    }else{
      break;
    }
  }
  //cout << cnt << endl;
  while(cnt > 0){
    ll c = 2 * pow(5, cnt);
    ans += n / c;
    cnt--;
  }
  if(n % 2 != 0){
    ans = 0;
  }
  cout << ans << endl;

}

int main(){
  input();
  solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int p, q, r; cin >> p >> q >> r;
    cout << min({p + q, r + q, p + r}) << "\n";
}


Measured memory_bytes: 256
//                          **********  YATIN KWATRA  ********** 

//AC bakshi Rabha

#include <bits/stdc++.h>
#define ll                      long long 
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uo                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<long,long>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define mod                     1000000007
// #define node                    Node

using namespace std;

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

}


void solve()
{ 
       ll a,b,c,k;
       cin >> a >> b >> c >> k;

       ll ans = 0;

       if(k<=a) {

        ans = k;
        cout << ans << endl;
        return;

       }
      ans = a;
      k-=a;

      if(k<=b) 
      {
         cout << ans << endl;
         return;
      }

      k-=b;

      ans += (-1)*(k);
      cout << ans << endl;
       
}
int main() {
    
    FIO
 //   INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll cnt = 0;
vector<pair<ll, ll>> ans;
vector<bool> visited;
void f(ll node, vector<vector<ll>> &graph) {
  if (visited[node]) return;
  visited[node] = true;

  ll found = ++cnt;
  for(ll nxt: graph[node]) {
    f(nxt, graph);
  }
  ll solve = ++cnt;
  ans[node] = {found, solve};
}

int main() {
  ll input(n);
  vector<vector<ll>> graph(n);
  ans = vector<pair<ll, ll>>(n);
  visited = vector<bool>(n);
  REP(i, n) {
    ll input(u, k);
    REP(j, k) {
      ll input(v);
      graph[u - 1].push_back(v - 1);
    }
  }

  REP(i, n) f(i, graph);
  REP(i, n) {
    cout << i + 1 << " " << ans[i].first << " " << ans[i].second << endl;
  }
}



Measured memory_bytes: 3128
import numpy as np
n,k = map(int,input().split())
m = 10**9 + 7
gcds = np.zeros(k+1, int)

for i in range(k,0,-1):
  tmp = k // i
  gcds[i] = pow(tmp,n, m)
  for j in range(tmp,1,-1):
    gcds[i] -= gcds[j*i]
ans = 0
for i in range(k,0,-1):
  ans = (ans + gcds[i]*i)%m
print(ans)

Measured memory_bytes: 27416
n = input()
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
ans = sum(list(map(int, str(n))))
if ans%9 == 0: print('Yes')
else: print('No')


Measured memory_bytes: 10760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(( x - r  < 0 || x + r > W ) || ( y - r  < 0 || y + r > H )) {
			System.out.println("No");
		}else if(( x - r >= 0 && x + r <= W ) && ( y - r >= 0 && y + r <= H )) {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 26388
# WAなんだこれ・・
# Sが１文字の時
# Sが同じ文字で複数文字の時
import sys
input = sys.stdin.readline

S = input()
K = int(input())


def main():
    comp_s = compress(S)
    # print(comp_s)

    # １種類の文字で構成されている場合
    if len(comp_s) == 1:
        char_length = comp_s[0][1] * K
        # これで終わり
        print(char_length // 2)
    else:
        increment = 0
        for s in comp_s:
            increment += (s[1] // 2)
        # 暫定でS一つ分の合計をだす
        total = increment

        # 最初と最後の文字が同じ
        if comp_s[0][0] == comp_s[-1][0]:
            # かつどちらも奇数個
            if comp_s[0][1] % 2 != 0 and comp_s[-1][1] % 2 != 0:
                increment += 1

        # 残りのSの繰り返し分を足す
        total += increment * (K - 1)

        print(total)


def compress(S):
    prevc = None
    tmp_count = 1
    comp_s = []
    for i in range(len(S) - 1):
        if i == 0:
            pass
        elif prevc == S[i]:
            tmp_count += 1
        else:
            comp_s.append([prevc, tmp_count])
            tmp_count = 1

        prevc = S[i]

    # 最後一個拾うの忘れずに
    comp_s.append([prevc, tmp_count])

    return comp_s


if __name__ == '__main__':
    main()


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

int main() {
	long long n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 1e18;
	for (int b = 0; b < 2; b++) {
		long long s = 0, now = 0;
		for (int i = 0; i < n; i++) {
			long long c = i%2==b ? 1 : -1;
			s += a[i];
			if (s <= 0 && c == 1) {
				now += c - s;
				s = 1;
			} else if (s >= 0 && c == -1) {
				now += s - c;
				s = -1;
			}
		}
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
using System;

namespace AtCoderABC126A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            char[] c = Console.ReadLine().ToCharArray();

            c[K - 1] =  (char)(c[K - 1] + 'a' - 'A');

            string ans = new string(c);

            Console.WriteLine(ans);
        }
    }


}


Measured memory_bytes: 11092
#include<cstdio>
#include<algorithm>

using namespace std;

int a[51],b[51];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]); 
	for(int i=1;i<=n;++i) b[i]=i;
	int o=0;
	for(int i=1;i<=n;++i) 
		if(a[i]!=b[i]) o++;
	if(!o || o==2) printf("YES");
	else printf("NO");
} 

Measured memory_bytes: 128
class Maximum
  def initialize
    @arr = []
    monky
  end
  def monky
    def @arr.[](i)
      super(i - 1)
    end
    def @arr.[]=(i, value)
      super(i - 1, value)
    end
  end
  def buildHeap(root = 1)
    left, right = root * 2, root * 2 + 1
    if @arr[right]
      buildHeap(left); buildHeap(right)
      max = [[@arr[left], left], [@arr[right], right]].max
      if max[0] > @arr[root]
        @arr[root], @arr[max[1]] = @arr[max[1]], @arr[root]
        rebuildHeap(max[1])
      end
    elsif @arr[left]
      buildHeap(left)
      if @arr[left] > @arr[root]
        @arr[root], @arr[left] = @arr[left], @arr[root]
        rebuildHeap(left)
      end                                                       
    end
  end
  def rebuildHeap(root = 1)
    left, right = root * 2, root * 2 + 1
    if @arr[right]
      max = [[@arr[left], left], [@arr[right], right]].max
      if max[0] > @arr[root]
        @arr[root], @arr[max[1]] = @arr[max[1]], @arr[root]
        rebuildHeap(max[1])
      end
    elsif @arr[left]
      if @arr[left] > @arr[root]
        @arr[root], @arr[left] = @arr[left], @arr[root]
        rebuildHeap(left)
      end
    end      
  end
  def insert(array)
    @arr = array
    monky
    buildHeap
  end
  def to_s
    @arr.join(" ")
  end
end
def main(input = STDIN)
  heap = Maximum.new
  input.gets
  heap.insert(input.gets.split(" ").map(&:to_i))
  puts " " + heap.to_s
end
main

Measured memory_bytes: 163644
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    ifstream ifs("in.txt");
    int n;
    cin >> n;
    VL a(n);
    REP(i,n) cin >> a[i];
    REP(i,n){
        a.push_back(a[i]);
    }
    VL s(2*n+1);
    REP(i,2*n) s[i+1] = s[i] + a[i];
    s.push_back(1e17);
    s.push_back(2e17);
    s.push_back(3e17);
    ll l = 1, r = 1e16;
    while (r - l > 1){
        ll m = (l + r) / 2;
        bool pos = 0;
        REP(i,n){
            int x = i;
            REP(j,3){
                x = lower_bound(s.begin(), s.end(), s[x] + m) - s.begin();
            }
            if (x <= i + n){
                pos = 1;
                break;
            }
        }
        if (pos) l = m;
        else r = m;
    }

    cout << l << endl;

    return 0;
}

Measured memory_bytes: 7464
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()
 
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
 
int N;
char data[130][130];
bool used[130][130];
 
void bfs(int y, int x) {
  if ( used[y][x] ) return;
  used[y][x] = true;
  Rep(k, 4) {
    int ny = y+dy[k], nx = x+dx[k];    
    if ( ny < 0 || nx < 0 || ny >= N || nx >= N || data[ny][nx] == 'x' ) continue;
    bfs(ny, nx);
  }
}
 
signed main() {
  cin >> N;
  Rep(i, N) Rep(j, N) cin >> data[i][j];
 
  int ans = 0;
  Rep(i, N) Rep(j, N) {
    if ( data[i][j] == 'o' && !used[i][j] ) {
      bfs(i, j);
      ans++;
    }
  }
 
  cout << ans/3 << endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long 
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double
 
const int N=1e5+3;
int sum(int n)
{
	return (n*(n+1))/2;
}
int sol()
{
	int n;
	cin >> n;
	
	int tot=n*(n+1);
	tot/=2;
	int th=n/3,fi=n/5,com=n/15;
 
	cout<<sum(n)-sum(th)*3-sum(fi)*5+sum(com)*15;
	return 0;
}
 
 
 
int32_t main()
{
 
 
 int t=sol();
}

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

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

    map<int,int> f;
    rep(i,N) f[P[i]] = i;

    vector<int> rev;

    rep(i,N-1) {
        if (f[i] > f[i+1]) rev.push_back(i);
    }

    if (rev.size() >= 1) {
        int MAX = 0;
        rep(i,rev.size()-1) MAX = max(MAX, rev[i+1]-rev[i]);
        MAX = max(MAX, rev[0] + 1);
        MAX = max(MAX, N-1-rev[rev.size()-1]);

        cout << N - MAX << endl;
    }
    else cout << 0 << endl;
}


Measured memory_bytes: 11516
pm = 10**9 + 7

l = gets.chomp.split(//)

a = l.inject([1,1]) do |s, x|
  r, b = s
  r3 = (3 * r) % pm
  b2 = (2 * b) % pm
  if x == "1"
    [r3, b2]
  else
    [r3 - b2, b]
  end
end

puts(a[0] % pm)


Measured memory_bytes: 9468
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  string S;
  cin>>S;

  cout<< ( S[0]==S[2] ? "Yes" : "No" )<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	int n,m,i,j;
    	cin>>n>>m;
    	int a[n];
    	int sum=0;
    	for(i=0;i<n;i++){
    		cin>>a[i];
    		sum+=a[i];
    		
		}
		int x=0;
		for(i=0;i<n;i++)
		{
			if(a[i]*4*m>=sum)
			{
				x++;
			}
		}
		if(x>=m)
		{
			cout<<"Yes\n";
		}
    	else
    	{
    		cout<<"No\n";
		}
    	

    }

}

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

#define ll long long
#define endl "\n"

const ll lmt=2e5+5;
vector<ll>adj[lmt];
ll n,ans[lmt],res[lmt];
bool vis[lmt];


int main(){
	ios_base::sync_with_stdio(false);

	cin>>n;
	for(ll i=1;i<n;i++){
		ll u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	vis[1]=1;
	res[1]=1;
	for(ll i=2;i<=n;i++){
		ll sz=0;
		for(ll v:adj[i]){
			if(vis[v]==1){
				sz++;
			}
		}
		res[i]=res[i-1]-(sz-1);
		vis[i]=1;
	}
	for(ll i=1;i<=n;i++){
		ans[1]+=res[i];
	}
	for(ll i=2;i<=n;i++){
		vector<ll>nei;
		for(ll v:adj[i-1]){
			if(v>i-1){
				nei.push_back(v);
			}
		}
		ll pre=n,add=0;
		for(ll j=nei.size()-1;j>=0;j--){
			add+=((pre-nei[j]+1)*((j+1)-1));
			pre=nei[j]-1;
		}
		if(!nei.empty()){
			add-=((nei[0]-1)-i+1);
		}
		if(nei.empty()){
			add=0;
			add-=(n-i+1);
		}
		ans[i]=(ans[i-1]+add);
		ans[i]--;
	}
	ll sum=0;
	for(ll i=1;i<=n;i++){
		sum+=ans[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 20372
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
#define debug() for(ll l=0;l<50;l++){}
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
const ll M = 998244353;
const ll inf = 1e18+5;
const ll INF=INT_MAX;
using namespace std;
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
const int max1=500001;
pair<int,int>st[4*max1];
int arr[max1],arr1[max1];
void buildtree(int si,int ss,int se){
	if(ss==se){
        st[si].first=arr1[ss];
        st[si].second=arr1[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	if(arr1[mid]>arr1[mid+1]) st[si].first=st[2*si].first+st[2*si+1].first;
    else st[si].second=st[2*si].second+st[2*si+1].second;
	
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return INF;
	if(ss>=qs && se<=qe)
		return st[si].first;
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
int geteven(int si,int ss,int se,int qs,int qe){
	if(ss>qe || se<qs) //completely outside
		return 0;
	if(ss>=qs && se<=qe)
		return st[si].second;
	int mid=ss+(se-ss)/2;
	int l=geteven(2*si,ss,mid,qs,qe);
	int r=geteven(2*si+1,mid+1,se,qs,qe);
	return l+r;
}
int getodd(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return 0;
	if(ss>=qs && se<=qe)
		return st[si].first;
	int mid=ss+(se-ss)/2;
	int l=getodd(2*si,ss,mid,qs,qe);
	int r=getodd(2*si+1,mid+1,se,qs,qe);
	return l+r;
}
void update(int si,int ss,int se,int qi,int newval){
	if(ss==se){
        if(arr[ss]%2==1) st[si]={0,1};
        else st[si]={1,0};
		arr[ss]=newval;
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi,newval);
	else update(2*si+1,mid+1,se,qi,newval);
	st[si].first=st[2*si].first+st[2*si+1].first;
    st[si].second=st[2*si].second+st[2*si+1].second;
}
void solve(){
	string s;
	cin>>s;
	ll l=s.length();
	if(s[l-1]=='s') s+="es";
	else s+="s";
	cout<<s<<"\n";
	
}
int main(){
	fast;
	ll t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const int MAX = 510000;
ll 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;
  }
}

// 二項係数計算
ll 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;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll ans = 0;
  COMinit();
  for(int i = 0; i < n; i++) {
    if(i <= n - k) {
      ans -= COM(n - i - 1, k - 1) * a[i] % MOD;
      if(ans < 0) {
        ans += MOD;
      }
    }
    if(i >= k - 1) {
      ans += COM(i, k - 1) * a[i] % MOD;
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int a = 0;
  for (int i = 0; i < N-1; i++) {
    if (vec.at(i) == vec.at(i+1)) {
      a++;
    }
  }
  if (a == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

typedef long long ll;

int main() {
    ll N; cin >> N;
    ll ans = 0;
    ll i = 1;
    while (i * i < N - i) {
        if ((N - i) % i == 0) ans += (N - i) / i;
        i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll expo(ll a,ll b)
{
	if(b==0)
	return 1;
	else if(b%2==0)
	return expo(a*a,b/2);
	return expo(a*a,b/2)*a;
}
int main()
{
	ll n,m,i,j,l;
	cin>>n>>m;
	ll k[m+1];
	ll p[m+1];
	vector<ll> v[m+1];
	for(i=1;i<=m;i++)
	{
		ll k[i];
		cin>>k[i];
		for(j=0;j<k[i];j++)
		{
			ll x;
			cin>>x;
			v[i].pb(x);
		}
	}
	for(i=1;i<=m;i++)
	{
		cin>>p[i];
	}
	ll ans=0;
	ll mask=expo(2,n)-1;
	for(i=0;i<=mask;i++)
	{
		//cout<<i<<"\n";
		ll flag=0;
		for(j=1;j<=m;j++)
		{
			ll cnt=0;
			for(l=0;l<v[j].size();l++)
			{
				//cout<<v[j][l]<<"as";
				//cout<<(1<<(v[j][l]-1)&i)<<" dds";
				if((1<<(v[j][l]-1)&i)!=0)
				{
					//cout<<"yo\n";
				cnt++;
			}
				
			}
			//cout<<cnt<<"sd\n";
			if(cnt%2!=p[j]%2)
			{
				//cout<<cnt<<" "<<i<<" "<<"break\n";
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
		ans++;
	}
	}
	cout<<ans;
}

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

int main()
{
        char str[MAX];
        int str_length = 0;
        int i = 0;

        fgets( str, 200, stdin );
        str_length = strlen( str );

        for ( i = 0 ; i < str_length ; i = i + 1 )
        {
                if ( ( str[i] >= 'a' ) && ( str[i] <= 'z' ) )
                {
                        str[i] = str[i] - 32;
                }
        }

        fprintf( stdout, "%s", str );

        return 0;
}

Measured memory_bytes: 524
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var abc=[];
for(var i=0;i<Arr.length;i++){
if(abc.length==0 && Arr[i]=="0 0")break;
var arr=Arr[i].split(" ").map(Number);
abc.push(arr[0]+arr[1]);
if(abc.length==5){
   var max=abc.reduce(function(a,b){return Math.max(a,b);});
   var ABC="ABCDE".split("");
   var str=ABC[abc.indexOf(max)];
   console.log(str+" "+max);
   abc=[];
}
}

Measured memory_bytes: 9436
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (A<=X&&X <= A+B) {
		cout << "YES";
		return 0;
	}
	else cout << "NO";

}

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

int main() {
	// your code goes here
	int N;
	
	while(cin >> N && N){
		int m,e,j;
		for(int i=0;i<N;i++){
			cin >> m >> e >> j;
			if(max(m,max(e,j))==100 || (m+e)>=180 || m+e+j>= 240)
			cout <<"A" << endl;
			else if(m+e+j>=210 || (m+e+j>=150 && max(e,m)>=80))
			cout <<"B" << endl;
			else 
			cout << "C" << endl;
		}
	}
	return 0;
}

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

typedef long long ll;


const int MOD = 1000000007;
int MAX_SZ;
int K, N;
string S;
vector<ll> fac, finv, inv;
vector<ll> pow25, pow26;

void COMB_init() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i <= MAX_SZ; 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;
	}
}

ll COMB(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;
}

void input_init(void) {
	cin >> K;
	cin >> S;
	N = S.length();
	MAX_SZ = K + N - 1;
	fac.resize(MAX_SZ + 1);
	finv.resize(MAX_SZ + 1);
	inv.resize(MAX_SZ + 1);
	pow25.resize(K + 1);
	pow26.resize(K + 1);
	pow25[0] = pow26[0] = (ll)1;
	for (int i = 1; i <= K; ++i) {
		pow25[i] = (pow25[i - 1] * 25) % MOD;
		pow26[i] = (pow26[i - 1] * 26) % MOD;
	}
}

ll solve(void) {
	ll sum = (ll)0;
	for (int i = 0; i <= K; ++i) {
		ll val = (pow25[i] * COMB(i + N - 1, N - 1)) % MOD;
		val = (val * pow26[K - i]) % MOD;
		sum = (sum + val) % MOD;
	}
	return sum;
}

int main(void) {
	input_init();
	COMB_init();
	ll ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 66688
import sys
A="abcdefghijklmnopqrstuvwxyza"
def decode(s):
    x=""
    for c in s:
        if c in A: x+=A[A.index(c)+1]
        else: x+=c
    return x

for s in sys.stdin.readlines():
    for i in range(26):
        if "the" in s or "that" in s or "this" in s:break
        s=decode(s)
    print s[:-1]

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

int main(){
    int n,k;
    cin>>n>>k;
    int a[n+2];
    for(int i=1;i<=n;i++)cin>>a[i];
    int ans=1;n-=k;k--;
    ans+=n/k;
    if((n%k)!=0)ans++;
    cout<<ans;
}

Measured memory_bytes: 640
str = input()
q = int(input())
 
for _ in range(q):
    line = input().split()
    c = line[0]
    a = int(line[1])
    b = int(line[2]) + 1
 
    if c == 'replace':
        str = str[:a] + line[3] + str[b:]
    elif c == 'reverse':
        str = str[:a] + str[a:b][::-1] + str[b:]
    else:
        print(str[a:b])


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

int main(){
	long long int a,b,x;
  	cin >> a >> b >> x;
  	if (a%x==0 &&b%x==0)cout << b/x-a/x+1 <<endl;
	if (a%x!=0 &&b%x==0)cout << b/x-a/x <<endl;
	if (a%x==0 &&b%x!=0)cout << b/x-a/x+1 <<endl;
  	if (a%x!=0 &&b%x!=0)cout << b/x-a/x <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i, x, y;
	for(i=1;;i++){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0) break;
		
		printf("%d %d\n",(x > y)? y:x ,(x > y)? x:y);
	}
	return 0;
}

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

typedef long long ll;

int main(){

    int x, n;
    cin >> x >> n;
    int arr[102]={};

    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        arr[t]++;
    }

    int ans=110, val;
    for(int i=0; i<=101; i++){
        if(arr[i]==0){
            if (ans>abs(i-x)){
                // cout<<i<<" ";
                ans=abs(i-x);
                val=i;
            }
        }
    }
    // cout<<"\n";
    cout<<val<<'\n';

    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong a, b;
	cin >> a >> b;

	if (b == 1)
		cout << 0 << endl;
	else if (b <= a)
		cout << 1 << endl;
	else
		cout << 1 + (b-a)/(a-1) + ((b-a)%(a-1)>0) << endl;

	return 0;
}


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

int main() {

    string s;

    cin >> s ;
  
  string ans = "Yes";

  
  	for(int i = 0; i < s.size(); i ++){
    	if(i%2 == 0){
        	if(s.at(i) == 'L'){
              ans = "No";
              break;
            }
        }else{
          if(s.at(i) == 'R'){
            ans = "No";
              break;
          }
        }
      
    }
   
    
  
  
  cout << ans << endl;





}



Measured memory_bytes: 256
import numpy as np
M,D = map(int,input().split())
a = 0
for i in np.arange(22,D+1):
  d10 = int(i/10)
  d01 = i-d10*10
  if d01 <= 1:
    continue
  if 0 < d10*d01 and d10*d01 <= M:
    a += 1
print(a)

Measured memory_bytes: 21408
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input()) - 1])


Measured memory_bytes: 2940
from operator import itemgetter

n = int(input())
l = []
for i in range(n):
    k = [j for j in input().split()]
    l.append([k[0], int(k[1]), i])

l.sort(key=lambda x:(x[0],-x[1]))

for i in range(n):
    print(l[i][2]+1)

Measured memory_bytes: 3060