akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
 
	public static void main(String[] args) {
		new Main();	
	}
 
	public Main() {
		new A().doIt();
	}
	class A{
		class Data{
            int num,cnt;
            public Data(int num,int cnt) {
                this.num = num;
                this.cnt = cnt;
            }
        }
		void sort(Data data[],int m){
			Data temp;
			for(int i = 1;i < m;i++){
				for(int j = i;j > 0;j--){
					if(data[j].cnt > data[j-1].cnt){
						temp = data[j];
						data[j] = data[j-1];
						data[j-1] = temp;
					}
				}
			}
		}
		void doIt(){
			while(true){
				int i,j;
				int n = sc.nextInt();
				int m = sc.nextInt();
				if(n + m == 0)break;
				Data data[] = new Data [m];
				for(i = 0;i < m;i++)data[i] = new Data(i+1,0);
				for(i = 0;i < n;i++){
					for(j = 0;j < m;j++){
						data[j].cnt = data[j].cnt + sc.nextInt();
					}
				}
				sort(data,m);
				for(i = 0;i < m-1;i++)System.out.print(data[i].num+" ");
				System.out.println(data[m-1].num);
			}
		}
	}
}

Measured memory_bytes: 83356
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int N, M, X, Y;	cin >> N >> M >> X >> Y;
	vector<int> x(N), y(M);
	vector<int> num;
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> y[i];
	}
	for (int i = X + 1; i <= Y; ++i) {
		num.push_back(i);
	}
	bool b = false;
	for (int i = 0; i < num.size(); ++i) {
		b = false;
		for (int j = 0; j < N; ++j) {
			if (num[i] <= x[j]) {
				b = true;
			}
		}
		for (int j = 0; j < M; ++j) {
			if (num[i] > y[j]) {
				b = true;
			}
		}
		if (!b) {
			cout << "No War" << endl;
			cin >> N;
			return 0;
		}
	}
	cout << "War" << endl;
	cin >> N;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;

int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i =0 ; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}

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

using namespace std;

int main() {
    int n,k; cin>>n>>k;
    
    int ans=0;
    for (int i=0;i<n;i++) {
        int h; cin>>h;
        if (h >= k) ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    string t; cin >> t;
    int ans = 0;
    for (int i = 0; i < k; i++) {
        V< V<int> > dp(2, V<int>(3, 0));
        dp[0][0] = (t[i] == 's' ? r : 0);
        dp[0][1] = (t[i] == 'p' ? s : 0);
        dp[0][2] = (t[i] == 'r' ? p : 0); 
        for (int j = i + k; j < n; j += k) {
            dp[1] = V<int>(3, 0);
            dp[1][0] = max(dp[0][1], dp[0][2]) + (t[j] == 's' ? r : 0);
            dp[1][1] = max(dp[0][0], dp[0][2]) + (t[j] == 'p' ? s : 0);
            dp[1][2] = max(dp[0][0], dp[0][1]) + (t[j] == 'r' ? p : 0);
            swap(dp[0], dp[1]);
        }
        ans += max({dp[0][0], dp[0][1], dp[0][2]});
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3748
s = input()
if (int(s[:2]) >= 13 or s[:2] == '00') and (int(s[2:4]) >= 13 or s[2:4] == '00'):
    print('NA')
elif 0 < int(s[:2]) <= 12 and 0 < int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif 0 < int(s[:2]) <= 12:
    print('MMYY')
else:
    print('YYMM')
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  string s;
  cin >> s;
  int ans1 = 0;
  REP(i, s.size()) {
    if (i % 2 == 0) {
      if (s[i] == 'p') ans1--;
    } else {
      if (s[i] == 'g') ans1++;
    }
  }
  cout << ans1 << endl;
}

Measured memory_bytes: 3744
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
MOD = 1000000007

dp = [0]*(n+2)
dp[0] = 1
for i in range(n):
    if i+1 not in a:
        dp[i+1] += dp[i]
        dp[i+1] %= MOD
    if i+2 not in a:
        dp[i+2] += dp[i]
        dp[i+2] %= MOD

print(dp[n])


Measured memory_bytes: 13216
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            printf("%d\n",da[i]);
        }
        else{
            printf("%d ",da[i]);
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}


int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> da(h);
    rip(i,h,0){
        cin >> da[i];
    }
    vector<vector<int>> ans(h,vector<int>(w));
    vector<int> me(h,0);
    rip(i,h,0){
        rip(j,w,0){
            if(da[i][j] == '#'){
                me[i] ++;
            }
        }
    }
    int now = 1;
    rip(i,h,0){
        if(me[i]==0){
            continue;
        }
        bool ju = true;
        rip(j,w,0){
            if(ju && da[i][j] == '#'){
                ju = false;
            }
            else if(da[i][j] == '#'){
                now++;
            }
            ans[i][j] = now;
        }
        now++;
    }
    rip(i,h,1){
        if(me[i] == 0 && me[i-1] > 0){
            rip(j,w,0){
                ans[i][j] = ans[i - 1][j];
            }
            me[i] = me[i - 1];
        }
    }
    for(int i = h-2;i>-1;i--){
        if(me[i] == 0 && me[i+1]>0){
            rip(j,w,0){
                ans[i][j] = ans[i+1][j];
            }
            me[i] = me[i+1];
        }
    }
    vvdeb(ans);
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, p, mx, s = 0;
	cin >> n;
	n--; cin >> mx;
	s += mx;
	while (n--) {
		cin >> p;
		if (p > mx) mx = p;
		s += p;
	}
	s -= mx/2;
	cout << s << ende;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int &x : a) cin >> x;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; i++) ans += a[i];
    cout << ans;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define N_MAX 100000
#define Q_MAX 50000

int main(){
  int n,q,S[N_MAX],T[Q_MAX],l,m,r,i,j,cnt=0;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&T[i]);
  }
 
  for(i=0;i<q;i++){
    l = 0;
    r = n;
    while(l < r){
      m = (l + r)/2;
      if(T[i] == S[m]){
	cnt++;
	break;
      }
      else if(T[i] > S[m])l = m + 1;
      else if(T[i] < S[m])r = m;
    }
  }


  printf("%d\n",cnt);
  return 0;
  
}



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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}

inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}

bool isPrime(int n){
    for(int i=2; i*1LL*i <= n; i++){
        if(n%i == 0) return false;
    }
    return true;

}

int main()
{
    ///freopen("output.txt","w",stdout);
    //freopen("input.txt","r",stdin);
    FastIO;
    int cnt = 0;
    int n;
    cin>>n;
    for(int i=2; n && i<=55555; i += 5){
        if(isPrime(i)){
            cout<<i<<" ";
            n--;
        }
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

signed main(void){
  int N,ans=0;
  cin >> N;
  REP(i,N+1) ans+=i;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
typedef unsigned long long int ull;

using namespace std;
ull gcd(ull x1, ull x2){
  if(x1 == 0) { return x2; }
  if(x2 == 0) { return x1; }
  if(x1 > x2){
    return gcd(x1 % x2, x2);
  } else {
    return gcd(x1, x2 % x1);
  }
}
ull lcm(ull x1, ull x2){
  return x1 * x2 / gcd(x1, x2);
}

int main(){
  ull a, b;
  while(cin >> a >> b){
    cout << gcd(a,b) << " " << lcm(a,b) << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 3001;

int main(void){
    bool isL[N];
    rep(i, N) isL[i] = (!(i % 4) && (i % 100 || !(i % 400)));

    for(int a, b, cnt = 0; cin >> a >> b, a;){
        if(cnt ++) cout << endl;

        bool ex = false;
        for(; a <= b; a ++) if(isL[a]) ex = cout << a << endl;

        if(!ex) cout << "NA\n";
    }
 
    return 0;
}

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


int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	bool flag = 0;
	
	for(int i=0; i<=b; i++){
		if(! (a*i % b - c) ) {
			cout << "YES" << endl;
			flag = 1;
			break;
		}
	}
	if (!flag) cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
debug = false

def gcd(a,b)
  if b == 0 then
    return a
  elsif b == 1 then
    return 1
  end
  
  return gcd(b, a%b)
end

N = gets.to_i
T = Array.new(N)
A = Array.new(N)
N.times do |i|
  T[i], A[i] = gets.split.map(&:to_i)
  # temp = gets.split.map(&:to_i)
  # g = gcd(temp.max, temp.min)
  # T[i] = temp[0]/g
  # A[i] = temp[1]/g
end

t = T[0]
a = A[0]

(1...N).each do |i|
  puts "(t,a) = (#{t},#{a})" if debug
  #  a = A[i]*t/T[i] if a < A[i]*t/T[i]
  # if a > A[i] then
  #   a = (a+A[i]-1)/A[i]*A[i]
  # else
  #   a = A[i]
  # end

  # if t > a*T[i]/A[i] then
    
  # loop do
  #   if t > a*T[i]/A[i] then
  #     a += A[i]
  #   else
  #     break
  #   end
  # end
  # t = a*T[i]/A[i]

  g = [(a+A[i]-1)/A[i],(t+T[i]-1)/T[i]].max
  a = g*A[i]
  t = g*T[i]
  
end
puts "(t,a) = (#{t},#{a})" if debug

puts a+t


Measured memory_bytes: 1788
<?php
    $input = trim(fgets(STDIN));
    $array_area=explode(" ", $input);
    $a = $array_area[0];
    $b = $array_area[1];
    $c = $array_area[2];
    $result= $a < $b && $b < $c? "Yes" : "No";
    print $result;
    ?>

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

bool is753(long n)
{
    int b = 0;
    while (n != 0) {
        b |= 1 << (n % 10);
        if ((b & 0xA8) == 0xA8) return true; // 10101000
        n /= 10;
    }
    return false;
}

long solve(long n, long a)
{
    if (a > n) {
        return 0;
    }
    long ans = 0;
    if (is753(a)) {
        ans = 1;
    }
    ans += solve(n, a * 10 + 3);
    ans += solve(n, a * 10 + 5);
    ans += solve(n, a * 10 + 7);
    return ans;
}

int main()
{
    long n;
    cin >> n;
    long ans = solve(n, 0);
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a>=13){
        printf("%d\n", b);
    }else if(a>=6){
        printf("%d\n", b/2);        
    }else{
        printf("%d\n", 0);
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    try: inp = input()
    except: break
    L = list(map(int, inp.split(',')))
    l, v1, v2 = L[:-2], L[-2], L[-1]
    r_sum, l_sum = sum(l), 0
    ans = 0
    for i in range(10):
        l_sum += l[i]
        r_sum -= l[i]
        if l_sum * v2 >= r_sum * v1:
            ans += i + 1
            break
    print(ans)



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int drow[] = { -1, 0, 1, 0 };
int dcolumn[] = { 0, -1, 0, 1 };

int main() {
	int h, w;
	vector<string> m;

	cin >> h >> w;

	m.resize(h);
	for (int i = 0; i < h; i++) {
		cin >> m[i];
	}

	string result = "Possible";

	int i = 0;
	int j = 0;

	if (m[i][j] == '.') {
		result = "Impossible";
	}
	else {
		m[i][j] = '$';
	}

	while (result == "Possible" && (i != h - 1 || j != w - 1)) {
		int total = 0;
		int ni = i;
		int nj = j;
		for (int k = 0; k < 4; k++) {
			int ci = i + drow[k];
			int cj = j + dcolumn[k];

			if (ci > -1 && ci < h && cj > -1 && cj < w && m[ci][cj] == '#') {
				total++;
				ni = ci;
				nj = cj;
			}
		}

		if (total != 1 || ni < i || nj < j) {
			result = "Impossible";
		}
		else {
			i = ni;
			j = nj;
			m[i][j] = '$';
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (m[i][j] == '#') {
				result = "Impossible";
			}
		}
	}

	cout << result << "\n";

	return 0;
}

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

double pi = 3.14159265358979323846;

vector<vector<int> > adj;
map<int, int> res;
vector<bool> visited;

void bfs(int n){
    queue<int> q;
    visited[n] = true;
    q.push(1);
    while(!q.empty()){
        int len = q.size();
        for(int i = 0; i < len; i++){
            int parent = q.front();
            q.pop();
            for(auto j : adj[parent]){
                if(!visited[j]){
                    visited[j] = true;
                    res[j] = parent;
                    q.push(j);
                }
            }
        }
    }
}

void testCase(){
	int n, m, a, b;
    cin>>n>>m;
    adj.resize(n+1);
    for(int i = 0; i < m; i++){
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    visited.resize(n+1, false);
    
    // for(int i = 1; i <= n; i++){
    //     cout<<i<<" : ";
    //     for(auto j : adj[i]) cout<<j<<" ";
    //     cout<<endl;
    // }

    bfs(1);
    if(res.size() < n-1) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        for(int i = 2; i <= n; i++){
            cout<<res[i]<<endl;
        }
    }
}

int main(){
    int t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}


Measured memory_bytes: 14464
#include<iostream>
using namespace std;
int main(){
  int n[5],k,hantei=0;
  for(int i=0;i<5;i++){
      cin >> n[i];
  } 
  cin >> k;
  for(int i=0;i<5;i++){
      for(int j=i+1;j<5;j++){
          if(n[j]-n[i] > k){
              hantei = 1;
              break;
          }
      }
  }
  if(hantei == 0) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

ll fact(ll n)  // n!を求める(%mod)
{
  if (n == 0)
    return 1;
  else
    return n * fact(n - 1) % mod;
}

ll calc(ll n, ll k)  // nのk乗%mod
{
  if (k == 0) return 1;
  if (k % 2 == 0)
    return calc(n * n % mod, k / 2) % mod;
  else
    return n * calc(n * n % mod, k / 2) % mod;
}

ll comb(ll n, ll k)  // nCkを求める(%mod)
{
  return fact(n) * calc(fact(k), mod - 2) % mod * calc(fact(n - k), mod - 2) %
         mod;
}
int main() {
  ll x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (max(x, y) > min(x, y) * 2) {
    cout << 0 << endl;
    return 0;
  }
  ll k = 0;
  ll n = (x + y) / 3;
  ll m = abs(x - y);
  while (n != m) {
    k++;
    n -= 2;
  }
  cout << comb((x + y) / 3, k) << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<61);

int n;
vector<map<int, int>> edges;
vl depth;

void calcDep(int node, int d) {
  if (depth[node] != INF) return;
  depth[node] = d;

  for (auto it : edges[node]) {
    int next_node = it.ss;
    calcDep(next_node, d+1);
  }
}

pll findMid(int t, int d) {
  int pre = t;
  while (true) {
    for (auto it : edges[pre]) {
      int cur = it.ss;
      if (depth[cur] == d) {
        return mp(cur, pre);
      }
      if (depth[cur] == depth[pre]-1) {
        pre = cur;
        break;
      }
    }
  }
}

int calcNum(int node, int pre) {
  int num = 1;
  for (auto it : edges[node]) {
    int next_node = it.ss;
    if (next_node != pre) {
      num += calcNum(next_node, node);
    }
  }
  return num;
}

int main() {
  cin >> n;
  edges.resize(n);
  depth.assign(n, INF);
  rep(i,n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    edges[a][b] = b;
    edges[b][a] = a;
  }

  calcDep(0, 0);
  // outa(depth, n);
  pll mid_nodes = findMid(n-1, depth[n-1]/2);
  edges[mid_nodes.ff].erase(mid_nodes.ss);
  edges[mid_nodes.ss].erase(mid_nodes.ff);

  int fennec = calcNum(0, -1);
  int snuke  = calcNum(n-1, -1);

  // cerr << fennec << ", " << snuke << endl;
  if (fennec > snuke) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }

  return 0;
}


Measured memory_bytes: 18304
#include <stdio.h>

int main(void)
{
	int i, n, y, num[7];
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < 7; i++){
			num[i] = 0;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d\n", &y);
			
			if (y >= 70){
				num[6]++;
			}
			else {
				num[y / 10]++;
			}
		}
		
		for (i = 0; i < 7; i++){
			printf("%d\n", num[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
N = int(input())
numbers = [int(x) for x in input().split()]
numbers.sort()

csum = [0] * (N + 1)

for i in range(N):
  csum[i + 1] = csum[i] + numbers[i]

count = 1  # 一番大きい数は常にOK

for i in range(N - 1, -1, -1):
  if csum[i] * 2 < numbers[i]:
    break
  count += 1
  
print(count)  


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

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

using namespace std;

struct Edge { int next, dir; };

int w,h,sp;
bool field[20][20];
vector<Edge> G[500];
bool visited[500],used[500];
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

bool isValid(int x,int y) { return 0 <= x && x < w && 0 <= y && y < h; }

bool check2(int cur){
  rep(i,h*w) used[i] = false;
  rep(i,h) rep(j,w) if( field[i][j] || visited[j+i*w] ) used[j+i*w] = true;
  deque<int> deq;
  deq.push_back(cur);
  used[sp] = false;
  used[cur] = true;
  while( !deq.empty() ){
    int v = deq.front(); deq.pop_front();
    if( v == sp ) return true;
    rep(i,(int)G[v].size()) {
      int next = G[v][i].next;
      if( used[next] ) continue;
      used[next] = true;
      deq.push_back(next);
    }
  }
  return false;
}


bool check3(int cur){
  int counter;
  rep(i,h) rep(j,w) if( !field[i][j] && !visited[i*w+j] ){
    counter = 0;
    rep(k,4){
      int nx = j + dx[k], ny = i + dy[k];
      if( !isValid(nx,ny) ) continue;
      if( field[ny][nx] ) continue;
      if( visited[ny*w+nx] ) continue;
      ++counter;
    }
    if( counter == 1 ) {
      int outer = 0;
      int diff_x = abs(sp%w-j), diff_y = abs(sp/w-i);
      if( diff_x+diff_y <= 1 ) ++outer;
      diff_x = abs(cur%w-j), diff_y = abs(cur/w-i);
      if( diff_x+diff_y <= 1 ) ++outer;
      if( outer == 0 ) return false;
    }
  }
  return true;
}

bool dfs(int cur,int remain){
  if( remain == 0 ) {
    int diff_x = abs( cur % w - sp % w ), diff_y = abs( cur / w - sp / w );
    if( diff_x+diff_y == 1 ) return true;
    return false;
  }
  
  rep(i,(int)G[cur].size()){
    int next = G[cur][i].next;
    if( visited[next] ) continue;
    if( !check2(next) ) continue;
    if( !check3(next) ) continue;
    visited[next] = true;
    if( dfs(next,remain-1) ) return true;
    visited[next] = false;
  }

  return false;
}

void compute(){
  sp = -1;
  rep(i,h*w) G[i].clear(), visited[i] = false;
  rep(y,h) rep(x,w) if( !field[y][x] ){
    if( sp == -1 ) sp = x + y * w;
    rep(i,4){
      int nx = x + dx[i], ny = y + dy[i];
      if( !isValid(nx,ny) ) continue;
      if( field[ny][nx]   ) continue;
      G[x+y*w].push_back((Edge){nx+ny*w,i});
    }
  }

  rep(i,h*w) if( G[i].size() == 1 ) { puts("No"); return; }
  
  int remain = 0;
  rep(i,h) rep(j,w) if( !field[i][j] ) ++remain;
  visited[sp] = true;
  if( ( remain & 1 ) || remain == 0 ) { puts("No"); return; }
  puts(dfs(sp,remain-1)?"Yes":"No");
}

int main(){
  while( cin >> w >> h, w|h ){
    rep(i,h) rep(j,w) cin >> field[i][j];
    compute();
  }
  return 0;
}

Measured memory_bytes: 1188
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string ans = "NO";
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i <= b; i++) {
    if (a * i % b == c) {
      ans = "YES";
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

const int INF = 0x7fffffff;
const int _INF = 0x7fffffff + 1;

const int MAXN = 100000;
int buc[MAXN + 2];

int main()
{
    int n;
    cin>>n;
    int num = 0, temp;
    long long ans = 1;
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &temp);
        buc[temp]++;
        if(temp > num)
            num = temp;
    }
    int flag = 1;

    //printf("%d", num);

    if(num % 2)
    {
        int len = num;
        for(int i = 0; i <= MAXN; i++)
        {
            if(i % 2 && i <= len)
            {
                if(buc[i] != 2)
                    flag = 0;
            }
            else
            {
                if(buc[i] != 0)
                    flag = 0;
            }
        }
        num++;
    }
    else
    {
        int len = num;
        if(buc[0] != 1)
            flag = 0;
        for(int i = 1; i <= MAXN; i++)
        {
            if(i <= len && i > 0 && !(i % 2))
            {
                if(buc[i] != 2)
                    flag = 0;
            }
            else
            {
                if(buc[i] != 0)
                    flag = 0;
            }
        }
    }
    for(int i = 0; i < num / 2; i++)
        ans = (ans * 2) % 1000000007;

    if(flag)
        printf("%lld", ans);
    else
        printf("0");
    return 0;
}


Measured memory_bytes: 640
<?php
$sum = [0 => PHP_INT_MAX];
$ans = 0;
$mmax = 0;
fscanf(STDIN, "%d %d", $N, $M);
$arr = array_fill(1, $M, []);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    $arr[$A][] = $B;
}

for ($i = 1; $i <= $M; $i++) {
    foreach ($arr[$i] as $v) {
        if (!isset($sum[$v])) {
            $sum[$v] = 1;
        } else {
            ++$sum[$v];
        }
        if ($mmax < $v) {
            $mmax = $v;
        }
    }

    $ans += $mmax;
    if ($sum[$mmax] === 1) {
        unset($sum[$mmax]);
        $mmax = max(array_keys($sum));
    } else {
        --$sum[$mmax];
    }
}
echo $ans;

Measured memory_bytes: 47608
#!/usr/bin/env python3
a,b,k = map(int,input().split())
from fractions import gcd
g = gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    divisors.reverse()
    return divisors
li = make_divisors(g)
print(li[k-1])


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

int Holdmetight(int n){
    int sum=0;
    while (n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int total=0;
    for(int i=1;i<=N;i++){
        int sum=Holdmetight(i);
        if(sum>=A&&sum<=B){
            total+=i;
        }
    }
    cout<<total<<endl;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
    const char* c = strchr(na + 1, ',');
    cerr.write(na, c - na) << " : " << arg1 << " , ";
    __f(c + 1, args...);
}
#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    for (int tc = 1; tc <= t; tc++) solve();
    return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int& b : B) cin >> b;
  int a, ret = 0;
  for (int i = 0; i < N; i++) {
    int score = C;
    for (int j = 0; j < M; j++) {
      cin >> a;
      score += a * B[j];
    }
    if (score > 0) ret++;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

ll N, K;
vector< ll > d;

signed main()
{
  set< ll > a;
  cin >> N >> K;
  REP(i, K)
  {
    ll di;
    cin >> di;

    REP(j, di)
    {
      ll aj;
      cin >> aj;
      a.insert(aj);
    }
  }

  cout << N - a.size() << endl;
}


Measured memory_bytes: 3632
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;
    rep(i, SZ(s)){
        if(i % 2){
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10;

int main(void) {
	int x, y; cin >> x >> y;
	(!(y % 2) && (x * 2 <= y) && (y <= x * 4)) ? cout << "Yes\n" : cout << "No\n";
	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();

        if (x >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35760
ans = []
def dfs(li):
    if len(li) == n:
        ans.append(li)
        return
    else:
        for i in range(li[-1], m + 1):
            dfs(li + [i])
 
  

n, m, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(q)]

for i in range(1, m + 1):
   dfs([i])
# print(ans)

res = 0
for ptn in ans:
    tmp = 0
    for a, b, c, d in info:
        a -= 1
        b -= 1
        if ptn[b] - ptn[a] == c:
            tmp += d
    res = max(res, tmp)
print(res)

Measured memory_bytes: 95460
import sys
H, W, M = map(int, sys.stdin.readline().split())
hlst = {}
wlst = {}
hwlst = []

for i in range(M):
    h, w = map(int, sys.stdin.readline().split())
    if h in hlst:
        hlst[h] += 1
    else:
        hlst[h] = 1

    if w in wlst:
        wlst[w] += 1
    else:
        wlst[w] = 1

    hwlst.append([h, w])

h = max(hlst.values())
w = max(wlst.values())
hmax = [i for i in hlst if hlst[i] == h]
wmax = [i for i in wlst if wlst[i] == w]
num = len(hmax)*len(wmax)


for i in hwlst:
    if hlst[i[0]] == h and wlst[i[1]] == w:
        num -= 1

if num:
    print(h+w)
else:
    print(h+w-1)


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

int main(){
  int n, d; cin >> n >> d;
  int ans;
  if(n%(2*d+1))
  	ans = n/(2*d+1)+1;
  else
    ans = n/(2*d+1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int H, W;
  ci(H, W);
  ve<st> S(H);
  rep(i, H){
    ci(S.at(i));
    rep(j, W){
      if(S.at(i).at(j) == '.'){
        S.at(i).at(j) = '0';
      }
    }
  }
  rep(i, H){
    rep(j, W){
      if(S.at(i).at(j) == '#'){
        repi(k, i - 1, i + 2){
          repi(l, j - 1, j + 2){
            if(0 <= k && k <= H - 1 && 0 <= l && l <= W - 1){
              if(S.at(k).at(l) != '#'){
                S.at(k).at(l) ++;
              }
            }
          }
        }
      }
    }
  }
  rep(i, H){
    co(S.at(i));
  }
}

Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

int main(){
    GO();
    int n;
    cin>>n;
    cout<<fixed<<setprecision(12)<<1.0-((n/2)/(n+0.0))<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < s.length(); i++) {
			char target = s.charAt(i);
			int index = s.indexOf(target);
			int max = index;
			while (index != -1) {
				int tmp = s.indexOf(target, index + 1);
				if (tmp == -1) {
					max = Math.max(max, s.length() - index - 1);
				} else {
					max = Math.max(max, tmp - index - 1);
				}
				index = tmp;
			}
			ans = Math.min(ans, max);
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 22996
#include<stdio.h>
int n;
char p[110], q[110];
int main(){
    int i, j;
    scanf("%d",&n);
    scanf("%s%s",p,q);
    for(i=n;i>=1;i--){
        for(j=0;j<i;j++){
            if(q[j] != p[n-i+j])break;
        }
        if(j==i)break;
    }
    printf("%d\n",2*n-i);
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused_imports)]
 
// Input
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};
 
// Functions
 
// Main
fn main(){
    input!{
        N: usize,
        X: usize,
        L: [usize; N]
    }
    let (mut ans, mut d) = (1, 0);
    for i in 0..N{
        d += L[i];
        if d <= X{
            ans += 1;
        }else{
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;
  cout << (a > b ? "Alice" : (a < b ? "Bob" : "Draw")) << endl;

  return 0;
}


Measured memory_bytes: 256
#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>
using namespace std;

#define F               first
#define S               second
#define int             long long int
#define PB              push_back
#define MP              make_pair
#define PI              pair<int,int>
#define VI              vector<int>
#define MI              map<int,int>
#define PQB             priority_queue<int>
#define PQS             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define INF             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define loop(i,a,b)     for(int i=a;i<b;i++)

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

}

int32_t main(){
    c_p_c();
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";

}































































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p;
  while(cin>>n>>p,n){
    int v[51]={};
    int i=0,a=p;
    while(1){
      if(a==0){
        a=v[i], v[i]=0;
      }else if(a)
        a--, v[i]++;
      if(a==0 && v[i]==p){
        cout<<i<<endl;
        break;
      }
      i++;
      if(i==n) i=0;
    }
  }
  return 0;
}

Measured memory_bytes: 3096
import sys

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


def main():
    N, *S = map(int, read().split())

    total = sum(S)
    if total % 10 != 0:
        ans = total
    else:
        S.sort()
        m = -1
        for s in S:
            if s % 10 != 0:
                m = s
                break
        if m == -1:
            ans = 0
        else:
            ans = total - m

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 62024
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

vi vec(3);
int k;

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

    cin>>vec[0]>>vec[1]>>vec[2];
    cin>>k;
    sort(rall(vec));
    rep(i,k){
        vec[0]*=2;
    }
    cout<<vec[0]+vec[1]+vec[2]<<endl;
    
    return 0;
}


Measured memory_bytes: 888