akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
int main(){

  int i,j;
  std::string x,y;
  int a[1001][1001];
  int knum;
  for(i=0; i<1001; i++){
    for(j=0; j<1001; j++){
      if(j==0)a[i][j]=i;
      else if(i==0)a[i][j]=j;
      else a[i][j]=0;
    }
  }
  std::cin>>x;
  std::cin>>y;
  int vx,vy,vz;
  for(i=1; i<x.size()+1; i++){
    for(j=1; j<y.size()+1; j++){
      vx=a[i-1][j]+1;
      vy=a[i][j-1]+1;
      vz=a[i-1][j-1];
      if(x[i-1]==y[j-1]){
	if(vx<=vy && vx<=vz){
	  a[i][j]=vx;
	}else if(vy<=vx && vy<=vz){
	  a[i][j]=vy;
	}else{
	  a[i][j]=vz;
	}
      }else{
	if(vx<=vy && vx<=vz+1){
	  a[i][j]=vx;
	}else if(vy<=vx && vy<=vz+1){
	  a[i][j]=vy;
	}else{
	  a[i][j]=vz+1;
	}
      }
    }
    knum=a[x.size()][y.size()];
  }
  std::cout<<knum<<"\n";
  return 0;
}



Measured memory_bytes: 7136
#include <iostream>
#include <vector>
#include <algorithm>

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define INF 1001001001

using namespace std;

int main(void){
  int x,n, p[200];
  int d;
  
  cin >> x >> n;
  for (int i=0; i<n; i++) cin >> p[i];
  for (int d=0; true; d++){
    for (int sn=-1; sn<=1; sn+=2){
      int f=1, y;
      y = x + d*sn;
      for (int i=0; i<n; i++){
        if (y==p[i]) f=0;
      }
      if (f){
        cout << y << endl;
        return 0;
      }
    }
  }
        
  return 0;
}

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

bool palindromes(int n) {
  int m = 0;
  int t = n;
  int r = 0;
  while(t != 0) {
    r = t%10;
    m = m*10 + r;
    t /= 10;
  }
  if (n == m) return true;
  else return false;
}

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

Measured memory_bytes: 3620
use std::io;
use std::cmp;
use std::collections::BinaryHeap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let nm: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];

    let mut data: Vec<Vec<(usize,usize)>> = vec![Vec::new();n];

    for i in 0..m {
        let py: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let p = py[0]-1;
        let y = py[1];
        data[p].push((y,i));
    }

    let mut ans = vec![String::new();m];

    for i in 0..n {
        let mut d = &mut data[i];
        d.sort();

        for j in 0..d.len() {
            let item = d[j];
            ans[item.1] = format!("{:06}{:06}", i+1, j+1);
        }
    }

    for i in 0..m {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 19964
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split("");
    int count = 0;
    for(int i=0; i<3; i++) {
      if(str[i].equals("o"))
        count++;
    }
    System.out.println(700+count*100);
  }
}

Measured memory_bytes: 33108
use std::collections::VecDeque;

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()
}
fn input<T: std::str::FromStr>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

fn main() {
    let q = input::<i64>();
    let mut vec = VecDeque::new();
    for i in 0..q{
        let mut a = read_vec::<i64>();
        if a[0] == 0{
            if a[1] == 0{
                vec.push_front(a[2]);
            }
            if a[1] == 1{
                vec.push_back(a[2]);
            }
        }
        if a[0] == 1{
            let b = a[1] as usize;
            println!("{}", vec[b]);
        }
        if a[0] == 2{
            if a[1] == 0{
                vec.pop_front();
            }
            if a[1] == 1{
                vec.pop_back();
            }
        }
    }
}


Measured memory_bytes: 9956
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 ll x,k,d;
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>x>>k>>d;
	if(x<0) x=-x;
	ll q=x/d;
	if(q>k)
	{
		x-=k*d;
		cout<<x<<'\n';
	}
	else
	{
		k-=q;
		x=x%d;
		k%=2;
		if(k) x-=d;
		cout<<abs(x)<<'\n';
	}
	return 0;
}

// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3688
N = int(input())
L = [ input() for i in range(N)]
tmpl = []
tmp = L[0][0]
res = "Yes"
for l in L:
    if l in tmpl:
        res = "No"
        break
    if l[0] != tmp:
        res = "No"
        break
    tmp = l[-1]
    tmpl.append(l)
   
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

const long long LINF = 1000000000000000018ll;

struct Edge {
  int dst;
  long long cost;
  Edge() {}
  Edge(int x, int y) : dst(x), cost(y) {}
};

vector<vector<Edge> > graph;

vector<long long> dijkstra(int start_v, int v) {
  vector<long long> dist(v, 1000000000000000018ll);
  dist[start_v] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
    greater<pair<long long, int> > > q;

  q.push(make_pair(0, start_v));

  while (!q.empty()) {
    pair<long long, int> t = q.top(); q.pop();
    int cur_v = t.second;
    for (int i = 0; i < graph[cur_v].size(); i++) {
      int next_v = graph[cur_v][i].dst;
      long long cost = graph[cur_v][i].cost;
      if (dist[next_v] > dist[cur_v] + cost) {
        dist[next_v] = dist[cur_v] + cost;
        q.push(make_pair(dist[next_v], next_v));
      }
    }
  }
  return dist;
}

int main () {
  int v, e, r;
  cin >> v >> e >> r;

  graph.assign(v, vector<Edge>());
  for (int i = 0; i < e; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    graph[s].push_back(Edge(t, d));
  }

  vector<long long> dist = dijkstra(r, v);
  for (int i = 0; i < v; i++) {
    if ( dist[i] == LINF ) {
      cout << "INF" << "\n";
    } else {
      cout << dist[i] << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 19428
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();

        char[][] c = new char[h][w];
        for(int i = 0; i < h; i++){
            c[i] = (sc.next()).toCharArray();
        }

        int[] sel = new int[h + w];
        int count = 0;
        int num = 0;
        for(int l = 0; l < Math.pow(2, h + w); l++){
            for(int i = 0; i < h; i++){
                if(sel[i] == 0){
                    for(int j = 0; j < w; j++){
                        if(sel[j + h] == 0 && c[i][j] == '#'){
                            num++;
                        }
                    }
                }
            }
            if(num == k){
                count++;
            }
            sel = succ(sel);
            num = 0;
        }

        System.out.println(count);
        sc.close();
    }

    static int[] succ(int[] bin){
        int i = 0;
        while(i < bin.length && bin[i] != 0){
            bin[i] = 0;
            i++;
        }
        if(i < bin.length){
            bin[i] = 1;
        }

        return bin;
    }
}

Measured memory_bytes: 36484
N, C = gets.chomp.split.map(&:to_i)

d = []
c = []

C.times do
  d << gets.chomp.split.map(&:to_i)
end

N.times do
  c << gets.chomp.split.map(&:to_i)
end

x = [0] * C
y = [0] * C
z = [0] * C

N.times do |i|
  N.times do |j|
    x[c[i][j]-1] += 1 if (i + j) % 3 == 0
    y[c[i][j]-1] += 1 if (i + j) % 3 == 1
    z[c[i][j]-1] += 1 if (i + j) % 3 == 2
  end
end

min = Float::INFINITY
C.times.each do |xx|
  C.times.each do |yy|
    next if xx == yy
    C.times.each do |zz|
      next if xx == zz || yy == zz
      sum = x.map.with_index{|s, i| d[i][xx] * s}.inject(:+)
      sum += y.map.with_index{|s, i| d[i][yy] * s}.inject(:+)
      sum += z.map.with_index{|s, i| d[i][zz] * s}.inject(:+)
      min = [sum, min].min
    end
  end
end

puts min

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

int cmp(const void *a,const void *b)
{
   return *(int*)a-*(int*)b;
}

int main(void)
{
   int n, a[100000][2], i;
   long k;

   scanf("%d%ld",&n,&k);
   for(i=0;i<n;i++)
      scanf("%d%d",&a[i][0],&a[i][1]);

   qsort(a,n,sizeof(int)*2,cmp);

   for(i=0;i<n;i++){
      k-=a[i][1];
      if(k<=0){
         printf("%d\n",a[i][0]);
         return 0;
      }
   }
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<int,int> mp;
  int a;
  bool can=true;
  cin >>a;
  for(int i=0;i<a;i++){
    int b;
    cin >>b;
    if(mp.find(b)!=mp.end()) can=false;
    mp[b]=true;
  }
  if(can) cout <<"YES\n";
  else cout <<"NO\n";
  return (0);
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int max_num=max(x,y);
  ll ans=INF;
  rep(i,max_num+1){
    ll sum=0;
    int num_a,num_b;
    if(x-i>0)num_a=x-i;
    else num_a=0;
    if(y-i>0)num_b=y-i;
    else num_b=0;
    sum=c*i*2+a*num_a+b*num_b;
    ans=min(ans,sum);
  }
  cout<<ans;
}


Measured memory_bytes: 3608
import heapq

def make_adj_list(v):
    adj_list = [[-1 for i in range(v)] for j in range(v)]
    return adj_list

def prim(adj_list, v, s):
    # スタートを0とする
    min_d = 0
    heap = []
    used = []
    for i in range(v):
        used.append(False)
    used[s] = True
    for i in range(v):
        if adj_list[s][i] != -1:
            heapq.heappush(heap, (adj_list[s][i], i))
        #　スタートからつなぐことができる辺をheapに入れる

    while len(heap) != 0:
        cost, to = heapq.heappop(heap)
        if used[to]:
            continue
        min_d += cost
        used[to] = True
        for i in range(v):
            if adj_list[to][i] != -1:
                heapq.heappush(heap, (adj_list[to][i], i)) 
            #集合に入れた頂点からつなぐことができる辺をheapに入れる

    return min_d

def main():
    v = int(input())
    adj_list = make_adj_list(v)
    for i in range(v):
        adj_list[i] = [int(j) for j in input().split()]
    min_d = prim(adj_list, v, 0)
    print(min_d)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6360
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define rep11(i, n) for(int i = 1; i < (n) + 1; i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
typedef struct { int x; int y; } Pos;
using namespace std;
const ll E9P7 = 1000000007; 

int main() {
    int n;
    cin >> n;
    vector<int> d1(n), d2(n);
    rep(i, n) cin >> d1[i] >> d2[i];
    bool z = false;
    int c = 0;
    rep(i, n) {
        if (d1[i] == d2[i]) {
            z = true;
            c++;
        }
        else {
            z = false;
            c = 0;
        }
        if (c >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		sc.close();

		if (500 * K < X) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 21844
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, a[N][5], dp[N][5];

inline void readInput() {
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
}

inline void solve() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++)
				if (j ^ k)
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j]);
	cout << *max_element(dp[n], dp[n] + 5) << endl;
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 4224
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

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

type xxx struct {
	x int
}

type sortArray []xxx

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

// -----------------------------------------------------------------

func main() {
	n := readInt()
	ans := 0
	for i := 1; i < n+1; i++ {
		s := strconv.Itoa(i)
		if len(s)%2 == 1 {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1152
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    cnt = 0
    digit = 1 << i
    for j in a:
        if digit & j:
            cnt += 1
    ans += digit*cnt*(n - cnt)%mod

print(ans%mod)

Measured memory_bytes: 117968
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string N;
  cin >> N;
  string ans;
  rep(i, N.size()) {
    if (i % 2 == 0) {
      ans += N[i];
    }
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
string s;
signed main(){
	int a=0,ans=0;
	cin>>s;
	f(i,s.size()){
		if(s[i]=='B') a++;
		else ans+=a;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    int l = s.size();
    vector<char> v;
    for (int i = 0; i < l; ++i) {
        if (s[i] == 'B') {
            if (v.empty()) continue;
            v.pop_back();
        } else {
            v.push_back(s[i]);
        }
    }
    for(const char c : v) {
        cout << c;
    }
}

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    faster
    ll a,b,c,k,cnt=0;
    cin>>a>>b>>c>>k;
    while(k--)
    {
        if(a>0)
        {
            cnt++;
            a--;
            continue;
        }
        if(b>0)
        {
           b--;
           continue;
        }
        if(c>0)
        {
            cnt--;
            c--;
            continue;
        }
    }
    cout<<cnt<<nl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	vector<int> a(n),b(n),c(n);
	REP(i,n) cin >> a[i];
	REP(i,n) cin >> b[i];
	REP(i,n) cin >> c[i];
	sort(ALL(a));
	sort(ALL(c));
	ll ans = 0;
	REP(i,n) ans += (lower_bound(ALL(a), b[i]) - a.begin()) * (c.end() - upper_bound(ALL(c), b[i]));
	cout << ans << endl;
}

Measured memory_bytes: 1408
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
 //  cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        ll x;
        cin>>x;
        cout<<x+x*x+x*x*x;
     
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string s1,s2,ans;
int f[3001][3001];
char vt[3001][3001];
  void quyhoachdong()
  {
    int l1=s1.length();
    int l2=s2.length();

        for (int i=1;i<=s2.length();i++)
        {
            f[i][0]=0;
            for (int j=1;j<=s1.length();j++)
            {
                if (s2[i-1]==s1[j-1])
                 {
                     f[i][j]=f[i-1][j-1]+1;
                     vt[i][j] = 'a';
                 }
                else
                {
                    f[i][j]=max(f[i-1][j],f[i][j-1]);
                    vt[i][j] = (f[i-1][j]>f[i][j-1]) ? 'b' : 'c';
                }
            }
        }



}

void truyvet(int i,int j)
{
    if (i<1) return ;
    if (j<1) return ;

    if (vt[i][j]=='a')
    {
        truyvet(i-1,j-1);
        cout<<s2[i-1];
    }
    else if (vt[i][j]=='b')
    {
        truyvet(i-1,j);
    }
    else truyvet(i,j-1);
}
int main ()
{
   cin>>s2;
   cin>>s1;
   quyhoachdong();
   truyvet(s2.length(),s1.length());
}


Measured memory_bytes: 44288
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll x=min(a,min(b,min(c,min(d,e))));
    ll y;
    if(n%x==0) y=n/x;
    else y=(n/x)+1;
    cout << y + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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


    int main()
    {
    string s;
    cin>>s;
    int cnta=0;
    int cntb=0;
    for(int i=0; i<s.size(); i++)
    {
        if(i%2==0&&s[i]!='1') {++cnta;}
        else if(i%2!=0&&s[i]!='0'){++cnta;}

        else if(i%2==0&&s[i]!='0') {++cntb;}
        else if(i%2!=0&&s[i]!='1'){++cntb;}
    }
    cout<<min(cnta,cntb)<<endl;
    }

Measured memory_bytes: 512
N=int(input())
room=[[[0]*10 for _ in range(3)] for _ in range(4)]

for _ in range(N):
    b,f,r,v=map(int,input().split())
    room[b-1][f-1][r-1]+=v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {room[i][j][k]}", end="")
        print()
    if i!=3:
        print("####################")


Measured memory_bytes: 5632
from collections import defaultdict
import bisect

S = list(str(input()))
T = list(str(input()))

dict = defaultdict(list)
for i, c in enumerate(S):
    dict[c].append(i + 1)
# print(dict)

# Sの繰り返し数
div_cnt = 0
# 現在のindex
now = 0

for i, c in enumerate(T):

    # cがS中に存在しない場合
    if dict[c] == []:
        print(-1)
        exit()

    next = bisect.bisect_right(dict[c], now)
    # print(c, now, next)

    # nextがdictの右端になる場合
    # 次のsブロックを使う
    if next == len(dict[c]):
        div_cnt += 1
        now = dict[c][0]
    # 現在のsブロックがまだ使える場合
    else:
        now = dict[c][next]

ans = div_cnt * len(S) + now
print(ans)


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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();

        int x = N+M;
        int z = N*M;

        int a = (x*(x-1))/2 - z;
        System.out.println(a);



 }

    }


    







Measured memory_bytes: 35648
def reppref(s, n)
	(s.codepoints * ((s.size + n - 1) / s.size))[0, n]
end

s = gets.chomp
t = gets.chomp

ptn = reppref(t, s.size + t.size)
mp = [-1]
j = -1
ptn.size.times{|i|
	j = mp[j] while j >= 0 && ptn[i] != ptn[j]
	j += 1
	mp.push(j)
}

j = 0
mx = 0
reppref(s, s.size * 2 + t.size).each{|x|
	j = mp[j] while j == ptn.size || (j >= 0 && ptn[j] != x)
	j += 1
	mx = j if mx < j
}
puts (mx >= s.size + t.size ? -1 : mx / t.size)


Measured memory_bytes: 44812
#include<iostream>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	int ball[100005]={};
	bool can[100005]={};
	for(int i=1;i<=n;i++)
		ball[i-1]=1;
	can[0]=true;

	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin >> x >> y;
		if(can[x-1])
		{
			if(ball[x-1]==1)can[x-1]=false;
			can[y-1]=true;
		}

		ball[x-1]--;
		ball[y-1]++;
	}

	int ans=0;
	for(int i=1;i<=n;i++)
		if(can[i-1])ans++;

	cout << ans << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<map>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const LL INF = (1 << 30);


//定数
const int MOD = 1000000007;


//素因数分解
//in: number
//out: prime numbers
template<typename T>
vector<T> prime_factorization(T n) 
{
	vector<T> res;
	T check = 2;

	while (check*check <= n) {
		if (n%check == 0) {
			n /= check;
			res.push_back(check);
		}
		else {
			check++;
		}
	}
	if (n != 1) res.push_back(n);
	sort(res.begin(), res.end());
	return res;
}


//繰り返し累乗法
//in:  x,n,mod
//out: x^n(Mod mod)
template<typename T>
T mod_pow(T x, T n, T mod) {
	T res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}


//最大公約数
//(ユークリッドの互除法)
//in: a,b
//out:  GCD(a,b)
template<typename T>
T GCD(T a, T b) 
{
	if (a < b)swap(a, b);
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


//最小公倍数
//in:   n:a's size
//      a:LCM object
//out: LCM for a
template<typename T>
T LCM(T n, vector<T> a) 
{
	T res = a[0];
	FOR(i, 1, n) 
		res = res * a[i] / GCD(res, a[i]);
	return res;
}


//オイラーのφ関数
//(nに対して、1～nで互いに素な数の個数を示す)
//http://yoshiiz.blog129.fc2.com/blog-entry-410.html
template<typename T>
T totient_function(T n) 
{
	//φ(n) = n*Π(1-1/p)
	//※pはnの素因子全体
	T res = n;
	if (n % 2 == 0) {
		res /= 2;
		do { n /= 2; } while (n % 2 == 0);
	}

	T p = 3;
	while (p <= n / p) {
		if (n%p == 0) {
			res = res / p * (p - 1);
			do { n /= p; } while (n%p == 0);
		}
		p += 2;
	}

	if (n > 1) res = res / n * (n - 1);
	return res;
}
















//上に、ライブラリを作成していく。
//問題に応じて、以下を調整する。
LL n;

//サブ関数
//入力
void input()
{
	cin >> n;
	
}


//出力
void output()
{
	cout << totient_function(n) << endl;
}

//デバッグ
void debug(){
	int N;
	cin>>N;
}


//メイン関数
int main(){
	input();
	output();
	debug();
	
	return 0;
}



Measured memory_bytes: 3088
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	i := len(s)
	for {
		if i <= 7 {
			t := s[:i]
			if t == "dreamer" || t == "eraser" || t == "dream" || t == "erase" {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
			break
		}
		if t := s[i-7 : i]; t == "dreamer" {
			i = i - 7
		} else if t := s[i-6 : i]; t == "eraser" {
			i = i - 6
		} else if t := s[i-5 : i]; t == "dream" {
			i = i - 5
		} else if t := s[i-5 : i]; t == "erase" {
			i = i - 5
		} else {
			fmt.Println("NO")
			break
		}
	}
}

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

using namespace std;

const int M = 2e5 + 1;
int f[M];

// Mod things

int mod = 1e9 + 7;
int modPow(int n, int p) {
    if (!p)
        return 1;

    int r = modPow((1ll * n * n) % mod, p / 2);

    if (p & 1)
        return (1ll * n * r) % mod;
    return r;
}

int modInv(int n) { return modPow(n, mod - 2); }

int subMod(int a, int b) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int addMod(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int divMod(int n, int d) { return (1ll * n * modInv(d)) % mod; }

int choose(int n, int k) { return (1ll * f[n] * modInv((1ll * f[k] * f[n - k]) % mod)) % mod; }

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

    f[0] = 1;
    for (int i = 1; i < M; i++)
        f[i] = (1ll * f[i - 1] * i) % mod;

    int n, a, b, ans;
    cin >> n >> a >> b;

    ans = subMod(modPow(2, n), 1);

    int cur = 1;
    for (int i = 0; i < a; i++)
        cur = (1ll * cur * (n - i)) % mod;
    cur = divMod(cur, f[a]);

    ans = subMod(ans, cur);

    cur = 1;
    for (int i = 0; i < b; i++)
        cur = (1ll * cur * (n - i)) % mod;
    cur = divMod(cur, f[b]);
    ans = subMod(ans, cur);

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    if(a.fi==b.fi)return a.se>b.se;
    return a.fi<b.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll k; cin>>k;
ll a,b; cin>>a>>b;
ll temp = k;
bool flag = false;
while(k<=b)
{
    if(k>=a&&k<=b)flag = true;
    k+=temp;
}
if(flag)cout<<"OK\n";
else cout<<"NG\n";
return 0;

}
/*
1
4
4 2
10 3
3 4
9 2
*/


Measured memory_bytes: 3640
def main():
    N, M = map(int, input().split())

    ab = []
    i = 0
    while i < N:
        ab += [tuple(map(int, input().split()))]
        i += 1

    cd = []
    i = 0
    while i < M:
        cd += [tuple(map(int, input().split()))]
        i += 1

    i = 0
    while i < N:
        j = 0
        l = []
        while j < M:
            l.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
            j += 1
        i += 1
        print(l.index(min(l)) + 1)
main()


Measured memory_bytes: 3064
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
    CIN(x,a,b);
    COUT((x-a)%b);


    return 0;
}


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

using namespace std;
using namespace std::chrono; 

#define ull unsigned long long int
#define ll long long int 

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

int main(){

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

    int bingo[3][3];

    for(int i=0; i<3; i++){
        cin >> bingo[i][0] >>  bingo[i][1] >>  bingo[i][2];
    }

    auto start = high_resolution_clock::now(); 

    int n;
    int x;
    cin >> n;

    for(int i=0; i<n; i++){

        cin >> x;

        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(bingo[j][k] == x) bingo[j][k] = -1;
            }
        }

    }

    for(int j=0; j<3; j++){
        for(int k=0; k<3; k++){
            if((bingo[j][k] == -1 && (bingo[j][k] == bingo[j][k-1]) && (bingo[j][k]== bingo[j][k+1]))  && (k-1 >=0 && k+1 <3)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j+1][k] && bingo[j][k] == bingo[j-1][k]) && (j+1<3 && j-1>=0)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j-1][k-1] && bingo[j][k] == bingo[j+1][k+1]) && (j-1>=0 && k-1 >=0 && j+1<3 && k+1<3)){ 
                cout << "Yes" << endl;
                return 0;
            }
            else if((bingo[j][k] == -1 && bingo[j][k] == bingo[j-1][k+1] && bingo[j][k] == bingo[j+1][k-1]) && (j-1>=0 && k-1 >=0 && j+1<3 && k+1<3)){ 
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
   

    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<microseconds>(stop - start);
    double time = duration.count();

 //   cout << "Time" <<std::setprecision(5)<< time / 1000000.0 << "seconds" << endl; 

   return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
map<string,int> tmp;
//int cc=0;
//#define edg(a,b) ((abs((a)-(b))==1))
int ask(string s)
{
	int r=0;
	for(int i=0;i<s.size();i++) r+=(s[i]=='1');
	if(r<=1) return 0;
	if(tmp.count(s)) return tmp[s];
	/*
	++cc; vi rp;
	for(int i=0;i<s.size();i++)
		if(s[i]=='1') rp.pb(i);
	if(rp.size()==2)
	return tmp[s]=edg(rp[0],rp[1]);
	if(rp.size()!=3) throw "RE";
	bool a=edg(rp[0],rp[1]),b=edg(rp[0],rp[2]),
	c=edg(rp[1],rp[2]);
	return tmp[s]=a+b+c;*/
	cout<<"? "<<s<<endl;
	int x; cin>>x; return tmp[s]=x;
}
int n,ff[SZ]; vector<int> vs[SZ],rs;
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
void uni(int a,int b)
{int ga=gf(a),gb=gf(b);if(ga^gb)ff[ga]=gb;}
int cnt()
{
	int ans=0; rs.clear();
	for(int i=1;i<=n;i++) vs[i].clear();
	for(int i=1;i<=n;i++)
	{
		vs[gf(i)].pb(i);
		if(gf(i)==i);else continue;
		++ans; rs.pb(i);
	}
	random_shuffle(rs.begin(),rs.end());
	for(int i=1;i<=n;i++)
		random_shuffle(vs[i].begin(),vs[i].end());
	return ans;
}
const int B=4;
vector<pii> es;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) vs[i].pb(i);
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<i;j+=B)
		{
			string s; s.resize(n);
			for(int i=0;i<n;i++) s[i]='0';
			for(int k=0;k<B&&j+k<i;++k) s[j+k-1]='1';
			int a=ask(s); s[i-1]='1';
			int b=ask(s);
			if(a==b) continue;
			for(int k=0;k<B&&j+k<i;++k)
			{
				for(int i=0;i<n;i++) s[i]='0';
				s[j+k-1]=s[i-1]='1';
				if(ask(s)==1)
					es.pb(pii(j+k,i));
			}
		}
	}
	cout<<"!";
	for(auto r:es) printf(" (%d,%d)",r.fi-1,r.se-1);
	puts("");
	//cerr<<cc<<"\n";
}


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

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

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

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

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

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

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

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

fn exe(s: &str) -> String {
    let mut ans = "".to_string();
    for _ in 0..s.len() {
        ans = ans + "x";
    }
    ans
}

fn main() {
    input! {
        s: String,
    }
    let ans = exe(&s);
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
    public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		String S = sc.next();		
      String T = sc.next();
      int swap = 0;
      
      int length = S.length();
      for(int i=0;i<length;i++){
      	String s = S.substring(i,i+1);
        String t = T.substring(i,i+1);
        
        if(!s.equals(t)){
          swap++;
        }          
      }
	  System.out.println(swap);
		
		
    }
}

Measured memory_bytes: 55580
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    n = ri()
    A = ria()
    s = set()
    for v in A:
        s.add(v)

    print("YES" if len(s) == n else "NO")


if __name__ == "__main__":
    main()


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

int main(){
  char a,b;
  cin>>a>>b;
  if(a=='H'){
    if(b=='H')
      cout<<'H'<<endl;
    else
      cout<<'D'<<endl;
  }
  else{
    if(b=='H')
      cout<<'D'<<endl;
    else
      cout<<'H'<<endl;
  }
}


Measured memory_bytes: 256
n = int(input())
s = [[0,0] for i in range(n)]
for i in range(n) :
  x,l = map(int,input().split())
  s[i][0] = x-l
  s[i][1] = x+l
  
s = sorted(s, key=lambda x: x[1])
 
sd = {}
sd[10**10*s[0][0]+s[0][1]] = 1
for i in range(1,n) :
  if s[i][0] < s[i-1][1] :
    s[i] = s[i-1]
  if not 10**10*s[i][0]+s[i][1] in sd :
    sd[10**10*s[i][0]+s[i][1]] = 1
    
print(len(sd))

Measured memory_bytes: 80672
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

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



Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int h=sc.nextInt();
		System.out.println((a+b)*h/2);
		sc.close();
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<int> ret;
  int now=n;
  while(now!=0){
    bool flag=0;
    for(int j=m;j>0;j--){
      if(now-j>=0 && s[now-j]=='0'){
        now = now-j;
        ret.push_back(j);
        flag=1;
        break;
      }
    }
    if(!flag){
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(ret.begin(),ret.end());
  for(int &x:ret){
    cout << x << " ";
  }
  cout << endl;
  return 0;
}

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

template <typename Arg1>
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }

template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

template <typename Arg1>
void bug(Arg1&& arg1)
{ cout<<"->"<<arg1<<endl; }

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulmod(ll a,ll b,ll mod) 
{ ll res=0; a=a%mod; 
    while(b>0)
    { if(b%2==1) res=(res+a)%mod; 
      a=(a*2)%mod; b/=2; }
    return res % mod; } 

ll powmod(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 

ll modInverse(ll n, ll p) 
{ return powmod(n, p-2, p); } 

ll log(ll n, ll b)
{ ll c=0;
	while(n>(b-1))
	{ c++; n/=b; } return c; }

ll fib(ll n) 
{ double phi=(1+sqrt(5))/2; 
  return round(pow(phi,n)/sqrt(5)); } 

vector<bool> prime;
void sieve(int n)
{ prime.resize(n,true);
	for(int p=2;p*p<=n;p++)
		if(prime[p])
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false; }

void yes(){pn("Yes");}
void no(){pn("No");}
void bug(){cout<<"here"<<endl;}

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define pl pair<ll,ll>
#define pd pair<double,double>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vpl vector<pl>
#define vpd vector<pd>
#define vs vector<string>
#define vvl vector<vl>
#define vvs vector<vs>
#define vvpl vector<vpl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxpq(v) priority_queue<v>
#define minpq(v) priority_queue<v,vector<v>,greater<v>>

void solve()
{
	ll i,j;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll r=0;
	f0(i,n)
	if(s[i]=='R')
		r++;
	ll ans=0;
	f0(i,r)
	{
		if(s[i]=='W')
			ans++;
	}
	pn(ans);
}

int main()
{
	#ifdef Deeksha
		// freopen("../Downloads/validation_input.txt", "r", stdin);
		freopen("../Downloads/_input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	solve();/* 
	ll t;
	cin>>t;
	for(ll tt=1;tt<=t;tt++)
	{
		// cout<<"Case #"<<tt<<": ";
		solve();
	}
	//*/
}



Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long;
using namespace std;

/* initialize */
int pos;
vector<int> A, B, C;
/* main */
void recon(int l, int r){
    if (l >= r) return;
    int root = A[pos++];
    int m;
    m = distance(B.begin(), find(B.begin(), B.end(), root));
    recon(l, m);
    recon(m+1, r);
    C.push_back(root);
}
int main() {
    int n;
    cin >> n;
    int k;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &k);
        A.push_back(k);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &k);
        B.push_back(k);
    }

    int pos = 0;
    recon(0, A.size());
    for (int j = 0; j < n; ++j) {
        if (j) cout << " ";
        cout << C[j];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3236