akhauriyash/Code-Regression huggingface dataset:
nums=[int(s) for s in input().split()]

x=nums[0]
n=nums[1]

if n==0:
  print(x)
else:
  row=[int(s) for s in input().split()]
  ls=[]
  for i in range(0,220):
    if i not in row:
      ls.append(abs(i-x))

  ls.sort()

  if x-ls[0] not in row:
    print(x-ls[0])
  else:
    print(x+ls[0])


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

using namespace std;

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

  double ans = 0;
  double base = 1. / N;
  for (int i = 1; i <= N; ++i) {
    int cnt = 0;
    int tmp = i;
    while (tmp < K) {
      tmp = tmp * 2;
      cnt++;
    }
    ans += base * pow(0.5, cnt);
  }
  printf("%.12f\n", ans);
  return 0;
}



Measured memory_bytes: 256
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define cin_desync()                                                           \
    do {                                                                       \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    } while (0)

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

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int max_N = 2e5 + 10;
int A[max_N];

ll sadness(ll b);

int N;
int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    ll low = -N, high = 1e9, best = 0;
    while(low <= high) {
        ll mid = (low + high) >> 1;
        ll curr = sadness(mid), mr = sadness(mid + 1), ml = sadness(mid - 1);

        if (mr < curr) {
            low = mid + 1;
        } else if (ml < curr) {
            high = mid - 1;
        } else {
            best = mid;
            break;
        }
    }

    cout << sadness(best) << endl;
}

ll sadness(ll b) {
    ll sad = 0;
    for (int i = 1; i <= N; ++i) {
        sad += abs(A[i] - (b + i));
    }

    return sad;
}


Measured memory_bytes: 1024
#include <iostream>

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

char c[101][101];
char cT[201][101];

int main()
{
  int h, w;
  cin >> h >> w;

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 1; i <= 2 * h; i++) {
    for (int j = 1; j <= w; j++) {
      cT[i][j] = c[(i + 1) / 2][j];
    }
  }
  for (int i = 1; i <= 2 * h; i++) {
    for (int j = 1; j <= w; j++) {
      if (j == w) {
        cout << cT[i][j] << endl;
      } else {
        cout << cT[i][j];

      }
      // cout << "i: " << i << ", " << "j: " << j << " => "<< cT[i][j] << endl;
    }
  }

}


Measured memory_bytes: 504
#include <stdio.h>
int main(void)
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r); 
    if((x >= r && x <= W-r) && (y >= r && y <= H-r))
    printf("Yes\n");
    else
        printf("No\n"); 
        
    return 0;
} 


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    ll pre;
    cin >> pre;
    ll ans = 1, up = 0, dn = 0;
    rep(i, 1, n) {
        ll a;
        cin >> a;
        if (pre < a) up = 1;
        if (pre > a) dn = 1; 
        if (up && dn) {
            up = dn = 0;
            ans++;
        }
        pre = a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K=map(int,input().split())
D=list(map(int,input().split()))
for i in range (N,100000):
    a=str(i)
    b=list(map(int,a))
    l=len(b)
    c=0
    for j in range(l):
        if(b[j] in D):
            c=1
    if(c==0):
        ans=i
        break
print(ans)

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << a*b/2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String l[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("",0);
        String po=sc.next();
        int i=0;
        while(po.length()==4){
            po=po.replace(l[i],"");
            i++;
        }
        if(po.length()==2){
            i=0;
            while(po.length()==2){
                po=po.replace(l[i],"");
                i++;
            }
            if(po.length()==0)
            System.out.println("Yes");
            else 
            System.out.println("No");
        }
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <deque>

using namespace std;

typedef long long ll;

ll cupon_hash(int x, int y)
{
	return (ll)x * (ll)1e6 + (ll)y;
}

int main(void)
{
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B);
	vector<tuple<int,int, int>> cupons(M);

	int min_a = 1e8;
	int min_b = 1e8;

	for (int i = 0; i < A; i++)
	{
		cin >> a[i];
		min_a = min(a[i], min_a);
	}

	for (int i = 0; i < B; i++)
	{
		cin >> b[i];
		min_b = min(b[i], min_b);
	}

	for (int i = 0; i < M; i++)
	{
		int x, y, c;
		cin >> x >> y >> c;
		cupons[i] = make_tuple(x, y, c);
	}


	int min_cost = min_a + min_b;

	for (auto cupon : cupons)
	{
		int x = get<0>(cupon)-1;
		int y = get<1>(cupon)-1;
		int c = get<2>(cupon);
		min_cost = min(min_cost,a[x]+b[y]-c);
	}

	cout << min_cost << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;

int main () {
  
  string s, t;
  cin >> s >> t;
  
  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));
  
  /*
  int dp[s.size() + 1][t.size() + 1] = {0};
  */
  
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) {
      
      dp[i + 1][j + 1] = dp[i + 1][j];
      
      if (dp[i + 1][j + 1] < dp[i][j + 1]) {
        dp[i + 1][j + 1] = dp[i][j + 1];
      }
      
      if (s[i] == t[j] && dp[i + 1][j + 1] < dp[i][j] + 1) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      }
      
    }
  }
  
  int x = (int)s.size(), y = (int)t.size();
  string res = "";
  
  while (x > 0 && y > 0) {
    
    if (x > 0 && dp[x][y] == dp[x - 1][y]) {
      x--;
      continue;
    }
    
    if (y > 0 && dp[x][y] == dp[x][y - 1]) {
      y--;
      continue;
    }
    
    x--;
    y--;
    res = s[x] + res;
    
  }
  
  cout << res << endl;
  
}

Measured memory_bytes: 35584
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n;
int sum[300010];
vector<int> c;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n;c.resize(n);
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		
		c[x-1]++;
	}
	
	sort(all(c));
	
	for(int i=0;i<n;i++)sum[i+1]=sum[i]+c[i];
	
	int ans=n;
	
	for(int i=0;i<n;i++)
	{
		while(ans&&(n-(int)(lower_bound(all(c),ans)-c.begin()))+sum[(int)(lower_bound(all(c),ans)-c.begin())]/ans<i+1)ans--;
		
		cout<<ans<<endl;
	}
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    int a[n],c[n];
    int sum = 0;
    rep(i,0,n) cin>>a[i];
    rep(i,0,n){
        int b; cin>>b;
        sum+=b;
    }
    rep(i,0,n-1) cin>>c[i];

    rep(i,0,n-1){
        if(a[i]+1==a[i+1]) sum+=c[a[i]-1];
    }
    cout<<sum<<endl;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int l, r;
    cin >> l >> r;
    int d = r - l;
    ll ans = 2020;
    if(r - l <= 2019){
        for(ll i = l; i <= r; i++){
            for(ll j = i + 1; j <= r; j++){
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans;
    }else{
        cout << 0;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
n = int(input())
x, y = [list(map(int, input().split())) for _ in range(2)]
print(sum([abs(x[i] - y[i]) for i in range(n)]))
print(pow(sum([(x[i] - y[i]) ** 2 for i in range(n)]), 1/2))
print(pow(sum([abs(x[i] - y[i]) ** 3 for i in range(n)]), 1/3))
print(max([abs(x[i] - y[i]) for i in range(n)]))

Measured memory_bytes: 6788
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>

int main(void)
{
    int64_t N, W;
    std::cin >> N >> W;

    struct Item {
        int64_t w;
        int64_t v;
    };

    int64_t dp[N+1][W+1];
    memset(dp, 0, sizeof(dp));

    for (int64_t n = 1; n <= N; ++n) {
        Item item;
        std::cin >> item.w >> item.v;
        for (int64_t w = 1; w <= W; ++w) {
            if (w < item.w) {
                dp[n][w] = dp[n-1][w];
            } else {
                dp[n][w] = std::max(item.v + dp[n-1][w-item.w], dp[n-1][w]);
            }
        }
    }

    std::cout << dp[N][W] << std::endl;

    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n, a, b;
    cin >> n >> a >> b;
    vector<int> board(n, 0);
    board[a-1] = 1;
    board[b-1] = 1;
    int player = 1; // 1: A, 0: B

    int ptr_a = a-1;
    int ptr_b = b-1;

    while(1){
        if(player){
            if(board[ptr_a+1] == 0){
                board[ptr_a+1] = 1;
                ++ptr_a;
            }
            else{
                if(ptr_a == 0){
                    puts("Borys");
                    return 0;
                }
                board[ptr_a] = 0;
                --ptr_a;
            }
        }
        else{
            if(board[ptr_b-1] == 0){
                board[ptr_b-1] = 1;
                --ptr_b;
            }
            else{
                if(ptr_b == n-1){
                    puts("Alice");
                    return 0;
                }
                board[ptr_b] = 0;
                ++ptr_b;
            }
        }
        player = 1 - player;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int num;
  double w,h;
  
  while(scanf("%d",&num) != EOF){
    scanf(",%lf,%lf",&w,&h);
    if( w/(h*h) >= 25.0 ) cout << num << endl;
  }

  return 0;
}

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;
int a[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }  
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  string keys;
  getline(cin,keys);

  string str;
  vector<string> vs;
  while(getline(cin,str))
    vs.emplace_back(" "+str);

  vs.emplace(vs.begin(),"base:");
  
  Int n=vs.size();
  vector<Int> ind(n,0);
  for(Int i=0;i<n;i++)
    while(vs[i][ind[i]]==' ') ind[i]++;

  vector< map<string, Int> > pos(n);
  vector<string> val(n);
  
  MFP([&](auto dfs,Int i,Int p)->Int{
        // cout<<i<<" "<<p<<endl;
        
        string key;
        Int j=ind[i];
        while(vs[i][j]!=':') key+=vs[i][j++];        
        if(~p) pos[p][key]=i;
        
        j++;        
        val[i]=vs[i].substr(j);

        Int res=i+1;
        if(!val[i].empty()) return res;
        
        do{       
          res=dfs(res,i);
        }while(res<n&&ind[i]<ind[res]);

        return res;
      })(0,-1);
  
  Int cur=0;
  for(Int i=0;i<(Int)keys.size();i++){
    if(keys[i]!='.') continue;
    string nxt;
    Int j=i+1;
    while(j<(Int)keys.size()&&keys[j]!='.')
      nxt+=keys[j++];

    if(!pos[cur].count(nxt)){
      cout<<"no such property"<<endl;
      return 0;
    }
    
    cur=pos[cur][nxt];    
  }
  
  if(val[cur].empty()) cout<<"object"<<endl;
  else cout<<"string \""<<val[cur].substr(1)<<"\""<<endl;
  return 0;
}



Measured memory_bytes: 3424
n = int(input())
A = sorted(list(map(int, input().split())))

from itertools import accumulate

ans = 1
cumsum = list(reversed(list(accumulate(A))))

for a,cs in zip(reversed(A), cumsum[1:]):
    if a <= 2*cs:
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 20672
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

const int mod = 1000000007;
struct mint {
    ll x; // using long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    int n = sz(s);

    vector<vector<mint>> dp(n + 1, vector<mint>(4));
    dp[0][0] = 1;
    rep(i, n) {
        dp[i + 1][0] = dp[i][0];
        if (s[i] == '?') dp[i + 1][0] *= 3;
        rep(j, 3) {
            dp[i + 1][j + 1] += dp[i][j + 1];
            if (s[i] == '?') dp[i + 1][j + 1] += dp[i][j + 1] * 2;
            if (s[i] == 'A' && j != 0) continue;
            if (s[i] == 'B' && j != 1) continue;
            if (s[i] == 'C' && j != 2) continue;
            dp[i + 1][j + 1] += dp[i][j];
        }
    }
    cout<<dp[n][3]<<endl;
}

Measured memory_bytes: 7376
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(365)]

now = [0]*26
for i in range(365):
    no = -1
    score = -10**10
    for j in range(26):
        count = s[i][j]
        for k in range(26):
            if j == k:
                continue
            count -= (i+1-now[k])*c[k]
        if count > score:
            no = j
            score = count
    print(no+1)
    now[no] = i+1
    
    


Measured memory_bytes: 9400
#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;
constexpr ll MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n, 0);
  ll ans = 1;
  ll zero = 3;
  for(int i = 0; i < n; i++) {
    b[a[i]]++;
    if(a[i] == 0) {
      ans *= zero;
      zero--;
    } else {
      ans *= b[a[i] - 1];
      b[a[i] - 1]--;
    }
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

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

    vector<int> R,G,B;
    int64_t ans = 0;

    rep(i,n){
        if(s[i] == 'R')R.push_back(i);
        else if(s[i] == 'G')G.push_back(i);
        else if(s[i] == 'B')B.push_back(i);
    }

    for(int r:R){
        for(int g:G){
            int lar = max(r,g);
            int sma = min(r,g);
            int dis = lar - sma;
            int m = 0;
            if(binary_search(all(B),sma - dis))m++;
            if(binary_search(all(B),lar + dis))m++;
            if(dis%2==0){
                if(binary_search(all(B),sma + (dis/2)))m++;
            }
            ans += B.size() - m;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int prev_prev =0;
	int prev=abs(a[2]-a[1]);
	
	int current=0;
	if(n==2)
	{
		cout<<abs(a[2]-a[1]);
		return 0;
	}
	
	for(int i=3;i<=n;i++)
	{
		current=min(abs(a[i-1]-a[i])+prev,abs(a[i-2]-a[i])+prev_prev);
		prev_prev=prev;
		prev = current;
		//cout<<current<<endl;
	}
	cout<<current<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e18 + 17;
const int maxn = 1e5 + 10;
const int maxq = 1e2 + 10;
const int alf = 26;
const ll dlm = 1e9 + 7;
const int del = 998244353 ;
const int eps = 1e-7 ;


int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a*b)/2;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 111;

int N;

int main() {
    cin >> N;
    if (N&1) {
        cout << ((N-1)*(N-2)+N-1)/2 << endl;
        FOR (i, 1, N) cout << i << " " << N << endl;
        FOR (i, 1, N) FOR (j, i+1, N) {
            if (i+j != N) cout << i << " " << j << endl;
        }
    } else {
        cout << (N*(N-1)-N)/2 << endl;
        FOR (i, 1, N+1) FOR (j, i+1, N+1) {
            if (i+j != N+1) cout << i << " " << j << endl;
        }
    }
}

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

using namespace std;

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

    long long n;
    cin >> n;
    int res = 0;
    int last = -1;
    for(long long i = 2; i * i <= n; i ++){
        int cnt = 0;
        while(n % i == 0){
            n /= i;
            cnt ++;
        }
        for(int j = 1;; j ++){
            if(cnt < j) break;
            res ++;
            cnt -= j;
        }
    }
    if(n > 1) res ++;
    cout << res << "\n";
}


Measured memory_bytes: 3656
def main():
    N = int(input().strip())
    b = [None for _ in range(N)]

    index = N // 2
    # 追加場所
    side = -1
    if N % 2 == 0:
        side = 1

    a = map(int, input().strip().split())
    for i, a in enumerate(a):
        index = index + (side * i)
        b[index] = a
        # 追加場所の左右反転
        side *= -1
    print(" ".join(map(str, b)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 28136
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import collections
N=int(input())
A=list(map(int,input().split()))
S=sum(A)
D=collections.Counter(A)
Q=int(input())
for i in range(Q):
    B,C=map(int,input().split())
    S+=(C-B)*D[B]
    D[C]+=D[B]
    D[B]=0
    print(S)


Measured memory_bytes: 24260
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  var m = readLine.split(" ").map(_.toInt)
  while( (m(0),m(1)) != (0,0) ){
    val Array(n,x) = m
    println( ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) => sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length })

    m = readLine.split(" ").map(_.toInt)
  }
}

Measured memory_bytes: 44024
#include <iostream>
#include <string>
using namespace std;
int main()
{
 int i,k,r,p,s,n,c;
 c=0;
 string a,b;
 b="";
 cin >> n >> k;
 cin >> r >> s >> p;
 cin >> a;
 for(i=0;i<n;i++)
 {
  if(a[i]=='r')
  b.append(1,'p');
  else if(a[i]=='s')
  b.append(1,'r');
  else
  b.append(1,'s');
  if(i>=k)
  {
   if(b[i]!=b[i-k])
   {
    if(a[i]=='r')
    c+=p;
    else if(a[i]=='s')
    c+=r;
    else
    c+=s;
   }
   else
   b[i]='#';
  }
  else
  {
   if(a[i]=='r')
   c+=p;
   else if(a[i]=='s')
   c+=r;
   else
   c+=s;
  }
 }
 cout << c;
 return 0;
}

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

int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    ll guu = 0;
    if (n % 2 == 0) guu = 1;
    else guu = 0;
    ll dir = 0;
    ll posi = n-1;
    for (int i = 0; i < n; ++i) {
        cout << a[posi] << " ";
        if (dir == 0) {
            posi -= 2;
        }
        else {
            posi += 2;
        }
        if (posi < 0) {
            dir = 1;
            if (guu) posi = 0;
            else posi = 1;
        }
    }



}


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

int main() {
  int A, B, C, D;
  cin >> A >> B>> C >>D;

  if ( A+B > C+D ) {
    cout << "Left" << endl;
    }
  else if ( A+B == C+D ) {
    cout << "Balanced" << endl;
    }
  else if ( A+B < C+D ) {
    cout << "Right" << endl;
    }
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int H=nextInt();
		int W=nextInt();

		String[][] a = new String[H][];
		for(int i=0;i<H;i++){
			a[i]=toStringArray(nextString());
		}
		int[] alph = new int['z'-'a'+1];
		Arrays.fill(alph, 0);
		for(int i=0;i<a.length;i++){
			for(int k=0;k<a[i].length;k++){
				alph['z'-a[i][k].charAt(0)]++;
			}
		}
		int n4=0;
		int n2=0;
		int n=0;

		for(int i=0;i<alph.length;i++){
			if(alph[i]==0){
				continue;
			}
			n4+=alph[i]/4;
			if(alph[i]%4==2){
				n2++;
			}else if(alph[i]%4==0){

			}else{
				n++;
			}
		}
		if(n>1){
			System.out.println("No");
			return ;
		}

		if(H%2==0&&W%2==0){
			if(n2==0&&n==0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else {
			int x = H*W-n4*4;
			int o =0;
			if(H%2==1&&W%2==1){
				o=H+W-1;
			}else if(H%2==1){
				o=W;
			}else{
				o=H;
			}
			if(x<=o){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22740
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int i = 0;int size = 0;int max = 0;
    while(i<s.size()){
        if(s.at(i) == 'A' or s.at(i) == 'T' or s.at(i) == 'C' or s.at(i) == 'G'){
            size += 1;
        }else{
            size = 0;
        }
        if(max < size){
            max = size;
        }
        i++;
    }
    cout << max << endl;
}

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


int main(){
  vector<char>v={'y','u','i','o','p','h','j','k','l','n','m'};
  while(true){
    string s;int ans=0;
    cin>>s;
    int n=s.size();
    if(s=="#")break;
    rep(j,n){
    bool b=false;
    rep(i,v.size()){
      if(v[i]==s[j])b=true;
    }
    if(b)s[j]='r';
    else s[j]='l';
    }
    rep(i,n-1){
      if(s[i]!=s[i+1])ans++;
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

#define MOD 1000000007

typedef long long int llint;

int N;

int main() {
	cin >> N;
	vector<llint> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	llint ans = 0;
	for (int i = 0; i < 60; i++) {
		llint ones = 0;
		llint zeros = 0;
		for (int k = 0; k < N; k++) {
			if (A[k] & 1) { ones++; }
			else { zeros++; }
			A[k] = A[k] >> 1;
		}
		ans += ((llint)pow(2, i) % MOD * ones % MOD * zeros % MOD) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
//Work should be challenging and challange should be fun

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll x;
    cin>>x;
    if(x==1) cout<<"0";
    else cout<<"1";
}

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

ll a;
std::string b;

int main(){
    cin >> a;
    cin >> b;
    int b_int100 = stoi(b.substr(0, 1))*100 + stoi(b.substr(2, 1))*10 + stoi(b.substr(3, 1));
    ll c_100 = a * b_int100;
    cout << c_100 / 100;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll maxs = 1e5;

ll oo = 1e15;
ll a[maxs];
ll dp[maxs];

ll go(ll pos,ll n,ll k)
{
    if(pos > n)
        return oo;
    if(pos == n)
        return 0;
    if(dp[pos] != -1)
        return dp[pos];
    else
    {
        ll minn = INT_MAX;
        for(ll i = 1;i <= k; ++i)
        {
            if(i + pos <= n)
            {
                minn = min(minn,abs(a[pos + i] - a[pos]) + go(pos + i,n,k) );
            }
            else
                break;
        }
        
        dp[pos] = minn;
        return dp[pos];
    }
}

int main()
{
    ll n,k,i;
    cin >> n >> k;
    for(i = 1;i <= n;i++)
        cin >> a[i];
    memset(dp,-1,sizeof(dp));
    cout << go(1,n,k);
   
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
const int maxn=(1<<21)+10;
int n,m,f[21][maxn],lg[maxn],tr[maxn][2];
int main()
{
	scanf("%d%d",&n,&m);
	for(int j=0;j<=n;j++)
		for(int i=0;i<(1<<j);i++)
			scanf("%1d",&f[j][i^(1<<j)]);
	lg[0]=-1;
	for(int i=1;i<(1<<(n+1));i++) lg[i]=lg[i>>1]+1;
	for(int i=2;i<(1<<(n+1));i++)
		if((i>>(lg[i]-1))&1)
			tr[i][1]=i^(1<<lg[i]),tr[i][0]=tr[tr[i][1]][0];
		else
			tr[i][0]=i^(3<<(lg[i]-1)),tr[i][1]=tr[tr[i][0]][1];
	for(int j=n;j;j--)
		for(int i=(1<<j);i<(1<<(n+1));i++)
		{
			int k = i >> j, l = (i & ((1 << j) - 1)) ^ (1 << j);
			if(tr[l][0]) f[lg[tr[l][0]]][(((k << 1) ^ 1) << lg[tr[l][0]]) ^ tr[l][0]] += f[j][i];
			if(tr[l][1]) f[lg[tr[l][1]]][(((k << 1) ^ 0) << lg[tr[l][1]]) ^ tr[l][1]] += f[j][i];
			f[0][k] += f[j][i];
		}
	int ans=1;
	for(int i=2;i<(1<<(n+1));i++)
		if(f[0][i]>=m && lg[i]>lg[ans]) ans=i;
	int j=n;
	while((~ans>>j)&1) j--;
	while(j--) putchar(((ans>>j)&1)+'0');
	putchar('\n');
	return 0;
}

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

using namespace std;

int main(){
    long long int n,m,k,x;
    vector<long long int> a,b;

    cin >> n >> m >> k;

    a.push_back(0);
    cin >>x; a.push_back(x);
    for(long long int i=1;i<n;i++){
        long long int x; cin >> x; a.push_back(x+a[i]);
    }


    cin >>x; b.push_back(x);
    for(long long int i=1;i<m;i++){
        long long int x; cin >> x; b.push_back(x+b[i-1]);
    }

    int ans = 0;
    for(int i=0;i<a.size();i++){
        if(a[i]>k) break;
        auto itr = upper_bound(b.begin(),b.end(),k-a[i]);
        int idx = itr-b.begin();
        //cout << i+1 << "," << idx << endl;
        if(ans < idx+i){
            ans = idx+i;
        }
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 7964
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   string weather[] = {"Sunny", "Cloudy", "Rainy"};
   string s;
   cin >> s;

   int todayi;
   for(int i = 0; i < 3; i++)
   {
      if(weather[i] == s)
         todayi = i;
   }
   cout << weather[(todayi+1)%3] << endl;

   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A == B && B == C){
            System.out.println("No");
        }else if(A == B || B == C || C == A){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25172
/////////////////////////////////////////
///       Please Give Me AC!!!!!      ///
/////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    ll a, b, c, d; cin>> a >> b >> c >> d;
    cout<< max(max(a*c, a*d), max(b*c, b*d)) << endl;
}

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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  REP(i, 0, N) cin >> A[i];
  REP(i, 0, N) cin >> B[i];

  ll s = accumulate(B.begin(), B.end(), 0LL) - accumulate(A.begin(), A.end(), 0LL);

  ll x = 0, y = 0;
  REP(i, 0, N) {
    if(A[i] > B[i]) x += A[i] - B[i];
    if(A[i] < B[i]) y += (B[i] - A[i] + 1) / 2;
  }

  cout << (x <= s && y <= s ? "Yes" : "No") << endl;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int ans=-1;
    for(int i=1;i*i<=m;i++){
        if(m%i!=0)continue;
        if(i<=m/n)ans=max(ans,i);
        if(m/i<=m/n)ans=max(ans,m/i);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>
#include <ctime>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;
const ll INFLL = 1001001001001001001LL;


template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }




int main() {
	srand(time(NULL));
//Prepare
	int N;
	int A,B,C,D;
//
	int X;
	scanf("%d", &X);

	if (X <= 3) {
		printf("1");
		goto end;
	}

	
	for (int i = X; i >= 1; --i) {
		for (int j = 2; j <= (int)sqrt(X); ++j) {
			int Div = i;
			while (1) {
				if (Div % j == 0) {
					Div /= j;
					if (Div == 1) {
						printf("%d", i);
						goto end;
					}
				}
				else {
					break;
				}
				
			}
		}
	}
	end:

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	
	int w, h, x, y, r;
	int yn = 1;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r );
	
	if (
		x + r > w ||
		x - r<0 ||
		y + r>h ||
		y - r < 0
		)
		yn = 0;

	yn ? printf("Yes") : printf("No");

	printf("\n");


	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
 //stringstream num(c);
    //        num >> x;
using namespace std;
//long double value(double a)
//{
////    long  p=100;
////    double r=0.01;
////   long  n=12;
//   long double t,x;
//   t=ceil(log(a/100))/ceil(log(1+(0.01)));
//   round(t);
//    return  t;
//}
//int main()
//{
//   long double a;
//   cin>>a;
////   long double p=100;
////   long double r=1/00;
////   long double n=12;
//   long double t;
//   //a=p(1+r/n)^nt;
//  // t=log(a)/(log(p)+log(1+(r/n)))*n
//  long double x = value(a);
//   cout<<x;
//
//
//    return 0;
//}
//// double valueE(double d)
////{
////    return log(d)/(log(p)+log(1+(r/n)))*n;
////}
////
////// function to evaluate logarithm base-10
////double value10(double d)
////{
////    return log10(d);
////}
////
////// driver program to test the above function
////int main()
////{
////    double d = 100;
////    cout << "The logarithm value(base-e) of " << d
////         << " is " << valueE(d) << endl;
////    cout << "The logarithm value(base-10) of " << d
////         << " is " << value10(d) << endl;
////    return 0;
////}

int main()
{

    long k,a,b,c,sum=0;
    cin>>a>>b>>c>>k;
    if((k-a)>=0)
    sum+=a;
    else
        sum+=k;
    k-=a;
    if(k>0&&b!=0)
        k-=b;
 if(k>0&&c!=0)
    sum+=(k*(-1));
//    while(k!=0)
//    {
//        if(a!=0)
//        {
//            sum+=1;
//            a--;
//        }
//        else if(b!=0)
//        {
//            sum+=0;
//            b--;
//        }
//        else
//        {
//            sum+=(-1);
//            c--;
//        }
//        k--;
//    }
//
    cout<<sum;

}


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

int main() {
  int N;
  int P = 0;
  int W = 0;
  int G = 0;
  int Y = 0;
  string a;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a == "P") P++;
    else if (a == "W") W++;
    else if (a == "G") G++;
    else if (a == "Y") Y++;
  }
  if (Y>0) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nab = Input.ar;
        var h = Enumerable.Repeat(0, nab[0]).Select(v => Input.numL).ToArray();
        var left = 0L;
        var right = (long)1e9;
        while (right - left > 1)
        {
            var mid = (right + left) / 2;
            var ct = 0L;
            for (var i = 0; i < nab[0]; i++)
                ct += Max(0, (h[i] - nab[2] * mid + nab[1] - nab[2] - 1) / (nab[1] - nab[2]));
            if (ct > mid) left = mid;
            else right = mid;
        }
        WriteLine(right);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

char v[1005][1005];
int dp[1005][1005];
int n,m;
int solve(int x, int y){
	if(dp[x][y] != -1)
		return dp[x][y];
	if(x == n-1 and y == m-1)
		return 1;
	int ans = 0;
	if(y + 1 < m and v[x][y+1] == '.')
		ans = solve(x, y+1);
	if(x + 1 < n and v[x+1][y] == '.')
		ans = (ans + solve(x+1, y))%mod;
	return dp[x][y] = ans;
}

int main(){
	fastio;
	memset(dp, -1, sizeof(dp));
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> v[i][j];
	cout << solve(0,0) << '\n';
	return 0;
}


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

Measured memory_bytes: 1024
/*
  Contest 107
  A - Train
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0, i = 0;
    std::cin >> n >> i;
    std::cout << n - i + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 3504
import java.util.Scanner;

/**
 * Created by nakatsukatakahiro on 2017/06/10.
 */
class Main {



    public static void main(String[] args) {
        boolean[] color = new boolean[8];
        int overer = 0;
        Scanner scanner = new Scanner(System.in);

        int N = Integer.parseInt(scanner.next());

        for (int i = 0; i < N; i++) {
            int tmp = Integer.parseInt(scanner.next());
            if (tmp < 400) {
                color[0] = true;
            } else if (tmp < 800) {
                color[1] = true;
            } else if (tmp < 1200) {
                color[2] = true;
            } else if (tmp < 1600) {
                color[3] = true;
            } else if (tmp < 2000) {
                color[4] = true;
            } else if (tmp < 2400) {
                color[5] = true;
            } else if (tmp < 2800) {
                color[6] = true;
            } else if (tmp < 3200) {
                color[7] = true;
            } else {
                overer++;
            }
        }

        int ans = 0;

        for (int i = 0; i < 8; i++) {
            if (color[i]) {
                ans++;
            }
        }

        if (ans == 0) {
            System.out.println(1 + " " + overer);
        } else {
            int maxAns = ans + overer;
            System.out.println(ans + " " + maxAns);
        }

    }
}


Measured memory_bytes: 23764
while True:
    try:
        k = list(input())
        ans = 'd'
        lst1 = [k[:3], k[3:6], k[6:]]
        lst2 = [k[::3], k[1::3], k[2::3]]

        if k[4] != 's':
            if k[0] == k[4] and k[4] == k[8]:
                ans = k[4]

            elif k[2] == k[4] and k[4] == k[6]:
                ans = k[4]

        for i in lst1:
            if i.count('o') == 3:
                ans = 'o'
            elif i.count('x') == 3:
                ans = 'x'
            else:
                pass

        for i in lst2:
            if i.count('o') == 3:
                ans = 'o'
            elif i.count('x') == 3:
                ans = 'x'
            else:
                pass

        print(ans)

    except EOFError:
        break


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int a,b;
    cin>>a>>b;
    (a>8 || b>8)?cout<<":(":cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 3572