akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    long int a,n,x,y,z;
    x = 0;
    y = -1000000000000000000;
    z = 1000000000000000000;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a;
        x += a;//合計値
        y = max(a,y);
        z = min(a,z);
    }
    cout << z << " " << y << " " << x << endl;
    return 0;
}


Measured memory_bytes: 3132
n = int(input())
A = [int(input()) for _ in range(n)]
m = 30
C = [False]*m
x = 0
for a in A:
  x ^= a
  for i in range(m):
    if a>>i & 1:
      C[i] = True
      break
total = 0
ans = 0
for i in range(m-1, -1, -1):
  if (x>>i & 1) ^ total:
    if C[i]:
      ans += 1
      total ^= 1
    else:
      print(-1)
      break
else:
  print(ans)

Measured memory_bytes: 50956
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
s = 0
for i,b in enumerate(bb):
    t = min(aa[i]+aa[i+1], b)
    s += t
    if aa[i] >= t:
        aa[i] -= t
    else:
        t -= aa[i]
        aa[i] = 0
        aa[i+1] -= t
print(s)

Measured memory_bytes: 18476
// Vicfred
// https://atcoder.jp/contests/abc046/tasks/arc062_a
// math
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long n = readln.chomp.to!long;
    long[] ts;
    long[] as;

    long t = 1;
    long a = 1;
    foreach(_; 0..n) {
        long T, A;
        readf("%s %s\n", &T, &A);
        const long x = max((t + T - 1)/T, (a + A - 1)/A);
        t = x*T;
        a = x*A;
    }

    writefln("%s", t + a);
}



Measured memory_bytes: 2860
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}

typedef std::pair<ll, ll> P;
 
using namespace std;

int main(){
    vector<int> v(3);
    rep(i, 3) cin >> v[i];
    sort(all(v));
    int p = v[2] - v[0];
    int q = v[2] - v[1];
    ll ans = 0;
    if(p%2==0){
        if(q%2==0){
            ans += p/2 + q/2;
        }else{
            ans += p/2 + (q-1)/2;
            ans += 2;
        }
    }else{
        if(q%2==0){
            ans += (p-1)/2 + q/2;
            ans += 2;
        }else{
            ans += (p-1)/2 + (q-1)/2;
            ans += 1;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let x: i64 = read();
    let op: String = read();
    let y: i64 = read();
    if op.chars().next().unwrap() == '+' {
	println!("{}",x+y);
    }else{
	println!("{}",x-y);
    }
    
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ll, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define fi first
#define se second
// #define multicase
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
const ll N = 1e6 + 5;

ll n;
ll dp[N][5][5];

ll add(ll x, ll y) {
    return ((x % MOD) + (y % MOD)) % MOD;
}

void computeDP() {
    dp[0][1][1] = 1;
    for(ll idx = 1; idx <= n; idx++) {
        for(ll zero = 1; zero >= 0; zero--) {
            for(ll nine = 1; nine >= 0; nine--) {
                ll &sol = dp[idx][zero][nine];
                // sol = 8 * dp[idx - 1][zero][nine];
                // sol = add(sol, dp[idx - 1][1][nine]);
                // sol = add(sol, dp[idx - 1][zero][1]);
                for(int i = 0; i <= 9; i++) {
                    if(i == 0) sol = add(sol, dp[idx - 1][1][nine]);
                    else if(i == 9) sol = add(sol, dp[idx - 1][zero][1]);
                    else sol = add(sol, dp[idx - 1][zero][nine]);
                }
            }
        }
    }
}

void solve() {
    ll T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    while(T--) {
        cin >> n;
        computeDP();
        cout << dp[n][0][0] << "\n";
    }
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    solve();
 
}

Measured memory_bytes: 198816
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int a = 0, b = 0;
    cin >> a >> b;
    int cnt = 0;
    int tap = 1;
    while (tap < b) {
        tap += a-1;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

const int MAX_FACT = 1000001;
unsigned long long MOD = (unsigned long long)1e9 + 7;
unsigned long long fact[MAX_FACT], invFact[MAX_FACT], inv[MAX_FACT];

void init()
{
	fact[0] = 1;
	fact[1] = 1;
	invFact[0] = 1;
	invFact[1] = 1;
	inv[1] = 1;
	for (auto i = 2; i < MAX_FACT; ++i)
	{
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		invFact[i] = invFact[i - 1] * inv[i] % MOD;
	}
}

unsigned long long calcCombination(int n, int k)
{
	if (n < k)
	{
		return 0;
	}
	if ((n < 0) || (k < 0))
	{
		return 0;
	}

	return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
}

int main()
{
	int X, Y;
	cin >> X >> Y;

	init();

	auto result = 0ll;
	for (auto i = 0; i <= X; ++i)
	{
		auto d = X - i;
		if (d % 2 > 0)
		{
			continue;
		}
		auto j = d / 2;
		if (Y != 2 * i + j)
		{
			continue;
		}

		result += calcCombination(i + j, i);
	}

	cout << result << endl;

	return 0;
}

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

using namespace std;

int h[100100];
int a[100100];
int dp[100100];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	a[0] = 0;
	for (int i = 1; i < n; i++)
		a[i] = h[i] - h[i - 1];
	dp[1] = abs(a[1]);
	for (int i = 0; i + 2 < n; i++)
		dp[i + 2] = min(dp[i] + abs(a[i + 1] + a[i + 2]), dp[i + 1] + abs(a[i + 2]));
	cout << dp[n - 1];
}


Measured memory_bytes: 1408
n,k=map(int,input().split())
d={}
for i in range(n):
    a,b=map(int,input().split())
    if a in d.keys():
        d[a]+=b
    else:
        d[a]=b
keys=sorted(d.keys())
for x in keys:
    k-=d[x]
    if k<=0:
        print(x)
        break

Measured memory_bytes: 10588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int ans = P + Q + R - max({P, Q, R});
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] List = new int[n];
		
		for(int i=0;i<n;i++)
			List[i] = sc.nextInt();
		
		int q = sc.nextInt();
		
		for(int i=0;i<q;i++) {
			
			int b = sc.nextInt();
			int e = sc.nextInt();
			
			for(int j=0;j<(e-b)/2;j++) {
				int tmp = List[b + j];
				List[b + j] = List[e - j-1];
				List[e - j-1] = tmp;
			}
		}
		
		for(int i=0;i<List.length;i++) {
			System.out.print(List[i]);
			if(i != List.length - 1)
				System.out.print(" ");
			else
				System.out.println();
		}
	}
}


Measured memory_bytes: 34740
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		char[] input;
		StringBuffer ret = new StringBuffer();
		Scanner scanner = new Scanner(System.in);
		input = scanner.nextLine().toCharArray();
		for(int i = 0; i < input.length; i++) {
			char c = input[i];
			if (c >= 'A' && c <= 'C') {c += 26;}
			c -= 3;
			ret.append(c);
		}
		System.out.println(ret.toString());
	}
}

Measured memory_bytes: 26172
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(d);
        var answer = d[N / 2] - d[N / 2 - 1];
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 35100
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
#define sq(x) x*x
#define fr(i,m,n) for(i=m;i<n;i++)
#define vec vector<int>
#define sint set<int>
#define qint queue<int>
#define mip map<int,int>
#define pint priority_queue<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define full(v) v.begin(),v.end()
vec adj[100004];
int main()
{
    int i,j,k,a,b,c,x,y,z,n,m,t=0;
    string s,u,v;
    cin>>n>>m;int ara[n+3];
    fr(i,1,n+1) cin>>ara[i];
    while(m--){
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    fr(i,1,n+1){
        bool ans=true;z=adj[i].size();
        fr(j,0,z){
            if(ara[adj[i][j]]>=ara[i]){ ans=false;break;}
        }
        if(ans) t++;
    }
    cout<<t<<endl;

}



Measured memory_bytes: 9068
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, M; cin >> N >> M;
    vi A(N), B(N); REP(i, N) cin >> A[i] >> B[i];

    vector<pll> v;
    REP(i, N) v.push_back(pll(A[i], B[i]));

    sort(v.begin(), v.end());

    ll ans = 0;
    int cnt = 0;
    int i = 0;
    while(cnt < M) {
        if (M - cnt <= v[i].second) {
            ans += v[i].first * (M - cnt);
            cnt += M - cnt;
        } else {
            ans += v[i].first * v[i].second;
            cnt += v[i].second;
            i++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long N,ai,i,bar1,bar2;
    set<long long> bars;
    bar1 = 0;
    bar2 = 0;
    cin >> N;
    for (i= 0;i<N;i++){
        cin >> ai;
        if(bars.count(ai) > 0){
            bars.erase(ai);
            if (ai > bar1){
                bar2 = bar1;
                bar1 = ai;
            }else if(ai > bar2){
                bar2 = ai;
            }
        }else{
            bars.insert(ai);
        }
    }

    cout << bar1*bar2 << endl;
    return 0;
}

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

int main()
{
  int h,w;
  cin >> h >> w;
  char m[h+2][w+2];
  int i, j;
  rep(i, w+2){
    m[0][i] = 0;
  }
  for(int i =1; i <h+1; i++){
    m[i][0] = 0;
    for(int j = 1; j < w+1; j++){
      cin >> m[i][j];
    }
    m[i][w+1] = 0;
  }
  rep(i, w+2){
    m[h+1][i] = 0;
  }
  
  int n;
  for(int i = 1; i < h+1; i++){
    for(int j = 1; j < w+1; j++){
      n = 0; //number
	  if(m[i-1][j-1] == '#') n++;
      if(m[i-1][j] == '#') n++;
      if(m[i-1][j+1] == '#') n++;
      if(m[i][j-1] == '#') n++;
      if(m[i][j+1] == '#') n++;
      if(m[i+1][j-1] == '#') n++;
      if(m[i+1][j] == '#') n++;
      if(m[i+1][j+1] == '#') n++;
      
      if(m[i][j] == '#') cout << '#';
      else cout << n;
    }
    cout << endl;
  }
  return 0;
}
  
  /*
  int i = 0; int j = 0;
  int n = 0; //number
  if(m[i][j+1] == '#') n++;
  if(m[i+1][j] == '#') n++;
  if(m[i+1][j+1] == '#') n++;
      
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  
  for(int j = 1; j < w-1; j++){
    n = 0; //number
    if(m[i][j-1] == '#') n++;
    if(m[i][j+1] == '#') n++;
    if(m[i+1][j-1] == '#') n++;
    if(m[i+1][j] == '#') n++;
    if(m[i+1][j+1] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
  }
  
  j = w-1;
  n = 0; //number
  if(m[i][j-1] == '#') n++;
  if(m[i+1][j] == '#') n++;
  if(m[i+1][j-1] == '#') n++;
  
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  cout << endl;
  
  for(int i = 1; i < h-1; i++){
    j = 0;
    n = 0; //number
    if(m[i-1][j] == '#') n++;
    if(m[i-1][j+1] == '#') n++;
    if(m[i][j+1] == '#') n++;
    if(m[i+1][j] == '#') n++;
    if(m[i+1][j+1] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
    
    for(int j = 1; j < w-1; j++){
      n = 0; //number
	  if(m[i-1][j-1] == '#') n++;
      if(m[i-1][j] == '#') n++;
      if(m[i-1][j+1] == '#') n++;
      if(m[i][j-1] == '#') n++;
      if(m[i][j+1] == '#') n++;
      if(m[i+1][j-1] == '#') n++;
      if(m[i+1][j] == '#') n++;
      if(m[i+1][j+1] == '#') n++;
      
      if(m[i][j] == '#') cout << '#';
      else cout << n;
    }
    j = w-1;
    n = 0; //number
    if(m[i-1][j-1] == '#') n++;
    if(m[i-1][j] == '#') n++;
    if(m[i][j-1] == '#') n++;
    if(m[i+1][j-1] == '#') n++;
    if(m[i+1][j] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
    cout << endl;
  }
  
  i = h-1; j = 0;
  n = 0; //number
  if(m[i-1][j] == '#') n++;
  if(m[i-1][j+1] == '#') n++;
  if(m[i][j+1] == '#') n++;
      
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  
  for(int j = 1; j < w-1; j++){
    n = 0; //number
    if(m[i][j-1] == '#') n++;
    if(m[i][j+1] == '#') n++;
    if(m[i-1][j-1] == '#') n++;
    if(m[i-1][j] == '#') n++;
    if(m[i-1][j+1] == '#') n++;
    
    if(m[i][j] == '#') cout << '#';
    else cout << n;
  }
  
  j = w-1;
  n = 0; //number
  if(m[i][j-1] == '#') n++;
  if(m[i-1][j] == '#') n++;
  if(m[i-1][j-1] == '#') n++;
  
  if(m[i][j] == '#') cout << '#';
  else cout << n;
  cout << endl;
  
  return 0;
}
*/

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int cnt[1000100];
int main(){
//	freopen("B.in","r",stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	int s,t;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&s,&t);
		cnt[s]++,cnt[t]++;
	}
	for(int i=1;i<=n;i++){
		if(cnt[i]&1){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 512
import sys
        
def getpar(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[0] = -1
    par[p]  -1
    stack = [p]
    visited = set([p])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            stack.append(vf)
    return par

def topological_sort_tree(E, r):
    Q = [r]
    L = []
    visited = set([r])
    while Q:
        vn = Q.pop()
        L.append(vn)
        for vf in E[vn]:
            if vf not in visited:
                visited.add(vf)
                Q.append(vf)
    return L

mod = 998244353
N, K = map(int, input().split())

seg = 110
lim = K+1
M = (1<<(lim*seg)) - 1
segb = (1<<seg)-1
fold = 47
tm = (1<<fold)%mod
bfilter = 0


for _ in range(lim):
    bfilter = bfilter<<seg
    bfilter = bfilter | ((1<<fold) -1)
cfilter = M ^ bfilter
def modulo(x):
    x = x&M
    b = x&bfilter
    c = ((x&cfilter)>>fold) * tm
    x = b+c
    b = x&bfilter
    c = ((x&cfilter)>>fold) * tm
    x = b+c
    b = x&bfilter
    c = ((x&cfilter)>>fold) * tm
    x = b+c
    return x
    
        
Edge = [[] for _ in range(N)]
D = [0]*N
for _ in range(N-1):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)

P = getpar(Edge, 0)
L = topological_sort_tree(Edge, 0)

dp1 = [(1<<seg)]*N
dp2 = [1]*N
for l in L[:0:-1]:
    p = P[l]
    dp1[p] = modulo(dp1[p]*((dp1[l]>>seg) + dp1[l] + dp2[l]))
    dp2[p] = modulo(dp2[p]*(dp1[l]+dp2[l]))
res1 = (dp1[0]>>(K*seg)) & segb
res2 = (dp2[0]>>(K*seg)) & segb
print((res1+res2)%mod)



Measured memory_bytes: 894684
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
int main(){
    int n;cin>>n;
    int a[101]={};int d;
    fol(i,n){
        cin>>d;
        a[d]=1;
    }
    int ans =0;
    fol(i,101){
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        sc.nextLine();
        String[] A = new String[N];
        String[] B = new String[M];
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextLine();
        }
        for (int i = 0; i < M; ++i) {
            B[i] = sc.nextLine();
        }
 
        for (int i = 0; i < N - M + 1; ++i) {
            for (int j = 0; j < N - M + 1; ++j) {
                boolean ok = true;
                for (int k = 0; k < M; ++k) {
                    if (A[i + k].indexOf(B[k], j) != j) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    _out.println("Yes");
                    return;
                }
            }
        }
        _out.println("No");
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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


struct segtree{
    int size;
    vector<int> dat;
    int inf = 1 << 30;

    segtree (int N) {
        size = 1;
        while (size < N) size *= 2;
        dat = vector<int>(2*size-1, inf);
    }

    int op(int a, int b) {
        return min(a, b);
    }

    void update(int i, int x) { 
        i += size-1;
        dat[i] = x;
        while (i > 0) {
            i = (i-1)/2;
            dat[i] = op(dat[2*i+1], dat[2*i+2]);
        }
        return;
    }

    int query(int a, int b) {
        return query(a, b, 0, 0, size);
    }
    
    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return dat[k];

        int lv, rv;
        lv = query(a, b, 2*k+1, l, (l+r)/2);
        rv = query(a, b, 2*k+2, (l+r)/2, r);
        return op(lv, rv);
    }
};

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> ps(N);
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        ps[i] = {l, r};
    }
    sort(ps.begin(), ps.end());
    segtree st(N);
    for (int i = 0; i < N; i++) {
        st.update(i, ps[i].second);
    }
    int ans = 0;
    for (int i = 1; i < N-1; i++) {
        int t = min(st.query(0, i), st.query(i+1, N));
        ans = max(ans, ps[i].second-ps[i].first+1 + max(0, t-ps[N-1].first+1));
    }
    for (int i = 0; i < N-1; i++) {
        int t = max(0, st.query(0, i+1)-ps[i].first+1);
        int u = max(0, st.query(i+1, N)-ps[N-1].first+1);
        ans = max(ans, t+u);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2048
function read_line()
    map(x->parse(Int64, x), split(readline()))
end
function solve()
    n,k = read_line()

    if n == 1 && k == 0
        println("0 0 1 1")
        return
    end
    if (n == 1 && k == 1) || (k >= 2^n)
        println(-1)
        return
    end

    print(k, ' ')
    for i in 0:2^n-1
        if i != k
            print(i, ' ')
        end
    end
    print(k, ' ')
    for i in 2^n-1:-1:0
        if i != k
            print(i, ' ')
        end
    end
    println()
end
solve()


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

typedef long long ll;

int main() {
    int D, G;
    cin >> D >> G;
    G /= 100;
    vector<int> p(D), c(D);
    rep(i, D) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    int ans = 1000;
    rep(i, 1 << D) {
        int s = 0, t = 0;
        rep(j, D) {
            if ((i >> j) & 1) {
                s += (j + 1) * p[j] + c[j];
                t += p[j];
            }
        }
        if (s >= G) {
            ans = min(ans, t);
            //cout << "i=" << i << " ans=" << ans << endl;
        } else {
            rep(j, D) {
                int k = D - 1 - j;
                if ((i >> k) & 1) continue;
                int a = min(p[k], (G - s + k) / (k + 1));
                s += (k + 1) * a;
                t += a;
                if (s >= G) {
                    ans = min(ans, t);
                    //cout << "i=" << i << " j=" << j << " ans=" << ans << endl;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

string s,ss;
int t,ans=0;
bool ok;

int main()
{
	cin>>s>>t;
	if(s.size()<t)
	{
		puts("0");
		return 0;
	}
	if(t==3&&s.size()-1>=3) ans=(s.size()-1)*(s.size()-2)*(s.size()-3)/6*9*9*9;
	else if(t==2&&s.size()-1>=2) ans=(s.size()-1)*(s.size()-2)/2*9*9;
	else if(t==1&&s.size()-1>=1) ans=(s.size()-1)*9;
	rep(i,s.size()) ss.pb('0');
	if(t==3)
	repn(i,9)
	{
		if(i>s[0]-'0') break;
		if(i<s[0]-'0') ans+=(s.size()-1)*(s.size()-2)/2*9*9;
		else
		repn(j,9)
		{
			repn(k,9)
			{
				repn(p,s.size()-1)
				{
					for(int r=p+1;r<s.size();r++)
					{
						rep(rr,s.size()) ss[rr]='0';
						ss[0]=i+'0';
						ss[p]=j+'0';
						ss[r]=k+'0';
						ok=true;
						rep(rr,s.size())
						{
							if(ss[rr]>s[rr])
							{
								ok=false;
								break;
							}
							if(ss[rr]<s[rr]) break;
						}
						if(ok) ans++;
					}
				}
			}
		}
	}
	else if(t==2)
	{
		repn(i,9)
		{
			if(i>s[0]-'0') break;
			if(i<s[0]-'0') ans+=(s.size()-1)*9;
			else
			repn(j,9)
			{
				repn(k,s.size()-1)
				{
					rep(p,ss.size()) ss[p]='0';
					ss[0]=i+'0';
					ss[k]=j+'0';
					ok=true;
					rep(rr,s.size())
					{
						if(ss[rr]>s[rr])
						{
							ok=false;
							break;
						}
						if(ss[rr]<s[rr]) break;
					}
					if(ok) ans++;
				}
			}
		}
	}
	else if(t==1) ans+=s[0]-'0';
	cout<<ans<<endl;
	return 0;
}

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

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

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    vector<int> a(N+1);
    rep(i, N) cin >> a[i+1];
    
    vector<int> b_(N+1);
    
    for (int i = N; i >= 1; --i)
    {
        int sum = 0;
        for (int j = i + i; j <= N; j+=i)
        {
            sum ^= b_[j];
        }
        b_[i] = sum ^ a[i];
    }
    
    vector<int> b;
    
    for (int i = 1; i <= N; ++i)
    {
        if (b_[i]) b.push_back(i);
    }
    
    int M = static_cast<int>(b.size());
    cout << M << endl;
    
    rep (i, M)
    {
        printf("%d%c", b[i], (i==M-1 ? '\n' : ' '));
    }
    
    
    return 0;
}

Measured memory_bytes: 3192
a, b = map(int, input().split())
s = input()

if s.count('-') != 1:
    print("No")
else:
    for i in range(len(s)):
        if s[i] == '-' and i == a:
            print("Yes")
        elif s[i] == '-' and i  != a:
            print("No")

Measured memory_bytes: 3060
import java.util.*;
import java.math.BigInteger;

public class Main{
	public static int gcd(int a, int b, int c){
 	return calculateGcd(calculateGcd(a, b), c);
	}

	public static int calculateGcd(int a, int b) {
  	if (a == 0) return b;
   	if (b == 0) return a;
    if (a > b) return calculateGcd(b, a % b);
    return calculateGcd(a, b % a);
 	}
   public static void main(String[] args){
     Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
     BigInteger sum = BigInteger.valueOf(0);
     for(int i=1;i<=a;i++){
       for(int j=1;j<=a;j++){
         for(int k=1;k<=a;k++){
           sum=sum.add(BigInteger.valueOf(gcd(i,j,k)));
         }
       }
     }
     System.out.println(sum);
   }
}

Measured memory_bytes: 56116
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	string S, T;
	cin >> S >> T;
	bool ans = true;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			ans = false;
		}
	}
	if (ans) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

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

int main() {
    string S; cin >> S;
    if (S.size() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    map<char, int> m;
    for (int i = 0; i < S.size(); i++) {
        if (m.count(S.at(i))) {
            m[S.at(i)]++;
        } else m[S.at(i)] = 1;
    }
    
    for (int i = 0; i < m.size(); i++) {
        if (m.at(S.at(i)) % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3548
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>C(N);
	rep(i, N) in >> C[i];

	std::vector<LL>dp(N), memo(212345);
	dp[0] = 1; memo[C[0]] = 1;
	for (LL i = 1; i < N; ++i)
	{
		if (C[i] == C[i - 1]) dp[i] = dp[i - 1];
		else memo[C[i]] = dp[i] = (dp[i - 1] + memo[C[i]]) % mod;
	}
	out << dp[N - 1] << std::endl;
}


Measured memory_bytes: 4992
#include <stdio.h>
void insertionSort(int A[],long N,long g);
void ShellSort(int A[],long N);
void trace(int A[],long N);
long long  cnt=0;
int main(void)
{
    long N;
    long i;
    int A[1000000]={0};
    
    scanf("%ld",&N);
    for (i=0;i<N;i++)scanf("%d",&A[i]);
    
	ShellSort(A,N);
	printf("%lld\n",cnt);
    trace(A,N);
    
    return 0;
}

void insertionSort(int A[],long N,long g)
{
    long i,j,temp;
    for(i=g;i<N;i++){
        j=i-g;
        temp=A[i];
        while(j>=0&&A[j]>temp){
            A[j+g]=A[j];
            j-=g;
            cnt++;
        }
        A[j+g]=temp;
    }
    
}

void trace(int A[],long N)
{
    int i;
    for (i=0;i<N;i++){
        printf("%d\n",A[i]);
    }
}

void ShellSort(int A[],long N)
{
    cnt=0;
    int h=0;
    int m=-1;
    int i;
    int G[30]={0};
    int ct;
    while(h<=N){
        h=3*h+1;
        m++;
    }
    printf("%d\n",m);
    for (i=0;i<m;i++){
		h=(h-1)/3;
		G[i]=h;
	}
		
    for (h=0;h<m;h++){
    	if (h>0)printf(" ");
    	printf("%d",G[h]);
    	insertionSort(A,N,G[h]);
	}
	printf("\n");
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

string A;
int nxt[300000][26];

int dp[300000];
const int INF = 1 << 29;

int rec(int pos) {
    if(dp[pos] >= 0)  return dp[pos];
    int res = INF;
    for(int i = 0; i < 26; i++){
        int n = nxt[pos][i];
        if(n != -1){
            res = min(res, rec(n) + 1);
        }
        else{
            res = 0;
        }
    }
    return dp[pos] = res;
}

int main(){

    cin >> A;
    
    int last[30];
    memset(last, -1, sizeof(last));

    for(int i = (int)A.size() - 1; i >= 0; i--){
        int c = A[i] - 'a';
        for(int j = 0; j < 26; j++){
            nxt[i+1][j] = last[j];
        }
        last[c] = i + 1;
    }

    for(int j = 0; j < 26; j++){
        nxt[0][j] = last[j];
    }

    memset(dp, -1, sizeof(dp));
    
    string ans;
    int pos = 0;
    bool is_end = false;
    while(!is_end){
        for(int i = 0; i < 26; i++){
            int n = nxt[pos][i];
            if(n == -1){
                is_end = true;
                ans += ('a' + i);
                break;
            }
        }
        if(is_end) break;

        for(int i = 0; i < 26; i++){
            int n = nxt[pos][i];
            if(rec(pos) == rec(n) + 1){
                pos = n;
                ans += A[pos - 1];
                break;
            }
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 23428
#include<bits/stdc++.h>
#define S 100000
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;vector<int>E[S];int u[2*S],v[2*S],r[2*S],ans[2*S],d[S],cnt=1,b[2*S],ok[S]{1};queue<int>que;void bfs(int u, int t) {que.push(u); while (!que.empty()) {int p = que.front(); que.pop(); for (int v : E[p]) {if (t) {if (d[v] > d[p] && !ok[v]) {ok[v] = 1; cnt++; que.push(v);}}else if (!~d[v]) {d[v] = d[p] + 1; que.push(v);}}}}int main(){int n,m,q;scanf("%d%d%d",&n,&m,&q);rep(i, m){scanf("%d%d",&u[i],&v[i]);u[i]--;v[i]--;E[u[i]].push_back(v[i]);E[v[i]].push_back(u[i]);}memset(d,-1,sizeof(d));d[0]=0;bfs(0,0);rep(i,m){if(d[u[i]]>d[v[i]])swap(u[i],v[i]);}rep(i,n)E[i].clear();rep(i,q){scanf("%d",&r[i]);r[i]--;b[r[i]]=1;}rep(i,m){if(!b[i]){if(d[v[i]]>d[u[i]]){E[u[i]].push_back(v[i]);}}}bfs(0,1);for(int i=q-1;i>=0;i--){ans[i]=n-cnt;if(d[v[r[i]]]>d[u[r[i]]]&&!ok[v[r[i]]]){E[u[r[i]]].push_back(v[r[i]]);if(ok[u[r[i]]]){cnt++;ok[v[r[i]]]=1;bfs(v[r[i]],1);}}}rep(i,q)printf("%d\n",ans[i]);}

Measured memory_bytes: 14592
#include<iostream>
#include<algorithm>
using namespace std;
int H,W,c[26],d4,d2,d1,t;
char a;
int main(void){
    cin>>H>>W;
    for(int i=0;i<H*W;i++){cin>>a;c[a-'a']++;}
    sort(c,c+26,greater<int>());
    d1=H%2&&W%2;
    d2=(H*(W%2)+W*(H%2)-d1)/2;
    d4=(H*W-d2*2-d1)/4;
    for(int i=0;i<26;i++){
        t=min(d4,c[i]/4);
        d4-=t;
        c[i]-=4*t;
        if(i==25&&d4!=0){cout<<"No"<<endl;return 0;}
    }
    for(int i=0;i<26;i++){
        t=min(d2,c[i]/2);
        d2-=t;
        c[i]-=2*t;
        if(i==25&&d2!=0){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

#define all(x) x.begin(),x.end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long MOD=1e9+7;
const long long LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=2050;

ll dp[MAXN][MAXN];
void solve(int T){
	ll s;
	scanf("%lld",&s);
	for(int i=1;i<=2000;i++)dp[1][i]=1;
	for(int i=1;i<=700;i++){
		dp[i][0]=1;
		for(int j=1;j<=2000;j++){
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=MOD;
		}
	}
	ll ans=0;
	for(int i=1;3*i<=s;i++){
		ans+=dp[i][s-3*i];
		ans%=MOD;
	}
	printf("%lld\n",ans);
}
signed main(){
	int t=1;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//scanf("%d",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 14988
from itertools import product
N = int(input())
ans = 0
for l in range(1, 10):
    for p in product("357", repeat=l):
        v = "".join(p)
        if "3" in v and "5" in v and "7" in v and int(v) <= N:
            ans += 1
            continue
        elif int(v) > N :
            break
print(ans)

Measured memory_bytes: 3060
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        n:usize,
        a:[usize;n],
    }

    let max = *a.iter().max().unwrap();

    let eratosthenes = Eratosthenes::new(max);
    let is_set_wise = a.iter().fold(0, |acc, &ai| gcd(acc, ai)) == 1;

    let mut count = vec![0; max + 1];
    for ai in a {
        let set = eratosthenes.factorization(ai);
        for &s in set {
            count[s] += 1;
        }
    }

    let is_pair_wise = count.into_iter().max().unwrap() <= 1;

    let ans = if is_pair_wise {
        "pairwise coprime"
    } else if is_set_wise {
        "setwise coprime"
    } else {
        "not coprime"
    };
    println!("{}", ans);
}

use num_integer::gcd;
use std::collections::HashSet;

/// 二分累乗法
pub fn pow(x: isize, n: usize) -> isize {
    if n == 0 {
        1
    } else if n == 1 {
        x
    } else if n % 2 == 1 {
        x * pow(x, n - 1)
    } else {
        pow(x * x, n / 2)
    }
}

/// n以下のすべての整数に対して
/// 素数判定 O(!)
/// 素因数分解 O(1)
/// を実現するデータ構造
/// 構築 (N log N)
pub struct Eratosthenes {
    primes: Vec<HashSet<usize>>,
}

impl Eratosthenes {
    /// 構築 O(N log N)
    pub fn new(n: usize) -> Self {
        let mut v = vec![HashSet::new(); n + 1];

        for i in 2..n {
            if v[i].len() <= 1 {
                v[i].insert(i);

                let mut j = 2;
                while i * j <= n {
                    v[i * j].insert(i);
                    j += 1;
                }
            }
        }

        Self { primes: v }
    }

    /// 素数判定 O(1)
    pub fn is_prime(&self, i: usize) -> bool {
        assert!(i < self.primes.len());

        self.primes[i].len() <= 1
    }

    /// 素因数分解 O(1)
    pub fn factorization(&self, i: usize) -> &HashSet<usize> {
        assert!(i < self.primes.len());

        &self.primes[i]
    }
}


Measured memory_bytes: 152084
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool t=true;
  for(int i=0;i<s.size();i++){
   if(s[i]=='7'){
     t=false;
     cout << "Yes" << endl;
     break;
   }
  }
  if(t)cout << "No" << endl;
}


Measured memory_bytes: 3564
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  A, B = readInts()
  if (A + B) % 2 == 0:
    print((A + B) // 2)
  else:
    print("IMPOSSIBLE")

if __name__ == "__main__":
  main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vector<char> s(n);
	vector<int> cnt(26,1);
	REP(i,n){
		cin>>s[i];
		cnt[s[i]-'a']++;
	}
	
	llong ans=cnt[0];
	for(int i=1;i<26;++i){
		ans*=cnt[i];
		ans%=(int)MOD;
	}
	
	cout<<ans-1<<endl;
	return 0;
}//AGC031_b.復習.

Measured memory_bytes: 384
import java.io.IOException;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args) throws IOException {
		int a=scan.next().charAt(0)-'A';
		int b=scan.next().charAt(0)-'A';
		if(a==b) {
			System.out.println("=");
		}
		else {
			System.out.println(a<b?"<":">");
		}
	}
}

Measured memory_bytes: 22996
using System;

namespace ABC159A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split();
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            
                int s = 0;
                for (int i = 0; i < a; i++)
                {
                    s = s + i;
                }
                int t = 0;
                for (int i = 0; i < b; i++)
                {
                    t = t + i;
                }
                

                Console.WriteLine(s + t);
            
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B;
  cin>>A>>B;
  for(int i = 0;i<(2*A-1);i++){
    cout << B-A+1+i << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    cout << fixed << setprecision(16);

    int r;
    cin >> r;

    cout << 2 * M_PI * r << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 M = 256;
int64 N;
vector<int64> v;

void R(int64 S, int64 A, int64 C) {
  v[0] = S;
  FOR(i, 1, N) {
    v[i] = (v[i-1]*A+C)%M;
  }
}

double calc(const vector<int64>& I, int64 S, int64 A, int64 C) {
  map<int64, int64> mp;
  int64 now = S;
  REP(i, N) {
    now = (now * A + C) % M;
    mp[(I[i]+now)%M]++;
  }
  double res = 0;
  for (auto x : mp) {
    res += (double)x.sc/(double)N * log2((double)x.sc/(double)N);
  }
  return -res;
}

int main(void) {
  using T = tuple<int64, int64, int64>;
  while (cin >> N && N) {
    T res = T(0, 0, 0); double val = INF;
    vector<int64> I(N);
    REP(i, N) cin >> I[i];
    REP(S, 16) REP(A, 16) REP(C, 16) {
      double ret = calc(I, S, A, C);
      if (ret < val) {
        res = T(S, A, C);
        val = ret;
      }
    }
    cout << get<0>(res) << " " << get<1>(res) << " " << get<2>(res) << endl;
  }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long F = 100;
  long long year = 0;
  while (F < X){
    year++;
    F = (long long) (((double) F * 1.01) / 1);
  }
  cout << year;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

import static java.lang.Math.sqrt;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        IntStream.rangeClosed(1, n)
            .map(i -> IntStream.rangeClosed(1, (int) sqrt(i))
                .map(x -> (int) IntStream.rangeClosed(1, (int) sqrt(i))
                    .filter(y -> {
                            final int tmp = 4 * i - 2 * x * y - 3 * x * x - 3 * y * y;
                            if (tmp <= 0) {
                                return false;
                            }

                            final int root = (int) sqrt(tmp);
                            final int z = (-(x + y) + root) / 2;
                            return z > 0 && given(x, y, z) == i;
                        }
                    )
                    .count()
                )
                .sum()
            ).forEach(System.out::println);
    }

    private static int given(final int x, final int y, final int z) {
        return x * x + y * y + z * z + x * y + y * z + z * x;
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
    

Measured memory_bytes: 63568
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>

struct Stop {
	int start, end, position;
	Stop() {}
	Stop(int s, int t, int x) :start{ s }, end{ t }, position{ x }{};
};
template<typename T>
struct WithKey {
	int key;
	T value;
	bool operator<(const WithKey<T>& other) const {
		return key < other.key;
	}
	bool operator>(const WithKey<T>& other) const {
		return key > other.key;
	}
};
int main() {
	int n, q; std::cin >> n >> q;
	std::vector<Stop> stops(n);
	for (auto& stop : stops) std::cin >> stop.start >> stop.end >> stop.position;
	std::vector<WithKey<int>> persons(q);
	for (auto i = 0; i < q; ++i) {
		persons[i].key = i;
		std::cin >> persons[i].value;
	}
	std::sort(persons.begin(), persons.end());
	std::priority_queue<WithKey<Stop>, std::vector<WithKey<Stop>>, std::greater<WithKey<Stop>>> start_at, end_at;
	for (const auto& stop : stops) {
		start_at.push(WithKey<Stop>{ stop.start - stop.position, stop });
	}
	std::vector<int> position(q, -1);
	for (const auto& p : persons) {
		while (!start_at.empty() && start_at.top().key <= p.value) {
			auto top = start_at.top();
			end_at.push(WithKey<Stop>{top.value.position, top.value}); start_at.pop();
		}
		while (!end_at.empty() && end_at.top().value.end - end_at.top().value.position <= p.value) {
			end_at.pop();
		}
		if (!end_at.empty()) {
			position[p.key] = end_at.top().key;
		}
	}
	std::cout << position[0];
	for (auto i = 1; i < position.size(); ++i)
		std::cout << '\n' << position[i];
}



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

vector<string> S = {"dreamer", "dream", "erase", "eraser"};
bool dp[111111];

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

   int n = s.size();
   dp[0] = true;
   for (int i = 0; i <= n; i++) {
      for (int j = 0; j < S.size(); j++) {
         if (i >= S[j].size()) {
            dp[i] |= dp[i-S[j].size()] && s.substr(i-S[j].size(), S[j].size()) == S[j];
         }
      }
   }

   puts(dp[s.size()]?"YES":"NO");

   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> A(N);
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        sum^=A[i];
    }
    
    for(int i=0;i<N;i++) cout<<(sum^A[i])<<" ";
    cout<<endl;
    
}



Measured memory_bytes: 3968