akhauriyash/Code-Regression huggingface dataset:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


n = int(input())
a = list(map(int, input().split()))

l = [0]*(n+2)
r = [0]*(n+2)
m = [0]*(n+2)

for i in range(n+1):
    j = n-i
    if i == 0:  # j = n
        l[i] = 0
        r[j+1] = 0
    else:
        l[i] = gcd(l[i-1], a[i-1])
        r[j] = gcd(r[j+1], a[j])

m = [gcd(l[i], r[i+1]) for i in range(n+1)]

print(max(m))


Measured memory_bytes: 14400
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

// そのノードを通る確率
unordered_map<long, double> existance;

// そのノードを起点としたときのゴールまでの期待値
unordered_map<long, double> to_goal;

// 接続
unordered_map<long, unordered_set<long>> joint;

void solve() {
  long N, M;
  cin >> N >> M;
  rep (i, M) {
    long s, t;
    cin >> s >> t;
    joint[s].insert(t);
  }

  // そのノードを通る確率
  existance[1] = 1;
  for (long i = 1; i < N; i++) {
    double tmp = existance[i];
    tmp /= joint[i].size();
    for (long it: joint[i]) existance[it] += tmp;
  }

  // そのノードを起点としたときのゴールまでの期待値
  to_goal[N] = 0;
  for (long i = N - 1; i >= 1; i--) {
    double sum = 0;
    for (long it: joint[i]) sum += to_goal[it] + 1;
    sum /= joint[i].size();
    to_goal[i] = sum;
  }

  double ans_without_aoki = to_goal[1];
  double aoki = 0;
  for (long node = 1; node < N; node++) {
    // 枝の本数
    long edge_count = joint[node].size();

    // 塞げないケースで早期return
    if (joint[node].size() < 2) continue;

    double tmp_max = 0;
    for (auto it: joint[node]) tmp_max = max(tmp_max, to_goal[it]);
    tmp_max++;

    double current_to_goal = to_goal[node];
    double enhanced_to_goal = (current_to_goal * edge_count - tmp_max) / (edge_count - 1);
    double diff = current_to_goal - enhanced_to_goal;
    double tmp_result = diff * existance[node];
    aoki = max(aoki, tmp_result);

/*
    cout << "----------" << endl;
    cout << "node: " << node << endl;
    cout << "tmp_max: " << tmp_max << endl;
    cout << "edge_count: " << edge_count << endl;
    cout << "current_to_goal: " << current_to_goal << endl;
    cout << "enhanced_to_goal: " << enhanced_to_goal << endl;
    cout << "diff: " << diff << endl;
    cout << "tmp_result: " << tmp_result << endl;
*/
  }

//  cout << "aoki: " << aoki << endl;

  double ans = ans_without_aoki - aoki;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 8064
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), f = sc.nextInt(), c = 0;
        Map<String, Integer> mp = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            String[] v = new String[m];
            for (int j = 0; j < m; j++) {
                v[j] = sc.next();
                for (int k = 0; k < j; k++) {
                    String[] t = { v[j], v[k] };
                    Arrays.sort(t);
                    String tt=t[0]+" "+t[1];
                    if(mp.containsKey(tt)) {
                        mp.put(tt, mp.get(tt)+1);
                        if(mp.get(tt)==f) {
                            c++;
                        }
                    }else {
                        mp.put(tt, 1);
                        if(f==1)c++;
                    }
                }
            }
        }
        System.out.println(c);
        for (Map.Entry<String, Integer> m : mp.entrySet()) {
            if (m.getValue() >= f) {
                System.out.println(m.getKey());
            }
        }
    }
}


Measured memory_bytes: 38808
import java.util.Scanner;

public class Main {



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

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		
		int ans = -1;
		
		
		for(int i = 0 ; i < 2000; i++) {
			if((int)(i *0.08) == a && (int)(i * 0.1) == b) {
				ans = i;
				break;
			}
			
		}
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, w[maxn], c[maxn], dp[N];

main () {
	cin >> n >> m;
	forn (i, 1, n)
		cin >> w[i] >> c[i];


	forn (i, 1, n)
		forev (j, m, w[i])
			dp[j] = max(dp[j], dp[j - w[i]] + c[i]);

	cout << *max_element(dp + 1, dp + 1 + m);			
} 

Measured memory_bytes: 1024
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int64_t n;
  cin>>n;
  int64_t a;
  for(int i=sqrt(n);i>=1;i--){
    if(n%i==0){
      a=i;
      break;
    }
  }
  cout<<a+n/a-2<<endl;
  }

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    int a,b;
    cin>>a>>b;
    
    int x = min(a,b);
    int y = a+b-x;

    for ( int i = 0 ; i < y ; i++ )
    {
        cout<<x;
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

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

	int n, W; cin >> n >> W;

	vector<ll> wl(n, 0), vl(n, 0);

	for(int i = 0; i < n; i++) cin >> wl[i] >> vl[i];
	vector<vector<ll>> dp(n, vector<ll>(W + 1, 0));

	dp[0][0] = INT_MIN;
	for(int i = 0; i <= W; i++) {
		if(i >= wl[0]) dp[0][i] = vl[0];
		else dp[0][i] = 0;
	}

	for(int i = 1; i < n; i++) {
		for(int w = 0; w <= W; w++) {
			dp[i][w] = dp[i - 1][w];
			if(w - wl[i] >= 0) {
				dp[i][w] = max(dp[i][w], vl[i] + dp[i - 1][w - wl[i]]);
			}
		}
	}
	cout << dp[n - 1][W] << endl;
}

Measured memory_bytes: 79488
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[201010];

int main() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
	}
	if (a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	LL ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] - 1 == a[i - 1]) {
			ans++;
		}
		else if (a[i] - 1 > a[i - 1]) {
			cout << -1 << endl;
			return 0;
		}
		else {
			ans += a[i];
		}
	}
	cout << ans << endl;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 705;
bitset<N> adj[N];
int col[N];
bitset<N> dp;

int c0, c1;
int n;

void dfs(int u){
  if(col[u]==0) c0 ++ ;
  else c1 ++ ;
  for(int j = 0 ; j < n; j ++ ){
    if(adj[u][j]) continue;
    if(col[j] == -1){
      col[j]=1-col[u];
      dfs(j);
    }
    else if(col[j] == col[u]){
      cout << -1;
      exit(0);
    }
  }
}

int main(){
  fastIO;
  int m;
  cin >> n >> m;
  int u, v;
  for(int i = 0 ; i < m ; i ++ ){
    cin >> u >> v;
    u--;
    v--;
    adj[u][v]=1;
    adj[v][u]=1;
  }
  for(int i = 0 ; i < n; i ++ ){
    adj[i][i] = 1;
    col[i] = -1;
  }
  dp[0] = 1;
  int bit;
  for(int i = 0 ; i < n; i ++ ){
    if(col[i] == -1){
      c0 = 0;
      c1 = 0;
      col[i]=0;
      dfs(i);
      for(int j = n; j >= 0 ; j -- ){
        bit = 0;
        if(j >= c0 && dp[j-c0] == 1) bit = 1;
        if(j >= c1 && dp[j-c1] == 1) bit = 1;
        dp[j] = bit;
      }
    }
  }
  int res = (int)1e9;
  int x,y;
  for(int i = 0 ; i <= n; i ++ ){
    if(dp[i] && dp[n-i]){
      x = i;
      y = (n-i);
      res = min(res, x*(x-1)/2 + y*(y-1)/2);
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 384
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

min_diff = 100000
counter = 0
for i in range(N):
    diff = abs(A - T + H[i] * 0.006)
    if diff < min_diff:
        counter = i + 1
        min_diff = diff

print(counter)

Measured memory_bytes: 3060
def main():
    import sys
    sys.setrecursionlimit(1000000)
    h, w, d = map(int, input().split())
    p = []
    for i in range(1, h + 1):
        l = map(int, input().split())
        for j, k in enumerate(l, 1):
            p.append((k, (i, j)))
    p.sort(key=lambda x: x[0])

    q = int(input())

    dist = [0] * (w * h + 1)

    def Q(i, c, x, y):
        if i + d > w * h:
            return
        _, (nx, ny) = p[i + d - 1]
        nc = c + abs(nx - x) + abs(ny - y)
        dist[i + d] = nc
        Q(i + d, nc, nx, ny)

    for i in range(d):
        n, (x, y) = p[i]
        Q(n, 0, x, y)

    res = []
    for _ in range(q):
        l, r = map(int, input().split())
        res.append(dist[r] - dist[l])

    ans = '\n'.join(map(str, res))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 138412
temp = list(map(int,input().split()))
a = temp[0]
b = temp[1]
k = temp[2]
if k > 0:
  if k < a:
    a = a - k
  else:
    k = k - a
    a = 0
    if k < b:
      b = b - k
    else:
      b = 0

print(str(a)+' '+str(b))

Measured memory_bytes: 3064
S=input()
length = len(S)
# 例えば5->2,1,2,  4->2,2 に分けて調べれば良い
if length % 2 == 0:
    half = length//2
    mae = S[0:half]
    ushiro = S[half:]
else:
    half = (length)//2
    mae = S[0:half]
    ushiro = S[half+1:]
count = 0
for (s1,s2) in zip(mae,ushiro[::-1]):
    if not s1 == s2:
        count += 1
print(count)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[220000];
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	bool f=true;
	for (int i=2;i<=n;++i) if (a[i]==a[i-1]) f=false;
	if (f) printf("YES"); else printf("NO");
	return 0;
} 

Measured memory_bytes: 896
import java.util.*;
import java.util.Comparator;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long x[] = new long[N];
		long y[] = new long[N];
		long z[] = new long[N];
		long all_plus[] = new long[N];
		long all_minus[] = new long[N];
		long beautiful_plus[] = new long[N];
		long beautiful_minus[] = new long[N];
		long delicious_plus[] = new long[N];
		long delicious_minus[] = new long[N];
		long popular_plus[] = new long[N];
		long popular_minus[] = new long[N];
		for(int i = 0 ; i < N; i++) {
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
			z[i] = sc.nextLong();
			all_plus[i] = x[i] + y[i] + z[i];
			all_minus[i] = -x[i] - y[i] - z[i];
			beautiful_plus[i] = x[i] - y[i] - z[i];
			beautiful_minus[i] = -x[i] + y[i] + z[i];
			delicious_plus[i] = -x[i] + y[i] - z[i];
			delicious_minus[i] = x[i] - y[i] + z[i];
			popular_plus[i] = -x[i] - y[i] + z[i];
			popular_minus[i] = x[i] + y[i] + -z[i];
		}
		
		Arrays.sort(all_plus);
		Arrays.sort(all_minus);
		Arrays.sort(beautiful_plus);
		Arrays.sort(beautiful_minus);
		Arrays.sort(delicious_plus);
		Arrays.sort(delicious_minus);
		Arrays.sort(popular_plus);
		Arrays.sort(popular_minus);
		long all_p = 0;
		long all_m = 0;
		long beautiful_p = 0;
		long beautiful_m = 0;
		long delicious_p = 0;
		long delicious_m = 0;
		long popular_p = 0;
		long popular_m = 0;
		for(int i = N - 1; i > N - 1 - M; i--) {
			all_p += all_plus[i];
			all_m += all_minus[i];
			beautiful_p += beautiful_plus[i];
			beautiful_m += beautiful_minus[i];
			delicious_p += delicious_plus[i];
			delicious_m += delicious_minus[i];
			popular_p += popular_plus[i];
			popular_m += popular_minus[i];
		}
		
		System.out.println(Math.max(all_p, Math.max(all_m, Math.max(beautiful_p, Math.max(beautiful_m, Math.max(delicious_p, Math.max(delicious_m, Math.max(popular_p, popular_m))))))));
	}
}


Measured memory_bytes: 26732
/**
*    created: 07.07.2020 21:20:06
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    if (a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 105;
const int oo = 1e9 + 5;

bool edge[N][N];
int sum[N];

void solve() {
	int n;
	cin >> n;
	if (n & 1) {
		for (int i = 1; i < n; ++i) {
			edge[i][n] += i;
			edge[n][i] += i;
			sum[n] += i;
			sum[i] += n;
		}
		--n;
	}
	for (int i = 1, j = n; i < j; ++i, --j) {
		for (int k = 1; k <= n; ++k) {
			if (k == i || k == j) continue;
			edge[i][k] = 1;
			edge[k][i] = 1;
			sum[i] += k;
			edge[j][k] = 1;
			edge[k][j] = 1;
			sum[j] += k;
		}
	}
	int cnt = 0;
	for (int i = 1; i <= n+1; ++i) {
		for (int j = i + 1; j <= n+1; ++j) {
			if (edge[i][j]) ++cnt;
		}
	}
	cout << cnt << '\n';
	for (int i = 1; i <= n+1; ++i) {
		for (int j = i + 1; j <= n+1; ++j) {
			if (edge[i][j]) {
				cout << i <<' '<< j << '\n';
			}
		}
	}
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 256
while 1:
   H, W = map(int, raw_input().split())
           
   if H == 0 and W == 0:
      break
   for i in range(H):
      if i%2 == 0:
         if W%2 == 0:
            print "#."*(W/2)
         elif W%2 == 1:
            print "#."*(W/2)+"#"
      elif i%2 == 1:
         if W%2 == 0:
            print ".#"*(W/2)
         elif W%2 == 1:
            print ".#"*(W/2)+"."
   print ""

Measured memory_bytes: 6296
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[])
{
	int i;
	int n;
	int* p;
	int h[14], s[14], d[14], c[14];
	char in_m[52];
	int  in_r[52];

	for (i = 1; i < 14; i++) {
		h[i] = 0;
		s[i] = 0;
		d[i] = 0;
		c[i] = 0;
	}

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> in_m[i] >> in_r[i];
		switch (in_m[i]) {
		case 'S': p = s; break;
		case 'D': p = d; break;
		case 'C': p = c; break;
		case 'H': p = h; break;
		}
		p[in_r[i]] = 1;
	}
	for (i = 1; i < 14; i++) {
		if (s[i] == 0) cout << "S " << i << endl;
	}
	for (i = 1; i < 14; i++) {
		if (h[i] == 0) cout << "H " << i << endl;
	}
	for (i = 1; i < 14; i++) {
		if (c[i] == 0) cout << "C " << i << endl;
	}
	for (i = 1; i < 14; i++) {
		if (d[i] == 0) cout << "D " << i << endl;
	}

	return 0;
}

Measured memory_bytes: 3036
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	_ = readInt()
	k := readInt()
	b := readBytes()

	b[k-1] = b[k-1] + byte('a') - byte('A')

	fmt.Println(string(b))
}


Measured memory_bytes: 640
n,m,x = map(int,input().split())
c = []
a = []
ans = 12*(10**5)+1
for _ in range(n):
    ca = list(map(int,input().split()))
    c.append(ca[0])
    a.append(ca[1:])

for i in range(2**n):
    l = [0]*m
    cost = 0
    for j in range(n):
        if (i>>j)&1:
            cost += c[j]
            for k in range(m):
                l[k] += a[j][k]
    if min(l)>=x:
        ans = min(cost,ans)
if ans == 12*(10**5)+1:
    ans = -1
print(ans)

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

ll a[500000];
int main() {
   ll i,j;
   ll k,n,maxd;
   cin >>k>>n; 
   for(i=0; i<n; i++)
   {
     cin >>a[i];
   }

  // sort(a+0,a+n);
   maxd=k-a[n-1]+a[0];
  //  cout<<maxd<<endl;
   for(i=0; i<n-1; i++)
   {
     if(maxd<a[i+1]-a[i])
     {
       maxd=a[i+1]-a[i];
     }
   }
   cout<< k-maxd <<endl;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
V = []
for i in range(N):
    a, b = map(int, input().split())
    V.append((a, b))

def solve(P):
    res = 0
    for a, b in V:
        if P & a == a:
            res += b
    return res
ans = solve(K)
for i in range(32):
    if K & (1 << i):
        P = (K | ((1 << i)-1) )^ (1 << i)
        ans = max(ans, solve(P))
print(ans)

Measured memory_bytes: 58072
#include <iostream>
int main(){
    int n, m, l, r;
    std::cin >> n >> m;
    int beg = 0;
    int end = n;
    int ans;
    for(int i=0; i<m; ++i){
        std::cin >> l >> r;
        if(l > beg) beg = l;
        if(r < end) end = r;
    }

    if(beg > end) ans = 0;
    else ans = end - beg + 1;
    std::cout << ans << std::endl;
    return 0;
}

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

#define MAX_N 1000000

int prime[MAX_N];         // i??????????´???°
bool is_prime[MAX_N + 1]; // is_prime[i]???true????????°i????´???°

// n??\???????´???°?????°?????????
int sieve(int n) {
  int p = 0;
  for (int i = 0; i <= n; i++)
    is_prime[i] = true;
  is_prime[0] = false;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2 * i; j <= n; j += i)
        is_prime[j] = false;
    }
  }
  return p;
}

int main(){
    int n;
    while(scanf("%d",&n) != EOF){
        cout << sieve(n) << endl;
    }

    return 0;
}


Measured memory_bytes: 4436
<?php
  
fscanf(STDIN,"%s",$s);
fscanf(STDIN,"%s",$t);


$t_modi = $t;
$c=0;
for($i=0;$i<strlen($s);$i++){
  $t_modi = $t_modi[strlen($s)-1].$t_modi;
  $t_modi = substr($t_modi,0,-1);
  if($t_modi == $s){
    echo "Yes\n";
    exit;
  }
//echo $t_modi."\n";
}

echo "No\n";


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

using namespace std;
using ll = long long;
#define int ll

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int a, b;

void init()
{
	cin >> a >> b;
}

void solve()
{
	PRINT(a * b % 2);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);



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

    int l,r,d;
    cin >> l >> r >> d; 
    cout << r/d-(l-1)/d << endl;
     

    return 0;

}


Measured memory_bytes: 3608
def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
    
def main():
    while True:
        a = numinput()
        if a[0] == 0 and a[1] == 0: break
        H = a[0];  W = a[1]
        for i in range(H):
            bar = ""
            for j in range(W):
                if (i + j) % 2 == 0: bar += "#"
                else: bar += "."
            if i < H - 1: print(bar)
            else: print(bar + '\n')
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,W;
	cin >> n >> W;
	vector<ll> v(n);
	vector<ll> w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i]; 
	}
	vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));//dp[i][j]はi番までの重さの和がj以下の最大の価値

	for(int i = 0; i < n; i++) {
		for(int j = 1; j <= W; j++) {
			if (w[i]> j){//入らない
				dp[i+1][j] = dp[i][j];
			}
			else{
				dp[i+1][j] =max(dp[i][j],dp[i][j - w[i]]+v[i]);
			}
		}
	}
	cout << dp[n][W] << endl;

	return 0;
}

Measured memory_bytes: 80256
S=input()
l=len(S)
p=0
for i in range(l):
    if i%2==0:
        if S[i]=='R' or S[i]=='U' or S[i]=='D':
           p=p
        else:
            p+=1
    else:
        if S[i]=='L' or S[i]=='U' or S[i]=='D':
            p=p
        else:
            p+=1
if p>0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#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;

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

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

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

#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())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

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

string IntToString(int number)
{
  stringstream ss;
  ss << number;
  return ss.str();
}

bool check(int n, set<int> D){
  int N = n;
  while(N>0){
    if(D.count(N%10) != 0) return false;
    N /= 10;
  }
  return true;
}

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

  set<int> D;
  REP(i, K){
    cin >> x;
    D.insert(x);
  }

  int ans = N;
  while(!check(ans, D)){
    ans++;
  }

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


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if(A>100 || B>100 || C>100 || A<0 || B<0 || C<0)
		return 0;
	A=A+B;
	B=A-B;
	A=A-B;
	A=A+C;
	C=A-C;
	A=A-C;
	printf("%d	%d	%d",A,B,C);
  	return 0;
}

Measured memory_bytes: 128
def resolve():
    n=int(input())
    s=[i for i in input()]
    count=0
    l1=[0 for i in range(n)]
    for i in range(n):
        l1[i]=count
        if s[i]=='W':
            count+=1
    count=0
    l2=[0 for i in range(n)]
    for i in range(n-1,-1,-1):
        l2[i]=count
        if s[i]=='E':
            count+=1
    print(min([l1[i]+l2[i] for i in range(n)]))



if __name__ == "__main__":
    resolve()

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

using namespace std ; 


const int N = 1e5 + 7 ; 

int n; 

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ; 
        //freopen("in.in" , "r" , stdin) ; 
        int x ;
        cin >> x >> n ;
        set<int> s ; 
        for(int i =-150 ; i <= 150 ; i++){
                s.insert(i) ; 
        } 
        for(int i = 0 ;i < n;i++){
                int t ; cin >> t; 
                s.erase(t) ; 
        }
        int ans =10000 ; 
        int out = x ; 
        for(auto u : s){
                if(abs(x - u) < ans){
                        ans = abs(x - u) ; 
                        out = u ; 
                }
        }
        cout<< out ; 
        return 0 ; 
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N;
    cin >> N;
    map<int,int> mp;
    REP(_,N){
        int A;
        cin >> A;
        if(!mp.count(A)) mp[A] = 0;
        mp[A]++;
    }

    int kaburi = 0;
    for(const auto &it : mp) {
        auto [v,cnt] = it;
        kaburi += cnt - 1;
    }

    cout << N - ((kaburi+1)/2)*2 << endl;
}

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

Measured memory_bytes: 8288
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const string table[] = {
	"abcde",
	"fghij",
	"klmno",
	"pqrst",
	"uvwxy",
	"z.?! ",
};

string solve( string src )
{
	if ( src.size() % 2 )
	{
		return "NA";
	}

	string res;

	for ( int i = 0; i < src.size(); i += 2 )
	{
		int idx1 = src[i] - '1', idx2 = src[ i + 1 ] - '1';
		if ( !( 0 <= idx1 && idx1 < 6 && 0 <= idx2 && idx2 < 5 ) )
		{
			return "NA";
		}
		res += table[ idx1 ][ idx2 ];
	}

	return res;
}

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

	string str;
	while ( cin >> str )
	{
		cout << solve( str ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
	int N; cin >> N;
	string S;
	long long M=0,A=0,R=0,C=0,H=0,B[5];
	long long ans=0;
	int D[10]={0,0,0,0,0,0,1,1,1,2},E[10]={1,1,1,2,2,3,2,2,3,3},F[10]={2,3,4,3,4,4,3,4,4,4};
	for(int i=0; i<N; i++){
		cin >> S;
		if(S[0]=='M') M+=1;
		if(S[0]=='A') A+=1;
		if(S[0]=='R') R+=1;
		if(S[0]=='C') C+=1;
		if(S[0]=='H') H+=1;
	}
	B[0]=M,B[1]=A,B[2]=R,B[3]=C,B[4]=H;
	for(int i=0; i<10; i++){
		ans+=B[D[i]]*B[E[i]]*B[F[i]];
	}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N,K,X,Y; cin >> N >> K >> X >> Y;
  int ans = 0;
  rep(i,N){
    if(i<K)ans+=X;
    else ans+=Y;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n, r;
    cin >> n >> r;
    if(n >= 10) {cout << r << endl; END;}
    cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
N = int(input())

T,A = [int(i) for i in input().split()]


H = [int(i) for i in input().split()]

ans = 0

for i in range(N):
    if abs(T - 0.006 * H[i]  - A) < abs(T - 0.006 * H[ans] -A):
        ans = i
print(ans+1)


Measured memory_bytes: 3060
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val bools = s.map { it == '1' }
    val resultTrue = search(bools, true)
    val resultFalse = search(bools, false)
    if (resultTrue < resultFalse) {
        println(resultTrue)
    } else {
        println(resultFalse)
    }
}

private fun search(bools: List<Boolean>, first: Boolean): Int {
    var count: Int = 0
    bools.fold(first) { acc, b ->
        if (acc == b) {
            count++
            !b
        } else {
            b
        }
    }
    return count
}

Measured memory_bytes: 32648
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

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

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;

int n, k, a[105], win[100005];

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

    cin >> n >> k;

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (i >= a[j])
                win[i] |= !win[i - a[j]];
        }
    }

    if (win[k])
        cout << "First";
    else
        cout << "Second";

    cout << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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


ll a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;

  
  
  
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;


ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll i=2; i<MAX; i++){
		fac[i] = fac[i-1]*i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}


ll com(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll x = 0;
vvl G; ll n;

ll dfs(ll u, ll p){
	ll sum = n-1;
	vl cnt;
	ll res = 0;
	for(auto v : G[u]){
		if(v==p) continue;
		ll df = dfs(v,u);
		cnt.push_back(df);
		sum -= df;
	}
	if(sum != 0) cnt.push_back(sum);
	if(cnt.size()==1) return n-sum;
	ll minus = 1;
	ll mul = 1;
	for(auto i : cnt){
		minus += modpow(2,i,mod)-1;
		if(minus<0) minus += mod;
		else minus %= mod;
		mul *= modpow(2,i,mod);
		mul %= mod;
	}
	x = (x + mod + mul - minus) % mod;
	return n-sum;
}

int main(){
	cin >> n;
	G.resize(n);
	comInit();
	rep(i,n-1){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ll y = modpow(2,n,mod);
	dfs(0,-1);
	cout << x*modpow(y,mod-2,mod)%mod << endl;
}

Measured memory_bytes: 36992
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
	int main() {
		double a, b;
		std::cin >> a >> b;
		double c = a / b;
		
		std::cout << std::fixed << std::setprecision(10) << c << std::endl;
		return 0;
	}

Measured memory_bytes: 256
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int t = sc.nextInt();
      int[] x = new int[n];
      int ans = 0;
      for(int i = 0;i < n;i++)x[i]=sc.nextInt();
      for(int i = 0;i < n-1;i++){
      	ans += Math.min(x[i+1]-x[i],t);
      }
      System.out.println(ans+t);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 62608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, ans=0;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    rep(i, n){
        int diff = v[i] - c[i];
        if( diff > 0) ans += diff;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public void Germany() {
		Scanner sc = new Scanner(System.in);
		int H,W;
		H = sc.nextInt();
		W = sc.nextInt();
		while(H != 0 && W != 0){
			for(int i = 1;i <= H;i++) {
				for(int x = 1;x <= W;x++) {
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.println( );
			H = sc.nextInt();
			W = sc.nextInt();
		}
	}
	public static void main(String[] args) {
			new Main().Germany();
	}
}

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

int main(){
	string s;
	int n;
	cin >> s >> n;
	int a,b;
	string str,str2;
	for(int i = 0; i < n; i++){
		cin >> str >> a >> b;
		if(str == "print"){
			for(int j = a; j < b+1; j++){
				cout << s[j];
			}
			cout << endl;
		}else if(str == "reverse"){
			str2 = s.substr(a,b+1-a);
			reverse(str2.begin(),str2.end());
			s.replace(a,str2.length(),str2);
		}else{
			cin >> str2;
			s.replace(a,str2.length(),str2);
		}
	}
	return 0;
}		

Measured memory_bytes: 3224
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define P 16777216
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, k;

int main()
{
    scanf("%d%d", &n, &k);
    if(k<=(n+1)/2) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool solve(vi a)
{
	int n=a.size();
	sort(all(a));

	if(a[0]!=(a[n-1]+1)/2)
		return false;

	int mn=a[0],mx=a[n-1];
	if(a[n-1]&1){  // 直径が奇数
		for(int x=mx;x!=mn;x--)
			if(count(all(a),x)<2)
				return false;
		return count(all(a),a[0])==2;
	}
	else{  // 直径が偶数
		for(int x=mx;x!=mn;x--)
			if(count(all(a),x)<2)
				return false;
		return count(all(a),a[0])==1;
	}

	return true;
}

int main()
{
	for(int n;cin>>n && n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		cout<<(solve(a)?"Possible":"Impossible")<<endl;
	}
}


Measured memory_bytes: 384
N, A, B = map(int, input().split())
S = input()
n = 0
f = 0
for i in range(N):
  c = S[i]
  if c == "a":
    if n < A+B:
      n += 1
      print("Yes")
    else:
      print("No")
  elif c == "b":
    f += 1
    if n < A+B and f <= B:
      n += 1
      print("Yes")
    else:
      print("No")
  else:
    print("No")


Measured memory_bytes: 4016