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

int main() {
  int x,n;	cin >> x >> n;
  vector<int> data(102);
  for(int i=0;i<n;i++){
    int t;
    cin >> t;
    data.at(t)=1;
  }
  
  int c=0;
  while(1){
    if(data.at(x-c)==0){
      cout << x-c;
      return 0;
    }
    if(data.at(x+c)==0){
      cout << x+c;
      return 0;
    }
    c++;
  }
  
  
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

const int MAXN = 200010;

ll n;
ll a[MAXN];

void solve() {
  vector<ll> v;
  for (int i=0;i<n;i++) {
    v.push_back(i - a[i]);
  }
  sort(v.begin(), v.end());

  ll cnt = 0;
  for (int i=0;i<n;i++) {
    auto lower = lower_bound(v.begin(), v.end(), a[i] + i);
    auto upper = upper_bound(v.begin(), v.end(), a[i] + i);
    cnt += upper - lower;
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 6852
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 998244353

long long int result[3010][3010] = {};

int main() {
	int n, s;
	cin >> n >> s;
	long long int ans = 0;
	int a[3000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	result[0][a[0]] = 1;
	if (a[0] == s) ans += n;
	for (int i = 1; i < n; i++) {
		result[i][a[i]] += i + 1;
		result[i][a[i]] %= mod;
		if (a[i] == s) {
			ans += (i + 1) * (n - i);
			ans %= mod;
		}
		for (int j = 0; j < s; j++) {
			result[i][j] += result[i - 1][j];
			if (j - a[i] >= 0) result[i][j] += result[i - 1][j - a[i]];
			result[i][j] %= mod;
		}
		if (s - a[i] >= 0) {
			ans += (n - i) * result[i - 1][s - a[i]];
			ans %= mod;
		}
	}
	// for (int i = 0; i < n; i++) {
	// 	for (int j = 0; j <= s; j++) {
	// 		cout << result[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << ans << endl;
}

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

int main()
{
    int n,k,q;

    cin >> n >> k >> q; 
    vector<int> p(n);
    rep(i, q) {
        int m;
        cin >> m;
        ++p[m-1];
    }

    rep(i, n) {
        string ans = "No";
        if (k+p[i]-q > 0)
            ans = "Yes";
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define INF INT_MAX/2

int W;
int A[101010];
int dp[101010];

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

	while (cin >> W)
	{
		rep(i, 0, W) cin >> A[i];
		rep(i, 0, W) dp[i] = 0;
		rep(i, 0, W) if (A[i] == 0)
		{
			int m = INF;

			rrep(j, i - 1, 0)
			{
				if (A[j] == 0) break;
				if (A[j] > 0)
				{
					dp[j] = max(dp[j], min(m, A[j]));
				}
				else
				{
					m = min(m, -A[j]);
				}

				m--;
				if (m == 0) break;
			}

			m = INF;
			rep(j, i + 1, W)
			{
				if (A[j] == 0) break;
				if (A[j] > 0)
				{
					dp[j] = max(dp[j], min(m, A[j]));
				}
				else
				{
					m = min(m, -A[j]);
				}

				m--;
				if (m == 0) break;
			}
		}

		int ans = 0;
		rep(i, 0, W) ans += dp[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
//#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)   int x; cin>>x; while(x--)

const int mod = 1e9 + 7;
void very_fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}


int32_t main()
{
	very_fast();
	//no_of_test(x)
	{
		int x, n;
		cin >> x >> n;
		vector<int>v(n);
		unordered_map<int, int>chk;
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
			chk[v[i]]++;
		}
		int ans = 0;
		while (true)
		{
			if (chk[x - ans] == 0)
			{
				cout << x - ans << endl;
				return 0;
			}
			if (chk[x + ans] == 0)
			{
				cout << x + ans << endl;
				return 0;
			}
			ans++;
		}
	}
	return 0;
}





Measured memory_bytes: 3672
def main():
    import sys
    input = sys.stdin.readline
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    for i in range(0, F, A):
        for j in range(0, F, B):
            ij = i * 100 + j * 100
            if ij > F:
                break
            waters.add(ij)
    sugers = set()
    for i in range(0, F, C):
        for j in range(0, F, D):
            ij = i + j
            if ij > F:
                break
            sugers.add(ij)
    ans_water = 0
    ans_suger = 0
    ans = 0
    for water in waters:
        for suger in sugers:
            if water + suger == 0:
                continue
            if water + suger > F:
                continue
            if 100 * suger > E * water:
                continue
            if 100 * suger / (water + suger) > ans:
                ans = 100 * suger / (water + suger)
                ans_water = water
                ans_suger = suger
    if ans_suger == 0:
        if A * 100 <= F:
            print(A*100, 0)
        elif B * 100 <= F:
            print(B*100, 0)
        else:
            print(0, 0)
    else:
        print(ans_water+ans_suger, ans_suger)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3192
N=int(input())
A=list(map(int,input().split()))
X=0
if N>2:
    X=A[2]
for i in range(3,N):
    X=(X|A[i])-(X&A[i])
S=A[0]+A[1]
if (S-X)%2==1 or (S-X)<0:
    print(-1)
else:
    D=(S-X)//2
    if D&X>0:
        print(-1)
    else:
        a=D
        for i in range(50,-1,-1):
            if ((X>>i)&1) and ((a+(1<<i))<A[0]):
                a+=(1<<i)
        if a>0 and A[0]>=a:
            print(A[0]-a)
        else:
            print(-1)

Measured memory_bytes: 9252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
int dp[200005][2];//0:1 1:2
char s[200005];
int main(){
	ios::sync_with_stdio(false);
	cin>>s+1;
	n=strlen(s+1);
	dp[1][0]=dp[2][1]=1;
	for (int i=1;i<n;++i){
		if (dp[i][0]){
			dp[i+2][1]=max(dp[i+2][1],dp[i][0]+1);
			if (s[i+1]!=s[i]) dp[i+1][0]=max(dp[i+1][0],dp[i][0]+1);
		}
		if (dp[i][1]){
			dp[i+1][0]=max(dp[i+1][0],dp[i][1]+1);
			if (s[i+1]!=s[i-1]&&s[i+2]!=s[i]) dp[i+2][1]=max(dp[i+2][1],dp[i][1]+1);
		}
	}
	cout<<max(dp[n][1],dp[n][0]);
	return 0; 
}

Measured memory_bytes: 2048
import math
N=int(input())
sN=math.sqrt(N)
ans=10000
for i in range(1,int(sN)+1):
    if N%i==0:
        k1=N/i
        k=int(k1)
    
        if ans > len(str(k)):
            ans=len(str(k))

print(ans)

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline

    N, D = map(int, input().split())

    ans = 0
    for _ in range(N):
        x, y = map(int, input().split())
        if x * x + y * y <= D * D:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let a: i32 = sc.read();

        // AOJのRustのバージョンは古いので、一旦Stringで取得後に最初の文字を取ります。
        let op: String = sc.read();
        let op = op.as_bytes()[0] as char;
        // 新しいバージョンのRustでは次のようにすれば十分です。
        // let op: char = sc.read();

        let b: i32 = sc.read();
        let ans = match op {
            '+' => a + b,
            '-' => a - b,
            '*' => a * b,
            '/' => a / b,
            _ => break
        };
        println!("{}", ans);
    }
}



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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    deque<int> d;
    rep(i,n){
        int p=lower_bound(all(d),a[i])-d.begin();
        if(p==0) d.push_front(a[i]);
        else d[p-1]=a[i];
    }
    int ans=d.size();
    cout<<ans<<endl;
}



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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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

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

signed main(){
    int N, A; cin >> N >> A;
    cout << N * N - A << endl;
}


Measured memory_bytes: 256
s = input()
k = int(input())
n = len(s)
p = ['']*(4*n)

for i in range(n):
    p[i] = s[i]
    p[i+n] = s[i]
    p[i+2*n] = s[i]
    p[i+3*n] = s[i]

a = [0,0,0,0]

judge = 0
for i in range(1,4*n):
    if p[i] == p[i-1]:
        a[i//n] += 1
        p[i] = ''
        if i == n:
            judge = 1
        if judge == 1 and i == 2*n:
            judge = 2

if judge == 0:
    print(a[0]*k)
    
elif judge == 2:
    if k == 1:
        print(a[0])
    else:
        print(a[0]+a[1]*(k-1))
else:
    res = (a[0]+a[1])*(k//2)
    if k%2 == 1:
        res += a[0]
    print(res)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int a,b;
    cin >> a >> b;
    a--,b--;
    printf("100 100\n");
    for(int i=0;i<50;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(i%2&&j%2&&a)
            {
                a--;
                printf(".");
            }
            else printf("#");
        }
        printf("\n");
    }
    for(int i=50;i<100;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(i%2&&j%2&&b)
            {
                b--;
                printf("#");
            }
            else printf(".");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, (input().split())))
a.append(0)
mon = 1000
kab = 0
x = 0
for i in range(n):
    if a[i] <= a[i+1]:
        kab = mon//a[i]
        mon += kab*(a[i+1]-a[i])
print(mon)

Measured memory_bytes: 9164
n, a, b, c, d = map(int, input().split())
s = input()

def check(l, r):
  if (r-l) <= 1:
    return True
  for i in range(l, r):
    if s[i:i+2] == '##':
      return False
  return True

def check2(l, r):
  for i in range(l, r-1):
    if s[i:i+3] == '...':
      if check(b, i) and check(i+2, c-2):
        return (True, i+1)
  return (False, -1)

if c < d:
  flag = check(a, c-2) and check(b, d-2)
else:
  flag, idx = check2(b-2, d)
  if flag:
    s = s[:idx] + '#' + s[idx+1:]
    flag = check(a, c-2)

print('Yes' if flag else 'No')


Measured memory_bytes: 41596
struct REC(Vec<usize>);
impl REC {
    fn f(&mut self, x: usize) -> usize {
        if x == 0 {
            1
        } else if self.0[x] != !0 {
            self.0[x]
        } else {
            self.0[x] = self.f(x % x.count_ones() as usize) + 1;
            self.0[x]
        }
    }
}

fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let x: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let mut m = 0;
    for i in 0..n {
        if x[i] == '1' {
            m += 1;
        }
    }
    let mut l = vec![0; n];
    let mut suml = 0;
    let mut r = vec![0; n];
    let mut sumr = 0;
    let mut p = 1;
    let mut q = 1;
    for i in (0..n).rev() {
        l[i] = p;
        r[i] = q;
        if x[i] == '1' {
            suml = (suml + p) % (m + 1);
            if m > 1 {
                sumr = (sumr + q) % (m - 1);
            }
        }
        p = p * 2 % (m + 1);
        if m > 1 {
            q = q * 2 % (m - 1);
        }
    }

    let mut rec = REC(vec![!0; n + 1]);

    for i in 0..n {
        if x[i] == '1' {
            if m == 1 {
                println!("0");
                continue;
            }
            println!("{}", rec.f((sumr + (m - 1) - r[i]) % (m - 1)));
        } else {
            println!("{}", rec.f((suml + l[i]) % (m + 1)));
        }
    }
}

Measured memory_bytes: 7508
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {

    string S;
    cin >> S;

    string a,b;
    rep(i,3){
        a = S[i];
        b = S[i+1];
        if(a == b){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

string s;
int n;
ll dfs(int i, vector<bool> p) {
    ll sum = 0;
    if (i == n-1) {
        int j2 = 0;
        rep(j, i) {
            if (p[j])  {
                sum += stoll(s.substr(j2, j-j2+1));
                j2 = j + 1;
            }
        }
        sum += stoll(s.substr(j2, i-j2+1));
        return sum;
    }
    p[i] = true;
    sum += dfs(i+1, p);
    p[i] = false;
    sum += dfs(i+1, p);
    return sum;
}

int main(){
    cin >> s;
    n = s.size();
    vector<bool> p(n-1);
    cout << dfs(0, p) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
char s[200020];
int bit[200020];bool c[200020];
set<int> e[26];
int lowbit(int x){return x&-x;}
void add(int x,int y){
	while(x <= n){
		bit[x] += y;
		x += lowbit(x);
	}
}
int query(int x){
	int r = 0;
	while(x){
		r += bit[x];
		x -= lowbit(x);
	}
	return r;
}
int main(){
	scanf("%s",s+1);
	n = strlen(s+1);
	for(int i=1; i<=n; i++){
		e[s[i]-'a'].insert(i);
		add(i, 1);
		c[i] = true;
	}
	int cnt = 0;
	for(int i=0; i<26; i++)
		cnt += e[i].size() % 2;
	if(cnt > 1){
		puts("-1");
		return 0;
	}
	int L = 1, R = n;
	long long int res = 0;
	while(1){
		while(L<=n && !c[L])++L;
		while(R>0 && !c[R])--R;
		if(L>=R)break;
		int S = s[L]-'a', E = s[R]-'a';
		if(S == E){
			add(L, -1);
			add(R, -1);
			c[L] = false;
			c[R] = false;
			e[S].erase(L);
			e[E].erase(R);
			continue;
		}
		int A = e[S].size() > 1 ? query(n) - query(*e[S].rbegin()) : n+1;
		int B = e[E].size() > 1 ? query(*e[E].begin() - 1) : n+1;
		if(A < B){
			res += A;
			c[L] = false;
			c[*e[S].rbegin()] = false;
			add(L, -1);
			add(*e[S].rbegin(), -1);
			e[S].erase(*e[S].rbegin());
			e[S].erase(*e[S].begin());
		}else{
			res += B;
			add(R, -1);
			add(*e[E].begin(), -1);
			c[R] = false;
			c[*e[E].begin()] = false;
			e[E].erase(*e[E].begin());
			e[E].erase(*e[E].rbegin());
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 10752
N = int(input())
S = []
for _ in range(N):
  S.append(input())
ans = 0
tailA, headB, b_a = 0, 0, 0
for s in S:
  ans += s.count('AB')
  h, t = s[0], s[-1]
  if h == 'B' and t != 'A':
    headB += 1
  elif h != 'B' and t == 'A':
    tailA += 1
  elif h == 'B' and t == 'A':
    b_a += 1
ans += min(tailA, headB)
if b_a > 0:
  ans += b_a - 1
  if tailA > 0 or headB > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const ll INF=1e18+5;
int main()
{
    IO;
    int n ;
    cin>>n;
    double arr[n+2];
    for(int i = 0; i< n ; i ++) cin>>arr[i];
    double dp[n+2][n+2];
    for(int i = 0 ; i<=n ; i++)
    {
        for(int j =0 ; j <=n;j++)
        {

            dp[i][j]=1;
        }
    }
    for(int i = 0 ; i< n ; i ++)
    {
        for(int j = 0 ; j <=i+1 ; j ++)
        { // dp [i][j]= prob of j out of i
            if(j==0){ // all of them is false
                if(i==0){
                    dp[i][j]=1-arr[i];
                }else{
                    dp[i][j]=(1-arr[i])*dp[i-1][j];
                }
            }else{
                if(i==0){
                    if(j==1){
                        dp[i][j]=arr[i];
                    }
                }else if (j==i+1) {
                    dp[i][j]=arr[i]*dp[i-1][j-1];
                }else{
                        dp[i][j]=(1-arr[i])*dp[i-1][j]+(arr[i]*dp[i-1][j-1]);
                    }

            }
        }
    }
    double ans=0;
    for(int i = n; i>n/2;i--){
        ans+=dp[n-1][i];
    }
    printf("%.10f\n", ans);
    return 0;
}


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

using namespace std;

int gcd(int x, int y) {
  return y ? gcd(y, x%y) : x;
}

int main(){
    long long int A,B,C,D,e,sum=0,s=0;
    cin >> A >> B >> C >> D;
    sum = B-A+1;
    e = C*D/gcd(C,D);
    s = B/C + B/D - B/e - (A-1)/C - (A-1)/D + (A-1)/e ;
    cout << sum-s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(std::vector<long long> H, std::vector<long long> M, long long K){
  ll x = H[0]*60 + M[0];
  ll y = H[1]*60 + M[1];
  y -= K;
  cout << y - x << endl;

}

int main(){
    std::vector<long long> H(2);
				std::vector<long long> M(2);
				for(int i = 0 ; i < 2 ; i++){
								scanf("%lld",&H[i]);
								scanf("%lld",&M[i]);
				}
				long long K;
				scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
    return 0;
}


Measured memory_bytes: 3684
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    ll a,b;
    cin>>a>>b;
    
    ll S=0;

    rep(i,b-a) S+=i;

    cout << S-a << endl;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  long long ans=k;
  for(int i=1;i<n;i++)ans*=k-1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3516
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

int n, m;
vector<vector<int>> adj;

bool visited[501][3];
void dfs(int v, int depth) {
    if (visited[v][depth]) return;
    if (depth == -1) return;
    visited[v][depth] = true;

    for (auto u : adj[v]) {
        dfs(u, depth - 1);
    }
}

int main() {
    while (cin >> n >> m) {
        if (n == 0) break;
        rep(i, 501) rep(j, 3) visited[i][j] = false;
        adj = vector<vector<int>>();
        adj.reserve(n);
        rep(i, m) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            adj[a].push_back(b);
            adj[b].push_back(a);
        }
        dfs(0, 2);
        int ans = 0;
        rep(i, n) if (visited[i][0] || visited[i][1] || visited[i][2]) {
            ans++;
        }
        cout << ans - 1 << endl;
    }
}

Measured memory_bytes: 3248
#C
import sys
l, r = map(int, input().split())
ans=2018
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
        if ans == 0:
            print(0)
            sys.exit()
print(ans)

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

int main(void){
    int N;
    std::cin >> N;
    std::vector<long long> h(N + 1, 0), c(N + 1, 1E+10);
    for(int i = 0; i < N; i++) std::cin >> h[i];
    c[0] = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j <= i + 2; j++) c[j] = std::min(c[j], c[i] + abs(h[i] - h[j]));
    }
    std::cout << c[N - 1] << std::endl;
    return 0;
}

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

void trace(vector<int> &vi) {
    for (size_t i = 0; i < vi.size(); i++) {
        cout << vi[i];
        cout << ((i != vi.size() - 1) ? " " : "\n");
    }
}

void insertionSort(vector<int> &vi) {
    int v = 0;
    trace(vi);
    for (size_t i = 1; i < vi.size(); i++) {
        v = vi[i];
        int j = i - 1;
        while (j >= 0 && vi[j] > v) {
            vi[j + 1] = vi[j];
            j--;
        }
        vi[j + 1] = v;
        trace(vi);
    }
}

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

    int n;
    cin >> n;
    vector<int> vi(n);
    for (int i = 0; i < n; i++) {
        cin >> vi[i];
    }
    insertionSort(vi);
}


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

int main() {
  string A, B,C;
  cin >> A >> B >> C;
  if(A.at(A.size()-1)== B.at(0) && B.at(B.size()-1)== C.at(0)){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int n, a; cin >> n >> a;
    cout << n*n - a << endl;
}

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

int main(void){
  vector<int> num(100,0);
  int n,a,c;
  cin >> n;
  for(int i = 0;i < n; i++){
    cin >> a;
    num.at(a - 1)++;
  }
  c = count(num.begin(),num.end(),0);
  cout << 100 - c << endl;
}

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

int k[] = {1,5,10,50,100,500};

int main(){
  int sum = 0;
  for(int i=0;i<6;i++){
    int a; cin >> a;
    sum += k[i]*a;
  }
  cout << (sum>=1000) << endl;
}

Measured memory_bytes: 1160
def main(N=None, M=None, A=None):
    if not N:
        N, M = map(int, input().split())
        A = list(map(int, input().split()))
    ans = N - sum(A)
    if ans < 0:
        ans = -1
    print(ans)
    return ans


if __name__ == "__main__":
    # assert main(41, 2, [5, 6]) == 30
    # assert main(10, 2, [5, 6]) == -1
    # assert main(11, 2, [5, 6]) == 0
    # assert main(314, 15, [9, 26, 5, 35, 8, 9, 79,
    #                       3, 23, 8, 46, 2, 6, 43, 3]) == 9
    main()


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

int main() {
	string s, t;
	int count = 0;
	cin >> s;
	cin >> t;
	if (s.size() == t.size() - 1) {
		for (int i = 0; i < s.size(); i++) {
			if (s.at(i) != t.at(i)) {
				count++;
			}
		}
	}
	if (count == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int main() {
	char str[100001];
	bool hanten = false;
	vector<char>ft, bk;
	int Q, T, F;
	char c[2];
	scanf("%s", str);
	scanf("%d", &Q);
	rep(i, 0, Q) {
		scanf("%d",&T);
		if (T == 1)hanten = !hanten;
		else {
			scanf("%d", &F);
			scanf("%s", c);
			getchar();
			(((F - 1) ^ hanten) ? bk : ft).push_back(c[0]);
		}
	}
	if (hanten) {
		int len = strlen(str);
		vector<char>str2(len + 1);
		str2[len] = 0;
		rep(i, 0, len) {
			str2[i] = str[len - i - 1];
		}
		reverse(bk.begin(), bk.end());
		bk.push_back(0);
		ft.push_back(0);
		printf("%s%s%s", bk.data(), str2.data(), ft.data());
	}
	else {
		reverse(ft.begin(), ft.end());
		ft.push_back(0);
		bk.push_back(0);
		printf("%s%s%s", ft.data(), str, bk.data());
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,i,x;
	long long int y=0,z=0;
	set<long long int>A;
	vector<long long int>B;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&x);
		if(A.find(x)!=A.end()){
			B.push_back(x);
			A.erase(x);		}
		else A.insert(x);
	}
	sort(B.begin(),B.end());
	if(B.size()>=2) printf("%lld",B[B.size()-1]*B[B.size()-2]);
	else printf("0");
}

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

int main(){
  string S;
  cin>>S;
  int count=0;

  int countmax=0;

  for(int i=0;i<S.length();i++){
    if((S[i]=='A')||(S[i]=='C')||(S[i]=='G')||(S[i]=='T')){
      count++;
    }
    else{
      if(count>countmax)
        countmax=count;
      count=0;
    }
  }

  if(count>countmax)
    countmax=count;

  cout<<countmax<<endl;

  return 0;
}


Measured memory_bytes: 256
(let* ((s (read-line))
    (l (length s))
    (ans (abs (- (parse-integer (subseq s 0 3)) 753))))
    (dotimes (i (- l 3))
        (if (> ans (abs (- (parse-integer (subseq s (+ 1 i) (+ i 4))) 753)))
        (setq ans (abs (- (parse-integer (subseq s (+ 1 i) (+ i 4))) 753)))
        )
    )
    (princ ans)
)

Measured memory_bytes: 24360
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();

        int ans = 1;
        int tmp = 0;
        for (int i = 1; i <= N; ++i) {
            int num = i;
            int cnt = 0;
            while (true) {
                if (num % 2 == 0) {
                    ++cnt;
                    num /= 2;
                }
                else {
                    break;
                }
            }
            if (cnt > tmp) {
                tmp = cnt;
                ans = i;
            }
        }

        System.out.println(ans);
    }
}

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

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

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

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

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

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

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




Measured memory_bytes: 32524
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,W;
  cin>>N>>W;
  vector<int>w(N);
  vector<int64_t>v(N);
  for(int i=0;i<N;i++){
  cin>>w.at(i);
    cin>>v.at(i);
  
  }
  vector<vector<int64_t>>dp(N+1,vector<int64_t>(W+1,0));
   for(int i=1;i<=N;i++){
   for(int j=1;j<=W;j++){
   if(w.at(i-1)<=j){
   dp[i][j]=max(dp[i-1][j],dp[i-1][j-w.at(i-1)]+v.at(i-1));
   }else{
   dp[i][j]=dp[i-1][j];
   }
   
   }
   
   }cout<<dp[N][W]<<endl;
  
  
  return 0;
  
}

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

int main() {
  int N,x;//xは桁数をしらべるための値、yは各桁の合計値
  int y = 0;
  cin >> N;
  x = N;
  for (int i=0; i< 9; i++) {
    y += x % 10;
    x = x / 10;
    
  }
 if (N % y == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A = [0] * (n + 1)
for i in range(1, n + 1):
    A[i] = A[i - 1] + a[i - 1]

B = [0] * (m + 1)
for i in range(1, m + 1):
    B[i] = B[i - 1] + b[i - 1]

ans = 0
best = m
for i in range(n + 1):
    for j in range(best, -1, -1):
        t = A[i] + B[j]
        if t <= k:
            ans = max(ans, i + j)
            best = j
            break
print(ans)


Measured memory_bytes: 48708
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int seg[524288];

void add(int x) {
	x += 262144;
	seg[x]++;
	while (x) {
		x /= 2;
		seg[x] = seg[x * 2] + seg[x * 2 + 1];
	}
}

int rsq(int s, int t, int k = 1, int l = 0, int r = 262143) {
	if (t < l || r < s)return 0;
	if (s <= l && r <= t) {
		return seg[k];
	}
	int lv = rsq(s, t, k * 2, l, (l + r) / 2);
	int rv = rsq(s, t, k * 2 + 1, (l + r) / 2 + 1, r);
	return lv + rv;
}

void init(int N) {
	int n = N + 262149;
	int d = 262144;
	while (n) {
		for (int i = d;i <= n;i++) {
			seg[i] = 0;
		}
		d /= 2;
		n /= 2;
		seg[n * 2 + 1] = 0;
	}
}

int main() {
	ll T, N, K, L, R;
	cin >> T;
	while (T--) {
		cin >> N;
		vector<pair<ll, ll>> LU, RU;
		init(N);
		ll S = 0;
		for (int i = 0;i < N;i++) {
			cin >> K >> L >> R;
			if (K == N) {
				S += L;
			}
			else if (L > R) {
				LU.push_back({ K, L - R });
				S += R;
			}
			else {
				RU.push_back({ N - K,R - L });
				S += L;
			}
		}
		sort(all(LU));
		sort(all(RU));
		priority_queue<int, vector<int>, greater<int>> Q;

		for (auto P : LU) {
			Q.push(P.second);
			if (Q.size() > P.first) {
				Q.pop();
			}
		}
		while (!Q.empty()) {
			S += Q.top();
			Q.pop();
		}
		for (auto P : RU) {
			Q.push(P.second);
			if (Q.size() > P.first) {
				Q.pop();
			}
		}
		while (!Q.empty()) {
			S += Q.top();
			Q.pop();
		}
		cout << S << endl;
	}
}

Measured memory_bytes: 8772
#include <cstdio>

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

char s[N];
int a[N], n, f[N], nxt[3];

int main() {
    scanf("%s", s);
    for (; s[n]; ++n) a[n+1] = (a[n] + s[n] - 'a' + 1) % 3; // 求前缀和 
    // 判断是否可以操作 
    int flag = 0;  
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i-1]) flag = 1;
    }
    if (!flag) {
        puts("1");
        return 0;
    }
    // 递推 
    f[n] = 1;
    for (int i = 0; i < 3; ++i) nxt[i] = i == a[n] ? n : n + 1;
    for (int i = n-1; i; --i) {
        f[i] = a[i] == a[n]; // 后面可不可以不分段 
        for (int c = 1; c <= 2; ++c) {
            (f[i] += f[nxt[(a[i]+c)%3]]) %= MOD; // 后面加一段A或B 
        }
        nxt[a[i]] = i; // 记录该p值最后一次出现的位置 
    }
    printf("%d\n", (f[nxt[1]] + f[nxt[2]]) % MOD);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;

struct Human {
    int no;
    int result;
};
typedef struct Human Human;

int compareTo(const Human& a, const Human& b) {
    return(a.result > b.result);
}

int main(void) {
    int num; cin >> num;
    Human table[num];
    for(int r = 0; r < num; r++) cin >> table[r].no >> table[r].result;
    sort(table, table+num, compareTo);
    
    int minNo = INT_MAX, minResult = INT_MAX;
    int topResult = table[0].result;
    for(int r = 0; r < num && (table[r].result == topResult); r++) {
        if(table[r].no < minNo) {
            minNo = table[r].no; minResult = table[r].result;
        }
    }
    cout << minNo << " " << minResult << endl;
    return(0);
}

Measured memory_bytes: 1188
#include<stdio.h>

int main(){
	int n,m,d,x,y,i;
	for(;scanf("%d",&n),n;puts(n?"No":"Yes")){
		int f[21][21] = {0};
		for(i=n;i--;f[y][x] = 1)
			scanf("%d %d",&x,&y);
		scanf("%d",&m);
		x=y=10;
		for(i=m;i--;)
			for(scanf(" %c %d",&m,&d);d--;f[y][x]?n--,f[y][x]=0:0){
				x+=m==69?1:m==87?-1:0;
				y+=m==78?1:m==83?-1:0;
			}
	}
}

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

#define MOD 1000000007

main(){
	long long n,k,ans;
	string s;
	cin>>n>>s;
	k = 0;
	ans = 1;
	for(int i=0;i<2*n;i++){
		if(i > 0 && i <= n)
			ans *= i;
		ans %= MOD;
		if(s[i] == 'B')
			if(k%2 == 0)
				k++;
			else
				ans *= k--;
		else
			if(k == 0)
				k = MOD;
			else if(k%2 == 0)
				ans *= k--;
			else
				k++;
		ans %= MOD;
	}
	if(k != 0)
		ans = 0;
	cout<<ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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

long long factorial(long long i){ // 階乗
  if(i > 0)
    return i * factorial(i-1);
  else
    return 1;
}

// a^n mod
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n>0) {
    if(n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^(-1) mod
long long modinv(long long a, long long mod) {
  return modpow(a, mod-2, mod);
}

int main() {
  long long Q;
  const long long mod = 1000003;
  
  cin >> Q;
  
  // あらかじめ必要な階乗(mod)を計算しておく
  vector<long long> factmod;
  factmod.push_back(1); // 0! = 1
  long long tmp = 1;
  for(int i=1; i<mod+10; i++) { // 1000003!(mod 1,000,003) まで計算しておく．念のためちょっと多めに
    tmp = (tmp*i)%mod;
    factmod.push_back(tmp);
  }
  
  long long ans = 1;
  rep(i, Q) {
    long long x, d, n;
    cin >> x >> d >> n;
    
    if(d!=0) {
      // 求める積は d^n * (x/d) * (x/d + 1) * ... * (x/d + (n-1))
      // つまり d^n * (x/d + (n-1))! / (x/d - 1)! (mod 1000003)
      long long xbyd = x * modinv(d, mod) %mod; // x/d (mod)
      if(xbyd+n-1 > mod) {
        // x/d+n-1 が modより大きい時 (x/d + (n-1))! がゼロになる．
        ans = 0;
      } else {
		    if(xbyd==0) xbyd += mod; // xbyd-1 が負になるのを防ぐ
        ans = modpow(d, n, mod) * factmod[xbyd+n-1] %mod * modinv(factmod[(xbyd-1)%mod], mod) %mod;
      }
    } else { // d = 0
      // 求める積は x^n
      ans = modpow(x, n, mod);
    }

    if(ans<0) ans += mod;
    cout << ans << endl;
  }
}


Measured memory_bytes: 10604
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    cout << string(s.size(), 'x') << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int N;
    double a,x;
    scanf("%d", &N);
    if(N%2==0){
        a=N/2;
        x=a/N;
        printf("%lf\n", x);
    }
    else{
        a=(N+1)/2;
        x=a/N;
        printf("%0.10lf\n", x);
    }
    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

#define INF 1
#define MAX_V 50000

struct edge{
	int to;
	int cost;
};

typedef pair<int, int> P; // first??????????????¢???second??????????????????

// ?????????O(|E|log|V|)

int d[MAX_V];
vector<edge> G[MAX_V];

void shortest_path(int s, int V){ // V???????????°
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // ????????????????°???????????????´??°
	}
}

int main(){
	
	int W, H;
	
	int map[200][200];
	
	while(true){
		cin >> W >> H;
		
		if(cin.eof()){
			break;
		}
		
		for(int i = 0; i < 200; i++){
			for(int j = 0; j < 200; j++){
				map[i][j] = 0;
			}
		}
		
		for(int i = 1; i <= H; i++){
			for(int j = 1; j <= W; j++){
				cin >> map[j][i];
			}
		}
		
		for(int i = 0; i < MAX_V; i++){
			G[i].erase(G[i].begin(), G[i].end());
		}
		
		for(int i = 0; i < 150; i++){
			for(int j = 0; j < 150; j++){
				if(map[i][j] == map[i + 1][j]){
					int index1 = i + j * 200;
					int index2 = i + 1 + j * 200;
					edge e1, e2;
					e1.cost = 0;
					e2.cost = 0;
					e1.to = index2;
					e2.to = index1;
					G[index1].push_back(e1);
					G[index2].push_back(e2);
				}
				if(map[i][j] == map[i][j + 1]){
					int index1 = i + j * 200;
					int index2 = i + (j + 1) * 200;
					edge e1, e2;
					e1.cost = 0;
					e2.cost = 0;
					e1.to = index2;
					e2.to = index1;
					G[index1].push_back(e1);
					G[index2].push_back(e2);
				}
				
				if(j % 2 == 0){
					if(i >= 1 && map[i][j] == map[i - 1][j + 1]){
						int index1 = i + j * 200;
						int index2 = i - 1 + (j + 1) * 200;
						edge e1, e2;
						e1.cost = 0;
						e2.cost = 0;
						e1.to = index2;
						e2.to = index1;
						G[index1].push_back(e1);
						G[index2].push_back(e2);
					}
				}else{
					if(map[i][j] == map[i + 1][j + 1]){
						int index1 = i + j * 200;
						int index2 = i + 1 + (j + 1) * 200;
						edge e1, e2;
						e1.cost = 0;
						e2.cost = 0;
						e1.to = index2;
						e2.to = index1;
						G[index1].push_back(e1);
						G[index2].push_back(e2);
					}
				}
				
			}
		}
		
		shortest_path(0, 40000);
		
		int ans = 0;
		
		for(int i = 0; i < 150; i++){
			for(int j = 0; j < 150; j++){
				if(d[i + j * 200] != d[i + 1 + j * 200]){
					ans++;
				}
				if(d[i + j * 200] != d[i + (j + 1) * 200]){
					ans++;
				}
				
				if(j % 2 == 0){
					if(i >= 1 && d[i + j * 200] != d[i - 1 + (j + 1) * 200]){
						ans++;
					}
				}else{
					if(d[i + j * 200] != d[i + 1 + (j + 1) * 200]){
						ans++;
					}
				}
				
			}
		}
		
		/*
		for(int i = 0; i <= H + 1; i++){
			for(int j = 0; j <= W + 1; j++){
				cout << d[i * 200 + j] << " ";
			}
			cout << endl;
		}
		*/
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6272
n, m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

as.sort!
bs.sort!

if as.uniq != as || bs.uniq != bs
  puts(0)
else
  ans = 1
  a_head = as.size - 1
  b_head = bs.size - 1
  (n * m).times do |i|
    val = n * m - i
    can_set = nil
    if val == as[a_head]
      a_head -= 1
      if val == bs[b_head]
        b_head -= 1
        can_set = 1
      else
        can_set = bs.size - b_head - 1
      end
    elsif bs[b_head] == val
      b_head -= 1
      can_set = as.size - a_head - 1
    else
      can_set = (as.size - a_head - 1) * (bs.size - b_head - 1) - i
    end
    ans = (ans * can_set) % 1000000007
  end
  puts(ans)
end


Measured memory_bytes: 1912
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static String call(int n) {
		StringBuilder answer = new StringBuilder();
		for (int i = 3; i <= n; i++) {
			if (i % 3 == 0) {
				answer.append(" ").append(String.valueOf(i));
			} else {
				int tmp = i;
				while (tmp != 0) {
					if (tmp % 10 == 3) {
						answer.append(" ").append(String.valueOf(i));
						break;
					}
					tmp /= 10;
				}
			}
		}
		return answer.toString();
	}
	
	public static void main(String[] args){
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(input.readLine());
			System.out.println(call(n));
		} catch (Exception e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21156
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var ans = new int[N];
            for (int i = 0; i < N; i++) ans[A[i] - 1] = i + 1;

            Console.WriteLine(string.Join(" ", ans));
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    int cur = h[0];
    int c = 1;
    for (int i = 1; i < n; i++) {
        if (cur <= h[i]) {
            cur = h[i];
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

		int D = Integer.parseInt(sc.next());
		int G = Integer.parseInt(sc.next());
		int[][] arr  = new int [D][3];

		for(int i=0;i<D;i++) {
			arr[i][0] = Integer.parseInt(sc.next());
			arr[i][1] = Integer.parseInt(sc.next());
			arr[i][2] = arr[i][0]*100*(i+1) +arr[i][1];
		}
		int totalQueMin = Integer.MAX_VALUE;

		for(int i=0;i<1<<D;i++) {
			int totalQue = 0;
			int totalPoint = 0;
			boolean[] arrFlg = new boolean[D];
			for(boolean a:arrFlg) a = false;
			for(int j=0;j<D;j++) {
				if((1& i>>j) == 1) {
					totalQue += arr[j][0];
					totalPoint += (arr[j][1] + 100*(j+1)*arr[j][0]);
//					System.out.print("1");
					arrFlg[j] = true;
				} else {
//					System.out.print("0");
				}
			}
			label:while(totalPoint < G) {
				for(int m=D; m > 0; m--) {
					if(!arrFlg[m-1]) {
						int aa = m-1;
						for(int n=0;n<arr[aa][0];n++) {
							totalPoint += 100*(m);
							totalQue++;
							if(totalPoint >= G) break label;
						}
						totalPoint += arr[m-1][1];
							if(totalPoint >= G) break label;
					}
				}
			}

//			System.out.println("-----------------");
//			System.out.print(totalQue+ "  ");
//			System.out.println(totalPoint);
			totalQueMin = Math.min(totalQueMin, totalQue);
		}
		System.out.println(totalQueMin);


	}
}

Measured memory_bytes: 28204