akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

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

    return gcd(b, a % b);
}

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

int main(){
    std::ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> b >> a >> c >> d;
    ll c_d_lcm = lcm(c,d);

    ll a_c = a / c;
    ll a_d = a / d;
    ll a_c_d = a / c_d_lcm;
    ll a_ans = a - a_c - a_d + a_c_d;

    ll b_c = (b-1) / c;
    ll b_d = (b-1) / d;
    ll b_c_d = (b-1) / c_d_lcm;
    ll b_ans = (b-1) - b_c - b_d + b_c_d;

    cout << a_ans - b_ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, k, a[200100], i, j, b[200100]={0}, lo, cnt=0, f=0;
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<k;i++){
        for(j=0;j<n;j++){
            int l=max((long long)0,j-a[j]);
            int r=min(n-1,j+a[j]);
            b[l]++;
            if(r+1<n)b[r+1]--;
        }
        for(j=1;j<n;j++)b[j]+=b[j-1];
        for(j=0;j<n;j++){
            a[j]=b[j];
            if(b[j]==n) cnt++;
            b[j]=0;
            if(cnt==n){
                f=1;
                break;
            }
        }
        cnt=0;
        if(f==1) break;
    }
    for(i=0;i<n;i++){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;

}


Measured memory_bytes: 6752
#include <bits/stdc++.h>
#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 a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define int long long

int n;

int32_t main()
{
	IOS;
	cin >> n;
	int r, s = 0, t = n;
	while (n) {
		r = n % 10;
		s += r;
		n /= 10;
	}
	if (t % s)
		cout << "No" << endl;
	else 
		cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int R = scanner.nextInt();
        if (H >= 0) {
            System.out.println(1);
        } else if (H + R == 0) {
            System.out.println(0);
        } else {
            System.out.println(-1);
        }
    }

}



Measured memory_bytes: 26248
#include <bits/stdc++.h>
#define mp make_pair
using namespace std;

int a,b,c,d,x,y,z;
pair <int,int> dc[3];

inline int read()
{
	int x=0;char ch=getchar();bool f=false;
	while (ch<'0'||ch>'9'){if (ch=='-') f=true;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?-x:x;
}

int main()
{
	scanf("%d",&a);
	for (int i=1;i<=9;i++)
	{
		if (i*111>=a)
		{
			printf("%d\n",i*111);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# i番目は26 ^ i個
# i番目までの個数は 26 * (26 ^ i - 1) / 25

n = int(input())
_ = 96

# 桁数
ans = ''
while True:
  a, b = divmod(n, 26)
  #print(a, b)
  if b == 0:
    b = 26
    a -= 1
  ans += str(chr(b + _))
  if a == 0:
    break
  n = a
  
print(ans[::-1])

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int k;
  cin>>k;
  string s,b;
  cin>>s;
  if(s.size()<=k)
    cout<<s;
  else
  {
    for(int i=0;i<k;i++)
      b.push_back(s[i]);
    b.push_back('.');
    b.push_back('.');
    b.push_back('.');
           
  }
  cout<<b<<'\n';

}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s == "abc"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 764
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
#include<utility>
#include<tuple>
#include<cstdlib>
#include<cmath>
using namespace std;
#define ull unsigned long long
#define ll long long

int main() {
	ll n, z, w;
	cin >> n >> z >> w;
	vector<ll>a(n, 0);
	for (int i = 0; i < n; i++)cin >> a[i];
	if(n>1)	cout << max(abs(a[n - 1] - a[n - 2]), abs(a[n - 1] - w))<<endl;
	else cout << abs(a[n - 1] - w) << endl;

	return 0;
}





Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
$v = explode(" ",trim(fgets(STDIN)));

$o=array_map('current', array_chunk($v, 2));
$e=array_map('current', array_chunk(array_slice($v, 1), 2));

$oc = array_count_values($o);
$ec = array_count_values($e);

arsort($oc);
arsort($ec);

$cnt = 0;
foreach($ec as $k=>$v) {
  $okey[] = $k;
  $oval[] = $v;
  $ocnt[] = $N / 2 - $v;
  if ($cnt==1) break;
  $cnt++;
}
$cnt=0;
foreach($oc as $k=>$v) {
  $eekey[] = $k;
  $eeval[] = $v;
  $eecnt[] = $N / 2 - $v;
  if ($cnt==1) break;
  $cnt++;
}
$res = $eecnt[0]+$ocnt[0];
if ($eekey[0] == $okey[0]) {
  if (!isset($eekey[1]) && !isset($okey[1])) {
    $res = $N / 2;
  }
  else {
    $res = min($eecnt[0]+$ocnt[1],$eecnt[1]+$ocnt[0]);
  }
}

printf("%d\n",$res);


Measured memory_bytes: 60268
#include <stdio.h>
#include <iostream>
using namespace std;

typedef long long LL;

LL gcd(LL a,LL b)
{
	return b?gcd(b,a%b):a;
}

int main()
{
	LL a,b;
	cin>>a>>b;
	cout<<(a*b)/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;
    stack<char> t;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'S')t.push('S');
        if (s[i] == 'T') {
            if (t.size()!=0&&t.top() == 'S')t.pop();
            else t.push('T');
        }
    }
    cout << t.size() << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
const int N = 1010;
int dp[N][N];

int rec(int x, int p) {
  if(x < 0 || p < 0) return 0;
  if(!x) return !p;
  if(dp[p][x] != -1) return dp[p][x];
  int res = 0;
  for(int i = 0; i <= 5; ++i) {
    res |= rec(x - i, p - 1);
  }
  return dp[p][x] = res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  memset(dp, -1, sizeof dp);
  if(n % 100 == 0) {
    cout << 1 << '\n';
    return 0;
  }
  cout << (rec(n % 100, n / 100) ? 1 : 0) << '\n';
  return 0;
}


Measured memory_bytes: 4224
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();
		final int LEN = 51;
		
		long dp[][] = new long[LEN][LEN*LEN];
		dp[0][0] = 1;
		
		for (int i = 1; i <= N; i++) {
	      int x = sc.nextInt();
	      for (int j = i - 1; j >= 0; j--) {
		    for (int k = 0; k <= LEN*j; k++) {
              dp[j + 1][k + x] += dp[j][k];
			}
	      }
		}
		long ans = 0;
		for (int i = 1; i <= N; i++) {
          ans += dp[i][i*A];
        }
		System.out.println(ans);
	}
}

Measured memory_bytes: 25940
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-15;
ld PI = acos(-1.0);

void solve() {
    ll n, k;
    cin >> n >> k;
    vld a(n);
    rep(i, n) cin >> a[i];

    ld high = 1e9, low = 1.0;
    ll cnt = 0;
    while(cnt < 100) {
        ld mid = (high + low) / 2.0;
        ll sum = 0;
        rep(i, n) {
            ll m = a[i] / mid;
            if(a[i] / mid - (ld)m > EPS) ++m;
            sum += m;
        }
        if(sum <= k + n) high = mid;
        else low = mid;
        ++cnt;
    }
    ld ans = (high + low) / 2.0;
    ll ans2 = ans;
    if(ans - (ld)ans2 > EPS) ++ans2;
    cout << ans2 << endl;
    return;
}

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

Measured memory_bytes: 6360
#include "bits/stdc++.h"

using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define ld long double
 	#define lb lower_bound 
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
	#define all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
	
	 const int N =3e5+5;
	 const int lg=20;
	
	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};  
	 
	 
	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;	
	   }   
	   
mi mp;	   


void solve() {
	  
	  int n;
	  cin>>n;
	  vi a(n,0),b(n,0);
	  rep(i,0,n) {
		    cin>>a[i]>>b[i];
		  }
		  
		  sort(all(a));
		  sort(all(b));
		  
		  int x=0,y=0;
		  
		  if(n%2==1) {
			    x=a[n/2];
			    y=b[n/2];
			  }
		  else {
			     x=a[n/2-1]+a[n/2];
			     y=b[n/2-1]+b[n/2];
			  }	  
			  
			  cout<<y-x+1<<endl;		    
			  
		  } 
 
int32_t main() {
	cool;
	int t=1;	
	   //~ cin>>t;
	while(t--)
	   solve();		   
	   
	   return 0;	   
}


Measured memory_bytes: 6368
/**
 *    author:  tourist
 *    created: 31.03.2018 18:11:15       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63" << '\n';
    return 0;
  }
  vector<int> a;
  int s = 0;
  for (int i = 1; i <= 30000; i++) {
    if (i % 2 == 0 || i % 3 == 0) {
      a.push_back(i);
      s += i;
      if ((int) a.size() == n) {
        break;
      }
    }
  }
  int need = (6 - s % 6) % 6;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] + need <= 30000 && ((a[i] + need) % 2 == 0 || (a[i] + need) % 3 == 0)) {
      a[i] += need;
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << ' ';
    }
    cout << a[i];
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a[5],s,d,f,g,h,i,j;
	for(i=0;i<4;i++) scanf("%d",&a[i]);
	if(a[0]<a[2]) s=a[2];
	else s=a[0];
	if(a[1]<a[3]) d=a[1];
	else d=a[3];
	if(s<d) printf("%d\n",d-s);
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
XL = [inpl() for _ in range(N)]
XL.sort()

ans = 1
bx, bl = XL[0]
for i in range(1,N):
    nx, nl = XL[i]

    # print(bx,bl,nx,nl)
    if (nx-bx) >= bl+nl:
        bx = nx
        bl = nl
        ans += 1
    else:
        if nx + nl < bx+bl:
            bx = nx
            bl = nl
        else:
            continue



print(ans)


Measured memory_bytes: 29020
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    class Node
    {
        public int l;
        public char c;
        public Node prev;
    }

    public static void Main()
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();
        Node[][] dp = new Node[s.Length + 1][];
        for (int i = 0; i <= s.Length; i++)
        {
            dp[i] = new Node[t.Length + 1];
            for (int j = 0; j <= t.Length; j++)
                dp[i][j] = new Node();
        }
        for (int i = 1; i <= s.Length; i++)
        {
            for (int j = 1; j <= t.Length; j++)
            {
                if (s[i - 1] == t[j - 1])
                {
                    dp[i][j].c = s[i - 1];
                    dp[i][j].prev = dp[i - 1][j - 1];
                    dp[i][j].l = dp[i - 1][j - 1].l + 1;
                }
                else
                {
                    if(dp[i][j - 1].l< dp[i - 1][j].l)
                    {
                        dp[i][j].c = '\0';
                        dp[i][j].prev = dp[i - 1][j];
                        dp[i][j].l = dp[i - 1][j].l;
                    }
                    else
                    {
                        dp[i][j].c = '\0';
                        dp[i][j].prev = dp[i][j - 1];
                        dp[i][j].l = dp[i][j - 1].l;
                    }
                }
            }
        }

        Stack<char> w = new Stack<char>();
        for (Node i = dp[s.Length][t.Length]; i != null; i = i.prev)
        {
            if (i.c != '\0')
                w.Push(i.c);
        }
        while (w.Count > 0)
            Console.Write(w.Pop());
        Console.WriteLine();
    }
}


Measured memory_bytes: 376252
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  long long sum = 0;
  rep(i,N+1) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }

  cout << sum << endl;

  return 0;
}


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

int main(){
  int X;
  cin >> X;
  bool flag = false;
  for(ll A = -1000; A<=1000; A++){
    for(ll B = -1000; B<=1000; B++){
      if(X == A*A*A*A*A - B*B*B*B*B){
        cout << A << " " << B << endl;
        flag = true;
        break;
      }
    }
    if(flag){
      break;
    }
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+10;
const ll mod=1e9+7;
ll a[N]; 
int n,k;
int main(){
  cin>>n>>k;
  ++n;
  for(int i=1;i<=n;i++) a[i]=i-1;
  for(int i=1;i<=n;i++) a[i]+=a[i-1];
  ll ans=0;
   for(int i=k;i<=n;i++) 
     {
     	ll mi=a[i];
     	ll mx=a[n]-a[n-i];
     	ans=(ans+mx-mi+1)%mod;
	 }
	 cout<<ans;
return 0;
}


Measured memory_bytes: 5132
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        string s;
        cin>>s;
        ll cnt=0;
        for(int i=0;i<=n-3;i++)
        {
        	if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        		cnt++;
        }
        cout<<cnt;
    }
    return 0;
}

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

int main(void){
    int n,arr[3000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int ans=0;
    for(int i=1;i<n;i++){
        if(arr[i]==arr[i-1]){
            arr[i]=0;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# 入力割り当て
N = int(input())
i = 0
A = []
for i in range(N):
	A.append(int(input()))
A = sorted(A)

# 隣要素と比較し、同一でなければ加算
j = 0
ans = 1
for j in range(N-1):
	if A[j] != A[j+1]:
		ans += 1

# 結果の表示
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

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

	    int a=gi();
	    int b=gi();

        //System.out.println(Math.max(a+b, Math.max(a-b, a*b)));
        if (a<=8&&b<=8) {
        	System.out.print("Yay!");
        }else {
        	System.out.print(":(");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
#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() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans=0;
  if ((b-a)%2 == 0) ans = max(a,b)-(a+b)/2;
  else ans = min(n-max(a,b),min(a,b)-1)+1+(b-a-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           string s;
           cin >> s;
           
           int mxr = 0 , c = 0;
           for(int i = 0 ; i < 3 ; i++)
           {
               if(s[i] == 'R')
               {
                   c++;
               }else c = 0;
               mxr = max(mxr , c);
           }
               mxr = max(mxr , c);
           cout << mxr << endl;
        }
    }



Measured memory_bytes: 3584
import sys

N, K = map(int, sys.stdin.readline().split())

if K == 0:
    print(N*N)
    sys.exit()

# b は K 以上
# a は b * c + K <= a < b * (c+1)
ans = 0
for i in range(1, N+1):
    # print(N // i, (i - K), max(N % i - K, 0))
    tmp = (N // i) * max(i - K, 0) + max(N % i + 1 - K, 0)
    ans += tmp

print(ans)

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

using namespace std;

int main() {
	string a, b;
	cin>>a>>b;
	int m = a.length(), n = b.length();
	
	vector<vector<int>> dp(m+1, vector<int>(n+1,0));
	
	for(int  i = 1;i<=m;i++) {
		for(int j = 1; j <=n; j++) {
			if(a[i-1]==b[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
		}	
	}
	/*for(auto d : dp) {
		for(auto i : d) cout<<i<<" ";
		cout<<'\n';
	}
	*/
	//return 0;
	int i = m, j= n;
	string str = "";
	while( i > 0 && j > 0) {
		if(a[i-1] == b[j-1]) {
			str = a[i-1] + str;
			i--;
			j--;
		}
		else if(dp[i-1][j] > dp[i][j-1]) {
			i--;
		}
		else{
			j--;
		}
	}
	cout<<str<<'\n';
	//cout<<0;
	return 0;

}

Measured memory_bytes: 35584
#include<stdio.h>
int main(void)
{
	int h,w,i,j;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0) break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}



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

int main()
{
    char A[3], B[3], C[3];
    memset(A, 0, sizeof(A));
    memset(B, 0, sizeof(B));
    memset(C, 0, sizeof(C));
    scanf("%s %s %s", A, B, C);
    printf("%c%c%c", A[0], B[1], C[2]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using vvi = std::vector<std::vector<int>>;

void solve()
{
    using namespace std;

    constexpr int inf = (1 << 23);

    int n;
    cin >> n;

    vector<int> d(n + 1);

    for (int i = 0; i < n; ++i)
    {
        cin >> d[i];
        if(i + 1 != n)
            cin.ignore(numeric_limits<streamsize>::max(), ' ');
    }

    cin.ignore(numeric_limits<streamsize>::max(), ' ');
    cin >> d[n];

    vvi dp (n, vector<int>(n, 0));

    //自分自身との積は乗算が発生しない
    for (int i = 0; i < n; ++i)
        dp[i][i] = 0;

    for (int l = 1; l < n; ++l)
    {
        for (int i = 0; i < n - l; ++i)
        {
            int j = i + l;
            dp[i][j] = inf;
            for (int k = i; k < j; ++k)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + d[i] * d[k + 1] * d[j + 1]);
            }
        }
    }

    cout << dp[0][n - 1] << endl;
}

int main()
{
    solve();
        return 0;
}
        


Measured memory_bytes: 3144
import sys
from io import StringIO
import unittest

def resolve():
    N, = map(int, input().split())

    kmin=100000000000
    kmax = 0
    lmin = 100000000000
    lmax = 0
    for i in range(N):
        x,y = map(int, input().split())
        k = y-x
        l = y+x
        kmin = min(kmin,k)
        lmin = min(lmin, l)
        kmax = max(kmax, k)
        lmax = max(lmax, l)


    print(max(kmax-kmin,lmax-lmin))
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 1
2 4
3 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
1 1
1 1"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 73812
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    a = np.fromstring(read(), np.int64, sep=' ')[1:]
    a = a[a % 2 == 0]
    if np.all((a % 3 == 0) | (a % 5 == 0)):
        print('APPROVED')
    else:
        print('DENIED')

if __name__ == '__main__':
    main()


Measured memory_bytes: 27288
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string s,t;
   cin >> s >> t;

   int ans = -1;
   rep(i,s.size()){
      if(s == t) {
         ans = 1;
         break;
      }
      s = s.back() + s.substr(0, s.size() -1 );//末尾要素を取得してから足し合わせ
   }

   if(ans == 1) cout << "Yes" << endl;
   else cout << "No" << endl;
   





   return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h,w,i,j;
    char a[52][52];
    cin >> h >> w;
    for(i = 1; i <= h; i++){
        for(j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }
    for(i = 0; i <= h+1; i++){
        for(j = 0; j <= w+1; j++){
            a[i][j] = '.';
            if(i != 0 && i != w+1)
                j = w+1;
        }
    }
    for(i = 1; i <= h; i++){
        for(j = 1; j <= w; j++){
            if(a[i][j] == '#' && a[i-1][j] == '.' && a[i][j-1] == '.' && a[i][j+1] == '.' && a[i+1][j] == '.'){
                cout << "No\n";
                return 0;
            }
        }
    }
    printf("Yes\n");
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a,b,c=0,i;
   scanf("%d",&a);
   for(i=0;i<3;i++){
    b=a%10;
    if(b==1){
        c++;
    }
    a/=10;
}
printf("%d\n",c);
return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, m, min_x, temp = 0, ans = 0;

	cin >> n >> m;
	vector<int> x(m);
	vector<int> diff_x(m - 1);
	for (int i = 0; i < m; i++)
		cin >> x[i];
	sort(x.begin(), x.end());
	ans = x[m - 1] - x[0];
	for (int i = 0; i < m - 1; i++)
		diff_x[i] = x[i + 1] - x[i];
	sort(diff_x.begin(), diff_x.end());
	if (m <= n)
	{
		n = 0;
		ans = 0;
	}
	for (int i = 0; i < n - 1; i++)
		ans -= diff_x[m - 2 - i];
	cout << ans << endl;
}


Measured memory_bytes: 4108
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int MAX_N = 51;

int64 sz[MAX_N], cnt[MAX_N];

void precalc() {
	sz[0] = cnt[0] = 1;

	for(int i = 1; i < MAX_N; ++i) {
		sz[i]  = 2 * sz[i - 1] + 3;
		cnt[i] = 2 * cnt[i - 1] + 1; 
	}
}

std::map<pair<int, int64>, int64> mem;

int64 get(int layer, int64 x) {
	auto arg = std::make_pair(layer, x);

	if(mem.count(arg)) {
		return mem[arg];
	}

	if(layer == 0) {
		return (mem[arg] = x);
	}

	if(x > 0) {
		if(x == sz[layer]) {
			return (mem[arg] = cnt[layer]);
		} else {
			int64 rez = 0;

			rez += get(layer - 1, std::min(x - 1, sz[layer - 1]));

			if(x >= sz[layer - 1] + 2) {
				++rez;
				rez += get(layer - 1, std::min(x - sz[layer - 1] - 2, sz[layer - 1]));
			}

			return (mem[arg] = rez);
		}
	}

	return (mem[arg] = 0);
}

void solve() {
	int n;
	int64 x;

	cin >> n >> x;
	cout << get(n, x) << '\n';
}

int main() {
	init_IO();

	precalc();
	solve();

	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a_unique = list(set(a))
a_unique.sort()

if len(a_unique) == 1 and a[0] == 0:
    ans = 'Yes'
elif len(a) % 3 == 0 :
    if len(a_unique) == 3:
        if bin(a_unique[0]) == bin(a_unique[1] ^ a_unique[2]) and bin(a_unique[1]) == bin(a_unique[0] ^ a_unique[2]) and bin(a_unique[2]) == bin(a_unique[1] ^ a_unique[0]) and a.count(a_unique[1]) == N//3 and a.count(a_unique[0]) == N//3 :
            ans = 'Yes'
        else:
            ans = 'No'
    elif len(a_unique) == 2:
        if a_unique[0] == 0 and a.count(a_unique[1]) == N//3 * 2:
            ans = 'Yes'
        else:
            ans = 'No'
    else:
        ans = 'No'
else:
    ans = 'No'

print(ans)



Measured memory_bytes: 14704
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (T &i : v) os << i << ' ';
    return os;
}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n, m;
    cin >> n >> m;
    scc_graph scc(n);
    while (m--) {
        ll a, b;
        cin >> a >> b;
        scc.add_edge(a, b);
    }

    auto v = scc.scc();
    co(v.size());
    for (auto &i : v){
        cout << i.size() << ' ';
        for (auto &j : i) cout << j << ' ';
        cout << '\n';
    }

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/
ll GCD(ll c, ll d){
    return (d ? GCD(d, c%d) : c);
}

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    ll a,b,c,d; cin >>a >> b>> c>>d;

    ll ans1 = ((b) / c) - ((a-1) / c);
    ll ans2 = b/d - (a-1)/d;
    ll e = (c*d/GCD(c, d));
    ll ans3 = b/e - (a-1)/e;
    ll answer = b - a + 1 -ans1 -ans2 +ans3; 
    cout << answer <<'\n';
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vint a(n), b(n);
    vint c(n - 1);
    rep(i, n) {
        cin >> a[i];
        --a[i];
    }
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];

    int ans = 0;
    rep(i, n) {
        ans += b[a[i]];
        if (i > 0 && a[i - 1] == a[i] - 1) {
            ans += c[a[i - 1]];
        }
    }
    cout << ans << endl;
}

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



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

int a[105];

int main()
{
    int n;
    scanf("%d",&n);
    int x=0;
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]<a[i-1])
        {
            for(int g=i;g>=0;g--)
            {
                if(a[g]<a[g-1])
                {
                    int t=a[g];
                    a[g]=a[g-1];
                    a[g-1]=t;
                    x++;
                }
            }
            i=n;
        }
    }
    for(int i=0;i<n;i++)
        if(i!=n-1)
            printf("%d ",a[i]);
        else
            printf("%d\n",a[i]);
    printf("%d\n",x);
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int digits = S.size();
    int N = stoi(S);

    int ans = 0;
    if (digits % 2 == 0) {
        digits--;
    } else {
        ans += N - pow(10, digits - 1) + 1;
        digits = digits - 2;
    }
    
    while (digits > 0) {
        ans += pow(10, digits - 1) * 9;
        digits = digits - 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define BUFSIZE 10000
int n=0;
int main(void){
char hoge[BUFSIZE];
     scanf("%s",hoge);
for(int i=0;i<BUFSIZE;i++){
    n++;    
    if(hoge[i]=='\0')
    break;
    
    }

for(int i=0;i<n-1;i++){
    printf("x");    
    }
}

Measured memory_bytes: 128
import sys, math

N = int(input())
genders = ['Male', 'Female']
low = 0
high = N - 1

tmp_seat = low
print(tmp_seat)

start = input()

tmp_seat = math.ceil((high + low) / 2)
print(tmp_seat)

while True:
    i = input()
    if i == 'Vacant':
        break
    else:
        if (tmp_seat % 2 == 0 and i == start) or (tmp_seat % 2 != 0 and i != start):
            low = tmp_seat   
        else:
            high = tmp_seat
        
        tmp_seat = math.ceil((high + low) / 2)
        print(tmp_seat)
            
sys.stdout.flush()

Measured memory_bytes: 3660
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)    sort(all(v)); (v).erase(unique(all(v)),(v).end())
#define printmatrix(a,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
//#define int long long

/*/-----------------------------Code begins----------------------------------/*/
int main(){
string s,d;
cin>>s>>d;
int n=s.size(),m=d.size();
int dp[n+1][m+1];
for(int i=0;i<=n;i++)
    dp[i][0]=0;
for(int j=0;j<=m;j++)
    dp[0][j]=0;
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        if(s[i-1]==d[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
}
vector<char> v;
//to print lcs
int i=n,j=m;
while(i>0&&j>0){
   if(dp[i][j]==dp[i-1][j])
    i--;
   else if(dp[i][j]==dp[i][j-1])
    j--;
   else {
    v.pb(s[i-1]);
    i--;
    j--;
   }
}
/*
cout<<"  ";
For(i,0,m)
cp(d[i]);
cout<<endl;
For(i,1,n+1){
    cout<<s[i-1]<<" ";
For(j,1,m+1)
    cout<<dp[i][j]<<" ";
cout<<endl;}*/
reverse(v.begin(),v.end());
for(auto &x:v)
cout<<x;
}
// abyxb axyb




















Measured memory_bytes: 35456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<vector<int>> d(n, vector<int>(2)); REP(i, n) REP(j, 2) cin >> d[i][j];
  FOR(i, 2, n) {
    if (d[i - 2][0] == d[i - 2][1] && d[i - 1][0] == d[i - 1][1] && d[i][0] == d[i][1]) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3656
from itertools import combinations

n = int(input())
l = (1 << n) - 1
r = range(n)
a = [[0, 0] for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y] |= 1 << x - 1

def fail(x):
  x = sum(1 << i for i in x)
  return not all(a[i][0] & x == a[i][1] & l - x == 0 for i in r if x >> i & 1)

while all(map(fail, combinations(r, n))):
  n -= 1
print(n)


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
char s[10];
int main(){
	    scanf("%s",s);
    int len = strlen(s);
    if(len==2) printf("%s\n",s);
    else
    {	swap (s[0],s[2]);
    	printf("%s\n",s);}
	return 0;
}	

Measured memory_bytes: 256
N = int(input())
ds = [int(input()) for i in range(N)]

max_d = 101
c = 0
answer = []

while len(ds) > 0:
  max_ds = max(ds)
  # if max_ds < max_d:
  max_d = max_ds
  c+=1
  ds = [d for d in ds if d != max_ds]

print(c)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  
  
  int N, k, best = 0; cin >> N >> k;
  vector<vector<int>> cell(2 * k, vector<int>(2 * k, 0));

  auto get = [&](int bx, int by, int tx, int ty){
    int cur = cell[tx][ty];
    if(bx > 0) cur -= cell[bx - 1][ty];
    if(by > 0) cur -= cell[tx][by - 1];
    if(bx > 0 && by > 0) cur += cell[bx - 1][by - 1];

    return cur;
  };

  for(int rep = 0; rep < N; ++rep){
    int x, y; cin >> x >> y;
    char c; cin >> c;
    if(c == 'W') x += k;
    x %= 2 * k;
    y %= 2 * k;
    cell[x][y]++;
  }
//
//  for(int r = -1; r < 2 * k; ++r){
//    for(int c = -1; c < 2 * k; ++c){
//      cout << cell[r][c] << " ";
//    }
//    cout << "\n";
//  }
//

//  cout << "\n\n";

  for(int r = 0; r < 2 * k; ++r){
    for(int c = 0; c < 2 * k; ++c){
      cell[r][c] += (r > 0 ? cell[r - 1][c] : 0)
                  + (c > 0 ? cell[r][c - 1] : 0)
                  - (r * c > 0 ? cell[r - 1][c - 1] : 0);
    }
  }
  
//  for(int r = 0; r < 2 * k; ++r){
//    for(int c = 0; c < 2 * k; ++c){
//      cout << cell[r][c] << " ";
//    }
//    cout << "\n";
//  }
//
  for(int r = 0; r < k; ++r){
    for(int c = 0; c < k; ++c){
      int cur = 0;
      cur += get(0, 0, r, c)
           + get(r + 1, c + 1, r + k, c + k)
           + get(r + k + 1, c + k + 1, 2 * k - 1, 2 * k - 1)
           + get(r + k + 1, 0, 2 * k - 1, c)
           + get(0, c + k + 1, r, 2 * k - 1);
      best = max({best, cur, N - cur});
    }
  }

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

Measured memory_bytes: 16000
#include <cstdio>
#include <vector>
const int MAXN = 605;
double dp[MAXN];
std::vector<int> G[MAXN];
int M, N;

// 1. Fix an edge to block
// 2. Try blocking every edge
// 3. Only need to consider blocking worst outgoing edge for each node
// 4. Fix a node to block outgoing edges
// 5. Try blocking only the worst edge

double solve(int node) {
    // Block outgoing edges from `node` only
    for (int i = 1; i <= N; ++i) {
        dp[i] = 0.0;
    }
    for (int i = N-1; i >= 1; --i) {
        int K = G[i].size();
        if (K == 1) {
            dp[i] = dp[G[i][0]] + 1.0;
            continue;
        }
        double max = 0.0;
        double sum = 0.0;
        int skip = 1;
        for (auto nxt: G[i]) {
            sum += dp[nxt];
            max = std::max(dp[nxt], max);
        }
        if (i != node) {
            max = 0.0;
            skip = 0;
        }
        dp[i] = 1.0 * (sum - max) / (K - skip) + 1.0;
    }
    return dp[1];
}

int main() {
    scanf(" %d%d", &N, &M);
    for (int i = 0; i < M; ++i) {
        int s, t;
        scanf(" %d%d", &s, &t);
        G[s].push_back(t);
    }
    double ret = N;
    for (int i = 1; i <= N; ++i) {
        ret = std::min(solve(i), ret);
    }
    printf("%.9f\n", ret);
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a,b,c,d; cin >>a >> b >> c >> d;
    ll ans = -1001001001001001001;
    chmax(ans, a*c);
    chmax(ans, a*d);
    chmax(ans, b*c);
    chmax(ans, b*d);

    cout << ans << endl;
}

Measured memory_bytes: 3644
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b,c,k=MI()
if k<=a:
    ans=k
elif k<=a+b:
    ans=a
else:
    ans=a-(k-a-b)
print(ans)

Measured memory_bytes: 9488