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

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;

int n;
int a[maxn], dp[maxn];
int main() {
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
const int BUF = 200005;


int nVal, val[BUF];

void read() {
    cin >> nVal;
    for (int i = 0; i < nVal; ++i) cin >> val[i];
}


void work() {
    int cnt = 1;
    for (int i = 0; i < nVal; ++i) {
        if (val[i] == cnt) {
            ++cnt;
        }
    }

    cout << (cnt == 1 ? -1 : nVal - cnt + 1) << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 1024
ss = input()
m = 0
for start in range(len(ss)//2):
    for end in range(start, len(ss) - 1):
        if len(ss[start:end]) > 0:
            if ss[start:end] == ss[end:2*end - start]:
                if (2*end - start) < len(ss):
                    m = max(m, 2*len(ss[start:end]))
print(m)

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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		int x = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		
		long[] cost = new long[n];
		for (int i = 0; i < n; i++) {
			int best = Integer.MAX_VALUE;
			
			for (int j = 0; j < n; j++) {
				int now = (i + n - j) % n;
				best = Math.min(best, a[now]);
				cost[j] += best;
			}
		}
		
		long outp = Long.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			outp = Math.min(outp, cost[i] + (long)i * x);
		}
		
		out.println(outp);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 9296
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		
		for(int i=0; i<M; i++){
			N -= Integer.parseInt(sc.next());
		}
	
		if(N >= 0) {
			System.out.println(N);
		} else {
			System.out.println(-1);
		}
		
	}

}

Measured memory_bytes: 41476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  int B = N % 500;
 
  if (B > A) {
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
}
  
}

Measured memory_bytes: 256
fn main() {
    let n = read::<usize>();
    let v = read_vec::<usize>();

    let mut index = 1;
    for i in 0..n {
        if v[i] == index {
            index += 1;
        }
    }

    if index == 1 {
        println!("-1");
    } else {
        println!("{}", n-(index-1));
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define int ll
void test_case(){
	int n,m,x; cin >> n >> m >> x;
	vector<int> a(n),b(m);
	for(auto &y : a)
		cin >> y;
	for(auto &y : b)
		cin >> y;
	int sum=0,count=0,i=0,j=0;        
        while(i<n && sum+a[i]<=x){    
            sum+=a[i];
            i++;
        }
        count=i;        
       
        while(j<m && i>=0){            
            sum+=b[j];             
            j++;
            while(sum>x && i>0){
                i--;
                sum-=a[i];
            }
            if(sum<=x && i+j>count)
                count=i+j;
        }
        cout<<count<<endl;
    } 
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 6308
import java.io.*;
import java.util.*;
 
public class Main{
    
    public static void main(String[] args) throws IOException {
        Reader.init();
        long N=Reader.nextLong();
      	long A=Reader.nextLong();
      	long B=Reader.nextLong();
        
      	if((B-A)%2==0){
      	  	println((B-A)/2);
        }
      	else{
          	long res=0;
          	if((A-1)<(N-B)){
            	res+=A-1;
              	A=1;
              	B=B-res;
              	B--;
              	res++;
              	res+=(B-A)/2;
            }
          	else{
            	res+=N-B;
              	B=N;
              	A=A+res;
              	A++;
              	res++;
              	res+=(B-A)/2;
            }
          	println(res);
        }
    }
    
    static int mod=1000000007;
    public static void read(int arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextInt(); } }
    public static void read(long arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.nextLong(); } }
    public static void read(String arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=Reader.next(); } }
    public static void print(Object O){ System.out.print(O); }
    public static void println(Object O){ System.out.println(O); }
    public static void display(int arr[]){ System.out.println(Arrays.toString(arr)); }
    public static void display(int arr[][], int N){ for(int i=0;i<N;i++){ System.out.println(Arrays.toString(arr[i])); } }
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
 
    static void init() {
        reader=new BufferedReader(new InputStreamReader(System.in));
        tokenizer=new StringTokenizer("");
    }
 
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) {
            tokenizer=new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
 
    static int nextInt() throws IOException { return Integer.parseInt(next()); }
    static double nextDouble() throws IOException { return Double.parseDouble(next()); }
    static long nextLong() throws IOException { return Long.parseLong(next()); }
    static String nextLine() throws IOException { return reader.readLine(); }
}

Measured memory_bytes: 23252
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

const INF: usize = std::usize::MAX;
macro_rules !min {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::min ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::min ($a ,min !($($rest ) ,+) ) } } ;}

#[fastout]
fn main() {
   input! {
      n: usize,
      mut t: [usize; n],
      mut v: [usize; n]
   }
   for i in 0..n {
      t[i] *= 2;
      v[i] *= 2;
   }
   for i in 0..n - 1 {
      t[i + 1] += t[i];
   }

   let mut l = vec![INF; t[n - 1] + 1];
   for i in 0..n - 1 {
      l[t[i]] = i;
   }
   l[0] = 0;
   for tn in 1..=t[n - 1] {
      if l[tn] != INF {
         l[tn] = std::cmp::min(l[tn - 1] + 1, v[l[tn]]);
      } else {
         l[tn] = l[tn - 1] + 1;
      }
   }

   let mut r = vec![INF; t[n - 1] + 1];
   for i in 1..n {
      r[t[i - 1]] = i;
   }
   r[t[n - 1]] = 0;
   for tn in (0..t[n - 1]).rev() {
      if r[tn] != INF {
         r[tn] = std::cmp::min(r[tn + 1] + 1, v[r[tn]]);
      } else {
         r[tn] = r[tn + 1] + 1;
      }
   }

   let mut m = vec![INF; t[n - 1] + 1];
   let mut tr = 0;
   for i in 0..n {
      for tn in tr..=t[i] {
         m[tn] = v[i];
      }
      tr = t[i];
   }

   let mut ans = 0;
   for tn in 0..=t[n - 1] {
      ans += 2 * min!{l[tn], r[tn], m[tn]};
   }
   println!("{}", (ans as f64) / 8.0);
}


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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  s.at(k-1) += 32;
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)   for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr int64_t MOD = 1000000007;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;
  string s;
  cin >> s;

  auto mask = 'W' ^ 'B';
  ll ans = 1, cnt = 0;
  for (auto && elem : s)
  {
    if ((elem ^ mask) == 'W')
    {
      ++ cnt;
    }
    else
    {
      ans *= cnt --;
      ans %= MOD;
    }
    mask ^= 'W' ^ 'B';
  }

  if (cnt != 0)
  {
    cout << 0 << endl;
  }
  else
  {
    rep (i, n)
    {
      ans *= i + 1;
      ans %= MOD;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 720
#include <iostream>
#include <set>
int main()
{
    std::multiset<int> s;

    int w,h,x,y,r;
    std::cin >> w;
    std::cin >> h;
    std::cin >> x;
    std::cin >> y;
    std::cin >> r;

    if(x-r >= 0 && x + r <= w && y-r >= 0 && y+r <= h)    
    {
        std::cout <<"Yes\n";
    }
    else
    {
        std::cout <<"No\n";
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>


#include <math.h>  /* M_PI */

int main(){

    double r;
    cin >> r;


    printf("%.10f\n", 2* r * M_PI);
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		StringBuilder sb = new StringBuilder();
		for (int i = n - 1; i >= 0; i -= 2) {
			sb.append(a[i]).append(" ");
		}
		int start = 0;
		if (n % 2 == 1) {
			start = 1;
		}
		for (int i = start; i < n; i += 2) {
			sb.append(a[i]).append(" ");
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


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

int main(){
	int k, a, b;	cin >> k >> a >> b;
  	
  	if(a%k == 0 || b%k == 0 || ((b/k - a/k) > 0)){
    	cout << "OK" << endl;
    }
  	else cout << "NG" << endl;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
  var N int
  fmt.Scan(&N)
  A := make([]int, N)
  
  for i:=range A {
    fmt.Scan(&A[i])
  }
  
  ans := 0
  for i:=1; i<=100; i++ {
    totalLoss := 0
    for j:= range A {
      totalLoss += (A[j]-i)*(A[j]-i)
    }
    if i==1 {
      ans = totalLoss
    }
    if totalLoss < ans {
      ans = totalLoss
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
typedef long long int llint;

template<typename T>
T gcd(T a, T b) {
  if(a < b) gcd(b, a);
  T r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

template<typename T>
T lcm(T a, T b){
  return (a/gcd(a, b)) * b;
}


int main(void){
  int n;
  std::cin >> n;

  llint result = 1;
  for(int i=0; i<n; i++){
    llint temp;
    std::cin >> temp;
    result = lcm(result, temp);
  }

  std::cout << result << std::endl;
  return 0;
}




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

int main(){
  int n;
  string s;
  int cnt1[26];

  for(int i = 0; i < 26; i++) cnt1[i] = 9999999;
  
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    int cnt2[26] = {};
    for(int j = 0; j < s.size(); j++) cnt2[s[j] - 'a']++;
    for(int j = 0; j < 26; j++) cnt1[j] = min(cnt1[j], cnt2[j]);
  }
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < cnt1[i]; j++) cout << (char)('a' + i);
  }
  cout << endl;
}


Measured memory_bytes: 256
Module _20190525

    Sub Main()

        Dim sRead As String = Console.ReadLine()

        Dim iAge As Integer = sRead.Split(" ")(0)
        Dim iFee As Integer = sRead.Split(" ")(1)

        If iAge >= 13 Then

            Console.WriteLine(iFee)

        ElseIf iAge >= 6 Then

            Console.WriteLine(iFee / 2)

        Else

            Console.WriteLine(0)

        End If

    End Sub

End Module


Measured memory_bytes: 11220
#include <stdio.h>
#include <math.h>

struct Point {
    double x;
    double y;
};

void koch(int n, Point a, Point b){
    if(n == 0) return;

    Point s, t, u;
    double th = M_PI * 60 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y); 
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y); 
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y); 
    koch(n - 1, t, b);
}

int main(){
    Point a, b;
    int n;

    scanf("%d", &n);
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y); 
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    return 0; 
}

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

const int K=26;
int nxt[200010][K];

int main()
{
    string s,t; cin>>s>>t;
    int A=s.size();
    int B=t.size();

    s+=s;
    for(int j=0;j<K;j++) nxt[2*A][j]=2*A;
    for(int i=2*A-1;i>=0;i--){
        for(int j=0;j<K;j++) nxt[i][j]=nxt[i+1][j];
        nxt[i][s[i]-'a']=i+1;
    }

    Lint cur=0;
    for(char c:t){
        int pos=cur%A;
        if(nxt[pos][c-'a']==2*A){
            cout<<-1<<endl;
            return 0;
        }
        cur+=nxt[pos][c-'a']-pos;
    }
    cout<<cur<<endl;
    return 0;
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1000000007, INF = 1e18;
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;}



signed main(){
	string s;
	cin >> s;
	vector<pair<int,int>>r,l;
	int cnt = 0;
	int now = 0;
	while(now<s.size()){
		cnt = 0;
		while(s[now]=='R'&&now<s.size()){
			cnt++;
			now++;
		}
		r.push_back({cnt,now-1});
		cnt = 0;
		while(s[now]=='L'&&now<s.size()){
			cnt++;
			now++;
		}
		l.push_back({cnt,now});
	}
	vector<int>ans(s.size(),0);
	reverse(ALL(r));
	reverse(ALL(l));
	int n = r.size();
	REP(i,n){
		int rs = r.back().first;
		int ls = l.back().first;
		int mid = r.back().second;
		r.pop_back();
		l.pop_back();
		ans[mid+1]+=(ls+1)/2+rs/2;
		ans[mid]+=ls/2+(rs+1)/2;
	}
	REP(i,s.size()){
		if(i)cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}

Measured memory_bytes: 3180
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // Initialize
        	var iK = cin.ReadInt;
          	var iX = cin.ReadInt;
            // Process
            // Output
        	WriteLine(500*iK>=iX?"Yes":"No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 27852
main :: IO ()
main = do
    [n, a, b] <- map read . words <$> getLine
    print $ solve n a b

solve :: Integral a => a -> a -> a -> a
solve n a b
    | a > b = 0
    | a == b = 1
    | n == 1 && a /= b = 0
    | otherwise = (b - a) * (n - 2) + 1

Measured memory_bytes: 508
n,t = map(int,input().split())
tm = list(map(int,input().split()))
start_time = -1
stop_time = -1
ans = 0
for i in range(0,n):
    if start_time <= tm[i] <= stop_time:
        stop_time += (t + tm[i]) - stop_time
    else:
        ans += (stop_time - start_time)
        start_time = tm[i]
        stop_time = tm[i] + t
    if i == n-1:
        ans += (stop_time - start_time)
print(ans)

Measured memory_bytes: 30828
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
   string s;
   cin >> s;
   rep(i,3)
   if(s[i]=='9'){
     s[i]='1';
   }else{
     s[i]='9';
   }
   cout << s<< endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cins(s);
    if(s[0]>='A' && s[0]<='Z')
        cout<<"A"<<endl;
    else
        cout<<"a"<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3648
X, K, D = map(int ,input().split())

X = abs(X)
if X // D > K:
    ans = X - K * D
else:
    if X // D % 2 == 0:
        if K % 2 == 0:
            ans = X % D
        else:
            ans = abs(X % D - D)
    else:
        if K % 2 == 0:
            ans = abs(X % D - D)
        else:
            ans = X % D

print(ans)


Measured memory_bytes: 8964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n;
  cin>>n;
  int64_t p=1;
  int64_t w=1000000007;
  for(int i=1;i<=n;i++)
  {
    p=p*i%w;
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*define
*********************************/
int input_ary[ 10000 ];

/*********************************
*function
*********************************/
int main( void )
{
	int input;
	int case_count;
	int loop;
char ch;
	case_count = 0;
	input = 0;

	while( 1 ) {
		scanf( "%d", &input );
		if ( 0 == input ) {
			break;
		}
		input_ary[ case_count ] = input;
		case_count++;
	}
	
	for( loop = 0; loop < case_count; loop++ ) {
		printf( "Case %d: %d\n", loop + 1, input_ary[ loop ] );
	}
	while( ( ch = getchar() ) != EOF );
	return ( 0 );
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
#10**9+7を法とする
mod = 10**9 + 7
#1/{abs(i-j)+1}の累積和をxで考える
x = [0]
#permutation
p = 1
ans = 0
#modの逆元として累積和を考える
for i in range(n):
    x.append((x[-1]+pow(i+1, mod-2, mod))%mod)
    p = (p*(i+1))%mod
#1/{abs(i-j)+1}の累積和はi = j で符号変化に注意
#1はダブルカウントしているので引く
for i in range(n):
    ans = (ans + a[i]*(x[i+1]+x[n-i]-1))%mod
#いま求めたのは1回あたりの期待値なのでn!回考える
print((ans*p)%mod)


Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(long long i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(long long i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
using Ps=pair<int,string>;

int main(){
    int n;
    cin>>n;
    int a=1000;
    while(n>1000){
        n-=a;
    }
    cout<<a-n<<endl;
    return 0;
}

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

int main(void) {
	int a, b;
	cin >> a >> b;
	int d = a / b;
	cout << d;
	cout << " "; 
	int r = a % b;
	cout << r;
	cout << " "; 
	double f = (double)a / (double)b;
	cout <<setprecision(10)<< fixed << f;
	return 0;
}


Measured memory_bytes: 3292
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll D;
    map<ll,ll> mp;
    mp.insert(make_pair(D,1));
    rep(i,N){
        cin >> D;
        if(mp.count(D)) mp[D]++;
        else mp.insert(make_pair(D,1));
    }
    ll M;
    cin >> M;
    ll T;
    string out = "YES";
    rep(i,M){
        cin >> T;
        if(mp.count(T)){
            mp[T]--;
            if(mp[T]<0){
                out = "NO";
                break;
            }
        }else{
            out = "NO";
            break;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	ll t,a;
	cin>>n>>t>>a;
	ll x=t,y=a;
	for(int i=1;i<n;i++){
		cin>>t>>a;
		ll p=max((x+t-1)/t,(y+a-1)/a);
		x=t*p,y=a*p;
	}
	cout<<x+y<<endl;
	return 0;
}

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

#define MAX_S    26

int main(void) {
	string S;
	int C[MAX_S];

	cin >> S;
	for (int i = 0; i < MAX_S; ++i)
		C[i] = 0;
	for (int i = 0; i < (int)S.length(); ++i) {
		int x = (int)(S[i] - 'a');
		++C[x];
	}
	string ans = "yes";
	for (int i = 0; i < MAX_S; ++i) {
		if (C[i] > 1) {
			ans = "no";
			break;
		}
	}

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


Measured memory_bytes: 256
n = int(input())
a = []
b = []
for i in range(n):
    x, y = map(int, input().split())
    a.append([x, y])
    b.append([y, x])
a = sorted(a)
b = sorted(b, reverse = True)

if n % 2 ==0:
    s = a[n//2 -1][0]
    e = b[n//2 -1][0]
    s2 = a[n//2][0]
    e2 = b[n//2][0]
    ans = e+ e2 -s-s2+1   
else:
    s = a[(n+1)//2 -1][0]
    e = b[(n+1)//2 -1][0]
    ans = e-s+1
print(ans)

Measured memory_bytes: 58676
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		sc.close();

		long nC2 = (long)n * (n-1) / 2;

		Map<Integer, Set<Integer>> setMap = new HashMap<Integer, Set<Integer>>();
		long[] useful = new long[m + 1];
		useful[m] = 0L;
		for (int i = m - 1; i >= 0; i--) {
			int ai = a[i];
			int bi = b[i];
			Set<Integer> setA = setMap.get(ai);
			Set<Integer> setB = setMap.get(bi);

			if (setA == null && setB == null) {
				Set<Integer> set = new HashSet<Integer>();
				set.add(ai);
				set.add(bi);
				setMap.put(ai, set);
				setMap.put(bi, set);
				useful[i] = useful[i + 1] + 1;

			} else if (setA != null && setB == null) {
				useful[i] = useful[i + 1] + setA.size();
				setA.add(bi);
				setMap.put(bi, setA);

			} else if (setA == null && setB != null) {
				useful[i] = useful[i + 1] + setB.size();
				setB.add(ai);
				setMap.put(ai, setB);

			} else if (setA != setB) {
				useful[i] = useful[i + 1] + setA.size() * setB.size();
				if (setA.size() > setB.size()) {
					setA.addAll(setB);
					for (int o : setB) {
						setMap.put(o, setA);
					}
				} else {
					setB.addAll(setA);
					for (int o : setA) {
						setMap.put(o, setB);
					}
				}
			} else {
				useful[i] = useful[i + 1];
			}
		}

		for (int i = 1; i <= m; i++) {
			System.out.println(nC2 - useful[i]);
		}
	}
}


Measured memory_bytes: 104800
#!usr/bin/env python3

import sys


def eliminate_ones(grid, row, col):
    if 0 <= row < 12 and 0 <= col < 12 and grid[row][col] == 1:
        grid[row][col] = 0
        eliminate_ones(grid, row+1, col)
        eliminate_ones(grid, row-1, col)
        eliminate_ones(grid, row, col+1)
        eliminate_ones(grid, row, col-1)


def main():
    while True:
        grid = [[int(num) for num in sys.stdin.readline().strip()]
                for _ in range(12)]

        num_of_islands = int()

        for row in range(len(grid)):
            for col in range(len(grid[row])):
                if grid[row][col] == 1:
                    num_of_islands += 1
                    eliminate_ones(grid, row, col)

        print(num_of_islands)

        if not sys.stdin.readline():
            break


if __name__ == '__main__':
    main()

Measured memory_bytes: 7760
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){
	ll n,m;
	cin>>n>>m;
	vector<ll> k(n,0);
	vector<ll> food(m,0);
	
	for(ll i=0;i<n;i++){
		cin>>k[i];
		for(ll j=0;j<k[i];j++){
			ll c=0;
			cin>>c;
			for(ll l=0;l<m;l++){
				if(c-1==l){
					food[l]++;
				}
			}
		}
	}

	ll ans=0;
	for(ll i=0;i<m;i++){
		if(food[i]==n){
			ans++;
		}
	}

	cout<<ans<<endl;
	
}


int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    string str;
    cin >> str;

    ll ans = 0;

    if(str.size() == 1){
        cout << str[0] << endl;
        return 0;
    }

    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            ll inum = 0;
            ll jnum = 0;
            if(i == j){
                inum++;
                jnum++;
            }
            if((int)(str[0] - '0') > i){
                int tmp = 1;
                for(int k = 0; k <= (int)str.size() - 2; k++){
                    inum += tmp;
                    tmp *= 10;
                }
            }else if((int)(str[0] - '0') == i){
                int tmp = 1;
                for(int k = 0; k <= (int)str.size() - 3; k++){
                    inum += tmp;
                    tmp *= 10;
                }
                int x = 0;
                for(int k = 1; k < (int)str.size() - 1; k++){
                    x *= 10;
                    x += (int)(str[k] - '0');
                }
                inum += x;
                if((int)(str.back() - '0') >= j){
                    inum++;
                }
            }else{
                int tmp = 1;
                for(int k = 0; k <= (int)str.size() - 3; k++){
                    inum += tmp;
                    tmp *= 10;
                }
            }
            if((int)(str[0] - '0') > j){
                int tmp = 1;
                for(int k = 0; k <= (int)str.size() - 2; k++){
                    jnum += tmp;
                    tmp *= 10;
                }
            }else if((int)(str[0] - '0') == j){
                int tmp = 1;
                for(int k = 0; k <= (int)str.size() - 3; k++){
                    jnum += tmp;
                    tmp *= 10;
                }
                int x = 0;
                for(int k = 1; k < (int)str.size() - 1; k++){
                    x *= 10;
                    x += (int)(str[k] - '0');
                }
                jnum += x;
                if((int)(str.back() - '0') >= i){
                    jnum++;
                }
            }else{
                int tmp = 1;
                for(int k = 0; k <= (int)str.size() - 3; k++){
                    jnum += tmp;
                    tmp *= 10;
                }
            }
            ans += inum * jnum;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	for (const char ch : s)
		cout<<'x';
	cout<<endl;
	return 0;
}


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

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long x,y,z,k;
  scanf("%ld %ld %ld %ld", &x, &y, &z, &k);
  long a[x],b[y],c[z];
  for (int i = 0; i < x; i++) {
    scanf("%ld", &a[i]);
  }
  for (int i = 0; i < y; i++) {
    scanf("%ld", &b[i]);
  }
  for (int i = 0; i < z; i++) {
    scanf("%ld", &c[i]);
  }
  long *ab;
  ab = (long *)malloc(sizeof (long) * x*y);
  long current = 0;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      ab[current] = a[i]+b[j];
      current++;
    }
  }
  qsort(ab, x*y, sizeof(long), cmpnum);
  long size = x*y;
  if (k < size) {
    size = k;
  }
  long *abc;
  abc = (long *)malloc(sizeof (long) * size*z);
  current = 0;
  for (int i = 0; i < size; i++) {
    for (int j = 0; j < z; j++) {
      abc[current] = ab[i]+c[j];
      current++;
    }
  }
  qsort(abc, size*z, sizeof(long), cmpnum);
  for (long i = 0; i < k; i++) {
    printf("%ld\n", abc[i]);
  }

  return 0;
}

Measured memory_bytes: 54920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int a,b;
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	cout<<min(n,m)+min(a,b);
	return 0;
}


Measured memory_bytes: 256
//ITP1_1_B
#include <iostream>
#include <cmath>

class ITP1_1_B
{
public:
    static void cubeNumber()
    {
        int num;
        std::cin >> num;
        std::cout << num * num * num << std::endl;
    }
};

int main()
{
    ITP1_1_B::cubeNumber();
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    string s[105] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> s[i], s[i] = '#' + s[i] + '#';
    for (int i = 0; i <= m + 1; i++) s[0] += '#', s[n + 1] += '#';
    for (int i = 0; i <= n + 1; i++) cout << s[i] << '\n';
}


Measured memory_bytes: 256
import math
import itertools

def getNum(card: str) -> int:
  return int(card[1])

def checkStable(origin: list, sorted: list) -> str: # Stable or Not stable
  N_origin = [[] for _ in range(9)]
  for item in origin:
    num = getNum(item)
    N_origin[num-1].append(item)

  for item in sorted:
    num = getNum(item)    

    if N_origin[num-1][0] != item:
      return False
    else:
      N_origin[num-1].pop(0)

  return True

def main():
  n = int(input())
  A = list(input().split())
  len_A = len(A)  
  B = list(A)
  C = list(A)

  # bubble sort
  for i in range(len_A): 
    for j in reversed(range(i+1, len_A)):
      if getNum(B[j]) < getNum(B[j-1]):
        tmp = B[j]
        B[j] = B[j-1]
        B[j-1] = tmp

  # select sort
  for i in range(len_A):
    min = i
    for j in range(i, len_A):
      if getNum(C[j]) < getNum(C[min]):
        min = j
    
    if min != i:
      tmp = C[min]
      C[min] = C[i]
      C[i] = tmp

  print(*B) #bubble sort
  if checkStable(A, B):
    print('Stable')
  else:
    print('Not stable')
  print(*C) #select sort
  if checkStable(A, C):
    print('Stable')
  else:
    print('Not stable')

if __name__ == '__main__':
  main()


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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _  = Console.ReadLine().Split();
            var s = int.Parse(_[0]);
            var w = int.Parse(_[1]);

            if(s <= w){
                Console.WriteLine("unsafe");
            }else{
                Console.WriteLine("safe");
            }
        }
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);
            int ans = B / A < C ? B / A : C;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    for (int mask = 0; mask < (1 << 3); ++mask) {
        int tmp = 0;
        tmp += s[0] - '0';
        for (int i = 0; i < 3; ++i) {
            if (mask & (1 << i)) {
                tmp += s[i + 1] - '0';
            }
            else {
                tmp -= s[i + 1] - '0';
            }
        }
        if (tmp == 7) {
            string ans = "";
            ans.push_back(s[0]);
            for (int i = 0; i < 3; ++i) {
                if (mask & (1 << i))
                    ans.push_back('+');
                else
                    ans.push_back('-');
                ans.push_back(s[i + 1]);
            }
            ans += "=7";
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <set>
#include <iostream>
#include <cassert>
#include <queue>
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define rep(i,a,b) for(int i = a;i < b; ++i)
using namespace std;

int main() {
    char c;
    cin >> c;
    char d = c + 1;
    cout << d;
    return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second


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

    ll a,b,k;
    cin >> k >> a >> b;
    for(int i=a; i<=b; i++)
    {
        if (i%k==0) return cout << "OK\n" , 0;
    }

    cout << "NG\n";

    return 0;
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    d = defaultdict(int)
    ans = 0
    for e in a:
        if d[e] < e:
            d[e] += 1
        else:
            ans += 1

    for e in d:
        if d[e] != e:
            ans += d[e]
    print(ans)
        
    

    
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

2 3 4 4
3 4 4
2 3 4
2 3 4
2 4 4


"""


Measured memory_bytes: 22344
h,*s=open(0)
h,w,k=map(int,h.split())
m=b=h+w
while b:
 b-=1;r=t=j=-1;d=[0]*h
 while~j+w:
  j+=1;i=c=0
  while h-i:
   d[c]+=s[i][j]>'0'
   if d[c]>k:d=[0]*h;f=t<j;r-=h*w*~-f-1;t=j;j-=f;break
   c+=b>>i&1;i+=1
 m=min(m,r-~c)
print(m)

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << setprecision(10) << setiosflags(ios::fixed);

    int n, k;
    cin >> n >> k;

    ld p = 0.0;
    for (int i = 1; i <= n; ++i) {
        ld add_p = 1.0;
        for (int x = i; x < k; x *= 2) add_p *= 0.5;
        p += add_p;
    }
    p /= n;

    cout << p << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char str[1000];
    int num;
    
    scanf("%s\n", str);
    scanf("%d\n", &num);
    
    for (int i = 0; i < num; i++)
    {
        char buf[1000];
        
        char name[8];
        int param1, param2;
        char replaced[1000];
        scanf("%s %d %d\n", name, &param1, &param2);
        // printf("%s %d %d\n", name, param1, param2);  // DEBUG
        // printf("%s\n", str); // DEBUG

        if (strcmp(name, "print") == 0)
        {
            strncpy(buf, str+param1, param2-param1+1);
            buf[param2-param1+1] = '\0';
            printf("%s\n", buf);
        }
        else if (strcmp(name, "reverse") == 0)
        {
            int start = param1;
            int end = param2;
            
            strcpy(buf, str);
            while(start < end)
            {
                char tmp;
                tmp = buf[start];
                buf[start] = buf[end];
                buf[end] = tmp;
                start++;
                end--;
            }
            strcpy(str, buf);
        }
        else if (strcmp(name, "replace") == 0)
        {
            strcpy(buf, str);
            scanf("%s\n", replaced);
            for(int i = 0; i < (param2 - param1 + 1); i++)
            {
                buf[i + param1] = replaced[i];
            }
            strcpy(str, buf);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int s, t;
	cin >> s >> t;

	vector<vector<int>> Glaph(N);
	vector<vector<int>> Depth(N, vector<int>(N, INF32));

	queue<pair<int, int>> next;

	for (int i = 0; i < N; i++)
	{
		if (0 < i)
		{
			Glaph[i].push_back(i - 1);
			next.push(make_pair(i, i - 1));
			Depth[i][i - 1] = 1;
		}

		if (i + 1 < N)
		{
			Glaph[i].push_back(i + 1);
			next.push(make_pair(i, i + 1));
			Depth[i][i + 1] = 1;
		}
	}

	for (int i = 0; i < N; i++)
	{
		Depth[i][i] = 0;
	}
	Glaph[s - 1].push_back(t - 1);
	next.push(make_pair(s - 1, t - 1));
	Depth[s - 1][t - 1] = 1;
	Glaph[t - 1].push_back(s - 1);
	next.push(make_pair(t - 1, s - 1));
	Depth[t - 1][s - 1] = 1;

	for (int i = 1; i < N; i++)
	{
		cout << next.size() / 2 << endl;

		for (int loop = next.size() - 1; 0 <= loop; loop--)
		{
			pair<int, int> current = next.front();
			next.pop();
			for (auto to : Glaph[current.second])
			{
				if (Depth[current.first][current.second] + 1 < Depth[current.first][to])
				{
					//cout << i << ":" << current.first << " " << to << " " << Depth[current.first][current.second] + 1 << endl;
					Depth[current.first][to] = Depth[current.first][current.second] + 1;
					next.push(make_pair(current.first, to));
				}
			}
		}
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 16128