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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin >> a >> b;
	int temp=0,n=16;
	while(true){
		if(a == 0 && b == 0){
			puts("Yay!");
			return 0;
		}
		if(a ==0){
			n -= (temp*2);
			n /= 2;
			if((n-b) < 0){
				puts(":(");
				return 0;
			}
			puts("Yay!");
			return 0;
		}
		if(b == 0){
			n -= (temp*2);
			n /= 2;
			if((n-a) < 0){
				puts(":(");
				return 0;
			}
			puts("Yay!");
			return 0;
		}
		a--; b--;
		temp++;
	}
	
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int H,W,m,n;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H==W && H==0) break;
         
        if(H<=2){
            for(m=0;m<H;m++){
                for(n=0;n<W;n++) printf("#");
                printf("\n");
            }
        }
        else{
            for(m=1;m<=H;m++){
                if(m==1 || m==H){
                    for(n=0;n<W;n++) printf("#");
                    printf("\n");
                }
                if(m!=1 && m!=H){
                    printf("#");
                    for(n=0;n<W-2;n++) printf(".");
                    printf("#");
                    printf("\n");
                }
            }
            printf("\n");
        }
    }
return 0;
}

Measured memory_bytes: 572
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N,x;
    cin >> N >> x;
    vector<int> v(N);
    ll ans = 0LL;
    REP(i,0,N) cin >> v[i];
    for(int i = 1; i < N; i++){
        if(v[i-1] + v[i] > x){
            if(v[i-1] + v[i] - x > v[i]){
                ans += 1LL*v[i];
                v[i] -= v[i];
                ans += 1LL*(v[i-1] - x);
                v[i-1] = x;
            }else{
                ans += 1LL*(v[i-1]+v[i]-x);
                v[i] -= (v[i-1]+v[i]-x);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]

ans = 0
for a in [-1, 1]:
    for b in [-1, 1]:
        for c in [-1, 1]:
            s = []
            for x, y, z in P:
                s.append(a*x + b*y + c*z)
            s.sort(reverse=1)
            ans = max(ans, sum(s[:M]))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) { cin >> a[i]; }
    map<ll, ll> mp;
    rep(i, N) { mp[a[i]]++; }
    ll ans = 0;
    for (auto p : mp) {
        ll x = p.first;
        ll n = p.second;
        if (n < x) {
            ans += n;
        } else {
            ans += n - x;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
long long x[100010],y[100010],p[100010];
long long q[100010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long a,b,c,d,e,n,ccnt=0,ans=0;
  string s,v,o;
  char z[100010],y[100010];

  cin>>a>>b;
  cin>>s;
    if(s[b-1]=='A') s[b-1]='a';
    else if(s[b-1]=='B') s[b-1]='b';
    else if(s[b-1]=='C') s[b-1]='c';
  cout<<s<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  int ans = 0;
  int prev;
  cin >> prev;
  for (int i=1; i<n; ++i) {
    int a;
    cin >> a;
    if (a==prev) {
      ans++;
      prev = 0;
    } else prev = a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj2199().doIt();
    }
    class aoj2199{
    	int dp[][] = new int[20001][256];
    	int C[] = new int[16];
    	int x[] = new int[20001];
    	int MAX = 200000000;
    	void set(int N,int M){
    		for(int i = 0;i <= N;i++){
    			for(int j = 0;j < 256;j++){
    				dp[i][j] = MAX;
    			}
    		}
    		for(int i = 0;i < M;i++)C[i] = sc.nextInt();
    		for(int i = 0;i < N;i++)x[i] = sc.nextInt();
    	}
    	int dp_table(int N,int M){
    		dp[0][128] = 0;
    		for(int i = 0;i < N;i++){
    			for(int j = 0;j < 256;j++){
    				if(dp[i][j] == MAX)continue;
    				for(int k = 0;k < M;k++){
    					int y = j + C[k];
    					if(y > 255)y = 255;
    					else if(y < 0)y = 0;
    					dp[i+1][y] = Math.min(dp[i+1][y],dp[i][j] + (x[i] - y)*(x[i] - y));
    				}
    			}
    		}
    		int min = MAX;
    		for(int i = 0;i < 256;i++)min = Math.min(min,dp[N][i]);
    		return min;
    	}
    	void doIt(){
    		while(true){
    			int N = sc.nextInt();
    			int M = sc.nextInt();
    			if(N + M == 0)break;
    			set(N,M);
    			System.out.println(dp_table(N,M));
    		}
    	}
    }
}

Measured memory_bytes: 92468
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int a, b, h, m;

    cin >> a >> b >> h >> m;

    double theta1 = 2.0 * PI * (double)m / 60.0;
    double theta2 = 2.0 * PI * ((double)m / 60.0 + (double)h) / 12.0;
    double theta = abs(theta1 - theta2);

    double ans = sqrt(double(a * a) + double(b * b) - 2.0 * a * b * cos(theta));

    cout << setprecision(10) << fixed << ans << "\n";

    return 0;
}



Measured memory_bytes: 4208
// inputに入力データ全体が入る
function Main(input) {
  var a,b;
  a = Number(input.split('\n')[0].split(' ')[0]);
  b = Number(input.split('\n')[0].split(' ')[1]);
  
  if(a < 6){
    console.log(0);
  }else if(a < 13){
    console.log(b / 2);
  }else{
    console.log(b);
  }  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<iostream>
#include<string>
#define INF 500050
using namespace std;
int a[INF];
int n,k,ans=1;
int main()
{
	cin >> n;
	
	for(int i=1; i<=3; i++) {
		ans *= n;
	}
	cout<<ans<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool b[21][21];
int w,h,count=0;

void dfs(int x, int y){
 b[y][x]=1;count++;
 int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
 int nx,ny;
 for(int i=0;i<4;i++){
  nx=dx[i]+x;
  ny=dy[i]+y;
  if(0<=nx&&nx<w&&0<=ny&&ny<h)
   if(b[ny][nx]==0)dfs(nx,ny);
  }
 }

int main(){
char a;
int sx,sy;
while(1){
cin>>w>>h;
count=0;
if(w+h==0)break;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++){
cin>>a;
b[i][j]=0;
if(a=='#')b[i][j]=1;
if(a=='@'){sx=j;sy=i;}
}
dfs(sx,sy);
cout<<count<<endl;
}
 return 0;
}

Measured memory_bytes: 3132
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def check(vec, init_pos, target_pos):
    dp = {init_pos}

    for nv in vec:
        dp_next = set()
        for v in dp:
            dp_next.add(v - nv)
            dp_next.add(v + nv)
        dp = dp_next

    return target_pos in dp


def main():
    S = readline().strip()
    x, y = map(int, readline().split())

    L = [len(commands) for commands in S.split('T')]

    init_x = L[0]
    x_commands = [c for c in L[2::2] if c != 0]
    y_commands = [c for c in L[1::2] if c != 0]

    ok = check(x_commands, init_x, x) and check(y_commands, 0, y)

    if ok:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 75692
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int a = scan.nextInt();
		String s = scan.next();
		out.println(a >= 3200 ? s : "red");
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main(){
   string s;
   int a[4];
   int i;
   cin>>s;
   for(i=0;i<4;i++) a[i]=(s[i]-'A');
   sort(a,a+4);
   if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2]) cout<<"Yes";
   else cout<<"No";
   return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


string s;
int M;
vector<int> h;

bool input() {
  cin >>s;
  if (s == "-") return false;
  cin >>M;
  h.assign(M, 0); rep(i, M) cin >>h[i];
  return true;
}

void solve(){
  string t = s;
  rep(j, M){
    int a = h[j]; int b = s.size() - h[j];
    for (int i=0; i<b; i++){
      t[i] = s[i+a];
    }
    for (int i=0; i<a; i++){
      t[i+b] = s[i];
    }
    swap(s, t);
  }
  cout <<s <<endl;
}

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


Measured memory_bytes: 3160
N,M = map(int,input().split())
C = {i:0 for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    C[a] = (C[a]+1)%2
    C[b] = (C[b]+1)%2
flag = 0
for i in range(1,N+1):
    if C[i]==1:
        flag = 1
        break
if flag==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 87648
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	int N, M; cin >> N >> M; 
	vector<int> E[300010] = {}; 
	for(int i = 0; i < M; i++){
		int u, v; cin >> u >> v; 
		u--; v--; 
		E[u*3].push_back(v*3+1); 
		E[u*3+1].push_back(v*3+2); 
		E[u*3+2].push_back(v*3); 
	}
	int S, T; 
	cin >> S >> T; 
	S --; T --; 
	int D[300010] = {}; 
	fill(D, D+N*3, 1145141919); 
	D[S*3] = 0; 
	queue<int> que; 
	que.push(S*3); 
	while(que.size()){
		int t = que.front(); que.pop();
		for(int i = 0; i < E[t].size(); i++){
			if(D[E[t].at(i)] < 1145141919) continue; 
			D[E[t].at(i)] = D[t] + 1; 
			que.push(E[t].at(i)); 
		}
	}
	if(D[T*3] == 1145141919) cout << -1 << endl; 
	else cout << D[T*3] / 3 << endl; 
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), c(M), x(M), y(M);
  rep(i, A) cin >> a[i];
  rep(i, B) cin >> b[i];
  int mn = inf;
  rep(i, M) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--, y[i]--;
    mn = min(a[x[i]]+b[y[i]]-c[i], mn);
  }
  sort(all(a));
  sort(all(b));
  cout << min(a[0]+b[0], mn) << endl;
  return 0;
}


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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N){
        int a;
        cin >> a;
        A.at(i) = a - (i + 1);
    }

    sort(all(A));

    int b = A.at(N/2);
    ll ans = 0;
    rep(i, N){
        ans += abs(A.at(i) - b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

bool possible(string &s, int i) {
    if(i == s.size()) return true;

    int n = s.size()-1;

    int sz = n-i+1;

    if(sz < 5) return false;

    if(s[i] == 'd') {

        if(s[i+1] == 'r' and s[i+2] == 'e' and
           s[i+3] == 'a' and s[i+4] == 'm') {
                bool ans = possible(s, i+5);
                if(ans) return ans;

           if(i+5 <= n and i+6 <= n) {
                if(s[i+5] == 'e' and s[i+6] == 'r') {
                    bool ans = possible(s, i+7);
                    if(ans) return ans;
                }
           }
           return false;
        } else return false;

    } else if(s[i] == 'e') {
        if(s[i+1] == 'r' and s[i+2] == 'a' and
           s[i+3] == 's' and s[i+4] == 'e') {
                bool ans = possible(s, i+5);
                if(ans) return ans;

           if(i+5 <= n) {
                if(s[i+5] == 'r') {
                    bool ans = possible(s, i+6);
                    if(ans) return ans;
                }
           }
           return false;
        } else return false;
    } else return false;

}

int main() {
    string s;
    cin>>s;
    if(possible(s, 0)){
        cout<<"YES";
    } else cout<<"NO";

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n,a[100],b,i;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i-1];
	}
	for(b=n;b>=1;b--){
		if(b==n){
			cout<<a[b-1];
		}else{
			cout<<" "<<a[b-1];
		}
	}
	cout<<endl;
	return 0;
}        

Measured memory_bytes: 3080
#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 bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int X, Y; cin >> X >> Y;
    cout << X + Y/2 << endl;

    return 0;
}


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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 2e9
#define int long long

const int N = 1e2 + 5;
const int VAL = 1e5 + 5;
int n , W;
int w[N] , v[N];
int dp[N][VAL];

main()
{
    //freopen("BAG.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> W;
    FOR(i , 1 , n)
        cin >> w[i] >> v[i];
    memset(dp , -1 , sizeof(dp));
    FOR(i , 0 , n)
        dp[i][0] = 0;
    int res = 0;
    FOR(i , 1 , n)
        FOR(j , 1 , W)
        {
            dp[i][j] = dp[i - 1][j];
            if(j >= w[i] && dp[i - 1][j - w[i]] != -1)
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i] , dp[i][j]);
            res = max(res , dp[i][j]);
        }
    cout << res;
}


Measured memory_bytes: 82304
nums= input().split()


for i in range(len(nums)):
    nums[i] = int(nums[i])
    
nums.sort()


if nums[1] == nums[2] and nums[0]<nums[1]:
    print("Yes")
elif nums[1] == nums[0] and nums[1]<nums[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

    
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 126976
X, K, D = map(int, input().split())

if X >= 0:
    num = min(K, X//D)
    X -= num*D
    K -= num
    if K%2:
        X -= D
else:
    num = min(K, abs(X)//D)
    X += num*D
    K -= num
    if K%2:
        X += D

print(abs(X))


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

using namespace std;
typedef unsigned long long ull;
int main(int argc, char *argv[])
{
 
    string s;
  	cin>>s;
     ull size=s.size();
     int curr=0;
     int maxicnt=0;
     set<char> charset={'A','C','G','T'};
    for(ull i=0;i<size;i++){

        if(charset.count(s[i])>0){
              curr++;
              if(i==size-1){
                  maxicnt=max(maxicnt,curr);
              }
        }else{
            if(curr>0){
                maxicnt=max(maxicnt,curr);
            }
            curr=0;
        }
    }
    cout<<maxicnt<<endl;
}


Measured memory_bytes: 256
def main():
    ii = lambda : int(input())
    mi = lambda : map(int,input().split())
    li = lambda : list(map(int,input().split()))
    n = ii()
    v = [[] for _ in range(n)]
    for i in range(n-1):
        u,vv,w = mi()
        v[u-1].append([vv -1,w % 2])
        v[vv-1].append([u -1,w % 2])
    flag = [0] * n
    flag[0] = 1
    ans = [-1] * n
    from collections import deque
    q = deque()
    q.append((0,0))
    ans[0] = 0
    while q:
        ima,ima_col = q.popleft()
        for lis in v[ima]:
            if flag[lis[0]] :continue
            flag[lis[0]] = 1
            if lis[1]:
                ans[lis[0]] = lis[1] - ima_col
                q.append((lis[0],lis[1] - ima_col))
            else:
                ans[lis[0]] = ima_col
                q.append((lis[0],ima_col))
    for i in range(n):
        print(ans[i])
main()
    
    

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

int main(){
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  if(a1==a2&&a1==a3){
    cout << 1 << endl;
  }
  else if(a1==a2||a1==a3||a2==a3){
    cout << 2 << endl;
  }
  else{
    cout << 3 << endl;
  }
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx, dy = ty - sy;

    string res = "";

    rep(i, dx) res += "R";
    rep(i, dy) res += "U";
    rep(i, dx) res += "L";
    rep(i, dy) res += "D";

    res += "D";
    rep(i, dx + 1) res += "R";
    rep(i, dy + 1) res += "U";
    res += "L";
    res += "U";
    rep(i, dx + 1) res += "L";
    rep(i, dy + 1) res += "D";
    res += "R";

    cout << res << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lolololololol ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main(){ lolololololol
	string a, b;
	cin>>a>>b;
	for(int i=0; i<a.size(); i++){
		if(a[i]!=b[i]){cout<<"No\n"; return 0;}
	}
	cout<<"Yes\n";
}

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

int n;
int a[55];

bool chk() {
	for(int i=1;i<n;i++)
		if(a[i] < a[i-1]) return false;
	return true;
}

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	
	bool f = chk();
	for(int i=0;i<n && !f;i++)
		for(int j=i+1;j<n && !f;j++) {
			swap(a[i], a[j]);
			f = chk();
			swap(a[i], a[j]);
		}
	puts(f ? "YES" : "NO");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============BIT============================
const ll MAX_N = pow(10, 5) * 5 + 1;
ll n;
vector<ll> bit(MAX_N + 1, 0);

ll sum(ll i) {
  i += 1;
  ll s = 0;
  while (i > 0) {
    s += bit.at(i);
    i -= i & -i;
  }
  return s;
}

void add(ll i, ll x) {
  i += 1;
  while (i <= n) {
    bit.at(i) += x;
    i += i & -i;
  }
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, Q;
  cin >> N >> Q;
  n = N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    add(i, a);
  }
  for (ll i = 0; i < Q; ++i) {
    ll q, p, x;
    cin >> q >> p >> x;
    if (q == 0) {
      add(p, x);
    }
    else {
      ll ans = sum(x - 1);
      if (p != 0) {
        ans -= sum(p - 1);
      }
      cout << ans << "\n";
    }
  }
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> k(m);
	vector<vector<int>> s(m);

	for (int i = 0; i < m; i++) {
		int kin;
		cin >> kin;
		k.at(i) = kin;
		for (int j = 0; j < kin; j++) {
			int sin;
			cin >> sin;
			s.at(i).push_back(sin);
		}
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		int pin;
		cin >> pin;
		p.at(i) = pin;
	}
	
	int bit;
	int count = 0;
	vector<int> on(n);
	for (bit = 0; bit < (1 << n); bit++) {
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) on.at(i) = 1;
			else on.at(i) = 0;
		}
		// check if each light is turned on
		bool check = true;
		int sum = 0;
		for (int i = 0; i < m; i++) {
			int size = s.at(i).size();
			for (int j = 0; j < size; j++) {
				int idx = s.at(i).at(j) - 1;
				sum += on.at(idx);
			}
			if (sum % 2 != p.at(i)) {
				check = false;
				break;
			}
			sum = 0;
		}
		if (check) count++;
		
	}

	cout << count << endl;
	return 0;

}


Measured memory_bytes: 3600
import sys

read = sys.stdin.read


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


def make_table(n, mod=10 ** 9 + 7):
    N = n
    # 元テーブル
    g1 = [0] * (N + 1)
    g1[0] = 1
    g1[1] = 1

    # 逆元テーブル
    g2 = [0] * (N + 1)
    g2[0] = 1
    g2[1] = 1

    # 逆元テーブル計算用テーブル
    inverse = [0] * (N + 1)
    inverse[0] = 0
    inverse[1] = 1

    for i in range(2, N + 1):
        g1[i] = (g1[i - 1] * i) % mod
        inverse[i] = (-inverse[mod % i] * (mod // i)) % mod
        g2[i] = (g2[i - 1] * inverse[i]) % mod

    return g1, g2


N, K, *A = map(int, read().split())
A.sort()
mod = 10 ** 9 + 7
if K == 1:
    print(0)
    exit()

g1, g2 = make_table(N)
A = [0] + A
answer = 0
for i in range(1, N + 1):
    answer += A[i] * (cmb(i - 1, K - 1, mod) - cmb(N - i, K - 1, mod)) % mod
    answer %= mod

print(answer)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    REP(i, N) cin >> v[i] >> w[i];
    int dp[N+1][W+1] = {};
    int res = 0;
    REP(i, N){
        REP(j, W+1){
            if(j<w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(max(dp[i][j], dp[i][j-w[i]]+v[i]), dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 7024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        p: usize,
        q: usize,
        r: usize,
    }
    let pq = p + q;
    let pr = p + r;
    let qr = q + r;
    println!("{}", [pq, pr, qr].iter().min().unwrap());
}


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

int main() {
	char s[100];
	int k;
	cin >> s;
	cin >> k;
	for (int i = 0; i < k; i++) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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


int main() {
	ll N, A, B;
	cin >> N >> A >> B;

	ll repeat = N / (A + B);

	ll last = N - (A + B) * repeat;

	cout << A * repeat + min(A, last) << endl; 
	 
	return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
a = []
for _ in range(H):
	a.append(input())

dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0]=1

for i in range(1,H):
	if a[i][0]=='#':
		dp[i][0] = 0
	else:
		dp[i][0] = dp[i-1][0]

for j in range(1,W):
	if a[0][j]=='#':
		dp[0][j] = 0
	else:
		dp[0][j] = dp[0][j-1]

for i in range(1,H):
	for j in range(1,W):
		if a[i][j]=='#':
			dp[i][j] = 0
		else:
			dp[i][j] = dp[i-1][j]+dp[i][j-1]
ans =dp[H-1][W-1]
ans = ans%((10**9)+7)
print(ans)

Measured memory_bytes: 263884
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def scores(c, s, t):
    last = [0] * 26
    V = []
    lastv = 0
    D = len(t)
    for d, i in enumerate(t):
        last[i] = d+1
        if d != D-1:
            continue
        v = s[d*26+i]
        sub = sum([c[j]*(d+1-last[j]) for j in range(26)])
        # print(v, sub)
        lastv += v-sub
        V.append(lastv)
    return V


def main():
    D, *cs = map(int, read().split())
    c = cs[:26]
    s = cs[26:]

    b = 0
    ans = []
    for d in range(D):
        maxi = 0
        score_max = -1000000000
        for i in range(26):
            score = scores(c, s, ans + [i])[-1]
            # print(i, score)
            if score > score_max:
                maxi = i
                score_max = score
        ans.append(maxi)
        b += 26

    ans = [a+1 for a in ans]
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 69592
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.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;}

using ll=long long;
using R=long double;
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};

const pid_t pid = getpid();
// Problem Specific Parameter:

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

	int ans = n;

	int fw = 0, le = 0;
	rrep(j,n,1) le += (s[j] == 'E');

	rep(i,n){
		chmin(ans,fw + le);
		fw += (s[i] == 'W');
		if(i+1 < n) le -= (s[i+1] == 'E');
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
    int N;
    string S;
    cin >> N >> S;
    int cnt = 0;
    for (int i = 0; i < S.length() - 2; i++) {
        if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,h,w;
    cin>>n>>h>>w;
    ll ans= (n-h+1)*(n-w+1);
    cout<<ans<<endl;
    return  0;
}


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

namespace Print_a_Frame
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = "";
            List<string> inputs = new List<string>();

            while (true)
            {
                input = Console.ReadLine();
                if (input.Equals("0 0"))
                {
                    break;
                }
                inputs.Add(input);
            }

            foreach (string item in inputs)
            {
                string[] frame = item.Split(' ');
                int row = int.Parse(frame[0]);
                int col = int.Parse(frame[1]);

                for (int i = 0; i < col; i++)
                {
                    Console.Write("#");
                }

                Console.WriteLine();

                for (int i = 0; i < row - 2; ++i)
                {
                    string temp = "";

                    for(int j = 0; j < col -2;++j)
                    {
                        temp += ".";
                    }
                    Console.WriteLine("#" + temp + "#");
                }

                for (int i = 0; i < col; ++i)
                {
                    Console.Write("#");
                }

                Console.WriteLine();
                Console.WriteLine();
            }

        }
    }
}



Measured memory_bytes: 22060
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N, K;
string S, T;
map<int, int> mp;

void solve() {
	cin >> N >> K;

	ll cnt = 0;

	long double pr = 0;

	for (ll i = N; i > 0; i--) {

		if (i >= K) {
			//cout << i << "!" << cnt <<endl;
			//pr += 1;
			mp[0]++;
			continue;
		}

		if ((K / pow(2, cnt)) > i) {
			//cout << i << "%" << cnt <<endl;
			cnt++;
			i++;
			continue;
		}

		//pr += (1.0 / pow(2, cnt));
		mp[cnt]++;
		//cout << i << ": " << (1.0 / pow(2, cnt))*(1.0 / N) << " : " << cnt<<endl;

	}

	ll bigm = pow(2,ceil(log2(K)));

	ll ch = 0;

	for (auto p : mp) {
		//cout << p.first << ":" << p.second << endl;
		ch += p.second * (bigm / pow(2, p.first));
		//cout << ch << endl;
	}
	//cout << ch<<endl;
	//cout << bigm << endl;
	//pr = ((long double)p.second / pow(2.0, p.first)) * (1.0 / N);
	pr = (long double)ch / bigm / N;
	cout << setprecision(12) << pr;

}

int main() {
	solve();
	cout << endl;
	return 0;
}


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

int minCost(int n,int* arr,int k)
{
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);

    for(int i=2;i<n;i++)
    {
        int ans = INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i<j){
                break;
            }
            int option = abs(arr[i] - arr[i-j]) + dp[i-j];
            ans = min(ans,option);
        }
        dp[i] = ans;
    }
    return dp[n-1];
    
}

int main() 
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    cout<<minCost(n,arr,k);
    return 0;
}


Measured memory_bytes: 1024
input = gets.to_i
nums = gets.split(' ').map(&:to_i)

arr = []
arr.push(0)

for i in 1..input do
	arr.push(arr.last+nums[i-1])
end

arr.sort!

pointer = 0
ans = 0
while pointer <= input do
	num = arr[pointer]
	i = pointer+1
	count = 1
	while arr[i] == num do
		count += 1
		i += 1
	end
	
	if count > 1 then 
		count = count*(count-1)/2
		ans +=count
	end
	
	pointer = i

end
puts ans


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

int INF=1e9;

int n;
int d[20][20];

int dp[1<<17];

int rec(int S){
    if(dp[S]>=0)return dp[S];
    
    if(S==(1<<n)-1){
        dp[S]=0;
        return dp[S];
    }
    
    int res=INF;
    for(int u=0;u<n;u++){
        if(!(S>>u&1)){
            int x=d[u][0];
            for(int i=0;i<n;i++){
                if(S>>i&1)x=min(x,d[u][i+1]);
                res=min(res,rec(S|1<<u)+x);
            }
        }
    }
    dp[S]=res;
    return dp[S];
}


int main(void){
    while(1){
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            for(int j=0;j<=n;j++){
                cin>>d[i][j];
            }
        }
        for(int i=0;i<1<<17;i++){
                dp[i]=-1;
        }
        int ans=rec(0);
        cout<<ans<<endl;
    }
    return 0;
}



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

class Program
{
    void Run()
    {
        var sc = new Scanner();
        string s = sc.NextString();
        int a = int.Parse(s.Substring(0, 2));
        int b = int.Parse(s.Substring(2, 2));
        bool ya = a > 0;
        bool ma = a <= 12 && a >= 1;
        bool yb = b > 0;
        bool mb = b <= 12 && b >= 1;
        if (ya && ma && yb && mb) Console.WriteLine("AMBIGUOUS");
        else if (ma) Console.WriteLine("MMYY");
        else if (mb) Console.WriteLine("YYMM");
        else Console.WriteLine("NA");
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define endl "\n"
#define goat() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL))
typedef long long ll;
int arr[10005];
int main() {
	goat();
	int n, k, i, c = 0;
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	for (i = 1; i <= n; i++) {
		if (i % 2 != 0 && arr[i] % 2 != 0) {
			c++;
		}
	}
	cout << c;
}

Measured memory_bytes: 3636
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define rep0(_i, _n) for(int _i = 0, _l = _n; (_i)<(_l) ;++_i)
#define rep1(_i, _n) for(int _i = 1, _l = _n; (_i)<=(_l) ;++_i)
#define rans(i) (cout << ((i)?"Yes" : "No") << '\n')
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define multi int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(T begin, T end){while(begin != end)cin >> *begin, ++begin;}
template<typename T> void write(T begin, T end){while(begin != end)cout << *begin << " \n"[next(begin) == end], ++begin;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 300010;
int n;
vector<int> a, b;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	a.resize(n), b.resize(n);
	read(a.begin(), a.end()), read(b.begin(), b.end());
	vector<int> sa(a), sb(b), pos(n);
	sort(sa.begin(), sa.end()), sort(sb.begin(), sb.end());
	for(int i = 0;i < n;++i)if(sa[i] > sb[i])rout("No");		
	for(int i = 1;i < n;++i)if(sa[i] <= sb[i-1])rout("Yes");
	for(int i = 0;i < n;++i)pos[lower_bound(sb.begin(), sb.end(), b[i]) - sb.begin()] = i;
	for(int i = 0;i < n;++i)a[i] = pos[lower_bound(sa.begin(), sa.end(), a[i]) - sa.begin()];
	int cnt = 0;
	rep0(i, n){
		while(a[i] != i)++cnt, swap(a[i], a[a[i]]);
	}	
	rans(cnt <= n-2);
}

Measured memory_bytes: 2176
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

// 二項係数計算
long long 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;
}

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

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  string s; cin >> s;
  int ans=0;
  rep(i,3){
    if (s[i]=='1'){ans++;}
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256