akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int univprime[100000] = {};
int univcnt = 0;
void primemake(){
  int i;
  int j=0;
  int primef = 1;
  for(i=2;i<100000;i++){
    primef = 1;
    for(j=0;j<univcnt;j++){
      if(i % univprime[j] == 0){
        primef = 0;
        break;
      }
    }
    if(primef){
      univprime[univcnt] = i;
      univcnt++;
    }
  }
}

int main(){
  int hoge[50000] = {};
  int q = 0;
  int l[100000] = {};
  int r[100000] = {};
  int i = 0;
  int j = 0;
  int s = 0;
  int scheck = 0;
  int t = 0;
  int tcheck = 0;
  int likeflag = 0;
  int lp = 0;
  int rp = 0;
  int result = 0;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d",&l[i],&r[i]);
  }
  
  primemake();
  
  for(i=0;i<50000;i++){
    s = 2*i + 1;
    t = (s + 1) / 2;
    scheck = 0;
    tcheck = 0;
    for(j=0;j<univcnt;j++){
      if(s == univprime[j]){
        scheck = 1;
      }
      if(t == univprime[j]){
        tcheck = 1;
      }
    }
    
    if(scheck*tcheck){
      //printf("%d/",i);
      for(j=i;j<50000;j++){
        hoge[j]++;
      }
    }
    
  }
  
  for(j=0;j<50000;j++){
    //printf("%d,",hoge[j]);
  }
  
  for(i=0;i<q;i++){
    lp = (l[i]-1)/2;
    rp = (r[i]-1)/2;

    result = hoge[rp] - hoge[lp];
    if(lp != 0 && hoge[lp-1] < hoge[lp]){
      result++;
    }
    printf("%d\n",result);
  }
  
  return 0;
}

    
  
  

Measured memory_bytes: 1536
N,M=map(int,input().split())
S=input()
T=input()
from fractions import gcd
g=gcd(N,M)
L=N*M//g
for i in range(g):
    if S[i*N//g]!=T[i*M//g]:
        print(-1)
        break
else:
    print(L)

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    vector<P> A(N);
    rep(i, N) { 
        ll tmp;
        cin >> tmp;
        A[i] = P(tmp, i+1);
    }
    sort(all(A));
    rep(i, N) {
        cout << A[i].second << " ";    
    }
    cout << endl;
    return 0;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, int> pi;


int main()
{
    int n, m;
    cin >> n >> m;
    lli a[n];
    for(auto &x: a) cin >> x;
    sort(a, a+n);
    lli b[n] = {0};
    map<lli, int> mp;
    while(m--){
        lli bi, ci;
        cin >> bi >> ci;
        mp[ci]+= bi;
    }
    vector<pi> v;
    for(pi x: mp){
        v.push_back(x);
    }
    sort(v.begin(), v.end(), greater<pi>());
    int ind = 0;
    for(pi x: v){
        ind += x.second;
        if(ind > n){
            b[n-1] = max(b[n-1], x.first);
            break;
        }
        b[ind-1] = x.first;
    }

    lli ans = 0, mx = 0;
    for(int i=n-1; i>=0; i--){
        mx = max(mx, b[i]);
        ans += max(a[i], mx);
    }
    cout << ans << "\n";

    return 0;
}


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

signed main(){
	int q;
	multimap<string,int>m;
	cin>>q;
	while(q--){
		int t,y;
		string x;
		cin>>t;
		if(t==0){
			cin>>x>>y;
			m.insert(make_pair(x,y));
		}
		if(t==1){
			string l;
			cin>>l;
			map<string,int>::iterator end,it;
			it=m.lower_bound(l);
			end=m.upper_bound(l);
			for(;it!=end;it++){
				cout<<(*it).second<<endl;
			}
		}
		if(t==2){
			cin>>x;
			m.erase(x);
		}
		if(t==3){
			string l,r;
			cin>>l>>r;
			map<string,int>::iterator end,it;
			it=m.lower_bound(l);
			end=m.upper_bound(r);
			for(;it!=end;it++){
				cout<<(*it).first<<' '<<(*it).second<<endl;
			}
		}
	}
}



Measured memory_bytes: 24916
#include <stdio.h>
#include <stdlib.h>

int main(void){
int i, n, p[30], ans=0;
scanf("%d", &n);
for(i=1; i<=n; i++) scanf("%d", &p[i]);

 for(i=2; i<=n-1; i++){
   if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
   if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
 }
printf("%d\n", ans);
return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main (void){

    int a,b,c;

    scanf("%d %d %d",&a, &b, &c);

    if (a < b)
    {
    if (b < c)
    printf("Yes\n");
    else
     printf("No\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2580
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int r = 0, s = 1, p = 2;

	int N, K;
	int R, S, P;
	vector<vector<int>> dp;
	
	int sum = 0;
	string T;
	
	cin>>N>>K;
	
	cin>>R>>S>>P;
	
	cin>>T;
	
	dp.resize(3, vector<int>(N+K+10));
	
	for(int i = 0; i < N; i++){
		if(T[i] == 'p') {
			dp[r][i + K] = max(dp[r][i + K], max(dp[p][i], dp[s][i] + S));
			dp[s][i + K] = max(dp[s][i + K], max(dp[p][i], dp[r][i]));
			dp[p][i + K] = max(dp[p][i + K], max(dp[r][i], dp[s][i] + S));
		} else
		if(T[i] == 's') {
			dp[r][i + K] = max(dp[r][i + K], max(dp[p][i], dp[s][i]));
			dp[s][i + K] = max(dp[s][i + K], max(dp[p][i], dp[r][i] + R));
			dp[p][i + K] = max(dp[p][i + K], max(dp[r][i] + R, dp[s][i]));
		} else
		if(T[i] == 'r') {
			dp[r][i + K] = max(dp[r][i + K], max(dp[p][i] + P, dp[s][i]));
			dp[s][i + K] = max(dp[s][i + K], max(dp[p][i] + P, dp[r][i]));
			dp[p][i + K] = max(dp[p][i + K], max(dp[r][i], dp[s][i]));
		}
		// cout<<endl<<"i = "<<i<<endl;
		// cout<<dp[r][i]<<endl;
		// cout<<dp[s][i]<<endl;
		// cout<<dp[p][i]<<endl;
	}
	
	for(int i = 1; i <= K; i++){
		sum += max(dp[r][N+i-1],max(dp[s][N+i-1],dp[p][N+i-1]));
		// cout<<endl<<"i = "<<i<<endl;
		// cout<<dp[r][i]<<endl;
		// cout<<dp[s][i]<<endl;
		// cout<<dp[p][i]<<endl;
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 6352
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::collections::vec_deque::VecDeque;
use std::i64::MAX;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.parse::<usize>();
    let l = sc.parse::<i64>();
    let t = sc.parse::<i64>();

    let mut x: Vec<i64> = vec![0; n];
    let mut w: Vec<usize> = vec![0; n];

    for i in 0..n {
        x[i] = sc.parse::<i64>();
        w[i] = sc.parse::<usize>();
    }

    let cross_count = (0..n)
        .map(|i| {
            let w0 = w[0];
            let wi = w[i];
            if w0 == wi {
                return 0;
            }

            let interval;
            if w0 == 1 {
                interval = x[i] - x[0];
            } else {
                interval = x[0] + l - x[i];
            }

            if interval > t * 2 {
                return 0;
            }

            let time = t * 2 - interval;
            let count;
            if time % l == 0 && w[0] == 1 {
                count = time / l;
            } else {
                count = time / l + 1;
            }
            return count;
        })
        .collect::<Vec<i64>>();

    let count_sum: i64 = cross_count.iter().sum::<i64>() % (n as i64);
    let position;
    let num;
    if w[0] == 1 {
        position = (x[0] + t) % l;
        num = count_sum;

    } else {
        position = (x[0] - (t % l) + l) % l;
        num = (n as i64) - count_sum;
    }

    let mut positions: Vec<i64> = (0..n)
        .map(|i| {
            let p;
            if w[i] == 1 {
                p = (x[i] + t) % l;
            } else {
                p = (x[i] - (t % l) + l) % l;
            }
            return p;
        })
        .collect::<Vec<i64>>();
    positions.sort();

    let mut a = 0;
    for i in 0..n {
        if positions[i] == position {
            a = i;
            break;
        }
    }

    let mut ans: Vec<i64> = vec![0;n];
    for i in 0..n {
        let idx = (i + num as usize) % n;
        let p = (a + i as usize) % n;
        ans[idx] = positions[p];
    }

    for a in &ans {
        println!("{}", a);
    }

}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

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

int main(){
    int N,D,X; cin>>N>>D>>X;
    for(int i=0;i<N;i++){
        int a; cin>>a;
        for(int j=0;j<D;j++){
            if(j*a+1<=D) X++;
        }
    }
    cout<<X<<endl;
}

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

static const int N = 1000;

int LCS(string x, string y) {
    int c[N + 1][N + 1];
    int n = x.length();
    int m = y.length();
    int maxl = 0;
    x = ' ' + x;
    y = ' ' + y;

    REP(i, n) c[i][0] = 0;
    REP(i, m) c[0][i] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(x[i] == y[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i][j - 1], c[i - 1][j]);
            }
            maxl = max(c[i][j], maxl);
        }
    }

    return maxl;
}

int soraLCS(string x, string y) {
    int n = x.length();
    int m = y.length();
    x = ' ' + x;
    y = ' ' + y;
    int c[N + 1][N + 1];
    REP(i, n) c[i][0] = 0;
    REP(i, m) c[0][i] = 0;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(x[i]==y[j]){
                c[i][j] = c[i-1][j-1] +1;
            }else{
                c[i][j] = max(c[i-1][j],c[i][j-1]);
            }
        }
    }
    return c[n][m];
}

int main() {
    int q;
    string X, Y;

    cin >> q;
    REP(i, q) {
        cin >> X >> Y;
        cout << soraLCS(X, Y) << endl;
    }
    return 0;
}


Measured memory_bytes: 7144
#include <cstdio>

int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	bool flag = 0;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= m; ++j)
			if (i * m + j * n - i * j * 2 == k) {
				flag = 1;
				break;
			}
	puts(flag ? "Yes" : "No");
	return 0;
}


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

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	ll ans = 0;
	rep(i,n-2){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type sortString []rune

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

type sortStringR []rune

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

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	ss := sortString(s)
	sort.Sort(ss)
	rt := sortStringR(t)
	sort.Sort(rt)
	if string(ss) < string(rt) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
class Cell 
  attr_reader :x, :y, :cost, :goal, :eval
  
  def initialize(x, y, c)
    @x = x
    @y = y
    @cost = c
    @goal = $w - 1 - x + $h - 1 - y
    @eval = @cost + @goal
  end
  
  def to_s
    "cell: x=#{@x},y=#{@y},c=#{@cost},g=#{@goal},e=#{@eval}"
  end
end

class PriorityQueue
  attr_reader :elements
  
  def initialize
    @elements = []
  end

  def push(n)
    i = @elements.size
    while i > 0
      p = (i-1) / 2
      break if @elements[p].eval <= n.eval
      @elements[i] = @elements[p]
      i = p
    end
    @elements[i] = n
  end
  alias :<< :push
  
  def pop
    min = @elements[0]
    n   = @elements.pop
    unless @elements.empty?
      i = 0
      while i * 2 + 1 < @elements.size
        if @elements[i * 2 + 2].nil? or @elements[i * 2 + 1].eval < @elements[i * 2 + 2].eval
          buf = i * 2 + 1
        else
          buf = i * 2 + 2
        end
        break if @elements[buf].eval >= n.eval
        @elements[i] = @elements[buf]
        i = buf
      end
      @elements[i] = n
    end
    min
  end
  
  def empty?
    @elements.empty?
  end
  
  def to_s
    @elements.each do |elem|
      puts elem
    end
  end
end

$h, $w = gets.chomp.split.map(&:to_i)
matrix = Array.new($h) { gets.chomp.split("").map{ |x| x == "." ? 0 : 1 } }

opened = Array.new($h) { Array.new($w, false) }

x, y, cost = 0, 0, 0
opened[y][x] = true
queue = PriorityQueue.new
queue << Cell.new(x, y, 1)
until [x, y] == [$w-2, $h-1] or [x, y] == [$w-1, $h-2]
  cell = queue.pop
  x, y, c = cell.x, cell.y, cell.cost
  
  if x+1 <= $w-1 and matrix[y][x+1] == 0 and !opened[y][x+1]
    queue << Cell.new(x+1, y, c+1)
    opened[y][x+1] = true
  end
  
  if x-1 >= 0 and matrix[y][x-1] == 0 and !opened[y][x-1]
    queue << Cell.new(x-1, y, c+1)
    opened[y][x-1] = true
  end
  
  if y+1 <= $h-1 and matrix[y+1][x] == 0 and !opened[y+1][x]
    queue << Cell.new(x, y+1, c+1)
    opened[y+1][x] = true
  end
  
  if y-1 >= 0 and matrix[y-1][x] == 0 and !opened[y-1][x]
    queue << Cell.new(x, y-1, c+1)
    opened[y-1][x] = true
  end
  cost = c+1
  
  if queue.empty?
    puts -1
    exit
  end
end
puts matrix.flatten.select { |x| x == 0 }.size - cost


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

string S;
int dp[80001][11];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> S, S != "0") {
    int n = S.size();

    memset(dp, 0, sizeof(dp));

    int ans = 0;
    rep(i, n) {
      int d = S[i] - '0';
      if(d) dp[i+1][d%11] += 1;
      rep(j, 11) dp[i+1][(j*10 + (S[i]-'0'))%11] += dp[i][j];
      ans += dp[i+1][0];
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 10044
#include <stdio.h>

#define N 20

int main() {
	static int cc[N], vv[N];
	int n, i, x, y;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &vv[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &cc[i]);
	x = y = 0;
	for (i = 0; i < n; i++)
		if (cc[i] < vv[i]) {
			x += vv[i];
			y += cc[i];
		}
	printf("%d\n", x - y);
	return 0;
}


Measured memory_bytes: 128
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    ll n;
    cin >> n;
    ll c500 = n / 500;
    n %= 500;
    cout << c500 * 1000 + (n / 5) * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

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

		primeSet(50021);

		while(stdIn.hasNext()){
			int n = stdIn.nextInt();

			for(int i=n-1;;i--){
				if(primes[i]){
					System.out.print(i+" ");
					break;
				}
			}
			for(int i=n+1;;i++){
				if(primes[i]){
					System.out.println(i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns    #-}
{-# LANGUAGE ConstraintKinds #-}
import           Control.Monad
import           Control.Monad.Primitive      (PrimMonad, PrimState)
import           Data.Bits
import qualified Data.ByteString.Char8        as BS
import           Data.Char                    (isSpace)
import           Data.Int                     (Int64)
import           Data.List                    (unfoldr)
import           Data.Monoid
import qualified Data.Vector.Generic          as G
import qualified Data.Vector.Generic.Mutable  as GM
import qualified Data.Vector.Unboxing         as U
import qualified Data.Vector.Unboxing.Mutable as UM

main = do
  [n,q] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  xs0 <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  tree <- fromVector_BIT (U.coerceVector xs0 :: U.Vector (Sum Int))
  replicateM_ q $ do
    [t,u,v] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    if t == 0 then
      let (p,x) = (u,v) in
      add_BIT tree p (Sum x)
    else do
      let (l,r) = (u,v)
      Sum a <- queryM_BIT tree l
      Sum b <- queryM_BIT tree r
      print $ b - a

--
-- Binary Indexed Tree (BIT), or Fenwick Tree
--

type CommutativeMonoid a = Monoid a

newtype BIT mvec s a = BIT (mvec s a)

-- index: 1-based
-- property: forall vec i. fromVector_BIT vec >>= flip queryM_BIT i == pure (G.scanl (<>) mempty vec G.! i)
queryM_BIT :: (Monoid a, GM.MVector mvec a, PrimMonad m) => BIT mvec (PrimState m) a -> Int -> m a
queryM_BIT (BIT vec) !i = doQuery i mempty
  where
    doQuery 0 !acc = return acc
    doQuery i !acc = do y <- GM.read vec (i - 1)
                        let !j = (i - 1) .&. i
                        doQuery j (y <> acc)
{-# INLINE queryM_BIT #-}

-- index: zero-based
-- property: forall vec i x. do { tree <- fromVector_BIT vec; add_BIT tree i x; return tree } == fromVector_BIT (G.accum (<>) vec [(i,x)])
add_BIT :: (CommutativeMonoid a, GM.MVector mvec a, PrimMonad m) => BIT mvec (PrimState m) a -> Int -> a -> m ()
add_BIT (BIT vec) !i !y = loop (i + 1)
  where
    loop !k | k > GM.length vec = return ()
    loop !k = do x <- GM.read vec (k - 1)
                 GM.write vec (k - 1) $! x <> y
                 loop (k + (k .&. (-k)))
{-# INLINE add_BIT #-}

new_BIT :: (Monoid a, GM.MVector mvec a, PrimMonad m) => Int -> m (BIT mvec (PrimState m) a)
new_BIT n = BIT <$> GM.replicate n mempty

asUnboxedBIT :: (PrimMonad m) => m (BIT UM.MVector (PrimState m) a) -> m (BIT UM.MVector (PrimState m) a)
asUnboxedBIT = id

-- TODO: Efficient initialization
fromVector_BIT :: (CommutativeMonoid a, PrimMonad m, G.Vector vec a) => vec a -> m (BIT (G.Mutable vec) (PrimState m) a)
fromVector_BIT vec = do
  mvec <- GM.replicate (G.length vec) mempty
  G.imapM_ (add_BIT (BIT mvec)) vec
  return (BIT mvec)
{-# INLINE fromVector_BIT #-}


Measured memory_bytes: 22472
import java.util.Scanner;

public class Main {
	
	public static void main (String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int ans = 1000;
		
		for (int i = 0; i + 2 < s.length(); i++) {
			ans = Math.min(ans, Math.abs(753 - Integer.parseInt(s.substring(i, i + 3))));
		}
		
		System.out.println(ans);
		
	}
	
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 300005;

int a[N], f[N];

int val[N << 2];
void push_up(int u) {
    val[u] = max(val[u << 1], val[u << 1 | 1]);
}
void update(int u, int l, int r, int x, int v) {
    if (l == r) {
        val[u] = max(val[u], v);
        return;
    }
    int mid = l + r >> 1;
    if (x <= mid)
        update(u << 1, l, mid, x, v);
    else
        update(u << 1 | 1, mid + 1, r, x, v);
    push_up(u);
}
int query(int u, int l, int r, int x, int y) {
    if (x <= l && r <= y) return val[u];
    int mid = l + r >> 1;
    int res = 0;
    if (x <= mid) res = max(res, query(u << 1, l, mid, x, y));
    if (y > mid) res = max(res, query(u << 1 | 1, mid + 1, r, x, y));
    return res;
}
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    const int wc = 300000;
    for (int i = 1; i <= n; i++) {
        int x = max(1, a[i] - m), y = min(wc, a[i] + m);
        update(1, 1, wc, a[i], query(1, 1, wc, x, y) + 1);
    }

    cout << val[1] << endl;
    return 0;
}


Measured memory_bytes: 9016
class Selector
  class << self
      
    def run(routes_and_time, choices)
      routes, limit_time = routes_and_time.split.map(&:to_i)
      candidates = choices.map{ |x| x.split.map(&:to_i)}
      selected = select_candidates(candidates,limit_time)
      choose_route(selected)
    end
  
    private
  
    def select_candidates(candidates, limit_time)
      candidates.map { |x| x[0] if x[1] <= limit_time}.compact
    end
  
    def choose_route(selected)
      selected.empty? ? "TLE" : selected.min
    end
  end
end

puts Selector.run(gets,readlines)

Measured memory_bytes: 1788
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int k[10],w[10],kp = 0,wp = 0,maxk,maxw,n = 0,tk,tw;
	for(int i=0; i<10; i++)
		cin>>k[i];
	for(int i=0; i<10; i++)
		cin>>w[i];

	while(n < 3)
	{
		for(int i=0; i<10; i++){
			if(maxk < k[i]){
				maxk = k[i];
				tk =i;
			}
		}
		kp += maxk;
		maxk = 0;
		k[tk] = 0;

		for(int i=0; i<10; i++){
			if(maxw < w[i]){
				maxw = w[i];
				tw =i;
			}
		}
		wp += maxw;
		maxw = 0;
		w[tw] = 0;
		
		n++;
	}
	cout<<kp<<" "<<wp<<endl;		

	return 0;

}

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

using namespace std;


 main()
{
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(q + 10, 0);
    for(int i = 0; i < q; i++) cin >> a[i];
    vector<int> m(n + 10, q);
    for(int i = 0; i < q; i++){
        m[a[i] - 1]--;
    }
    for(int i = 0; i < n; i++) if(k - m[i] > 0) cout << "Yes" << endl; else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>inline void OUT(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

int dp[20][2][2][2][2][2];

signed main(){
	string s;
	cin>>s;
	dp[0][1][0][0][0][0] = 1;
	REP(i,s.size()){
		REP(j,2){
			int lim = j ? s[i]-'0' : 9;
			REP(k,lim+1)REP(l,2)REP(m,2)REP(n,2)REP(o,2){
				dp[i+1][j&(k==lim)][k==5][l&(k==1)][m][(n&(k==3))|o]
					+= dp[i][j][l][m][n][o];
			}
		}
	}
	int ans = 0;
	REP(j,2)REP(l,2)REP(m,2)REP(n,2)ans += dp[s.size()][j][l][m][n][1];
	OUT(ans);
}


Measured memory_bytes: 3216
# coding: utf-8
while 1:
    data=[]
    for i in range(int(input())):
        data.append(len(input()))
    if len(data)==0:
        break
    for i in range(len(data)):
        j=i
        tmp=0
        while tmp<5:
            tmp+=data[j]
            j+=1
        if tmp!=5:
            continue
        tmp=0
        while tmp<7:
            tmp+=data[j]
            j+=1
        if tmp!=7:
            continue
        tmp=0
        while tmp<5:
            tmp+=data[j]
            j+=1
        if tmp!=5:
            continue
        tmp=0
        while tmp<7:
            tmp+=data[j]
            j+=1
        if tmp!=7:
            continue
        tmp=0
        while tmp<7:
            tmp+=data[j]
            j+=1
        if tmp!=7:
            continue
        print(i+1)
        break


Measured memory_bytes: 5612
import sys
input=sys.stdin.readline
N,M = map(int,input().split())
nCr = {}
def cmb(n, r):
    if n == 0:
        return 0
    if r == 0 or r == n:
         return 1
    if r == 1:
         return n
    if (n,r) in nCr:
         return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(N,2)
b = cmb(M,2)
print(a+b)


Measured memory_bytes: 3064
#include<stdio.h>

int makelist(int* list,int kazu){
	int i,j;
	for(i=0;i<kazu;i++){
		list[i]=1;
	}
	list[0]=0;
	list[1]=0;
	for(i=2;i<kazu;i++){
		if(list[i]){
			for(j=2*i;j<kazu;j+=i){
				list[j]=0;
			}
		}
	}
	return 0;
}

int main(){
	int list[300000];
	int n,ans;
	int i;
	makelist(list,300000);
	while(1){
		scanf("%d",&n);	
		if(n==0){
			break;
		}
		ans=0;
		for(i=n+1;i<=2*n;i++){
			if(list[i]==1)
				ans++;
		}
		
		printf("%d\n",ans);
	}
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

const long long mod = 1000000007;
int N;
vector<ll> A;
vector<ll> B;
vector<ll> C;
vector<ll> D;
vector<ll> sumA;
vector<ll> sumB;
vector<ll> sumC;
vector<ll> sumD;

vector<ll> get_sumvec(vector<ll> a){
    vector<ll> sumvec(N+1, 0);
    for(int i=N-1; i>=0; i--){
        sumvec[i] = sumvec[i+1] + a[i];
    }
    return sumvec;
}

int solve(
    bool isAq,
    bool isBq,
    bool isCq
){
    vector<ll> BC(N, 0);
    for(int i=0; i<N; i++){
        auto b = isBq? D[i] : B[i];
        auto c = isCq? sumD[i+1] : sumC[i+1];
        BC[i] = (b * c) % mod;
    }
    auto sumBC = get_sumvec(BC);

    vector<ll> ABC(N, 0);
    for(int i=0; i<N; i++){
        auto a = isAq? D[i] : A[i];
        auto bc = sumBC[i+1];
        ABC[i] = (a * bc) % mod;
    }
    ll res = 0;
    for(int i=0; i<N; i++){
        res += ABC[i];
        res %= mod;
    }
    return res;
}

int main()
{
    string S;
    cin >> S;
    N = S.size();
    A = vector<ll>(N, 0);
    B = vector<ll>(N, 0);
    C = vector<ll>(N, 0);
    D = vector<ll>(N, 0);
    for(int i=0; i<N; i++){
        if     (S[i]=='A') A[i]++;
        else if(S[i]=='B') B[i]++;
        else if(S[i]=='C') C[i]++;
        else if(S[i]=='?') D[i]++;
    }
    sumA = get_sumvec(A);
    sumB = get_sumvec(B);
    sumC = get_sumvec(C);
    sumD = get_sumvec(D);
    int Q = sumD[0];
    long long powQ0 = 1;
    long long powQ1 = 1;
    long long powQ2 = 1;
    long long powQ3 = 1;
    for(int i=0; i<Q; i++){
        powQ0 *= 3;
        powQ0 %= mod;
        if(i==0) continue;
        powQ1 *= 3;
        powQ1 %= mod;
        if(i==1) continue;
        powQ2 *= 3;
        powQ2 %= mod;
        if(i==2) continue;
        powQ3 *= 3;
        powQ3 %= mod;
    }
    ll res = 0;
    res += solve(false, false, false) * powQ0;
    res %= mod;
    if(Q>=1){
        res += solve(false, false,  true) * powQ1;
        res += solve(false,  true, false) * powQ1;
        res += solve( true, false, false) * powQ1;
        res %= mod;
    }
    if(Q>=2){
        res += solve(false,  true,  true) * powQ2;
        res += solve( true,  true, false) * powQ2;
        res += solve( true, false,  true) * powQ2;
        res %= mod;
    }
    if(Q>=3){
        res += solve(true, true, true) * powQ3;
        res %= mod;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (N == 1) {
		if (A == B) {
			cout << 1 << endl;
		}
		else
			cout << 0 << endl;
	}
	else {
		if (A < B) {
			cout<<(ll)(B-A)*(N-2)+1;
		}
		if (A == B) {
			cout << 1 << endl;
		}
		if (A > B) {
			cout << 0 << endl;
		}
	}
}



Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<map>
using namespace std;

typedef long long ll;

ll N, P;

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for (ll i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			res[i]++;
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}

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

	map<ll, ll> res;
	res = prime_factor(P);

	ll sum = 1;
	for (map<ll,ll>::iterator i = res.begin(); i != res.end(); i++) {
		if (i->second >= N) {
			ll num = (i->second / N);
			sum *= pow(i->first,num);
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    int N,X,T; cin >> N >> X >> T;

    int lo = 0, hi = N*T, res = -1;
    while(lo <= hi) {
        int mid = (lo+hi)/2;
        if (mid*X >= N) hi = mid-1, res = mid;
        else lo = mid+1; 
    }

    cout << res*T << "\n";
}

Measured memory_bytes: 3612
//#include<bhaai.h>
#include<bits/stdc++.h>
using namespace std;
#define to int64_t
#define mo 1000000007
#define fr(a,e) for(int i=a;i<=e;i++)
#define yah_faster_baby ios_base::sync_with_stdio(0);cin.tie(0);

to ans,n,k,m,r[100005],p[100005],a,b;
//vector <int> v[100005];
//char s[100005];
double d,x;
int main()
 {  yah_faster_baby
    cin>>n;
    if(n%2==0)
    {cout<<"-1\n";return 0;}
    ans=1;k=7;
    while(ans<=10000000&&k%n)
    {++ans;
     k*=10;
     k+=7;
     k%=n;
    }
    if(ans==10000001)
    cout<<"-1\n";
    else
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3656
from heapq import heappush, heappop

N, M = map(int, input().split())
A = list(map(int, input().split()))
hp = []
for i in range(N):
    heappush(hp, A[i] * -1)
for i in range(M):
    tmp = heappop(hp)
    heappush(hp, -(-tmp // 2))
print(sum(hp) * -1)


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

int main() {
  int N, i;
  string S;
  cin >> N ;

  for(i=1;i<=N;i++){
    cin >>S;
    if(S=="Y"){
      cout <<"Four";
      break;
    }
    
    else if(i==N){
      cout <<"Three";
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

int n;
map<int, set<int>> m;
int d_to_1[100001], d_to_n[100001];

int count_subtree(int c,int p) {
    int s = 0;
    for(auto e: m[c]) {
        if(e != p) {
            s += count_subtree(e,c);
        }
    }
    return s + 1;
}

int main() {
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        m[a].insert(b);
        m[b].insert(a);
    }
    queue<int> q;
    q.push(n);
    while (!q.empty()) {
        int c = q.front();
        q.pop();
        for (auto e:m[c]) {
            if (d_to_n[e] == 0 && e != n) {
                d_to_n[e] = d_to_n[c] + 1;
                q.push(e);
            }
        }
    }
    vector<int> p;
    int c = 1;
    while (c != n) {
        p.push_back(c);
        for (auto e: m[c]) {
            if (d_to_n[e] < d_to_n[c]) {
                c = e;
                break;
            }
        }
    }
    p.push_back(n);
    int r_f = p[(p.size() - p.size() / 2) - 1], r_s = p[p.size() - p.size() / 2];
    if(count_subtree(r_f,r_s) <= count_subtree(r_s,r_f)) cout << "Snuke";
    else cout << "Fennec";
    cout << endl;
}

Measured memory_bytes: 24572
#include <stdio.h>
#include <stdlib.h>

#define INT(X) \
  ( *( (const int *)(X) ) )
#define SQ(X) \
  ( (X) * (X) )

static int
compare (
  const void *a,
  const void *b
  )
{
  return ( INT( a ) - INT( b ) );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int r[ 3 ] = { 0 };
  int n;

  for ( n = 0; ; ++n )
  {
    int d[ 3 ];

    scanf ( "%d%d%d", &d[ 0 ], &d[ 1 ], &d[ 2 ] );
    qsort ( d, 3, sizeof ( int ), compare );
    if ( d[ 0 ] + d[ 1 ] <= d[ 2 ] ) break ;

    if ( SQ( d[ 0 ] ) + SQ( d[ 1 ] ) == SQ( d[ 2 ] ) )
      ++r[ 0 ];
    else if ( SQ( d[ 0 ] ) + SQ( d[ 1 ] ) > SQ( d[ 2 ] ) )
      ++r[ 1 ];
    else
      ++r[ 2 ];
  }
  
  printf ( "%d %d %d %d\n", n, r[ 0 ], r[ 1 ], r[ 2 ] );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
using namespace std;
int main()
{
   long long  int n,a,t,sum=0;
    cin>>n;
    for(t=1;t<=n;t++)
    {
      if(t%3==0 || t%5==0)
      sum=sum;
      else
        sum+=t;
    }
        cout<<sum;
return 0;
}


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

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

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

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

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

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

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

int main()
{
	for(int n;cin>>n&&n;){
		map<int,int> f;
		rep(i,n){
			int x; cin>>x;
			f[x]++;
		}
		int cnt=0;
		for(auto p:f)
			cnt+=p.second-1;
		cout<<n-(cnt+1)/2*2<<endl;
	}
}


Measured memory_bytes: 4864
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

n=get.join("").to_i
if (n**0.5).to_i**2==n
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X, N = MII_split()
if N==0:
    print(X)
    exit()
ps = LII_split()

# diss = map(lambda x: abs(X - x), ps)
# min_dis = min(diss)

for dis in range(105):
    if X - dis not in ps:
        ans = X - dis
        break
    elif X + dis not in ps:
        ans = X + dis
        break
print(ans)

Measured memory_bytes: 9156
X,Y=map(int,input().split())

# (i+1,j+2)の移動をa回
# (i+2,j+1)の移動をb回
# X=a+2b
# Y=2a+b
# となるa,bが存在するか？
# b=(2X-Y)/3が整数となればOK

b=(2*X-Y)/3
if not float.is_integer(b):
  print(0)
  exit(0)
  
b=int(b)
a=X-2*b

# aとbの回数が決まったので、a+bCmin(a,b)をやればいい

DIV=10**9+7
from functools import reduce
def nCr(n,r,DIV):
  if r<n-r:
    r=n-r
  if r==0:
    return 1
  f=lambda x,y:x*y%DIV
  X=reduce(f,range(n-r+1,n+1))
  Y=reduce(f,range(1,r+1))
  return X*pow(Y,DIV-2,DIV)%DIV

print(nCr(a+b,b,DIV))

Measured memory_bytes: 3572
use proconio::input;
fn main() {
    input! {
        n:usize,
        A:[usize; n]
    };
    let mut i = 1;
    let mut j = 0;
    let mut m: i64 = (n-1) as i64;
    loop {
        if j == n {
            println!("{}", n-1-m as usize);
            break;
        }
        m -= match A[j..].iter().position(|&x| x==i) {
            Some(k) => {
                i += 1;
                j += k+1;
                k as i64
            },
            None => {
                let t = j;
                j = n;
                n as i64 - t as i64
            }
        };
        if m < 0 {
            println!("-1");
            break;
        }
    }
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define endl "\n"
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define com(a, b) a ## b
#define scv(a, b, c) #a#b#c
#define db(x) cerr << "[" << #x << ": " << (x) << "] " << endl;
#define run cerr << 1 << endl; 
template<class T> void printvec(vector<T>& x, int a, int b) {foru (i, a, b) cout << x[i] << " "; cout << endl;}

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const ld PI = acos((ld) -1);
const ld EPS = 1e-6;
const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;
const int BASE = 10000;

void solve() {
    string s;
    cin >> s;
    for (auto x : s) {
        if (x == '7') {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No";
}

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
} 

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
template<class T>fstream& operator>>(fstream& is, vector<T>& v)
{
	int n = v.size();
	REP(i, n) {
		is >> v[i];
	}
	return is;
}
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define DOWN(T) std::greater<T>()
template<class T>istream& operator>>(istream& is, vector<T>& v)
{
	int n = v.size();
	REP(i, n) {
		is >> v[i];
	}
	return is;
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
using vpii = vector<pii>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
//int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


int dx[8] = { 1,0,0,-1,1,-1,1,-1 };
int dy[8] = { 0,1,-1,0,1,1,-1,-1 };

bool ed[55][55];

signed main()
{
	QUICK_CIN;
	debug_input;
	int w, h;
	while (cin >> w >> h, w + h) {
		vector<vi> tile(h, vi(w));
		REP(i, h) {
			REP(j, w) {
				cin >> tile[i][j];
			}
		}

		int ans = 0;

		REP(i, h) {
			REP(j, w) {
				if (tile[i][j] != 1) {
					continue;
				}
				REP(i, 55) {
					REP(j, 55) {
						ed[i][j] = false;
					}
				}
				queue<pii> q;
				q.push({ i,j });
				while (q.size()) {
					auto t = q.front();
					q.pop();
					auto x = t.second;
					auto y = t.first;

					if (ed[y][x]) {
						continue;
					}
					ed[y][x] = true;
					tile[y][x] = 2;

					REP(k, 8) {
						auto nx = min(w-1,max(0LL,x + dx[k]));
						auto ny = min(h-1,max(0LL,y + dy[k]));

						if (tile[ny][nx] == 1 && !ed[ny][nx]) {
							q.push({ ny,nx });
						}
					}
				}
				ans++;
			}
		}
		cout << ans << endl;

	}
}

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

x=[]
y=[]

for i in range(c-a):
    x.append("R")
    y.append("L")

for i in range(d-b):
    x.append("U")
    y.append("D")

x2=["D","R"]+x+["U","L"]
y2=["U","L"]+y+["D","R"]

ans=x+y+x2+y2

print(''.join(ans))

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

int main(){
  string s;
  int ans =0;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << (a + b) * c / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

vector<ll> A(3);

rep(i,3) cin >> A[i];

sort(all(A));

cout << A[0]+A[1] << endl;

return 0;

}

Measured memory_bytes: 256