akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(std::string S, std::string T){
    ll ans = 1e9;
    rep(si,S.size()){
        if(si + T.size() > S.size()) break;
        ll cnt = 0;
        rep(i, T.size()){
            if(T[i] != S[si+i]) cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;

}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3632
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N+10);
  for(int i = 1;i <= N;i++)cin >> A[i];

  vector<int> flag(N+10,0);
  flag[1]=1;
  bool hantei = true;
  int i = 1;
  ll owari = 0;
  while(hantei){
    if(flag[A[i]]==0){
      flag[A[i]]=1;
      i = A[i];
      owari++;
    }else{
      owari++;
      hantei = false;
    }
  }
  int j = A[i];
  int k = j;
  ll roop = 0;
  vector<int> flag2(N+10,1);
  while(flag2[k]){
    flag2[A[j]] = 0;
    roop++;
    j = A[j];
  }
/*
  cout << k << endl;
  cout << owari << "  " << roop << endl;
*/

  if(K<=owari){
    ll ans = 1;
    while(K>0){
      K--;
      ans = A[ans];
    }
    cout << ans << endl;
  }else{
    ll ans = k;
    ll kaisuu;
    kaisuu = (K-owari)%roop;
    while(kaisuu>0){
      kaisuu--;
      ans = A[ans];
    }
    cout << ans << endl;
  }


}


Measured memory_bytes: 6424
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a = 0;
	int b = 0;
	int c = 0;
	int aw = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++)
	{
		if (c % i == 0)
		{
			aw++;
		}
	}
	cout << aw << endl;
	
	return 0;
}

Measured memory_bytes: 3072
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())

mod = 10**9+7

cum = [i for i in range(10**6)]
def cumsum(lst): #元のリストを保持
    res = lst[:]
    for i in range(1,len(res)):
        res[i] += res[i-1]
    return res
cum = cumsum(cum)
def cumsumdif(l,r,lst): #求めたい差のインデックスを入れる
    if l == 0:
        return lst[r]
    else:
        return lst[r] - lst[l-1]

def reydeoro(n):
    return n*(n+1)//2

ans = 0
for i in range(k,n+1):
    ans += cum[n] -cum[n-i] - cum[i-1] + 1 #+1:al自体を含むため
    ans %= mod

print((ans+1)%mod) #k = n+1のとき

Measured memory_bytes: 151700
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int n;
double dp[310][310][310];

double recur(int a, int b, int c) {
	if(!(a+b+c)) return 0;
	if(dp[a][b][c] > -.5) return dp[a][b][c];
	dp[a][b][c] = 0;
	double step = (double)n/(a+b+c), sm = a+b+c;
	if(a) dp[a][b][c] += (recur(a-1, b, c)+step)*a/sm;
	if(b) dp[a][b][c] += (recur(a+1, b-1, c)+step)*b/sm;
	if(c) dp[a][b][c] += (recur(a, b+1, c-1)+step)*c/sm;
	return dp[a][b][c];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	vector<int> m(4); forl(i, 0, n) { int t; cin >> t; m[t]++; }
	forl(i, 0, 310) forl(j, 0, 310) forl(k, 0, 310) dp[i][j][k] = -1;
	cout << setprecision(100) << recur(m[1], m[2], m[3]) << endl;
}


Measured memory_bytes: 233088
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}

	//dp[i] = iマス目にたどりつくための最小コスト
	dp := make([]int, n)

	// 1マス目は0
	dp[0] = 0
	// 2マス目はh[1]-h[0]
	dp[1] = int(math.Abs(float64(h[1] - h[0])))

	for i := 2; i < n; i++ {
		// 1マス前から移動したときの最小コスト
		step1 := dp[i-1] + int(math.Abs(float64(h[i]-h[i-1])))
		// 2マス前から移動したときの最小コスト
		step2 := dp[i-2] + int(math.Abs(float64(h[i]-h[i-2])))
		// 小さい方をdp[i]として採用する
		dp[i] = int(math.Min(float64(step1), float64(step2)))
	}

	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2688
#include<stdio.h>

void output(int A[],int N){
 int i;
 for(i=0;i<N;i++){
  if(i>0)printf(" ");
  printf("%d",A[i]);
  }
 printf("\n");
}
 
void insertionSort(int A[], int N){
 int j,i,v;
 for(i=1;i<N;i++){
  v=A[i];
  j=i-1;
  while(j>=0 && A[j]>v){
   A[j+1]=A[j];
   j--;
   }
  A[j+1]=v;
  output(A,N);
 }
}
 
int main(void){
 int N,i,j;
 int A[100];
 
 scanf("%d",&N);
 for(i=0;i<N;i++)scanf("%d",&A[i]);
 
 output(A,N);
 insertionSort(A,N);
  
 return 0;
}
 

 

Measured memory_bytes: 2692
a,b,c,d=gets.chomp.split.map(&:to_i)
counter1=0
counter2=0
if c%b==0
  counter1 = c/b
else 
  counter1 = c/b+1
end
if a%d==0
  counter2 = a/d
else 
  counter2 = a/d+1
end
if counter1<= counter2
  puts "Yes"
else
  puts "No"
end  

Measured memory_bytes: 14280
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

fn main() {
    let mut reader = TokenReader::new();
    let price = reader.next::<i32>();
    let bills = (price + 999) / 1000;
    let change = bills * 1000 - price;
    println!("{}", change);
}


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

int main() {
    string n;
    cin >> n;
    for(int i=0;i<3;i++){
        if(n[i]=='9'){n[i]='1';}
        else{n[i]='9';}
    }
    cout << n << endl;
return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back

#define PI 3.14159265358979323846
#define N 100000
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	map<string, int> mi;

	int n;
	cin >> n;;
	string s;
	for (int i = 0; i < n; ++i)
	{
		cin >> s;
		mi[s]++;
	}

	int ma = 0;
	for(auto e : mi)
		ma = max(ma, e.ss);

	vector<string> v;
	for(auto e : mi)
		if (e.ss == ma)
			v.pb(e.ff);

	for(auto e : v)
		cout << e << "\n";
	return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}


template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    cout << string(tx-sx, 'R') << string(ty-sy, 'U');
    cout << string(tx-sx, 'L') << string(ty-sy, 'D');
    cout << 'D' << string(tx-sx+1, 'R') << string(ty-sy+1, 'U') << 'L';
    cout << 'U' << string(tx-sx+1, 'L') << string(ty-sy+1, 'D') << 'R';
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
class Solution:
    def solve(self, n: int, s: str, t: str) -> str:

        ans = ''
        for i in range(n):
            ans += s[i] + t[i]

        return ans


if __name__ == '__main__':

    # standard input
    n = int(input())
    s, t = input().split()

    # solve
    solution = Solution()
    print(solution.solve(n, s, t))


Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int n, k;

int main(){
	while(1){
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) break;

		vector<string> v;
		set<string> num;
		for(int i=0; i<n; i++){
			char tmp[3];
			scanf("%s", tmp);
			v.push_back(tmp);
		}
		sort(v.begin(), v.end());

		do{

			string tmp = "";
			for(int i=0; i<k; i++)
				tmp += v[i];
			num.insert(tmp);

		}while(next_permutation(v.begin(), v.end()));

		printf("%lu\n", num.size());
	}
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

ll dp[110][100010];

int main() {
    ll N, W; cin >> N >> W;
    vector<ll> w(N);
    vector<ll> v(N);
    rep(i, N) cin >> w.at(i) >> v.at(i);
    
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i][j] = dp[i+1][j];
            }
            else {
                dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
            }
        }
    }

    cout << dp[0][W] << endl;
}

Measured memory_bytes: 81724
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int x2 = sc.nextInt();
        int x3 = sc.nextInt();
        int x4 = sc.nextInt();
        int x5 = sc.nextInt();
        
        if (x1 == 0) {
            System.out.println(1);
        } else if (x2 == 0) {
            System.out.println(2);
        } else if (x3 == 0) {
            System.out.println(3);
        } else if (x4 == 0) {
            System.out.println(4);
        } else if (x5 == 0) {
            System.out.println(5);
        }
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  printf("%s\n", (s < t) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


int dp[(int)1e5+1][13];

int MOD = 1e9+7;

int main(){
  string S;
  cin >> S;
  int N = sz(S);
  reverse(S.begin(), S.end());
  if(S[0] == '?'){
    rep(i, 10){
      dp[0][i] = 1;
    }
  }else{
    int idx = S[0] - '0';
    dp[0][idx] = 1;
  }

  int num = 1;
  for(int i=1; i<N; i++){
    num *= 10;
    num %= 13;
    if(S[i] == '?'){
      rep(k, 13){
        rep(j, 10){
          int r = (j*num + k) % 13;
          dp[i][r] += dp[i-1][k];
          dp[i][r] %= MOD;
        }
      }
    }else{
      rep(k, 13){
        int j = S[i] - '0';
        int r = (j*num + k)%13;
        dp[i][r] += dp[i-1][k];
        dp[i][r] %= MOD;
      }
    }
  }

  cout << dp[N-1][5] << endl;

  return 0;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
// nCk
int64_t nCk(int64_t a, int64_t b){
  int64_t c = 1;
  for(int i=1; i<=b; i++){
    c *= a +1 - i;
    c /= i;
  }
  return c;
}


int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.rbegin(),vec.rend());
  int64_t sum = 0;
  int64_t cnt = 0;
  int64_t begin = 100;
  int64_t end = -1;
  for(int64_t i=0; i<N; i++){
    if(i < A){
      sum += vec.at(i);
    }
    if(vec.at(i) == vec.at(A-1)){
      cnt++;
      begin = min(begin,i);
      end = i+1;
    }
  }
  
  cout << setprecision(20) << (double)sum / (double)A << endl;
  int64_t ans = 0;
  if(vec.at(0) != vec.at(A-1)){
    ans = nCk(cnt,A-begin);
  }
  else{
    for(int i=A; i<=B; i++){
      if(vec.at(i-1) != vec.at(A-1)){
        break;
      }
      ans += nCk(end,i);
    }
  }
  cout << ans << endl;
}  

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int A, B, C, D;

	cin >> A >> B >> C >> D;
	if (C <= A) {
		if (D <= A) cout << 0 << endl;
		else if (A < D && D < B) cout << D - A << endl;
		else if(D >= B)     cout << B - A << endl;
	}
	else if (A < C && C < B) {
		if (D <= B) cout << D - C << endl;
		else if(D >=B)  cout << B - C << endl;
	}
	else 
		cout << 0 << endl;

		return 0;
	}














Measured memory_bytes: 256
# include <bits/stdc++.h>
# define f first
# define s second

using namespace std;

const int N = 1e6;

long long n, x, y, ans;
pair <long long, long long> a[N], b[N];

int main(){
      scanf("%lld", &n);
      for(int i = 1;i <= n;i ++){
             scanf("%lld %lld", &a[i].f, &a[i].s);
             if(a[i].f > a[i].s)
                 swap(a[i].s, a[i].f);
             b[i].f = a[i].s, b[i].s = a[i].f;
      }

      sort(b + 1, b + n + 1);
      sort(a + 1, a + n + 1);

      ans = (a[n].f - a[1].f) * (b[n].f - b[1].f);
      long long r = a[n].f, l = 1e9;
      for(int i = 1;i < n;i ++){
             l = min(a[i].s, l);
             r = max(r, a[i].s);
             ans = min(ans, (b[n].f - a[1].f) * (r - min(l, a[i + 1].f)));
      }
      cout << ans;
}


Measured memory_bytes: 10624
from operator import itemgetter

N = int(input())

book = []

for i in range(N):
  s, p = input().split()
  book.append([i,s,int(p)])

book = sorted(book, key = itemgetter(2), reverse = True)
book = sorted(book, key = itemgetter(1))

for num in book:
  print(int(num[0])+1)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 110;

int main() {
	int n;
	cin >> n;
	int a[N];
	rep(i, n) cin >> a[i];
	int sum_a = 0;
	int ans = INF;
	for(int i = -100; i <= 100; i++) {
		sum_a = 0;
		rep(j, n) {
			sum_a += pow((a[j] - i), 2);
		}
		ans = min(sum_a, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, K = rl()
answer = 0
if K == 0:
    print(N**2)
    exit()
for b in range(K+1, N+1):
    x = N // b
    answer += x * (b-K) + max(0, (N-(x*b))-K+1)
    #print(answer)

print(answer)
#59


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> price(n);
  rep(i,n) cin >> price[i];
  sort(price.begin(),price.end());
  int ans = 0;
  rep(i,n) {
    if(i == n-1) ans += price[i]/2;
    else ans += price[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

#define MAX 8

using namespace std;
bool field[9][9];
int x, y;

char solve(){
  if(x+1 < MAX && y+1 < MAX && field[y][x+1] && field[y+1][x] && field[y+1][x+1]) return 'A';
  else if(y+3 < MAX && field[y+1][x] && field[y+2][x] && field[y+3][x]) return 'B';
  else if(x+3 < MAX && field[y][x+1] && field[y][x+2] && field[y][x+3]) return 'C';
  else if(x-1 >= 0 && y+2 < MAX &&field[y+1][x] && field[y+1][x-1] && field[y+2][x-1]) return 'D';
  else if(x+2 < MAX && y+1 < MAX &&field[y][x+1] && field[y+1][x+1] && field[y+1][x+2]) return 'E';
  else if(x+1 < MAX && y+2 < MAX &&field[y+1][x] && field[y+1][x+1] && field[y+2][x+1]) return 'F';
  else if(x-1 >= 0 && y+1 < MAX &&field[y][x+1] && field[y+1][x-1] && field[y+1][x]) return 'G';
}


int main(){
  string tmp[8];
  
  while(cin >> tmp[0] >> tmp[1] >> tmp[2] >> tmp[3] >> tmp[4] >> tmp[5]
	>> tmp[6] >> tmp[7]){
    bool flag = 0;
    
    for(int i = 0 ; i < 8 ; i++){
      for(int j = 0 ; j < 8 ; j++){
	field[i][j] = tmp[i][j] - '0';
      }
    }
    
    for(y = 0 ; y < 8 ; y++){
      for(x = 0 ; x < 8 ; x++){
	if(field[y][x] && !flag){
	  cout << solve();
	  flag = 1;
	}
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n, k = map(int,input().split())
d = list(map(str, input().split()))
d_n = [i for i in range(10) if i not in d]

def search(x):
    count = 0
    for i in d:
        if str(x).find(i) == -1:
            count += 1
    if len(d) == count:
        return True
while True:
   if search(n):
       break
   else:
       n += 1
print(n)
       



Measured memory_bytes: 3060
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-09-23 05:32:29
*/

#include <iostream>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

int main()
{
    int a, b;
    cin >> a >> b;

    cout << a*b << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> S(N);
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  vector<int> T(M);
  for (int i = 0; i < M; i++){
    cin >> T[i];
  }
  vector<vector<long long>> dp(N + 1, vector<long long>(M + 1, 0));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      dp[i + 1][j + 1] += dp[i + 1][j];
      dp[i + 1][j + 1] += dp[i][j + 1];
      if (S[i] == T[j]){
        dp[i + 1][j + 1] ++;
      } else {
        dp[i + 1][j + 1] += MOD - dp[i][j];
      }
      dp[i + 1][j + 1] %= MOD;
    }
  }
  cout << (dp[N][M] + 1) % MOD << endl;
}

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

int main(){
    string X;
    cin >> X;
    int digit_sum = 0;
    for(int i = 0; i < X.size(); i++){
        digit_sum += X[i] - '0';
    }
    if(stoi(X) % digit_sum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


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

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

using namespace std;

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

	int cnt=0,def=0;
	rep(i,n){
		if(s[i]=='(') cnt++;
		else cnt--;
		if(cnt<0) cnt=0, def++;
	}
	cout<<string(def,'(')+s+string(cnt,')')<<endl;

	return 0;
}


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

using namespace std;

#define lli long long int

#define ulli unsigned long long int

#define Pi 3.14159265358979323846264338327950288419716939937510

int main(){
	
    ios :: sync_with_stdio(false);
   
    //ifstream cin; ofstream cout; cin.open("input.txt"); cout.open("output.txt");
    
    int n;
    
    cin>>n;
    
    vector <lli> a(n);
    
    map <lli,lli> c;
    
    lli total = 0;
    
    for(int i=0; i<n; i++){
    	
    	cin>>a[i];
    	
    	c[a[i]]++;
	}
	
	for(auto &i : c){
		
		total += (i.second*(i.second-1))/2;
	}
	
	for(int i=0; i<n; i++){
		
		lli x = c[a[i]];
		
		cout<<total+1-x<<endl;
	}
}

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

using namespace std;

const int N = 1e5 + 7;

int a[4][N], f[4][N], n;

int main()
{
    //freopen("C.inp","r",stdin);
    //freopen("C.out","w",stdout);

    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[1][i] >> a[2][i] >> a[3][i];

    f[1][1] = a[1][1];
    f[2][1] = a[2][1];
    f[3][1] = a[3][1];

    for(int i = 2; i <= n; i++)
    {
        f[1][i] = max(f[2][i - 1], f[3][i - 1]) + a[1][i];
        f[2][i] = max(f[1][i - 1], f[3][i - 1]) + a[2][i];
        f[3][i] = max(f[1][i - 1], f[2][i - 1]) + a[3][i];
    }

    cout << max(f[1][n], max(f[2][n], f[3][n]));
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())

L = []; R = []
for _ in range(m):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxL = max(L)
minR = min(R)

ans = max(0, minR-maxL+1)
print(ans)

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

#define max(a,b) (a > b ? a : b)
int tx[101];

int main(){
	int a, b, n;
	bool f;
	while(cin >> a >> b) {
		n = 0;
		f = false;
		fill(tx, tx + 101, 0);
		while (a != 0) {
			tx[a]++;
			tx[b]++;
			n = max(n, max(a, b));
			cin >> a >> b;
		}
		if (tx[1] % 2 != 0 && tx[2] % 2 != 0) {
			for (int i = 3; i <= n; i++) {
				if (tx[i] % 2 != 0) {
					f = true;
					break;
				}
			}
		}
		else {
			f = true;
		}
		if (f) {
			cout << "NG" << endl;
		}
		else {
			cout << "OK" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3044
import sys

#UnionFindTreeクラスの定義
class UnionFind():
    #クラスコンストラクタ
    #selfはインスタンス自身
    def __init__(self, n):
        #親ノードを-1に初期化する
        self.parents = [-1] * n

    #根を探す（再帰関数）
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    #xとyの木を併合する
    def union(self, x, y):
        #x,yの根をX,Yとする
        X = self.find(x)
        Y = self.find(y)

        #根が同じなら結合済み
        if X == Y:
            return

        #ノード数が多い方をXとする
        if self.parents[X] > self.parents[Y]:
            X, Y = Y, X

        #XにYのノード数を足す
        self.parents[X] += self.parents[Y]
        #Yの根をXとする
        self.parents[Y] = X


N, M = map(int, input().split())
info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]

#UnionFindインスタンスの生成
uf = UnionFind(N)
for a, b in info:
    #インデックスを調整し、a,bの木を結合
    a -= 1; b -= 1
    uf.union(a, b)

ans = min(uf.parents)

print(-ans)

Measured memory_bytes: 50220
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


public class AtCoder {
    static string[] S = new string[3];
    static void Main() {
        int te = 0;
        var D = new Dictionary<char, int>();
        D.Add('a', 0);
        D.Add('b', 1);
        D.Add('c', 2);
        char[] c = { 'A', 'B', 'C' };
        for(int i = 0; i < 3; i++) {
            S[i] = Console.ReadLine();
        }
        while (true) {
            int t = te;
            
           
            string s;
            if (S[t].Length > 1) {
                te = D[S[t][0]];
                s = S[t].Substring(1);
                S[t] = s;
            }

            else if(S[t].Length==1){
                te = D[S[t][0]];
                S[t] = "";
            }
            else {
                Console.WriteLine(c[t]);
                return;
            }
        }
    }
}

Measured memory_bytes: 3160
#include<stdio.h>
#include<string.h>
#define NUM 1000000
#define NAME 10



int main(){
  int i,q,time,n,j=0,sum=0,count=0;
  int a[NUM];
  char str[NUM][NAME];

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

  while(count!=n){
    time=a[j]-q;
    a[j]+=sum;
    if(time<=0){
      printf("%s %d\n",str[j],a[j]);
      count++;
      sum+=(q+time);
    }
    else if(time>0){
	a[i]=time;
	strcpy(str[i],str[j]);
	i++;
	sum+=q;
    }

    
    j++;
  }
  

  return 0;
}



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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define PF push_front
#define PB push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())
#define ALL(v) (v).begin(), (v).end()

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in() {int x; std::cin >> x; return x;}
 
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

int gcd(int a, int b){ int c; while (a != 0){ c = a; a = b % a; b = c; } return b; }

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

  int a = in(), b = in(), h = in();
  cout << (a + b) * h / 2;

  return (0);
}


Measured memory_bytes: 256
while line = gets
    a, l, x = line.chomp.split.map(&:to_i)
    h = Math.sqrt(l ** 2 - (a ** 2 / 4.0))
    result = a * h / 2
    s = (l + l + x) / 2.0
    result += 2 * Math.sqrt(s * (s - l) *(s - ((l + x) / 2.0)) * (s - ((l + x) / 2.0)))
    puts result
end



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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int total = r * 100 + g * 10 + b;
  if (total % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3552
#include <iostream>
using namespace std;
int n,m;
int p[100005];
int find(int x){
	if(x!=p[x])
	  p[x]=find(p[x]);
	return p[x];
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)p[i]=i;
	int a,b,c,f_a,f_b,ans=0;
	while(m--){
		cin>>a>>b>>c;
		f_a=find(a);
		f_b=find(b);
		if(f_a!=f_b)
		  p[f_a]=f_b;
	}
	for(int i=1;i<=100005;i++)
	   if(i==p[i])
	     ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N;
    cin >> N;
    string s;
    cin >> s;
    vector<ll> m_cnt(N+1);
    rep(n,1,N+1) {
        m_cnt[n] = m_cnt[n-1];
        if (s[n-1] == 'M') {
            m_cnt[n]++;
        }
    }
    vector<ll> c_cnt(N+1);
    rep(n,1,N+1) {
        c_cnt[n] = c_cnt[n-1];
        if (s[n-1] == 'C') {
            c_cnt[n]++;
        }
    }
    vector<ll> mc_cnt(N+1);
    rep(n,1,N+1) {
        mc_cnt[n] = mc_cnt[n-1];
        if (s[n-1] == 'C') {
            mc_cnt[n] += m_cnt[n];
        }
    }
    ll Q;
    cin >> Q;
    rep(i,0,Q) {
        ll k;
        cin >> k;
        ll ans = 0;
        rep(i,0,N) {
            if (s[i] != 'D') {
                continue;
            } else {
                ll e = min(i+k, N);
                ans += (mc_cnt[e] - mc_cnt[i]) - (c_cnt[e] - c_cnt[i]) * m_cnt[i];
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 26868
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int n,m;
    cin>>n>>m;
    int r=n,l=0;
    rep(i,m)
    {
        int tl,tr;
        cin>>tl>>tr;
        if(tr<l || r<tl)
        {
            cout<<0<<endl;
            return 0;
        }
        if(tl>l)l=tl;    
        if(tr<r)r=tr;
    }
    cout<<r-l+1<<endl;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define SIZE 100005
#define MOD 1000000007

using namespace std;
typedef long long int ll;

int pos[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&pos[i]);
	int to=0;
	ll ret=1;
	for(int i=0;i<n;i++)
	{
		while(to<n&&pos[to]>=2*(to-i+1)-1) to++;
		ret=ret*(ll) (min(n,to+1)-i)%MOD;
		//printf("%d\n",to);
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 
void solve(){
	ll x;
	cin>>x;
	if(x==0){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}    
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	vvi A(3, vi(3));
	rep(i, 3) rep(j, 3) cin >> A.at(i).at(j);
	// dbvv(A);
	int N; cin >> N;
	vector<vector<bool>> f(3, vector<bool>(3));	
	rep(i, N) {
		int b; cin >> b;
		rep(i, 3) rep(j, 3) {
			if (A.at(i).at(j) == b) f.at(i).at(j) = true;
		}		
	}
	// dbvv(f);
	bool g = false;	
	rep(i, 3) {
		if (f.at(i).at(0) && f.at(i).at(1) && f.at(i).at(2)) g = true;		
	}
	rep(j, 3) {
		if (f.at(0).at(j) && f.at(1).at(j) && f.at(2).at(j)) g = true;
	}
	if (f.at(0).at(0) && f.at(1).at(1) && f.at(2).at(2)) g = true;
	if (f.at(0).at(2) && f.at(1).at(1) && f.at(2).at(0)) g = true;	
	Yn(g);	
}

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

using namespace std;

int main(){
    int n, sum = 0, k = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        if (a[i]%10 == 0){
            k++;
        }
    }
    sort (a, a+n);

    if (sum%10 == 0 && k == n){
        sum = 0;
        cout << sum;
    }else if (sum%10 != 0){
        cout << sum;
    }else{
        for (int i = 0; i < n; i++){
            if (a[i]%10 == 0){
                continue;
            }else{
                sum -= a[i];
                cout << sum;
                break;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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 dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;

  for (int i = 0; i < n; i++) {
    if (i > 0 && a[i-1] != 0 && a[i] != 0) {  // 前の数字とペアを作る
      if (a[i-1] >= a[i]) {
        ans += a[i];
        a[i-1] -= a[i];
        a[i] = 0;
      } else {
        ans += a[i-1];
        a[i] -= a[i-1];
      }
    }
    if (a[i] >= 2) {   // 自分でペアを作る
      ans += a[i] / 2;
      a[i] = a[i] % 2;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3952
#include<stdio.h>
int main(){
  int a,b;
  int d,r;
  double f;

  while(1){
    scanf("%d%d",&a,&b);
    if(1<=a && b<=1000000000) break;
  }

  d = a/b;
  r = a%b;
  f = (double)a/b;

  printf("%d %d %.5f\n",d,r,f);
  return 0;
}

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

#define FOR(i, j, k) for(int i=j; i<k ; i++)
#define RFOR(i, j, k) for(int i=j; i>k ; i--)
#define REP(i, j) FOR(i, 0, j)
#define RREP(i, j) RFOR(i, j-1, -1)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;
    vi x(N); REP(i, N) cin >> x[i];
    vvi a(N, vi(20, 0));

    REP(j, 20) a[0][j] = (x[0] >> j) & 1;
//    FOR(i, 0, N) REP(j, 20) cout << x[i] << " " << j << " " <<  ((x[i] >> j) & 1) << endl;
    FOR(i, 1, N) REP(j, 20) a[i][j] = (x[i] >> j) & 1;
    FOR(i, 1, N) REP(j, 20) a[i][j] += a[i-1][j];
//    REP(i, N) REP(j, 20) cout << x[i] << " " << j << " " << a[i][j] << endl;

    int s = 0, t = 0;
    ll ans = 0;
    while(t < N) {
        bool is_success = true;
        REP(i, 20) {
            if (s == 0) {
                if (a[t][i] > 1) {is_success = false; break;}
            } else if (a[t][i] - a[s-1][i] > 1) {is_success = false; break;}
        }

        if (is_success) {
            ans += t - s + 1;
//            cout << s << " " << t << endl;
            t++;
        } else {
            s++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 24448
#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;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

string s[100];
int t[100];
int main(){
	int n;cin>>n;
	rep(i,n){
		cin>>s[i]>>t[i];
	}
	string x;cin>>x;
	int sum=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]==x)break;
		sum+=t[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<vector<int> > ID;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int solve(){
	string s;
	vector<string> cur,next;
	cin >> s;
	if(s=="#")return 1;
	cur.pb(s);
	for(int t=25;t>0;t--){
		for(int c=0;c<cur.size();c++){
			string str = cur[c];
			vector<int> idx;
			bool flag = false;
			for(int i=0;i<str.size();i++){
				if(str[i]==((char)('a'+t-1)))idx.pb(i);
				if(str[i]==((char)('a'+t))){
					flag = true;
					break;
				}
			}
			for(int i=0;i<idx.size();i++){
				string ns = str;
				ns[idx[i]]=((char)('a'+t));
				next.pb(ns);
			}
			if(flag==false)next.pb(str);
		}
		swap(cur,next);
		next.clear();
	}
	sort(all(cur));
	int ans = cur.size();
	cout << ans << endl;
	if(ans<=10){
		for(int i=0;i<ans;i++){
			cout << cur[i] << endl;
		}
	}else{
		for(int i=0;i<5;i++)cout << cur[i] << endl;
		for(int i=5;i>=1;i--)cout << cur[ans-i] << endl;
	}
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

Measured memory_bytes: 5032
import java.util.*;
import java.lang.*;
import java.io.*;
import java.awt.Point;

class Main
{

    private static final int[] dx = {0,1,1,0,-1,-1};
    private static final int[] dy = {1,1,0,-1,-1,0};

    private static class Pox implements Comparable<Pox>
    {
	public Point p;
	public int cnt;

	Pox()
	{
	    p = new Point(-1,-1);
	    cnt = 0;
	}

	Pox(int x,int y,int c)
	{
	    p = new Point(x,y);
	    cnt = c;
	}


	public int compareTo(Pox a)
	{
	    return -1;
	}


    }

      public static void main(String args[])throws IOException
    {
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	while(true)
	    {
		String line;
		line = in.readLine();
		int t,n;		t = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		n = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		if(t == 0 && n == 0)
		    break;
		HashMap<Point,Boolean> map = new HashMap<Point,Boolean>();

		for(int i=0;i<n;i++)
		    {
			int X,Y;
			line = in.readLine();
			X = Integer.parseInt(line.substring(0,line.indexOf(" ")));
			Y = Integer.parseInt(line.substring(line.indexOf(" ")+1));
			map.put(new Point(X,Y),true);
		    }

		int sx,sy;
		line = in.readLine();
		sx = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		sy = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		Queue<Pox> que = new PriorityQueue<Pox>();
		que.offer(new Pox(sx,sy,0));
		map.put(new Point(sx,sy),false);

		int[][] used = new int[400][400];

		for(int i=0;i<200;i++)
		    for(int j=0;j<200;j++)
			used[i][j] = 10000000;
		used[sy+100][sx+100] = 0;

		int counter = 1;
		while(que.size() > 0)
		    {
			Pox pox = que.poll();

			if(pox.cnt >= t)
			    {
				continue;
			    }

			for(int i=0;i<6;i++)
			    {
				int nx = pox.p.x + dx[i],ny = pox.p.y + dy[i];
				//if(!(Math.abs(nx) <= 30 && Math.abs(ny) <= 30))
				//continue;

				if(map.containsKey(new Point(nx,ny)))
				    {
					if(map.get(new Point(nx,ny)))
					    continue;
				    }
			
				if(used[ny+100][nx+100] <= pox.cnt)
				    continue;

				used[ny+100][nx+100] = pox.cnt;		        
				map.put(new Point(nx,ny),false);
				que.offer(new Pox(nx,ny,pox.cnt+1));
			    }

		    }
		System.out.println(map.size()-n);
	    }
    }

}

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

using namespace std;

int main(){
    long long int N,ans=0,now=0;
    cin >> N;
    vector<long long int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

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

    if(N%2==0){
        for(int i=N-1;N/2<=i;i--){
            ans += A[i];
        }

        for(int i=N/2;i<N-1;i++){
            ans += A[i];
        }
    }else{
        for(int i=N-1;N/2<i;i--){
            ans += A[i];
        }

        for(int i=N/2;i<N-1;i++){
            ans += A[i];
        }
    }

    
 
    cout << ans << endl;
}

Measured memory_bytes: 4852
#include <iostream>

using namespace std;

int main(void){
  char b;
  cin >> b;
  char array[26];

  array['A'-'A'] = 'T';
  array['T'-'A'] = 'A';
  array['C'-'A'] = 'G';
  array['G'-'A'] = 'C';

  cout << array[b-'A'] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 11:32-

            int n = sc.nextInt();
            int l = sc.nextInt();

            int sum = 0;
            int min = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                sum += l + i;
                if (Math.abs(min) > Math.abs(l + i)) min = l + i;
            }

            out.println(sum - min);
        }
    }
}


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

sa = m[1] - m[0]
flag = 0
hantei = m[0]

if sa == 0:
    if m[0] % n == 0:
        print("OK")
        exit()
    else:
        print("NG")
        exit()

if hantei % n == 0:
    flag += 1

for x in range(sa):
    hantei = (x + 1) + m[0]
    if hantei % n == 0:
        flag += 1

if flag >= 1:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 61884
n, m, l = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
b = [[int(j) for j in input().split()] for k in range(m)]

for i in range(n):
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += a[i][k]*b[k][j]
        print(sum, end="")
        if j != l - 1:
            print(' ', end="")
    print()



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

int main(){
  int a, b, c;
  cin  >> a >> b >> c;

  if(a<b){
    if(b<c){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = Integer.parseInt(sc.next());
    Set<String> hs = new HashSet<>();
    for(int i = 0; i < x; i++){
      String s = sc.next();
      String a = sc.next();
      if(s.equals("insert")){
        hs.add(a);
      }
      else if(s.equals("find")){
        if(hs.contains(a)){
          System.out.printf("yes\n");
        }
        else{
          System.out.printf("no\n");
        }
      }
    }
  }
}


Measured memory_bytes: 333572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    string S;
    cin >> S;
    int n = S.size();
    map<char, bool> M;
    rep(i, n)
    {
        M[S[i]] = true;
    }
    rep(i, 26)
    {
        if (M.count('a' + i) == 0)
        {
            cout << (char)('a' + i);
            return 0;
        }
    }
    cout << "None";
    return 0;
}

Measured memory_bytes: 512
import Numeric

mean :: Floating a => [a] -> a
mean xs = sum xs / (fromIntegral $ length xs)

var :: Floating a => [a] -> a
var xs = mean [x ** 2| x <- xs] - mean xs ** 2

stddev :: Floating a => [a] -> a
stddev = sqrt . var

main :: IO ()
main = do
  n <- readLn
  if n == 0 then return () else do
    s <- fmap (map read . words) getLine
    putStrLn $ showFFloat Nothing (stddev s) ""
    main

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

int main() {
  int N, M, T[100], P[100], X[100];
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> T[i];
  }
  cin >> M;
  for (int i = 0; i < M; ++i) {
    cin >> P[i] >> X[i];
  }
  for (int i = 0; i < M; ++i) {
    int sum = 0;
    for (int j = 0; j < N; ++j) {
      sum += P[i] - 1 == j ? X[i] : T[j];
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::cmp::min;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();

    let count_minus = a.iter().filter(|&&x| x < 0).count();
    let sum: i64 = a.iter().map(|&x| x.abs()).sum();
    let ans = sum - if count_minus % 2 == 0 {
        0
    } else {
        let mut min_i = a[0].abs();
        for a_i in a {
            min_i = min(min_i, a_i.abs());
        }
        min_i*2
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4476