akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

template<typename T>
using reversed_priority_queue = \
    std::priority_queue<T, std::vector<T>, std::greater<T> >;

ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,-1,0,1};

signed main() {
  ll H,W, INF=10000000;
  cin>>H>>W;
  vector<string> s(H);
  rep(i,0,H) cin>>s[i];
  vector<vector<ll>> v(H, vector<ll>(W, INF));
  queue<pair<ll, PLL>> q; // {distance, y, x}
  rep(i,0,H) rep(j,0,W) {
    if (s[i][j] == '#') {
      q.emplace(0, PLL(i,j));
    }
  }

  while (q.size() > 0) {
    auto t = q.front(); q.pop();
    ll d = t.first, i = t.second.first, j = t.second.second;
    if (v[i][j] <= d)
      continue;
    v[i][j] = d;
    rep(k,0,4) {
      ll ny = i+dy[k], nx = j+dx[k];
      if (ny<0 || ny>=H || nx<0 || nx>=W) continue;
      q.emplace(d+1, PLL(i+dy[k], j+dx[k]));
    }
  }

  ll ans = 0;
  rep(i,0,H)
    rep(j,0,W){
      ans = max(ans, v[i][j]);
    }
  cout<<ans<<endl;
  return 0;
}


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

int main(){

    int N;
    cin >> N;
    int buf;
    ll ans = 0;
    for (int i=0; i<N; i++){
        cin >> buf;
        buf--;
        ans += buf;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){
    int n, l[10];
    int i, max = 0, maxi, sum = 0;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%d", &l[i]);

        if(max < l[i]){
            max = l[i];
            maxi = i;
        }
    }

    for(i=0; i<n; i++){
        if(i != maxi)
            sum += l[i];
    }

    if(sum > max)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll k;
  cin >> k;
  vl ans;
  ll d = k%50;
  rep(i,50-d) ans.push_back(49-d);
  rep(i,d)ans.push_back(50);

  ll a = k/50;
  rep(i,50) ans[i]+=a;

  cout<<50<<endl;
  rep(i,50){
    cout<<ans[i] <<((i==50-1)?"\n":" ");
  }
  return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(3 * n);
    REP(i, 3 * n) {
        cin >> a[i];
    }
    multiset<ll> f;
    multiset<ll> s;
    vector<ll> fsum(n + 1);
    ll sum = 0;
    REP(i, n) {
        sum += a[i];
        f.insert(a[i]);
    }
    fsum[0] = sum;
    REP1(i, n) {
        fsum[i] = fsum[i - 1] + a[n + i - 1];
        f.insert(a[n + i - 1]);
        auto itr = f.begin();
        fsum[i] -= *itr;
        f.erase(itr);
    }
    vector<ll> ssum(n + 1);
    sum = 0;
    for (int i = 3 * n - 1; i >= 2 * n; i--) {
        sum += a[i];
        s.insert(a[i]);
    }
    ssum[n] = sum;
    for (int i = 2 * n - 1; i >= n; i--) {
        ssum[i - n] = ssum[i + 1 - n] + a[i];
        s.insert(a[i]);
        auto itr = --s.end();
        ssum[i - n] -= *itr;
        s.erase(itr);
    }

    ll mx = -1001001001001001001;
    REP(i, n + 1) {
        chmax(mx, fsum[i] - ssum[i]);
    }

    cout << mx << endl;
}

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

class Main {


  

  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt();

    int[] dp = new int[3];
    int[] cur = new int[3];
    for (int day = 0; day < N; day++) {
      
      int[] new_dp = new int[3];
      for (int i = 0; i < 3; i++) {
        cur[i] = in.nextInt();
        for (int j = 0; j < 3; j++) {
          if (i != j) {new_dp[j] = Math.max(new_dp[j], dp[i] + cur[i]);}
        }
      }
      dp = new_dp;
    }



    System.out.println(Math.max(dp[0], Math.max(dp[1], dp[2])));
  }

}

Measured memory_bytes: 92268
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]"):
    counter = 0
    for i in range(N):
        if A[i] >= B[i]:
            counter += B[i]
            A[i] -= B[i]
            B[i] = 0
        else:
            counter += A[i]
            B[i] -= A[i]
            A[i] = 0
            if A[i+1] >= B[i]:
                counter += B[i]
                A[i+1] -= B[i]
                B[i] = 0
            else:
                counter += A[i+1]
                B[i] -= A[i+1]
                A[i+1] = 0
    counter += min(A[N-1] + A[N], B[N-1])
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N+1) ]  # type: "List[int]"
    B = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19452
N,A,B,C,D = map(int,input().split())
S = input()
S = S[A-1:]
B -= A
C -= A
D -= A
A = 0

kabe = S.find("##")
if kabe != -1:
    if kabe < C or kabe < D:
        print('No')
        exit()
if C < D:
    print('Yes')
else:
    A = S[:B].rfind(".")
    S = S[A:]
    B -= A
    C -= A
    D -= A
    A = 0
    irekae = S.find("...")
    if irekae == -1:
        print('No')
        exit()
    if irekae + 2 <= C and irekae < D:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 9508
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        string s;
        stack<char> st;
        cin >> s;
        int ans = 0;
        rep(i, s.size()) {
            if (st.size() == 0) {
                st.push(s[i]);
            } else if (st.top() == '0' && s[i] == '1') {
                st.pop();
                ans += 2;
            } else if (st.top() == '1' && s[i] == '0') {
                st.pop();
                ans += 2;
            } else {
                st.push(s[i]);
            }
        }
        cout << ans << endl;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define pr printf
#define IN freopen("in.in","r",stdin);
#define OUT freopen("out.out","w",stdout);
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+6;
const int mod=1e9+7;
template<typename T>int O(T s){cout<<s<<endl;return 0;}
template<typename T>void db(T *bg,T *ed){while(bg!=ed)cout<<*bg++<<' ';puts("");}
inline ll mul_64(ll x,ll y,ll c){return (x*y-(ll)((long double)x/c*y)*c+c)%c;}
inline ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=a*a%c)if(b&1)ans=ans*a%c;return ans;}
inline void exgcd(ll a,ll b,ll &x,ll &y){if(!b)x=1,y=0;else exgcd(b,a%b,y,x),y-=(a/b)*x;}
int main(){
    string str[2];
    cin>>str[1];
    int q,f=0;cin>>q;
    while(q--){
        int t;sc("%d",&t);
        if(t==1)f=!f;
        else{
            int F;char c;
            sc("%d %c",&F,&c);
            str[F-1^f]+=c;
        }
    }
    if(f){
        reverse(str[1].begin(),str[1].end());
        O(str[1]+str[0]);
    }
    else{
        reverse(str[0].begin(),str[0].end());
        O(str[0]+str[1]);
    } 
}


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

int find_max(int, int, int);
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum;
    sum = a + b + c + (pow(2, k) - 1) * find_max(a, b, c);
    cout << sum << endl;
}

int find_max(int a, int b, int c){
    int max = a;
    if(b > max) max = b;
    if(c > max) max = c;
    return max;
}

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

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

    do
    {
        C -= B;
        if (C > 0)
            A -= D;
        // cout << C << endl;
        // cout << A << endl;
    } while (A > 0 && C > 0);

    if (A > 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main(){
  int n;
  int a[100010];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  sort(a+1,a+n+1);
  int ans=a[1];
  gai:;
  for(int i=1;i<=n;i++){
    if(a[i]%ans==0){}
    else if(a[i]%ans<=ans){
      ans=a[i]%ans;
      if(ans==1){
		  cout<<1<<endl;
		  return 0;
		}
      //gaiに戻る
      goto gai;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// A
		int a = sc.nextInt();
		// B
		int b = sc.nextInt();
		// X
		int x = sc.nextInt();
		
		// 出力
		
		for (int i = 0; i < b; i++) {
			if (a + i == x) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
		
		
	}
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x, y,z;
    bool operator<(const P &a)const{
        if(y!=a.y) return y>a.y;
        return x>a.x;
    }
};
vector<int> v[211111];
//bitset<4001000> b;
int i,n,d,m,k,a,b,c;
int e;
int o[211111];
int l[211111];
int j[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
int px[10]={-1,1,1,-1,1,1,-1,-1},py[10]={1,1,-1,-1,1,-1,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z=1987654321987654321,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> se[33],s1;

//priority_queue<P> q;
queue<int> q,q1;
string r[555],r5,r6;

char r1[11],r2[11];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());

bool as(P a,P b)
{
    //if(a.y!=b.y)
    //return a.y>b.y;
    return a.x>b.x;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

void f(int n)
{
    for(int h=0;h<v[n].size();h++)
    if(o[v[n][h]]==-1)
    {
        o[v[n][h]]=o[n]+1;
        f(v[n][h]);
    }
}

int g(int n)
{
    if(l[n]>=0) return l[n];
    if(n==0) return 0;
    if(n==1) return 1;
    if(n==2) return 0;
    l[n]=1-g(n-2);
    return l[n]=max(l[n],1-g(n-1));
}

int main()
{
    scanf("%d",&a);
    if(a==1)
    {
        puts("First");
        return 0;
    }
    for(int t=1;t<a;t++)
    {
        scanf("%d %d",&n,&m);
        v[n].push_back(m);
        v[m].push_back(n);
    }
    memset(o,-1,sizeof(o));
    o[1]=0;
    f(1);
    n=m=0;
    for(int t=2;t<=a;t++)
        if(o[t]>n)
        n=o[t],m=t;
    memset(o,-1,sizeof(o));
    o[m]=1;
    f(m);
    n=m=0;
    for(int t=1;t<=a;t++)
        if(o[t]>n)
        n=o[t],m=t;
    //printf("%d\n",n);
    memset(l,-1,sizeof(l));
    if(g(n)==0) puts("Second");
    else puts("First");
}


Measured memory_bytes: 22528
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;
long long int gcd(long long int a,long long int b);
int main(){
    int n;
    cin >> n;
    vector<long long int> a(n);
    vector<long long int> gcda(n);
    vector<long long int> gcdb(n);
    
    // vector<long long int> gcdm(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    if(n==2){
        cout << max(a.at(0),a.at(1)) << endl;
        return 0;
    }
    gcda.at(0)=a.at(0);
    for(int i=1;i<n;i++){
        gcda.at(i) = gcd(a.at(i),gcda.at(i-1));
    }
    gcdb.at(n-1)=a.at(n-1);
    for(int i=1;i<n;i++){
        gcdb.at(n-1-i)=gcd(a.at(n-1-i),gcdb.at(n-i));
    }

    long long int ans=max(gcdb.at(1),gcda.at(n-2));
    long long int temp;
    for(int i=1;i<n-1;i++){
        
        temp= gcd(gcda.at(i-1),gcdb.at(i+1));
        // cout << gcda.at(i) <<","<<gcdb.at(i) <<","<<temp << endl;
        if(temp>ans)ans=temp;
    }
    
    cout << ans << endl;
    return 0;
}
long long int gcd(long long int a,long long int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else return gcd(b,a%b);
}

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

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

	int res = 0;
	for(int i = 0; i < 1000; i++){
		int pos = 0;
		while(pos < n){
			if(s[pos++] - '0' == i / 100) break;
		}
		while(pos < n){
			if(s[pos++] - '0' == (i%100) / 10) break;
		}
		while(pos < n){
			if(s[pos++] - '0' == (i % 10)){
				res++;
				break;
			}
		}
	}

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

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(a == 1 || b == 1 || c == 1 || d == 1) {
    if(a == 9 || b == 9 || c == 9 || d == 9) {
      if(a == 7 || b == 7 || c == 7 || d == 7) {
        if(a == 4 || b == 4 || c == 4 || d == 4) {
          cout << "YES" << endl;
          return 0;
        }
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int,input().split()))


def dfs(A_s, index,Bss):
    if index == N:
        tmp = 1
        for b in Bss:
            tmp *= b
        return 1 if tmp % 2 == 0 else 0
    b_mi = Bss.copy()
    b_mi.append(A_s[index] - 1)

    b = Bss.copy()
    b.append(A_s[index])

    b_pl = Bss.copy()
    b_pl.append(A_s[index] + 1)
    return dfs(A_s,index + 1, b_mi) + dfs(A_s,index + 1,b) + dfs(A_s,index + 1,b_pl)


print(dfs(As,0,[]))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int dx[2][6]={{1,-1,0,0,-1,1},{1,-1,0,0,-1,1}};
int dy[2][6]={{0,0,-1,1,-1,-1},{0,0,1,-1,1,1}};
bool out[102][102];
bool used[102][102];
int cnt=0,w,h;
void dfs(int x,int y)
{
	used[x][y]=1;
	for(int r=0;r<6;r++)
	{
		int tx=x+dx[x%2][r];
		int ty=y+dy[x%2][r];
		if(tx<0||ty<0||tx>h+1||ty>w+1||used[tx][ty])continue;
		if(out[tx][ty])cnt++;
		else dfs(tx,ty);
	}
	return;
}
main()
{
	cin>>w>>h;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin>>out[i][j];
	dfs(0,0);
	cout<<cnt<<endl;
}

Measured memory_bytes: 3324
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=300000;
typedef pair<long long,int> P;
int main()
{
  int x,y,a,b,c,n,t,i;
  long long res=0;
  P p[N_MAX];
  cin >> x >> y >> a >> b >> c;
  n=a+b+c;
  t=x+y;
  for(i=0;i<a;i++){
    cin >> p[i].first;
    p[i].second=0;
  }
  for(i=0;i<b;i++){
    cin >> p[i+a].first;
    p[i+a].second=1;
  }
  for(i=0;i<c;i++){
    cin >> p[i+a+b].first;
    p[i+a+b].second=2;
  }
  sort(p,p+n,greater<P>());
  for(i=0;i<n;i++){
    if(p[i].second==0&&x>0){
      res+=p[i].first;
      x--; t--;
    }
    if(p[i].second==1&&y>0){
      res+=p[i].first;
      y--; t--;
    }
    if(p[i].second==2){
      res+=p[i].first;
      t--;
    }
    if(t==0) break;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N,D[60]={},ans=0;
    cin>>N;

    for(int i=0;i<N;i++){
        cin>>D[i];
    }

    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            ans+=D[i]*D[j];
        }
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define MAX 1000000

int main(void){
	int pn[MAX] = {1, 1, 0};
	int i, j, n, cnt;
	int max_root = sqrt((double)MAX) +1;
	i=2;
	while(i<=max_root){
		for(j=i+i;j<=MAX;j+=i){
			pn[j] = 1;//not_prime
		}
		while(1){
			i++;
			if(pn[i])break;
			if(i<=max_root)break;
		}
	}
	while(scanf("%d", &n) != EOF){
		cnt=0;
		for(i=2;i<=n;i++){
			if(!pn[i]) cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 4512
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	public void solve() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String[] wordArr = sc.nextLine().split(" ");
		sc.close();
		
		String ans = "";
		
		for(int i = 0; i < n; i++) {
			ans += wordArr[0].substring(i, i + 1) + wordArr[1].substring(i, i + 1);
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a, a+n);
    sort(b, b+n);
    if (n % 2 == 0) {
        cout << b[n/2] + b[n/2-1] - (a[n/2] + a[n/2-1]) + 1<< endl;
    } else {
        cout << b[n/2] - a[n/2] + 1 << endl;
    }
}


Measured memory_bytes: 5192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll mod = 1e9+7;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n)cin >> h[i];
    vector<int> dp(n+1, -1);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i = 2; i < n; i++){
        dp[i] = min((dp[i-1]+abs(h[i]-h[i-1])), (dp[i-2]+abs(h[i]-h[i-2])));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n) {
        cin>>a[i];
        sum+=a[i];
    }
    
    ll ans=LINF;
    ll now=0;
    rep(i,n) {
        now+=a[i];
        ans=min(ans,abs(now-(sum-now)));
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>


int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main() {
    int r = 0;
    int abc[3];
    std::cin >> abc[0] >> abc[1] >> abc[2];
    qsort(abc, 3, sizeof(int), compare_int);
    while (true) {
        if (abc[0] == abc[1] && abc[1] == abc[2]) {
            break;
        }
        if (abc[1] < abc[2]) {
            abc[0] += 1;
            abc[1] += 1;
            r++;
            continue;
        }
        abc[0] += 2;
        r++;
        if (abc[0] > abc[1]) {
            abc[1] += 1;
            abc[2] += 1;
            r++;
        }
    }
    std::cout << r << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n,k;
  cin>>n>>k;
  vector<ll>v(k);
  for(int i=0;i<k;i++)
  {
      cin>>v[i];
  }
  ll sum=0;
  if(k==1)
  {
      cout<<0<<"\n";
      exit(0);
  }
  ll maxx=INT_MIN;
  for(int i=0;i<k-1;i++)
  {
      sum+=v[i+1]-v[i];
      maxx=max(maxx,v[i+1]-v[i]);
  }
  maxx=max(maxx,n-v[k-1]+v[0]);
  sum+=n-v[k-1]+v[0];
  cout<<sum-maxx<<"\n";
}


Measured memory_bytes: 1792
list=input().split(" ")
N=int(list[0])
K=int(list[1])

sunuke_list=[1]

for i in range(N):
    sunuke_list.append(0)

for i in range(K):
    num=int(input())
    have_list=input().split(" ")
    for j in range(num):
        tmp=int(have_list[j])
        sunuke_list[tmp]=1

count=0
for i in range(1,N+1):
    if sunuke_list[i]==0:
        count+=1
print(count)

Measured memory_bytes: 9228
#include <iostream>
#include <vector>
#define MAX 200001
using namespace std;
typedef long long ll;
// Rank : height
// p    : parent
// s    : the number of nodes of the group
// total: the number of total pair
ll Rank[MAX], p[MAX];
ll s[MAX];
ll A[MAX], B[MAX];
ll total;
// funciton
void DisjollSet(ll size);
void makeSet(ll x);
void unite(ll x, ll y);
ll findSet(ll x);
ll comb(ll x);


int main() {
    ll n, m;
    cin >> n >> m;

    total = comb(n);

    DisjollSet(n);

    ll a, b;
    for (ll i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
    }

    vector<ll> res;
    res.push_back(total);
    ll p_a, p_b;
    for (ll i = m-1; i >= 0; i--) {
        p_a = findSet(A[i]);
        p_b = findSet(B[i]);
        // groupが同じかどうか
        if (p_a == p_b) {
            res.push_back(total);
        }
        else {
            ll a_size = s[p_a];
            ll b_size = s[p_b];
            unite(p_a, p_b);
            total -= comb(s[p_a]) - (comb(a_size) + comb(b_size));
            res.push_back(total);
        }
    }
    
    for (ll i = m-1; i >=0; i--) {
        cout << res[i] << '\n';
    }
    
}

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

void DisjollSet(ll size) {
    for (ll i = 0; i < size; i++) 
        makeSet(i);
}

void makeSet(ll x) {
    p[x] = x;
    Rank[x] = 0;
    s[x] = 1;
}

void unite(ll x, ll y) {
    if ( Rank[x] > Rank[y] ) {
        p[y] = x;
    }
    else {
        p[x] = y;
        if ( Rank[x] == Rank[y] ) {
            Rank[y]++;
        }
    }
    s[x] += s[y];
    s[y] = s[x];

}

ll findSet(ll x) {
    if ( x != p[x] ) {
        p[x] = findSet(p[x]);
    }
    return p[x];
}


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

const int N = 2e5 + 5;
int A[N], n;
long long k;
bool v[N];

signed main() {
	ios::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> A[i];
	int x = 1;
	while (!v[x])  {
		k--, v[x] = 1, x = A[x];
		if (!k) cout << x << endl, exit(0);
	}
	int s = x;
	int c = 0;
	while (++c, (x = A[x]) != s);
	k %= c;
	while (k--) x = A[x];
	cout << x << endl;
}

Measured memory_bytes: 4628
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

vector<int> prime_table(int n) {
    vector<int> is_prime(n + 1);
    if (n) iota(is_prime.begin() + 2, is_prime.end(), 2);
    for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
        for (int j = i + i; j <= n; j += i) is_prime[j] = 0;
    }
    return is_prime;
}

int main() {
    auto is_prime = prime_table(2e6);
    int n;
    while (cin >> n, n) {
        int prv = n, nxt = n;
        while (!is_prime[prv]) prv--;
        while (!is_prime[nxt]) nxt++;
        cout << nxt - prv << endl;
    }
    return 0;
}



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

int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
    cout<<a-k<<" "<<b<<endl;
  }
  else if(a+b>=k){
    cout<<0<<" "<<b-k+a<<endl;
  }
  else{
    cout<<0<<" "<<0<<endl;
  }
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = STR()
u = list(set(s))
ans = inf
for c in u:
    strt = s.index(c)
    res = strt
    cnt = 0
    for i in range(strt + 1, len(s)):
        if s[i] == c:
            res = max(res, cnt)
            cnt = 0
        else:
            cnt += 1
    res = max(res, cnt)
    ans = min(ans, res)
print(ans)

Measured memory_bytes: 60012
d,g=map(int,input().split())

p=[]
c=[]
for i in range(d):
    x,y=map(int,input().split())
    p.append(x)
    c.append(y)

m=100000000000000
for i in range(2**d):
    count=0
    count2=0
    for j in range(d):
        if i&(2**j):
            count+=p[j]*(j+1)*100+c[j]
            count2+=p[j]
    if count>=g and count2<m:
        m=count2
    for j in reversed(range(d)):
        if not(i&(2**j)):
            for k in range(p[j]):
                if count>=g and count2<m:
                    m=count2
                    break
                count+=(j+1)*100
                count2+=1
            break

print(m)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1e9+7;
 
int main(){
  int n;cin>>n;
  int h[n];
  rep(i,n)cin>>h[i];
  bool flag=1;
  int M=h[0];
  rep(i,n-1){
    if(h[i+1]>=M){
      M=h[i+1];
    }
    else{
      if(M-1>h[i+1]){
        flag=0;break;
      }
    }
  }
  cout<<(flag?"Yes":"No")<<endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import random

def copysign(x, y):
    return abs(x) * (1 if y >= 0 else - 1)

def dist(k, x, y):
    if not (abs(x) + abs(y) < 2 * k):
        return None
    if x == y == 0:
        return 0
    elif abs(x) + abs(y) == k:
        return 1
    elif (abs(x) + abs(y)) % 2 == 0:
        return 2
    else:
        return 3

def iterate_neighbors(k, x, y):
    assert abs(x) + abs(y) < 2 * k
    dz = (2 * k - abs(x) - abs(y)) // 2
    for dx in (dz, k - dz):
        dy = k - dx
        yield (dx, dy)
        yield (dx, - dy)
        yield (- dx, dy)
        yield (- dx, - dy)

def solve(k, x, y):
    while True:
        d = dist(k, x, y)
        if d == 0:
            return
        elif d == 1:
            dx = x
            dy = y
        elif d == 2:
            for dx, dy in iterate_neighbors(k, x, y):
                if dist(k, x - dx, y - dy) == 1:
                    break
            else:
                assert False
        elif d == 3:
            while True:
                dx = random.randint(0, k) * random.choice([-1, 1])
                dy = (k - abs(dx)) * random.choice([-1, 1])
                if dist(k, x - dx, y - dy) == 2:
                    break
        else:
            dx = copysign(min(k, abs(x)), x)
            dy = copysign(k - abs(dx), y)
        yield (dx, dy)
        x -= dx
        y -= dy

def main():
    k = int(input())
    x, y = map(int, input().split())
    if k % 2 == 0 and (abs(x) + abs(y)) % 2 != 0:
        print(-1)
        return
    ops = list(solve(k, x, y))
    print(len(ops))
    x = 0
    y = 0
    for dx, dy in ops:
        x += dx
        y += dy
        print(x, y)

main()


Measured memory_bytes: 20100
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }
const int maxn = 1000000;
int f[maxn + 1], fi[maxn + 1];
int ncr(int n, int r) { return mul(f[n], mul(fi[r], fi[n - r])); }

void precompute()
{
    f[0] = 1;
    for (int i = 1; i <= maxn; ++i)
        f[i] = mul(f[i - 1], i);

    fi[maxn] = inv(f[maxn]);
    for (int i = maxn - 1; i >= 0; --i)
        fi[i] = mul(fi[i + 1], i + 1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    precompute();
    int n;
    cin >> n;
    cout << f[n];
}


Measured memory_bytes: 8064
N = int(input())
L = list(map(int, input().split()))
L.sort()
a = [0,0]
count = 0
for i in range(N):
    count += 1
    if i == N-1:
        if count >= 2:
            a.append(L[i])
        if count >= 4:
            a.append(L[i])
        count = 0
        
    elif L[i] != L[i+1]:
        if count >= 2:
            a.append(L[i])
        if count >= 4:
            a.append(L[i])
        count = 0
            
print(a[-1]*a[-2])

Measured memory_bytes: 14224
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    rep(i, len - 1) {
        if (S[i] == S[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    rep(i, len - 2) {
        if (S[i] == S[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;

    return 0;
}


Measured memory_bytes: 512
/*input
100
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main() {
    IOS;
    int n;
    cin>>n;
    int t = sqrt(n);
    int diff = n - t*t;
    if(diff == 0){
        cout << "0 0 0 "<<t<<" "<<t<<" 0";
        exit(0);
    }
    t++;
    diff = t*t - n;
    cout << "0 0 1 "<<t<<" "<<t<<" "<<diff;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  double a, b, c, d, e, f, x, y;
  while (cin >> a >> b >> c >> d >> e >> f) {
    x = (e * c - b * f) / (a * e - b * d);
    y = (a * f - d * c) / (a * e - b * d);
    if (x == 0.0) x = 0.0;
    if (y == 0.0) y = 0.0;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

vector<vector<int>> g;
vector<int> ans;

void bfs(int n, vector<int>& dis, int v, int d, int c){
	queue<int> q;
	q.push(v);

	int u;
	while(!q.empty()){
		u = q.front(); q.pop();
		if(ans[u] == 0) ans[u] = c;

		for(auto to : g[u]){
			if(dis[to] < dis[u] - 1){
				dis[to] = dis[u] - 1;
				q.emplace(to);
			}
		}
	}
}

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

	g = vector<vector<int>>(n);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	//rep(i,n){ for(auto j : g[i]){ cout << j.first << ' ' ; } cout << endl; }

	int q;
	cin >> q;

	vector<int> v(q), d(q), c(q);
	rep(i,q){
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}

	ans = vector<int>(n,0);
	vector<int> dis(n,-1); // dis[i] :- 頂点iから距離dis[i]にある頂点は色が塗ってある
	for(int i = q - 1; i >= 0; i--){
		if(dis[v[i]] < d[i]){
			dis[v[i]] = d[i];
			bfs(n, dis, v[i], d[i], c[i]);
		}
	}
	for(auto i : ans){
		cout << i << endl;
	}
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

// 約数列挙
vector< ll > divisor(ll n) {
	vector< ll > ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret), greater<ll>());
	return (ret);
}

int main() {
	ll N;
	cin >> N;
	double ans = 0;
	for (int i = 0; i < N; i++) {
		double a; cin >> a;
		ans += 1.0 / a;
	}
	ans = 1.0 / ans;

	printf("%.10f", ans);
	cout << endl;
	return 0;
}

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

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

int main()
{
    int n, x; std::cin >> n >> x;
    std::vector<int> a(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i] = std::abs(a[i] - x);
    }

    int gg = a[0];

    for (int i = 1; i < n; i++) {
        gg = gcd(gg, a[i]);
    }

    std::cout << gg << std::endl;

    return 0;
}


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

#define vi vector<int>
#define vvi vector<vi>
#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

typedef long long ll;

int main() {
  int N, sign = 0, ans = 1;
  cin >> N;
  vi A(N, 0);
  rep1(i, 0, N) cin >> A[i];

  rep1(i, 0, N - 1) {
    if (A[i] == A[i + 1]) {
      continue;
    }
    int tmp = A[i] < A[i + 1] ? 1 : -1;
    if (tmp * sign < 0) {
      ans++;
      tmp = 0;
    }
    sign = tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct UnionFind{
  int par[10005];
  int rank[10005];
  UnionFind(int n){ init(n);}
  void init(int n){
    for(int i=0;i<n;i++){
      par[i] = i;
      rank[i] = 0;
    }
  }
  int find(int x){
    if(x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  int same(int x, int y){
    return find(x) == find(y);
  }
  void unite(int x, int y){
    x = find(x); y = find(y);
    if(x==y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }
};

int main(){
  int n,q;
  scanf("%d%d",&n,&q);
  UnionFind uf(n);
  while(q--){
    int com, x,y;
    scanf("%d%d%d",&com,&x,&y);
    if(com) printf("%d\n", uf.same(x,y));
    else uf.unite(x,y);
  }
  return 0;
}

Measured memory_bytes: 1108
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val W = Array(N) { readLine()!! }
    if (W.distinct().size != W.size) {
        println("No")
        return
    }

    var last = W[0].last()
    for (i in 1 until W.size) {
        if (W[i].first() != last) {
            println("No")
            return
        }
        last = W[i].last()
    }
    println("Yes")
}

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

int main() {
  string s; cin >>s;
  int ans = 7;
  if (s == "SUN"){
    ans = 7;
  }else if (s == "MON"){
    ans = 6;
  }else if (s == "TUE"){
    ans = 5;
  }else if (s == "WED"){
    ans = 4;
  }else if (s == "THU"){
    ans = 3;
  }else if (s == "FRI"){
    ans = 2;
  }else if (s == "SAT"){
    ans = 1;
  }
  cout <<ans <<endl;
}


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

int a, b, c, k;

int main()
{
	scanf("%d%d%d%d", &a, &b, &c, &k);
	if (k <= a) printf("%d\n", k);
	else
	{
		k = k - a; int Res = a;
		if (k <= b) printf("%d\n", Res);
		else
		{
			k = k - b;
			printf("%d\n", Res - k);
		}
	}
}

Measured memory_bytes: 3816
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

ll n, a[MAXN];
vll v[MAXN];

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	ll sum = 0;
	for ( int i = 0; i < n; i++ ){
		cin >> a[i];
		sum += a[i];
	}
	ll ans = 0, jvb = 99999999999;
	for ( int i = 0; i < n; i++ ){
		ans += a[i];
		sum -= a[i];
		jvb = min( jvb, abs( sum - ans ) );
	}
	cout << jvb << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll n,k;cin>>n>>k;
  COMinit();
  rep(i,1,k+1){
    ll ans=0;
    ans+=(COM(k-1,i-1)*(2*COM(n-k-1,i-1))%MOD)%MOD;
    ans%=MOD;
    ans+=(COM(k-1,i-1)*(COM(n-k-1,i))%MOD)%MOD;
    ans%=MOD;
    ans+=(COM(k-1,i-1)*(COM(n-k-1,i-2))%MOD)%MOD;
    ans%=MOD;
    if(n-k==0)ans=1;
    if(n-k<i-1)ans=0;
    
    cout<<ans<<endl;
  }
  
}



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b; cin>>a>>b;
  ll ans=a+b;
  chmax(ans, a-b);
  chmax(ans, a*b);
  cout<<ans<<endl;
  
}

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

void solve()
{
    int n;
    cin >> n;
    int a[100001] = {};
    ll sum = 0;
    for(int i = 0; i<n; i++)
    {
        ll c;
        cin >> c;
        sum += c;
        a[c]++;
    }

    int m;
    cin >> m;

    for(int i=0; i<m; i++)
    {
        ll b, c;
        cin >> b >> c;
        sum += (c-b)*a[b];
        a[c] += a[b];
        a[b] = 0;
        cout << sum << endl;
    }



}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    solve();
    return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int h[n],dp[n];
  
  for(int i=0;i<n;i++)
    cin>>h[i];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
  { dp[i]=INT_MAX;
    for(int j=1;j<=min(i,k);j++)
    {
    	dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	998244353//1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

inline int func(int a, int b)
{
	if (a > b)
		return a - b;
	else
		return b - a;
}

int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	map<int, int> p;
	x--;
	y--;

	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			int a = j - i;
			int b = func(j, y) + func(i, x) + 1;
			if (a > b)
				a = b;
			if (p.find(a) == p.end())
				p[a] = 1;
			else
				p[a]++;
		}
	for (int i = 1; i < n; i++)
		printf("%d\n", p.find(i) == p.end() ? 0 : p[i]);

	return 0;
}


Measured memory_bytes: 888
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := NextLineFloat()
	nums = bigToSmallFloat(nums)
	amount := 0.0
	for i := 0.0; i < float64(len(nums) - 1); i++ {
		amount += nums[int(i)] / math.Pow(2.0, i + 1)
	}
	amount += nums[n - 1] / math.Pow(2.0, float64(n - 1))
	fmt.Println(amount)
}

func NextLineFloat() []float64 {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	str := sc.Text()
	s := strings.Split(str, " ")
	var array []float64
	for i := 0; i < len(s); i++ {
		a, _ := strconv.Atoi(s[i])
		b := float64(a)
		array = append(array, b)
	}
	return array
}


func bigToSmallFloat(array []float64) []float64 {
	sort.Float64s(array)
	sort.Sort(sort.Reverse(sort.Float64Slice(array)))
	return array
}


Measured memory_bytes: 640