akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 210
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
int n;
int l[N];
int main()
{
//	freopen("AGC001A.in","r",stdin);
//	freopen("AGC001A.out","w",stdout);
	read(n);
	for(int i=1;i<=n*2;i++) read(l[i]);
	sort(l+1,l+n*2+1,greater<int>());
	int ans=0;
	for(int i=2;i<=n*2;i+=2) ans+=l[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
  int res = 60*h2+m2 - 60*h1 -m1 -k;
  cout << res << endl;

  return 0;
}


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

public class Main {

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

        int larger = Math.max(A,B);
        int smaller = Math.min(A,B);

        int ans = larger;
        larger--;
        ans += Math.max(larger, smaller);

        System.out.println(ans);


    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    cin >> n;
    double sum = 0;
    rep(i, n){
        lli a;
        cin >> a;
        sum += 1.0 / a;
    }
    cout << 1.0 / sum << endl;
}

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


int main()
{
  string ans = "No";

  int a, b, c;
  cin >> a >> b >> c;

  if (a == b && a != c) ans = "Yes";
  if (a == c && a != b) ans = "Yes";
  if (b == c && a != b) ans = "Yes";

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int P, Q, R;
	cin >> P >> Q >> R;
	int c1 = P + Q;
	int c2 = P + R;
	int c3 = Q + R;
	int answer = min(c1, min(c2, c3));
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
def div2count(num):
    n = 0
    while num % 2 == 0:
        n += 1
        num //= 2
    return n
N = int(input())
ans_num = 0 
ans = 1
for i in range(2,N+1):
    n = div2count(i)
    if n > ans_num:
        ans_num = n
        ans = i
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int i, j, k, p, q, r, x, y, u, v, n, m;
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=k;i<n;i++){
		if(a[i]>a[i-k]){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




Measured memory_bytes: 11468
#include<stdio.h>
int main(void){
  int a,b, v1, v2, v3, sum=0;
  scanf("%d%d%d%d%d",&a,&b,&v1,&v2,&v3);

  if(a<0){
    sum += (-1)*a*v1;
    a=0;
  }
  if(a==0){
    sum += v2;
  }
  sum += (b-a)*v3;
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1780
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    if len(S) % 2 == 1:
        print(NO)
        exit()
    n = 0
    while n != len(S):
        if S[n] == "h" and S[n+1] == "i":
            n += 2
        else:
            break
    if n == len(S):
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
      let mut iter = $s.split_whitespace();
      let mut next = || { iter.next().unwrap() };
      input_inner!{next, $($r)*}
  };
  ($($r:tt)*) => {
      let stdin = std::io::stdin();
      let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
      let mut next = move || -> String{
          bytes
              .by_ref()
              .map(|r|r.unwrap() as char)
              .skip_while(|c|c.is_whitespace())
              .take_while(|c|!c.is_whitespace())
              .collect()
      };
      input_inner!{next, $($r)*}
  };
}

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

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

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

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

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

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

  ($next:expr, $t:ty) => {
      $next().parse::<$t>().expect("Parse error")
  };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
  input!{
    n:usize,
    s:chars,
  }
  if n % 2 != 0 {println!("No"); return;}
  let mut ans = true;
  for i in 0..n/2{
    if s[i] != s[i+n/2] {
      ans = false;
      break;
    }
  }
  println!("{}", if ans{"Yes"} else {"No"});
}


fn is_prime(x:i64) -> bool {
  if x == 2 {return true;}
  if x < 2 || x % 2 == 0 {return false;}
  let mut j = 3;
  while j <= (x as f64).sqrt() as i64 {
      if x % j == 0 {
          return false;
      }
      j += 2;
  }
  true
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
  ll N;
  cin >> N;
  string str;
  map<string,int> m;
  for (int i = 0; i != N; ++i) {
    cin >> str;
    m[str] += 1;
  }


  int maxcnt{0};
  for (auto &&p: m) {
    if (maxcnt < p.second) {
      maxcnt = p.second;
    }
  }

  for (auto it = m.begin(); it != m.end(); ++it) {
    if (it->second == maxcnt) {
      cout << it->first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    char c;cin>>c;
    if(c>='a'){
        cout<<"a"<<"\n";
    }else{
        cout<<"A"<<"\n";
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3636
import sys
import math
import collections
#n = int(input())
n, a, b = map(int, input().split())
#s = input()
#x = list(map(int, input().split()))

c = a + b
d = math.floor(n / c)
e = n % c

ans = d * a
ans += min(e, a)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
const int64_t MAXN = 200100;
int64_t memo[MAXN * 2];

int main()
{
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> L(K), R(K);
  for (int i = 0; i < K; i++)
  {
    cin >> L.at(i) >> R.at(i);
  }
  memo[0] = 1;
  memo[1] = (MOD - 1) % MOD;
  for (int i = 0; i < N; i++)
  {
    if (i)
    {
      (memo[i] += memo[i - 1]) %= MOD;
    }
    int64_t cur = memo[i];
    for (int j = 0; j < K; j++)
    {
      int64_t l = L[j], r = R[j];
      (memo[i + l] += cur) %= MOD;
      (memo[i + r + 1] = memo[i + r + 1] - cur + MOD) %= MOD;
    }
  }
  cout << memo[N - 1] % MOD << endl;
}

Measured memory_bytes: 6648
#include <cstdio>
#define REP(i,n) for (int i=0;i<(n);i++)
int main(){
char a,b;
scanf("%c %c",&a,&b);
if(a=='H' && b=='H'){
printf("H");
}else if(a=='D' && b=='D'){
printf("H");
}else{
printf("D");
}
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int begin, end, n;
    scanf("%d %d %d", &begin, &end, &n);
    int i, count = 0;
    for(i = begin; i <= end; i++){
        if(n % i == 0)count++;
    }
    printf("%d\n", count);
}


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

using namespace std;
int main() {
  int k;
  cin >> k;
  int even, odd;
  if (k % 2 == 0) {
    odd = k / 2;
    even = odd;
  } else {
    odd = k / 2 + 1;
    even = odd - 1;
  }
  cout << (even * odd) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define MD 1000000007
#define INF 1ll<<60
const double PI=3.141592653589;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,m,cnt=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int tmp;
        cin>>tmp;
        cnt+=tmp;
    }
    cout<<((n-cnt)>=0?(n-cnt):-1)<<endl;
    return 0;
}


Measured memory_bytes: 3636
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def se(s,i)
  return if(i >= $s.size)
  s += $s[i]
  if(s <= $an[4])
    c = 4
    f = 0
      while(c >= 0)
        if(s == $an[c])
          f = 1
          break
        end
        c -= 1
      end
      if(f ==0)
        $an[4] = s
        $an.sort!
      end
    se(s,i+1)
  else
  return  
  end
  
end
$s = gets.chomp
k = inp[0]
$t = na(26,na(0))
$an  = na(5,"z"*4000)
$s.size.times do |d|
  se("",d)
end
puts $an[k-1]




Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
    int a, b, coin = 0;
    scanf("%d%d", &a, &b);
    for(int i = 0; i < 2; i++)
    {
        if(a <= b)
        {
            coin += b;
            b -= 1;
        }
        else
        {
            coin += a;
            a -= 1;
        }
    }
    printf("%d", coin);
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    readLine()
    val array = readLine()
        ?.split(" ".toRegex())
        ?.map(Integer::parseInt)
        ?.toIntArray()
        ?: intArrayOf()
    val mid = array.partition(0, array.lastIndex)
    println(array.mapIndexed { index, value ->
        if (index == mid) {
            "[$value]"
        } else {
            value.toString()
        }
    }.joinToString(" "))
}

fun IntArray.partition(p: Int, r: Int): Int {
    val x = this[r]
    var i = p - 1
    for (j in p until r) {
        if (this[j] <= x) {
            i++
            swap(i, j)
        }
    }
    swap(i + 1, r)
    return i + 1
}

fun IntArray.swap(i: Int, j: Int) {
    val tmp = this[i]
    this[i] = this[j]
    this[j] = tmp
}


Measured memory_bytes: 52472
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String s = sc.next();
		String[] strArray = s.split("");

		int countOne = 0;
		int countTwo = 0;

		for (int i = 0; i < strArray.length; i++) {
			String curS = strArray[i];

			if(i!=0 && i%2==1){
				if(curS.equals("0")){
					countOne++;
				}else{
					countTwo++;
				}
			}else{
				if(curS.equals("1")){
					countOne++;
				}else{
					countTwo++;
				}
			}

		}

		System.out.println(Math.min(countOne,countTwo));

	}
}


Measured memory_bytes: 34624
n, m = map(int, input().split())
H = list(map(int, input().split()))

A = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    A[u].append(v)
    A[v].append(u)

ans = 0
for i, a in enumerate(A):
    _max = H[i]
    flg = True
    for _a in a:
        if _max <= H[_a]:
            flg = False
            break
    if flg:
        ans += 1

print(ans)


Measured memory_bytes: 92876
def main():
    n, k = list(map(int, input().split()))
    if k % 2 == 0:
        n_k = sum([1 for i in range(1, n + 1) if i % k == 0])
        n_k2 = sum([1 for i in range(1, n + 1) if i % k == k // 2])
        print(n_k ** 3 + n_k2 ** 3)
    else:
        n_k = sum([1 for i in range(1, n + 1) if i % k == 0])
        print(n_k ** 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4632
#include<stdio.h>
 
int main(void){
	int N;
	scanf("%d", &N);
	int arr[N];
	int A = 0, B = 0;
	int m = 0, f = 0;
	int temp;
	int i, j;
	for(i=0;i<N;i++){
		scanf("%d", &temp);
		arr[i] = temp;
	}
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(m<arr[j]){
				m = arr[j];
				f = j;
			}
		}
		if(i%2){
			B += m;
		}else{
			A += m;
		}
		m = 0;
		arr[f] = 0;
	}
	printf("%d", A - B);
	return 0;
}

Measured memory_bytes: 128
N = gets.to_i

words = []

N.times do
  s = gets.chomp
  if words.include? s
    puts 'No'
    exit
  end

  if words.size > 0 && words.last[words.last.size - 1] != s[0]
    puts 'No'
    exit
  end

  words << s
end

puts 'Yes'

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if (N<105)
			System.out.println(0);
		
		else if (N<135)
			System.out.println(1);
		
		else if (N<165)
			System.out.println(2);
		
		else if (N<189)
			System.out.println(3);
		
		else if (N<195)
			System.out.println(4);
		
		else 
			System.out.println(5);
		
		sc.close();
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<array>
using namespace std;
int main(){
int N,ans=0,cnt=1;
cin>>N;
int a[N];
for (int i = 0; i < N; i++) {
  cin>>a[i];
}
for (int i = 0; i < N; i++) {
  if(a[i]==a[i+1]){
    cnt++;
  }

 if(a[i]!=a[i+1]){
   ans=ans+cnt/2;
   cnt=1;
 }


}
cout<<ans<<endl;










}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std; 
int main(){
  int n,r;
  int a[60]={}; 
  while(cin>>n>>r){
    if(n==0&&r==0)break;
    for(int i=0;i<n;i++){
      a[i]=n-i;
    }
    int b[60]={};
    for(int i=0;i<r;i++){
      int p,c;
      cin>>p>>c;
      for(int j=0;j<c;j++){
	b[j]=a[p-1+j];	
      }
      for(int j=0;j<p-1;j++){
	b[j+c]=a[j];
      }
      for(int j=0;j<n-p-c+1;j++){
	b[j+p+c-1]=a[j+p+c-1];
      }

      for(int i=0;i<n;i++){	
	a[i]=b[i];
      }
    }
    cout<<b[0]<<endl;
  }  
  return 0;
}

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

typedef long long ll;

const ll M=1e9+7;
ll N;

int main(){
    scanf("%lld", &N);
    ll ans=1;
    for(ll i=2; i<=N; i++){
        ans =ans * i %M;
    }
    printf("%lld\n", ans%M);
    return 0;
}



Measured memory_bytes: 256
module Main where

import Control.Monad
import Data.Array.IO
import qualified Data.Vector as V

main :: IO ()
main = do
  x <- getChar
  case x of
    'A' -> putStrLn "T"
    'T' -> putStrLn "A"
    'G' -> putStrLn "C"
    'C' -> putStrLn "G"

solve = 0

getInt :: IO Int
getInt = read <$> getLine

getInts :: IO [Int]
getInts = map read . words <$> getLine

getIntLines :: Int -> IO [Int]
getIntLines i = replicateM i getInt

getStrLines :: Int -> IO [String]
getStrLines i = replicateM i getLine


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

fn main() {
    let i = stdin();
    run(&mut i.lock(), &mut stdout());
}

fn run(i: &mut BufRead, o: &mut Write) {
    let hwd = read_vec::<usize>(i);
    let (h, w, d) = (hwd[0], hwd[1], hwd[2]);
    let mut a = Vec::new();
    for _ in 0..h {
        a.push(read_vec::<usize>(i));
    }
    let wh = w * h;
    let mut a_to_xy = vec![(usize::max_value(), usize::max_value()); wh + 1];
    for y in 0..h {
        for x in 0..w {
            a_to_xy[a[y][x]] = (x, y);
        }
    }
    fn abs_sub(x0: usize, s1: usize) -> usize {
        (x0 as isize - s1 as isize).abs() as usize
    }

    let mut mps = vec![0; wh + 1];
    for mut l in 0..d {
        let mut mp = 0;
        let mut xy0 = a_to_xy[l];
        loop {
            mps[l] = mp;
            l += d;
            if l > wh {
                break;
            }
            let xy1 = a_to_xy[l];
            mp += abs_sub(xy0.0, xy1.0) + abs_sub(xy0.1, xy1.1);
            xy0 = xy1;
        }
    }

    let q = read::<usize>(i);
    for _ in 0..q {
        let lr = read_vec::<usize>(i);
        let (mut l, r) = (lr[0], lr[1]);
        let mp = mps[r] - mps[l];
        writeln!(o, "{}", mp).unwrap();
    }
}

fn read_line(i: &mut BufRead) -> String {
    let mut line = String::new();
    i.read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn read<T: FromStr>(i: &mut BufRead) -> T {
    read_line(i).parse().ok().unwrap()
}
fn read_vec<T: FromStr>(i: &mut BufRead) -> Vec<T> {
    read_line(i)
        .split(' ')
        .map(|x| x.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 9340
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int H,N,c = 0;
    cin >> H >> N;
    vector<int> A(N);

    rep(i, N){
        cin >> A.at(i);
        c += A.at(i);
    }

    if(c >= H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

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

	vector<ll> a(n);

	vector<pair<ll, ll>> pairs(m);

	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> pairs[i].second >> pairs[i].first;

	sort(ASC(a));
	sort(DESC(pairs));

	int pwd = 0;

	for (int i = 0; i < m; i++)
	{
		if (pairs[i].first < a[pwd]) continue;

		int j = 0;

		while (pairs[i].first > a[pwd] && j < pairs[i].second)
		{
			a[pwd] = pairs[i].first;
			j++;
			pwd++;
		}
	}

	ll sum = 0;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 2560
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  while (cin >> n, n != -1) {
    double x = 1.0, y = 0.0, arg = 0.0;
    rep(_, n - 1) {
      double r = hypot(x, y);
      arg += atan(1.0 / r);
      double nextR = hypot(r, 1.0);
      x = nextR * cos(arg);
      y = nextR * sin(arg);
    }
    cout << prec(32) << x << endl << y << endl;
  }
}

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

const int MOD = 1000000007;

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

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

//最小公倍数
int lcm(int number1,int number2){
	return number1 * number2 / gcd(number1,number2);	
}
  
int main(){
string S, T;
cin >> S >> T;

if(S == T){
    cout << "Yes" << endl;
    return 0;
}

string S_C = S;
for(int i = 0; i < S.size() - 1; i++){ 
     string S_C2 = S_C;
     for(int j = 1; j < S.size(); j++){ 
     S_C[j] = S_C2[j - 1];     
     }
S_C[0] = S_C2[S.size() - 1];
if(S_C == T){
    cout << "Yes" << endl;
    return 0;
}
    // cout << S_C << endl; 
}

cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
 
typedef double D;
struct P {
    D x,y,z;
    P() { }
    P(D x_, D y_, D z_) : x(x_), y(y_), z(z_) { }
};
 
struct L {
    P a,b;
    L() { }
    L(P a_, P b_) : a(a_), b(b_) { }
};
 
struct C {
    P p;
    D r;
    C() { }
    C(P p_, D r_) : p(p_), r(r_) { }
};
 
const D EPS = 1e-8;
 
int sig(D a, D b) {
    if(a < b - EPS) return -1;
    if(a > b + EPS) return +1;
    return 0;
}
 
P operator +(P a, P b) {
    return P(a.x + b.x, a.y + b.y, a.z + b.z);
}
 
P operator -(P a, P b) {
    return P(a.x - b.x, a.y - b.y, a.z - b.z);
}
 
P operator *(P a, D t) {
    return P(a.x*t, a.y*t, a.z*t);
}
 
P vec(P from, P to) {
    return to - from;
}
 
D inp(P a, P b) {
    return a.x*b.x + a.y*b.y + a.z*b.z;
}
 
D norm(P p) {
    return inp(p,p);
}
 
D abs(P p) {
    return sqrt(norm(p));
}
 
P proj(L l, P p) {
    P a = vec(l.a, l.b);
    P b = vec(l.a, p);
    D t = inp(a,b) / norm(a);
    return l.a + a*t;
}
 
bool iSP(L s, P p) {
    P b = vec(s.a, s.b);
    P c = vec(s.a, p);
    if(sig(inp(b,c),0.0) < 0) return false;
    if(norm(b) < norm(c)) return false;
    return true;
}
 
D dSP(L s, P p) {
    P r = proj(s,p);
    if(iSP(s,r)) return abs(p - r);
    return min(abs(p - s.a), abs(p - s.b));
}
 
bool iSC(L s, C c) {
    return sig(dSP(s,c.p), c.r) <= 0;
}
 
int main() {
    int N, Q; cin >> N >> Q;
    vector<C> objs(N);
    vector<long long> cost(N);
    for(int i = 0; i < N; ++i) {
        cin >> objs[i].p.x >> objs[i].p.y >> objs[i].p.z >> objs[i].r >> cost[i];
    }
    for(int i = 0; i < Q; ++i) {
        L l;
        long long ans = 0;
        cin >> l.a.x >> l.a.y >> l.a.z >> l.b.x >> l.b.y >> l.b.z;
        for(int j = 0; j < N; ++j) {
            if(iSC(l,objs[j])) {
                ans += cost[j];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
 
typedef long long ll;
int N, A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    vector<int> v;
    map<int, int> cnt;
    rep(i, 0, N) {
        cnt[A[i]]++;
        if (cnt[A[i]] == 2) cnt[A[i]] = 0, v.push_back(A[i]);
    }
    sort(v.begin(), v.end(), greater<int>());

    ll ans = 0;
    if (2 <= v.size()) ans = 1LL * v[0] * v[1];
    printf("%lld\n", ans);
}

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

int main(void) {
	int K;
	string S;
	cin >> K >> S;

	int len = S.length();
	if (len > K) {
		S.erase(K);
		S += "...";
	}

	cout << S << '\n';
	return 0;
}


Measured memory_bytes: 3584
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int n;
	cin >> n;
	int l;
	cin >> l;
	long long geko = 0;
	REP(i, n) {
		geko += l + i;
	}
	long long mini_diff = 10000000;
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		if (mini_diff > llabs(l + i)) {
			mini_diff = llabs(l + i);
			ans = l + i;
		}
	}
	cout << geko - ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll =long long;
int main(){
  ll A=0;
  int N;
  std::cin>>N;
  std::vector<ll> add(N);
  for(int i=0;i<N;i++){
    ll B;std::cin>>B;
    A+=B;
    add[i]=(-B)-B;
  }
  std::sort(add.begin(),add.end(),std::greater<ll>());
  ll ans =A;
  for(int i=0;i<N-1;i+=2){
    ll p =add[i]+add[i+1];
    if(p>0){ans+=p;}
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
//#include <math.h>

int main(){
  int i, j;

  scanf("%d %d", &i, &j);

  int plus;
  int minus;
  int div;
  plus = i + j;
  minus = i-j;
  div = i*j;
  int max = plus;
  if(max<minus){
    max = minus;
  }
  if(max < div){
    max = div;
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 384
from itertools import count

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

d_cumsum = [0] * 60
for v in a:
    for i in count():
        d_cumsum[i] += v % 2
        v //= 2
        if v == 0:
            break

res = 0
mod = 10**9 + 7
for i, d in enumerate(d_cumsum):
    res += (2**i * d * (n-d)) % mod
    res %= mod

print(res)


Measured memory_bytes: 122936
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll ans = 1145141919;
    for(ll i = 1; i < N; i++){
        ll j = N - i;
        string s = to_string(i);
        string t = to_string(j);
        ll tmp = 0;
        for(char c : s) tmp += c - '0';
        for(char c : t) tmp += c - '0';
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def dfs(v, used):
  if not False in used: return 1
  ans = 0
  for i in range(n):
    if not matrix[v][i]: continue
    if used[i]: continue
    used[i] = True
    ans += dfs(i, used)
    used[i] = False
  return ans

n, m = map(int, input().split())
matrix = [[0]*n for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  matrix[a-1][b-1] = 1
  matrix[b-1][a-1] = 1

used = [False]*n
used[0] = True

print(dfs(0, used))

Measured memory_bytes: 9188
from sys import stdin
 
def main():
    S = list(stdin.readline().rstrip())
    Q = int(input())
    rev = 0
    head = []
    tail = []
 
    for _ in range(Q):
        q = stdin.readline()
        if q[0] == "1":
            rev = (rev+1)%2
        else:
            if q[2] == "1":
                if rev == 0:
                    head.append(q[4])
                else:
                    tail.append(q[4])
            else:
                if rev ==0:
                    tail.append(q[4])
                else:
                    head.append(q[4])
 
    if rev == 0:
        ans = "".join(head[::-1] + S + tail)
    else:
        ans = "".join(tail[::-1] + S[::-1] + head)
    
    print(ans)
    
main()

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  int a, b, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    ans += b - a + 1;
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
    int W, H, x, y, r;

    // input
    cin >> W >> H >> x >> y >> r;

    // output
    if ((x - r >= 0) && (y - r >= 0) && (x + r <= W) && (y + r <= H)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cstring>

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	int a[1000001] = { 0, };
	int arr[200001];
	int cnt[1000001] = { 0, };

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

		cnt[arr[i]]++;
	}

	sort(&arr[0], &arr[n]);

	int sol = 0;

	for (int i = 0; i < n; i++)
	{
		if (!a[arr[i]])
		{
			if (cnt[arr[i]] == 1)
			{
				sol++;
			}

			for (int j = arr[i]; j <= 1000000; j += arr[i])
			{
				a[j] = 1;
			}
		}
	}

	printf("%d\n", sol);

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, 0, n) cin >> p[i];
    rep(i, 0, n) cin >> q[i];
    vector<int> a(n);
    rep(i, 0, n) a[i] = i + 1;
    int x, y;
    int cnt = 0;
    do{
        if(a == p) x = cnt;
        if(a == q) y = cnt;
        cnt++;
    }while(next_permutation(a.begin(), a.end()));
    cout << abs(x - y) << endl;
    return 0;
}


Measured memory_bytes: 3604
n = gets.to_i
hash_b = Hash.new(0)
n.times { hash_b[gets.chomp] += 1 }

m = gets.to_i
hash_r = Hash.new(0)
m.times { hash_r[gets.chomp] += 1 }

res = []
hash_b.each do |k, v|
  res << v -= hash_r[k] || 0
end

puts res.max > 0 ? res.max : 0


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s, t;
    cin >> s >> t;

    int pos = -1, cnt = 0;
    rep(i, t.size()) {

        //前回の位置以降で、t[i]の文字が現れる位置を探す
        pos = s.find(t[i], pos+1);

        //もしそのような位置が無いのであればカウントを1増やす
        //あるなら次のt[i]へ
        if(pos != -1) continue;
        else cnt++;

        //再度sの先頭からt[i]を探す
        pos = s.find(t[i]);
        if(pos == -1) {
            cout << -1 << endl;
            return 0;
        }
    }

    int res = s.size()*cnt + pos + 1;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
import collections
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
c = collections.Counter(a)
cl = ""
if n%2 == 1:
	cl = "odd"
else:
	cl = "even"
ans = 0
if cl == "odd":
	for i in c:
		if i%2 == 1:
			print (ans)
			exit()
		if i == 0:
			if c[i] != 1:
				print (ans)
				exit()
		else:
			if c[i] != 2:
				print (ans)
				exit()
	ans = 2**(n//2)%mod
else:
	for i in c:
		if i%2 == 2:
			print (ans)
			exit()
		if c[i] != 2:
			print (ans)
			exit()
	ans = 2**(n//2)%mod
print (ans)

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

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

int main(){
  char s[10];
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}


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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	string s, t;
	in s >> t;
	ll x = s.length();
	ll ans = 0;
	rep(i, x)
	{
		if (s.at(i) != t.at(i))
		{
			ans++;
		}
	}
	out ans en;
}


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

using namespace std;

const int N = 1e6 + 7;
int a[N], n;

bool can(int x) {
  long long now = a[x];
  for (int i = 0; i < n; i++) {
    if (i == x) continue;
    if (now * 2 < a[i])
      return 0;
    now += a[i];
  }
  return 1;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", a+i);
  sort(a, a+n);
  int l = 0, r = n;
  while (l < r) {
    int mid = (l + r)/2;
    if (can(mid))
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d\n", n-l);
  return 0;
}

Measured memory_bytes: 640
program kyomu
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: antena(5),k,i,j

    do i=1,5
        read*, antena(i)
    end do
    read*, k

    do i=1,4
        do j=i+1,5
            if (antena(j)-antena(i) > k) then
                print'(a)', ':('
                stop
            end if
        end do
    end do
    print'(a)', 'Yay!'

end program kyomu

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public void solve() {
		Scanner in = new Scanner(System.in);
		long N = in.nextLong();
		in.close();
		
		/*
		long testSum = 0;
		for (long i=1; i<=N; i++) {
			if (N / i == N % i) {
				testSum += i;
				System.out.println("m = " + i + " : N mod m = " + (N%i));
			}
		}
		System.out.println("testSum = " + testSum);
		*/
		
		long sum = 0;
		// x is N mod m
		for (long x=1; x<Math.ceil(Math.sqrt(N)); x++) {
			if ((N-x) % x == 0) {
				long m = ((N-x) / x);
				if (N/m == N%m) {
					sum += m;
					//System.out.println("m = " + m + " : N mod m = " + (N%m));
				} else {
					//System.out.println("pass : m = " + m + " : N mod m = " + (N%m));
				}
			}
		}
		System.out.println(sum);
	
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
}


Measured memory_bytes: 21972
from functools import reduce

MAX_DIGIT = 60

N = int(input())
A = list(map(int, input().split()))

xorsum = reduce(lambda x, y: x ^ y, A)

A = [xor & ~xorsum for xor in A]

rank = 0
for digit in range(59, -1, -1):
    if (xorsum >> (MAX_DIGIT - digit - 1)) & 1 == 1:
        continue

    if rank >= N:
        break
    for j in range(rank, N):
        if A[j] & (1 << digit):
            break

    if j == N:
        continue

    if j > rank:
        A[rank] ^= A[j]

    for j in range(rank + 1, N):
        A[j] = min(A[j], A[j] ^ A[rank])

    rank += 1

x = 0
for i in range(N):
    x = max(x, x ^ A[i])

print(x * 2 + xorsum)


Measured memory_bytes: 81312
/*
I believe on myself and I will achieve
this->author = Fuad Ashraful Mehmet, CSE ,University of Asia Pacific
Todo:
https://codeforces.com/problemset/problem/830/B
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;
#define pb push_back
using namespace std;

typedef long long ll;
const int N=1e5+5;
int q,k,m,n,cs=1;

void HalfDead()
{
	cin>>n;
	int cnt=0;
	int d1,d2;

	bool ok=false;
	forn(i,n)
	{
		cin>>d1>>d2;
		if(d1==d2)cnt++;
		else cnt=0;

		if(cnt>=3)
		{
			//cout<<"Yes"<<endl;
			ok=true;
			
		}
	}

	cout<<(ok?"Yes":"No")<<endl;
}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);  cout.tie(0);
      // cout<<setprecision(10)<<fixed;
      int tc=1;
     // cin>>tc;
      while(tc--)
      {   
          HalfDead();
      }
      return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i;
	cin >> n;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	int mx = -1;
	int ans = 0;
	fo(i, 0, n){
		if(arr[i] >= mx)
		ans++;
		mx = max(mx, arr[i]);
	}
	cout << ans;
}

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

int main()
{
    int maxx = 0, x, n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x;
        if (x == maxx + 1) maxx = x;
    }
    if (maxx == 0) cout << -1;
    else cout << n - maxx;
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> a;
    for (int i = 1; i*(i+1) <= 10e5 * 2; i++){
        a.push_back(i*(i+1));
    }

    int x = N*2;
    int ans = -1;
    rep(i, a.size()){
        if(x == a[i]){
            ans = i+1;
        }
    }

    if(ans == -1){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        cout << ans + 1 << endl;
        vector<vector<int> > A(ans+1);
        int now = 1;
        for (int i = 0; i < ans+1-1; i++){
            for (int j = i+1; j < ans+1; j++){
                A[i].push_back(now);
                A[j].push_back(now);
                now++;
            }
        }
        rep(i, ans+1){
            cout << ans << " ";
            rep(j, ans){
                cout << A[i][j];
                if(j != ans-1){
                    cout << " ";
                }
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4288
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"8 13"# => r#"2"#,
r#"10 17"# => r#"11"#,
r#"54 65"# => r#"1"#,

}


fn solve(src: &str) -> String {
    input! {
        source = src,
        a: usize,
        b: usize,
    }
    let mut ans = 0;

    let mut v = vec![0; 999 + 1];
    for i in 1..v.len() {
        v[i] = v[i - 1] + i;
        if a < v[i - 1] && b < v[i] && v[i - 1] - a == v[i] - b {
            ans = v[i] - b;
            break;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
# input
L, R = map(int, input().split())

# define
nums = R - L + 1
mod = 2019
ans = float('inf')

# main
for i in range(L, R):
  for j in range(i+1, R+1):
    tmp = (i * j) % mod
    ans = min(ans, tmp)
    if tmp == 0:
      print(ans)
      exit()

# output
print(ans)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N = keyboard.nextInt();
		int[] ebi = new int[N];
		for(int i=0; i<N; i++) {
			ebi[i] = keyboard.nextInt();
		}
		Arrays.sort(ebi);
		
		int min = ebi[0];
		int Max = ebi[N-1];
		
		int kotae = 100000000;
		
		for(int j = min; j < Max + 1; j++) {
			int sum = 0;
			for(int k = 0; k < N; k++) {
			sum += Math.pow(ebi[k] - j , 2);
			}
			kotae = sum < kotae ? sum : kotae;
		}
		
		System.out.println(kotae);
		keyboard.close();
	}
}

Measured memory_bytes: 25172