akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int N,M,X,Y,x[105],y[105];
int main()
{
	int i;
	cin>>N>>M>>X>>Y;
	for (i=1;i<=N;i++) cin>>x[i];
	for (i=1;i<=M;i++) cin>>y[i];
	sort(x+1,x+N+1);sort(y+1,y+M+1);
	for (i=X+1;i<=Y;i++) if (i>x[N]&&i<=y[1]) break;
	if (i==Y+1) cout<<"War";
	else cout<<"No War";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;

int memo[105][105];
int r[105], c[105];

int func(int a, int b) {
	if (memo[a][b] != INT_MIN) return memo[a][b];
	if (b - a == 0) { 
		memo[a][b] = 0;
	}
	else {
		int m = INT_MAX;
		for (int k = a;k < b;k++) {
			m = min(m, func(a, k) + func(k + 1, b) + r[a] * c[k] * c[b]);
		}
		memo[a][b] = m;
	}
	return memo[a][b];
}

int main() {
	int n;
	cin >> n;
	Loop(i, n) {
		Loop(j, n) {
			memo[i][j] = INT_MIN;
		}
	}
	Loop(i, n) {
		cin >> r[i] >> c[i];
	}
	cout << func(0, n - 1) << endl;
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#define MAX 50
#define BLACK 'B'
#define WHITE 'W'
#define SPACE '.'
#define VISITED '#'

using namespace std;

int w, h;
int numB, numW;
int sum;
char data[MAX][MAX];
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

bool isOut(int x, int y) {
  if(x < 0 || x >= w) return true;
  if(y < 0 || y >= h) return true;
  return false;
}

void show() {
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cout << data[i][j];
    }
    cout << endl;
  }
  cout << endl;
}

void rec(int x, int y, char c) {
  data[y][x] = VISITED;
  if(sum != -1) sum++;
  for(int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(isOut(nx, ny)) continue;
    if(data[ny][nx] == VISITED) continue;
    if(data[ny][nx] == SPACE) {
      rec(nx, ny, c);
    } else if(data[ny][nx] != c) {
      sum = -1;
    }
  }
}

main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	cin >> data[i][j];
      }
    }

    numB = numW = 0;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	if(data[i][j] != SPACE && data[i][j] != VISITED) {
	  for(int k = 0; k < 4; k++) {
	    int nx = j + dx[k];
	    int ny = i + dy[k];
	    if(isOut(nx, ny)) continue;
	    if(data[ny][nx] == VISITED) continue;
	    if(data[ny][nx] != SPACE) continue;
	    sum = 0;
	    rec(nx, ny, data[i][j]);
	    if(sum != -1) {
	      if(data[i][j] == BLACK) {
		numB += sum;
	      } else {
		numW += sum;
	      }
	    }
	  }
	}
      }
    }

    cout << numB << ' ' << numW << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
int main(void)
{
	int number=0;
	int sum=0;
	scanf("%d",&number);
	int point[number];
	for(int i=0;i<number;i++)
	{
		point[i]=0;
	}
	for(int i=0;i<number;i++)
	{
		scanf("%d",&point[i]);
	}
	for(int i=0;i<number-1;i++)
	{
		for(int t=i+1;t<number;t++)
		{
			sum=sum+point[i]*point[t];
		}
	}
	printf("%d",sum);
	return 0;
} 


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    int N;
    char S[10010];

    scanf("%d %s", &N, S);

    for(int i = 0; i < strlen(S); i++) {
        S[i] += N;

        if('Z' < S[i]) {
          S[i] -= 'Z' + 1 - 'A';
        }
    }

    printf("%s\n", S);

    return 0;
}

Measured memory_bytes: 128
N,K=map(int,input().split())
ans=0
for b in range(K,N+1):
    if b==0:
        continue
    #aの数
    #N=pb+r
    #0<=r<bをp回ループした後、r個 or r+1個の余りがある
    #(b-K)でK<=r<bを表している
    #(N//b)でループ数を表している
    ans += (b-K)*int(N//b)

    if N%b>=K and K>0:
        #
        ans+=N%b-K+1
    elif N%b>=K:
        ans+=N%b 
print(ans)

Measured memory_bytes: 39024
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long X = lread();
    writeln((X < 1200) ? "ABC" : "ARC");
}


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

int main()
{
	string A, B;
	cin >> A >> B;

	string ans;
	if( A.size() > B.size() ) ans = "GREATER";
	else if( A.size() < B.size() ) ans = "LESS";
	else if( A > B ) ans = "GREATER";
	else if( A < B ) ans = "LESS";
	else ans = "EQUAL";

	cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll h,w; cin>>h>>w;
    if(h==1|| w==1)
        cout<<1;
    else cout<<(h*w+1)/2;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt()*2;
		int[] l = new int[n];
		for (int i=0; i<n; i++) {
			l[i] = in.nextInt();
		}
		Arrays.sort(l);
		int ans = 0;
		for (int i=0; i<n; i+=2) {
			ans += l[i];
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 10068
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    ull X = input<ull>(), Y = input<ull>();
    ll res = 1;
    while (true)
    {
        X *= 2;
        if (X > Y)
        {
            break;
        }
        else
        {
            res += 1;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
use io::*;
use std::process::exit;

fn main() {

    let con = read_string();
    let mut sc = Scanner::new(&con);

    let s: Vec<char> = sc.next::<String>().chars().collect();
    let len = s.len();

    let mut flag1 = 0;
    if s[0] != 'A' {
        println!("WA");
        exit(0);
    }
    if s[1].is_uppercase() {
        println!("WA");
        exit(0);
    }


    for i in 2..len-1 {
        if s[i].is_uppercase() && s[i] != 'C' {
            println!("WA");
            exit(0);
        }
        if s[i] == 'C' {
            flag1 += 1;
        }
    }
    if s[len-1].is_uppercase() {
        println!("WA");
        exit(0);
    }
    if flag1 == 1 {
        println!("AC");
    }else{
        println!("WA");
    }
}

pub mod io {

    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
const int N = 5e5 + 8;
int n;
char str[N];
int f[N];
void getFail(char* P, int* f){
    int m = strlen(P);
    f[0] = f[1] = 0;
    REP(i, 1, m){
        int j = f[i];
        while(j && P[i] != P[j]) j = f[j];
        f[i + 1] = P[i] == P[j] ? j + 1 : 0;
    }
}
int pre[N], suf[N];
bool equ(){
    if(n == 1) return true;
    REP(i, 1, n) if(str[i] != str[i - 1]) return false;
    return true;
}
int main(){
#ifdef ac
	freopen("in.txt","r",stdin);
#endif
	//freopen("out.txt","w",stdout);
    scanf("%s", str);
    n = strlen(str);
    if(equ()){
        printf("%d\n%d\n", n, 1);
        return 0;
    }
    getFail(str, f);
    REP(i, 2, n + 1){
        if(f[i] && i % (i - f[i]) == 0){
            pre[i] = 1;
        }
    }
    for(int i = 0, j = n - 1; i < j; i ++, j --)
        swap(str[i], str[j]);
    getFail(str, f);
    REP(i, 2, n + 1){
        if(f[i] && i % (i - f[i]) == 0){
            suf[n + 1 - i] = 1;
        }
    }
    if(pre[n] == 1){
        puts("2");
        int res = 0;
        REP(i, 1, n){
            if(pre[i] == 0 && suf[i + 1] == 0) res ++;
        }
        printf("%d\n", res);
        return 0;
    }
    else{
        puts("1\n1");
    }
    return 0;
}


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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,y;
    cin >> n >> y;
    
    bool flag = false;
    int a,b,c;
    a = 0;
    b = 0;
    c = 0;
    
    for(int i = 0; i <= n; i++){
        int sum = 0;
        for(int j = 0; j <= n; j++){
            sum = i * 10000 + j * 5000;
            if(y >= sum and (y - sum)/1000 + i + j == n){
                flag = true;
                a = i;
                b = j;
                c = n - i - j;
                break;
            }
            if(j + i >n) continue;
        }
    }
    
    if(flag) cout << a << " " << b << " " << c << endl;
    else cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
def hand_to_win(hand):
    if hand == 'r':
        return 'p'
    elif hand == 'p':
        return 's'
    elif hand == 's':
        return 'r'


def main():
    """
    r,s,pからスコアの大きい順に手を決めていく。
    kだけ前の値がかぶったらk後の手を邪魔しない手を選ぶ。
    """
    n, k = map(int, input().split(' '))
    r, s, p = map(int, input().split(' '))
    t = (input())

    score_map = {'r': r, 's': s, 'p': p}
    history = []

    score = 0

    for i, hand in enumerate(t):
        tobe_win = hand_to_win(hand)
        if 0 <= i - k and history[i - k] == tobe_win:
            h = set(['r', 'p', 's']) - set([tobe_win])
            if i + k <= n - 1:
                h -= set([hand_to_win(t[i + k])])
            history.append(h.pop())
            continue
        history.append(tobe_win)
        score += score_map[tobe_win]
    print(score)


main()


Measured memory_bytes: 4212
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>

#define Mod 1000000007
#define Maxn 100010
#define R register
#define ll long long

using namespace std;

int n;
int a[Maxn];

int main() {
	
	scanf("%d",&n);
	for(R int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	
	R int sum = 0;
	for(R int i=2; i<=n; i++) {
		if(a[i] == a[i-1]) {
			a[i] = Mod;
			sum ++;
		}
	}
	
	cout << sum << endl;
	
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる






int main() {
  int n,m;
  cin>>n>>m;

  vector<pair<ll,ll>> p(n);
  rep(i,n){
    cin>>p[i].fi>>p[i].se;
  }

  sort(all(p));

  int now=1;
  int x=0;
  ll ans=0;
  priority_queue<ll> que;
  while(now<=m){
    while(x<n && p[x].fi<=now) {
      que.push(p[x].se);
      x++;
    }
    if(!que.empty()) {
      ans+=que.top();
      que.pop();
    }
    now++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2936
#include <stdio.h>
#include <iostream>
#define R 11
#define C 10010

using namespace std;
int mp[R][C];
int r,c, Max;

void filp(int i)
{
    for (int j = 0; j < c; j++)
        mp[i][j] = !mp[i][j];
}

void dfs(int x)
{
    if (x == r-1)
    {
        int step;
        for (int j = 0; j < c; j++)
        {
            step = 0;
            for (int i = 0; i < r; i++)
            {
                if (mp[i][j])
                    step++;
            }
            if (step < r-step)
                for (int i = 0; i < r; i++)
                    mp[i][j] = !mp[i][j];
        }


        step = 0;
        for (int i = 0; i < r; i++)
            for (int j = 0; j < c; j++)
            {
                if (mp[i][j])
                    step++;
            }
        Max = max(step, Max);
        return;
    }
    dfs(x+1);
    filp(x);
    dfs(x+1);
}

int main()
{
    while(~scanf("%d%d", &r, &c) && (r != 0 || c != 0))
    {
        for (int i = 0; i < r; i++)
            for (int j = 0; j < c; j++)
                scanf("%d", &mp[i][j]);

        Max = 0;
        dfs(0);

        cout<<Max<<endl;
    }

}

Measured memory_bytes: 3504
n, a, b = list(map(lambda x: int(x), input().split(" ")))
x = list(map(lambda x: int(x), input().split(" ")))

cost = 0
px = x[0]
for i in range(1, len(x)):
    w_cost = (x[i] - px) * a
    if w_cost > b:
        cost += b
    else:
        cost += w_cost
    px = x[i]

print(cost)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
// transform(a.begin(), a.end(), a.begin(), ::toupper);
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  int N,L;
  cin >> N >> L;
  
  vector<string> vec(N);
  
  for(int i=0;i<N;i++){
  	cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  for(int i=0;i<N;i++){
	cout << vec.at(i);  
  }
  cout << endl;
  
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn solve(x: i64) -> i64 {
    let count_rep = x / 11;
    let mut rem = x - count_rep * 11;
    let count_six = (x - count_rep  * 11) / 6;
    rem -= count_six * 6;
    if rem == 0 {
        count_rep * 2 + count_six
    } else {
        count_rep * 2 + count_six + 1
    }
}

fn main() {
    input!{
        x: i64
    }
    println!{"{}", solve(x)};
}


Measured memory_bytes: 4352
H,W=map(int,input().split())
G=[input()+"." for _ in range(H)]+["."*(W+1)]
G_cnt=sum([g.count("#") for g in G])
p=[0,0]
i=1
while(p!=[H-1,W-1]):
    if G[p[0]+1][p[1]]==G[p[0]][p[1]+1]:
        print("Impossible")
        break
    elif G[p[0]+1][p[1]]=="#":
        p=[p[0]+1,p[1]]
        i+=1
    else:
        p=[p[0],p[1]+1]
        i+=1
else:
    if i==G_cnt:
        print("Possible")
    else:
        print("Impossible")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#define rep(i, n) for (int i = 0; i < n; i++) 

using namespace std;

int main() {
    int x;
    cin >> x;

    for (int i = 0; i < 1000; i++) {
        for (int j = -1000; j < 1000; j++) {
            if (x == (pow(i, 5) - pow(j, 5))) {
                cout << i << " " << j;
                //cout << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4024
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int i, j, n, s = 0, t = 1;
	int* k;

	scanf("%d", &n);
	
	k = (int*)malloc(n * sizeof(int));

	for(i=0; i<n; i++){
		scanf("%d", &k[i]);
	}

	for(i=0; i<n; i++){
		for(j=0; j<i; j++){
			if(k[i] >= k[j]) s++;
			if(s == i) t++;
		}
		s = 0;
	}

	printf("%d", t);




	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (pp(ll) p1, pp(ll) p2){
        return p1.ff >= p2.ff;
    }
};



int main(){
    FIO;
    ll n,d; cin >> n >> d;
    ll ans = 0;
    forn(i,0,n){
        db x,y; cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3804
//
//  D - Two Sequences.cpp
//  AtCoder Regular Contest 092
//
//  Created by Huang,Zhiqiang on 2018/3/22.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;
const int maxn=200010;

ll a[maxn],b[maxn],c[maxn];
ll n;

ll Midfind(ll k)
{
    ll l=0,r=n+1;
    while(l<r-1)
    {
        ll mid=(l+r)/2;
        if(c[mid]>=k)
            r=mid;
        else
            l=mid;
    }
    return r;
}

int main()
{
    //    int n;
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=n; i++)
        cin >> b[i];
    ll sum=0;
    for(int k=1; k<=29; k++)
    {
        ll res=(1<<k)-1;
        for(int i=1; i<=n; i++)
            c[i]=b[i]&res;
        sort(c+1,c+n+1);
        ll cnt=0;
        for(int i=1; i<=n; i++)
            cnt+=n-Midfind((1<<(k-1))-(a[i]&res))+1;
        for(int i=1; i<=n; i++)
            cnt-=Midfind(((1<<k)+(1<<(k-1)))-(a[i]&res))-Midfind((1<<k)-(a[i]&res));
        if(cnt%2)
            sum+=(1<<(k-1));
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int N, M;
vector<vector<int>> G;

int main(){
	cin >> N >> M;
	G.resize(N);
	rep(i,N) G[i].resize(M);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a][b] = G[b][a] = 1;
	}

	vector<int> array(N);
	rep(i,N) array[i] = i;

	int cnt = 0;
	do{
		if(array[0]!=0) break;
		int ok = 1;
		for(int i = 0; i+1<N; i++){
			int from = array[i];
			int to = array[i+1];
			if(G[from][to]==0) ok = 0;
		}
		if(ok) cnt++;
	}while(next_permutation(array.begin(), array.end()));

	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<tuple>

using namespace std;

const int INF = 1001001001;

vector<int> v[2505];
vector<int> rv[2505];
vector<tuple<int, int, int>> edge;
bool reachable1[2505];
bool reachable2[2505];
bool ok[2505];

void dfs(int n)
{
	if (reachable1[n]) {
		return;
	}
	reachable1[n] = true;
	for (int p : v[n]) {
		dfs(p);
	}
}

void rdfs(int n)
{
	if (reachable2[n]) {
		return;
	}
	reachable2[n] = true;
	for (int p : rv[n]) {
		rdfs(p);
	}
}

int main(int argc, char *argv[])
{
	int N, M, P;

	cin >> N >> M  >> P;

	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;
		A--;
		B--;
		C -= P;
		C = -C;
		v[A].push_back(B);
		rv[B].push_back(A);
		edge.emplace_back(A, B, C);
	}

	dfs(0);
	rdfs(N - 1);

	int w[2505];
	for (int i = 0; i < N; i++) {
		w[i] = INF;
	}
	for (int i = 0; i < N; i++) {
		ok[i] = reachable1[i] & reachable2[i];
	}
	bool update = true;
	int step = 0;
	w[0] = 0;
	while (update) {
		update = false;
		for (int i = 0; i < M; i++) {
			int a, b, c;
			tie(a, b, c) = edge[i];
			if (!ok[a]) {
				continue;
			}
			if (!ok[b]) {
				continue;
			}
			int nw = w[a] + c;
			if (nw < w[b]) {
				update = true;
				w[b] = nw;
			}
		}
		step++;
		if (step > N) {
			cout << -1 << endl;
			return 0;
		}
	}

	int ans = -w[N - 1];
	ans = max(ans, 0);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
import java.io.*;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T... ar) {
        for (T i : ar) {
            out.print(i + " ");
        }
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException {

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc) {
        int a = sc.ni(), b = sc.ni();
        out.println((a + b) % 2 == 0? a + b >> 1: "IMPOSSIBLE");
    }

    static class MyScanner {

        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc() {
            return nn().charAt(0);
        }

        int ni() {
            return Integer.parseInt(nn());
        }

        long nl() {
            return Long.parseLong(nn());
        }

        double nd() {
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n) {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        int[] niArr1(int n) {
            int[] ar = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        long[] nlArr0(int n) {
            long[] ar = new long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nl();
            }
            return ar;
        }

        long[] nlArr1(int n) {
            long[] ar = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nl();
            }
            return ar;
        }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,p[200005],k,ans=0;
signed main(){
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>p[i];
    sort(p,p+n);
    for(int i=0;i<n-k;i++){
        ans+=p[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1920
import java.util.*;
import java.math.*;
class Main {
    //
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuffer mae = new StringBuffer("");
        StringBuffer usiro = new StringBuffer("");
        int n = sc.nextInt();
        boolean rev = false;
        for(int i = 0;i < n;i++){
            int t = sc.nextInt();
            if(t==1){
                if(rev){
                    rev = false;
                }else{
                    rev = true;
                }
            }else{
                int f = sc.nextInt();
                String c = sc.next();
                if(rev){
                    if(f==1){
                        usiro.append(c);
                    }else{
                        mae.insert(0, c);
                    }
                }else{
                    if(f==1){
                        mae.insert(0, c);
                    }else{
                        usiro.append(c);
                    }
                }
            }
        }
        if(rev){
            StringBuffer str = new StringBuffer(s);
            System.out.println(usiro.reverse().toString()+str.reverse().toString()+mae.reverse().toString());
        }else{
            System.out.println(mae.toString()+s+usiro.toString());
        }
    }
}



Measured memory_bytes: 118500
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
        ($($t:ty),*) => {
            $(
                impl InputValue for $t {
                    fn parse(s: &str) -> $t { s.parse().unwrap() }
                }
            )*
    	}
    }
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    	($($t:ident),*) => {
    		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
    			fn parse(s: &str) -> ($($t),*) {
    				let mut tokens = s.split_whitespace();
    				let t = ($($t::parse(tokens.next().unwrap())),*);
    				t
    			}
    		}
    	}
    }
parse_tuple!(A, B, C, D, E);

// ===

const MOD: i64 = 1000000007;

fn powmod(a: i64, p: i64, m: i64) -> i64 {
    let mut ret = 1i64;
    let mut aa = a;
    let mut pp = p;
    while pp >= 1 {
        if pp & 1 == 1 {
            ret *= aa;
            ret %= m;
        }
        aa = aa * aa % m;
        pp >>= 1;
    }
    ret
}


fn main() {
    let (n, a, b, c, d): (usize, usize, usize, usize, usize) = read();

    let mut comb: Vec<Vec<i64>> = vec![vec![0; n+1]; n+1];
    for i in 0..(n+1) {
        comb[i][0] = 1;
        comb[i][i] = 1;
        for j in 1..i {
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            comb[i][j] %= MOD;
        }
    }

    let mut invfact: Vec<i64> = vec![0; n+1];
    invfact[0] = 1;

    let mut fact: i64 = 1;
    for i in 1..(n+1) {
        fact = fact * i as i64 % MOD;
        invfact[i] = powmod(fact, MOD-2, MOD);
    }


    let mut dp: Vec<Vec<i64>> = vec![vec![0; n+1]; n+1];
    dp[0][0] = 1;

    let diff = b - a;
    for g in 0..(diff+1) {
        let per = a + g;
        for i in 0..(n+1) {
            let base = dp[g][i];
            if base == 0 {
                continue;
            }
            dp[g+1][i] += base;
            dp[g+1][i] %= MOD;

            let mut left = n - i;
            let mut way: i64 = 1;
            for cnt in 1..(d+1) {
                let to = i + per * cnt;
                if to > n {
                    break;
                }

                way *= comb[left][per];
                way %= MOD;
                left -= per;

                if c <= cnt {
                    dp[g+1][to] += base * way % MOD * invfact[cnt] % MOD;
                    dp[g+1][to] %= MOD;
                }
            }
        }
    }
    println!("{:?}", dp[diff+1][n]);
}

Measured memory_bytes: 20732
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int out = 0;
        boolean isExist = false;
        int max = 1;
        for(int i = 0; i < n; i++){
            int a = scan.nextInt();
            if(!isExist && a == 1) isExist = true;
            else if(!isExist) out++;
            else if(a != max + 1) out++;
            else max = a;
        }
        if(!isExist) System.out.println(-1);
        else System.out.println(out);
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


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

int main(){
    double n;
    cin >> n;
    int i;
    double j = 0;
    int64_t disx = 1000000000000, disy = 1000000000000;
    for(i = 1; i <= sqrt(n); i++){
        j = n/i;
        if(fmod(j, 1) != 0){
            continue;
        }
        if(i+j-2 < disx+disy){
            disx = i-1;
            disy = j-1;
        }
    }
    cout << disx + disy << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b=0;
	scanf("%d",&a);
	for(int i=0;i<3;i++)
	{
		if(a%10==7)b=1;
		else 
		{
			a=a/10;
		}
		if(b==1)break;
	}
	if(b==1)printf("Yes");
	else if(b==0)printf("No");
	return 0;
}

Measured memory_bytes: 1728
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val vectorX = List.fill(n)(sc.nextInt())
  val vectorY = List.fill(n)(sc.nextInt())
  calcAndPrint(vectorX, vectorY, 1.0)
  calcAndPrint(vectorX, vectorY, 2.0)
  calcAndPrint(vectorX, vectorY, 3.0)
  calcInfAndPrint(vectorX, vectorY)

  def calcAndPrint(v1: List[Int], v2: List[Int], p: Double): Unit = {
    println(f"${v1.zip(v2).map(e => (e._1 - e._2).abs.toString.toBigDecimal.power(p)).sum.root(p)}%.6f")
  }

  def calcInfAndPrint(v1: List[Int], v2: List[Int]): Unit = {
    println(f"${v1.zip(v2).map(e => (e._1 - e._2).abs).max}%.6f")
  }

  implicit class StringExtends(val s: String) extends AnyVal {
    def toBigDecimal = BigDecimal(s)
  }

  implicit class DoubleExtends(val d: Double) extends AnyVal {
    def toBigDecimal = BigDecimal(d)
  }

  implicit class BigDecimalExtends(val b: BigDecimal) extends AnyVal {

    import scala.math.pow

    def power(d: Double) = pow(b.toDouble, d).toBigDecimal

    def root(d: Double) = pow(b.toDouble, 1.0 / d).toBigDecimal
  }

}

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

int main() {
  ll n,d,dd;
  cin>>n>>d;
  dd=d*d;
  
  ll res=0;
  for(int i=0; i<n; i++){
    ll xi,yi;
    cin>>xi>>yi;
    res += (xi*xi+yi*yi<=dd);
  }
  cout<<res<<endl;
}

Measured memory_bytes: 3608
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String b = sc.next();
       
        HashSet<Character> set = new HashSet<>();
        set.add('A');
        set.add('T');
        set.add('C');
        set.add('G');
        int max = 0;
        int tmp = 0;
        for (char c : b.toCharArray()) {
            if (set.contains(c)) {
                tmp++;
            } else {
                max = Math.max(max, tmp);
                tmp = 0;
            }
        }
        max = Math.max(max, tmp);
        System.out.println(max);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  queue<pair<string, uint64_t>> q;
  q.emplace("a", 1);
  while (!q.empty()) {
    pair<string, uint64_t> p = q.front(); q.pop();
    string s = p.first;
    uint64_t k = p.second;

    if (s.size() == N) {
      cout << s << endl;
      continue;
    }

    N_TIMES(i, k) {
      char c = 'a' + i;
      q.emplace(s + c, k);
    }
    {
      char c = 'a' + k;
      q.emplace(s + c, k + 1);
    }
  }

  return 0;
}

Measured memory_bytes: 8832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ');
			var a = firstLine[0];
			var b = firstLine[1];
			if (a == "H")
			{
				Console.WriteLine(b);
			}
			else
			{
				Console.WriteLine(b == "H" ? "D" : "H");
			}
        }
	}
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll k,s;cin>>k>>s;
  for(i=0;i<=k;i++){
    for(j=0;j<=k;j++){
      if(s-i-j>=0&&s-i-j<=k)res++;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,K,S=map(int,input().split())

A=[]

for i in range(K):
    A.append(S)

if S!=10**9:
    for i in range(N-K):
        A.append(S+1)
else:
    for i in range(N-K):
        A.append(S-1)

print(*A)

Measured memory_bytes: 49264
n = int(input())
L = list(map(int, input().split()))

L.sort()

cnt = 0
for i in range(n):
    for j in range(i, n):
        if L[i] == L[j]:
            continue
        for k in range(j, n):
            if L[j] == L[k]:
                continue
            if L[i]+L[j] > L[k]:
                cnt += 1

print(cnt)


Measured memory_bytes: 9080
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vd=vector<double>;



class maxmin_t
{
	int m_n;
	int m_max, m_min;
public:
	maxmin_t():m_n(0),m_max(-1),m_min(-1){}
	int get_n(){return m_n;}
	int get_max(){return m_max;}
	int get_min(){return m_min;}

	void set(int x)
	{
		if(!m_n)
		{
			m_max=m_min=x;
		}
		if(m_max<x) m_max=x;
		if(m_min>x) m_min=x;
		m_n++;
	}
};

using mm_t=maxmin_t;


void max_u(double&m, double v, int&is_first)
{
	if(m<v || is_first)
	{
		m=v;
		is_first=0;
	}
}


void min_u(double&m, double v, int&is_first)
{
	if(m>v || is_first)
	{
		m=v;
		is_first=0;
	}
}


double calc(maxmin_t&r, maxmin_t&l, maxmin_t&rlf, double t)
{
	double cr=0.0, cl=0.0;
	int crff=1, clff=1;

	if(r.get_n())
	{
		max_u(cr, r.get_max()+t, crff);
		min_u(cl, r.get_min()+t, clff);
	}
	if(l.get_n())
	{
		max_u(cr, l.get_max()-t, crff);
		min_u(cl, l.get_min()-t, clff);
	}
	if(rlf.get_n())
	{
		max_u(cr, rlf.get_max(), crff);
		min_u(cl, rlf.get_min(), clff);
	}
	return cl-cr;
}


double calc_s(mm_t&r, mm_t&l, mm_t&u, mm_t&d, mm_t&rlf, mm_t&udf, double t)
{
	double w=calc(r, l, rlf, t);
	double h=calc(u, d, udf, t);
	return w*h;
}


int cand(vd&c, mm_t&r, mm_t&l, mm_t&rlf)
{
	int cc=c.size();

	c.push_back(0.0);
	if(r.get_n() && rlf.get_n())
	{
		if(r.get_min()<rlf.get_min())
		{
			c.push_back(rlf.get_min()-r.get_min());
		}
		if(r.get_max()<rlf.get_max())
		{
			c.push_back(rlf.get_max()-r.get_max());
		}
	}
	if(l.get_n() && rlf.get_n())
	{
		if(l.get_min()>rlf.get_min())
		{
			c.push_back(-rlf.get_min()+l.get_min());
		}
		if(l.get_max()>rlf.get_max())
		{
			c.push_back(-rlf.get_max()+l.get_max());
		}
	}
	if(l.get_n() && r.get_n())
	{
		if(l.get_min()>r.get_min())
		{
			c.push_back((l.get_min()-r.get_min())*0.5);
		}
		if(l.get_max()>r.get_max())
		{
			c.push_back((l.get_max()-r.get_max())*0.5);
		}
	}
	return c.size()-cc;
}


int main(void)
{
	int n;


	while(scanf("%d", &n)==1)
	{
		vi x(n), y(n), f(n);
		maxmin_t r, l, u, d, rlf, udf;

		for(int i=0;i<n;i++)
		{
			char s[1+2];
			scanf("%d%d%1s", &x[i], &y[i], s);
			f[i]=s[0];
			switch(s[0])
			{
				case 'R' : r.set(x[i]); udf.set(y[i]); break;
				case 'L' : l.set(x[i]); udf.set(y[i]); break;
				case 'U' : u.set(y[i]); rlf.set(x[i]); break;
				case 'D' : d.set(y[i]); rlf.set(x[i]); break;
			}
		}

		{
		vd c;
		cand(c, r, l, rlf);
		cand(c, u, d, udf);
		int f=1;
		double ans=-1.0;
		for(auto mc:c)
		{
			min_u(ans, calc_s(r, l, u, d, rlf, udf, mc), f);
		}
		printf("%f\n", ans);
		}
	}
	return 0;
}


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

int atgc(string s){
    int x=s.size();
    int y=0;
    int t=0;
    rep(i,x){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            t++;
        }
        if(t==x) y=1;
        return y;
    }
    
}
int main() {
    string s;
    cin>>s;
    int x=s.size();
    int ans=0;
    int t=0;
    
        rep(i,x){
            for(int j=i;j<x;j++){
                if(s[j]=='A'||s[j]=='T'||s[j]=='G'||s[j]=='C'){
            t++;
        }else{break;}
            }
        ans=max(ans,t);    
        t=0;
        }
        
    
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m;
	int i, j;
	int a[1024];
	int vote[1024] = {0};
	int maxi;
	
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) scanf("%d", a + i);
	for (i = 0; i < m; i++){
		int b;
		
		scanf("%d", &b);
		for (j = 0; j < n; j++){
			if (b >= a[j]){
				vote[j]++;
				break;
			}
		}
	}
	
	for (i = maxi = 0; i < n; i++){
		maxi = vote[maxi] > vote[i] ? maxi : i;
	}
	printf("%d\n", maxi + 1);
	
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];

	ll ans = 0;

	bool flag = 0;

	for (int i = 0; i < n; i++){
		if (i+1 == a[i] and flag){
			flag = 0;
		}
		else if (i+1 == a[i]){
			flag = 1;
			ans++;
		}
		else flag = 0;
	}



	cout << ans << endl;

}


Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#define pb push_back
using namespace std;

const int MAXN = (int)1e5 + 5;
const int MOD = (int)1e9 + 7;
const int WHITE = 0;
const int BLACK = 1;

vector<int> g[MAXN];
int dp[MAXN][2];

void DFS(int node, int p = -1) {
    for (int i = 0; i < (int)g[node].size(); i++) {
        int viz = g[node][i];
        if (viz != p) {
            DFS(viz, node);
        }
    }

    dp[node][WHITE] = dp[node][BLACK] = 1;
    for (int i = 0; i < (int)g[node].size(); i++) {
        int viz = g[node][i];
        if (viz != p) {
            long long white = 1LL * dp[node][WHITE] * (dp[viz][WHITE] + dp[viz][BLACK]);
            dp[node][WHITE] = int(white % MOD);
            long long black = 1LL * dp[node][BLACK] * dp[viz][WHITE];
            dp[node][BLACK] = int(black % MOD);
        }
    }
    return;
}

int main(void) {
    int n;
    int x, y;

    scanf(" %d", &n);
    for (int i = 1; i < n; i++) {
        scanf(" %d %d", &x, &y);
        g[x].pb(y);
        g[y].pb(x);
    }
    DFS(1);
    printf("%d\n", (dp[1][WHITE] + dp[1][BLACK]) % MOD);

    return 0;
}



Measured memory_bytes: 13440
#include<stdio.h>

int main(){
  int n,can,ans;
  scanf("%d",&n);
  if(n<105){
    printf("0");
    return 0;
  }else{
    for(int i=105;i<=n;++i){//調べられる数
      if(i%2!=0){//奇数
        for(int j=1;j<=i;++j){//調べる
          if(i%j==0){
            can+=1;
            continue;
          }
        }
      }
      if(can==8){
        ans+=1;
        can=0;
      }else{
        can=0;
      }
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 51;
const int N = 50;
ll ans[MAXN];
int main()
{
    ll k; scanf("%lld", &k);
    int cnt = 0; while (k % N) k--, cnt++;
    for (int i = 1; i <= N; i++) ans[i] = k / N + N - 1;
    for (int i = 1; i <= cnt; i++)
    {
        ans[i] += N;
        for (int j = 1; j <= N; j++) if (j != i) ans[j]--;
    }
    printf("%d\n", N);
    for (int i = 1; i <= N; i++) printf("%lld%c", ans[i], " \n"[i == N]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{int x,a=0,w=0,t=0,r=0;
cin>>x;
string arr[x];
for(int i=0;i<x;i++){
    cin>>arr[i];
    if(arr[i]=="AC"){a++;}
    else if(arr[i]=="WA"){w++;}
    else if(arr[i]=="TLE"){t++;}
    else if(arr[i]=="RE"){r++;}
}
cout<<"AC"<<" "<<"x"<<" "<<a<<endl;

cout<<"WA"<<" "<<"x"<<" "<<w<<endl;

cout<<"TLE"<<" "<<"x"<<" "<<t<<endl;

cout<<"RE"<<" "<<"x"<<" "<<r<<endl;


    return 0;
}


Measured memory_bytes: 6676
import math
from collections import Counter


def prime_factrize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2

    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)

    return a


N = int(input())
ans = 1
mod = 10 ** 9 + 7

fact = math.factorial(N)
soinsuu = prime_factrize(fact)
c = Counter(soinsuu)

for i in c:
    ans *= (c[i] + 1)
print(ans % mod)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

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

int main()
{
	int S,W;
	cin >> S >> W;

	if(S<=W){
		cout << "unsafe" << endl;
	}
	else{
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3120