akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
using namespace std;


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;++i) cin >> vec[i];
    int tillnow = vec[0];
    long long int res = 0;
    for(int i=1;i<vec.size();++i){
        if(vec[i] < tillnow){
            res += tillnow - vec[i];
        }
        else{
            tillnow = vec[i];
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[500000];    //    p---|  Unit
int *left2 = new  int[500000]; // left2 --|--------> T
int *right2 = new int[500000];//right2---|
int *key = new int[500000];  // key----|
 
void Init(){
  rep(i,500000){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
 
 
int FindRoot(){
  rep(i,n){
    if(p[i] == NIL){
      return i;
    }
  }
}
 
 
 
void TREE_INSERT(int z){
  int y = NIL; 
  int x = root;
 
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
 
}
 
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
 
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
 
 
int main(){
  int val;
  string op;
  int zr;                    
 
 
  scanf("%d",&n);
  Init(); 
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;        
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
  }
 
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
 
  return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
  /// Return `true` if the slice was permuted, `false` if it is already
  /// at the last ordered permutation.
  fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
  /// Original author in Rust: Thomas Backman <serenity@exscape.org>
  fn next_permutation(&mut self) -> bool {
    // These cases only have 1 permutation each, so we can't do anything.
    if self.len() < 2 { return false; }

    // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
    let mut i = self.len() - 1;
    while i > 0 && self[i-1] >= self[i] {
      i -= 1;
    }

    // If that is the entire vector, this is the last-ordered permutation.
    if i == 0 {
      return false;
    }

    // Step 2: Find the rightmost element larger than the pivot (i-1)
    let mut j = self.len() - 1;
    while j >= i && self[j] <= self[i-1]  {
      j -= 1;
    }

    // Step 3: Swap that element with the pivot
    self.swap(j, i-1);

    // Step 4: Reverse the (previously) weakly decreasing part
    self[i..].reverse();

    true
  }
}
fn main() {
  let(n, m) = {
    let tmp: Vec<usize> = read_vec();
    (tmp[0], tmp[1])
  };

  let mut a = vec![0; n];

  for i in 0..m {
    let mut sw: Vec<usize> = read_vec();
    sw.remove(0);
    for s in sw {
      a[s-1] |= (1 << i);
    }
  }


  let mut p = 0;

  let mut p_vec: Vec<usize> = read_vec();
  for i in 0..m {
    p |= (p_vec[i] << i);
  }

  let mut count = 0;

  for bit in 0..(1<<n) {
    let mut t = 0;
    for i in 0..n {
      if bit & (1 << i) != 0 {
        t ^= a[i];
      }
    }

    if t == p { count += 1; }
  }

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


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

constexpr int64 mod = 1e9+7;

int main(void){
	int32 N;
	cin >> N;
	vector<int32> A(N), X(N, 0);
	REP(i, N) cin >> A[i];
	if(A[0] != 0){
		cout << -1 << endl;
		return 0;
	}
	FOR(i, 1, N){
		if(A[i] > A[i-1]+1){
			cout << -1 << endl;
			return 0;
		}
	}
	int32 res = 0;
	bool ok = 0;
	for(int32 i = N-1;i >= 0;i--){
		if(A[i] == 0 || A[i] != A[i+1]-1) ok = 0;
		if(ok) continue;
		res += A[i];
		ok = 1;
	}
	cout << res << endl;
}

Measured memory_bytes: 3328
from math import ceil
from bisect import bisect_right

n, d, a = map(int, input().split())
l = []
l2 = []
l3 = []
l4 = [0 for i in range(n+1)]
l5 = [0 for i in range(n+1)]
ans = 0
for i in range(n):
  x, h = map(int, input().split())
  l.append([x, h])
  l2.append(x + 2 * d)
  l3.append(x)
l.sort(key=lambda x: x[0])
l2.sort()
l3.sort()
for i in range(n):
  cnt = ceil((l[i][1] - l4[i] * a) / a)
  if cnt > 0:
    ans += cnt
    ind = bisect_right(l3, l2[i])
    l5[ind] += cnt
    l4[i] += cnt
  l4[i+1] = l4[i] - l5[i+1]
    
print(ans)

Measured memory_bytes: 62348
def main():
    a, b = map(int, input().split())

    l = []
    for i in range(2, 1001):
        h = 0
        for j in range(1, i):
            h = h + j
        l.append(h)

    for i in range(len(l) - 1):
        if l[i] - a == l[i + 1] - b:
            print(l[i] - a)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    long k,n,a[200000],b[200000],max=0;
    // char s[150];
    scanf("%ld%ld",&k,&n);
    for (size_t i = 0; i < n; i++)
    {
        scanf("%ld",&a[i]);
    }
    
    for (size_t i = 0; i < n-1; i++)
    {
        b[i] = a[i+1] - a[i];
    }
    b[n-1] = (k - a[n-1]) + a[0];
    
    for (size_t i = 0; i < n; i++)
    {
        if (max < b[i])
        {
            max = b[i];
        }
        
    }
    printf("%ld",k-max);
    
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
 
using namespace std;
 
typedef long long ll;

int main(){
	int n, alice=0, bob=0;
	cin >> n;
	
	vector<int> a(n);
	rep(i,n) cin >>a[i];
	
	sort(all(a) , greater<int>());
	
	for(int i = 0;i < n; i += 2){
		alice += a[i];
	}
	for(int i = 1 ; i < n ; i +=2){
		bob += a[i];
	}
	
	cout << alice - bob << endl;
	
	return 0;
}
	

Measured memory_bytes: 256
import math
n, d = map(int, input().split())
arr = []
ans = 0
for i in range(n):
  x = list(map(int, input().split()))
  arr.append(x)

p = []
for i in range(n):
  for j in range(n):
    if i < j:
      p.append([i, j])

for ij in p:
  y = arr[ij[0]]
  z = arr[ij[1]]
  d = 0
  for i, j in zip(y, z):
    d += (i - j) ** 2 
  d = math.sqrt(d)
  if d == int(d):
    ans += 1
print(ans)

Measured memory_bytes: 3064
<?php
//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
fscanf(STDIN, "%d", $N);
$A = array_map('intval', explode(" ", trim(fgets(STDIN))));
$A = array_values(array_unique($A));
$cnt = count($A);
$ans = $A[0];
for ($i = 1; $i < $cnt; $i++) {
    $ans = gcd($ans, $A[$i]);
    if ($ans === 1) break;
}
echo $ans;


Measured memory_bytes: 21040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))


class COneStrokePath {
public:
    vector<vector<int>> v;
    int n;
    int ans = 0;

    void dfs(int s, vector<bool> seen) {
      seen[s] = true;
      for (int next_v : v[s]) {
        if (!seen[next_v])dfs(next_v, seen);
      }
      int sum = 0;
      REP(i, seen.size()) {
        if (seen[i] == true) {
          sum++;
        }
      }
      if (sum == n) {
        ans++;
      }
    }

    void solve(std::istream &in, std::ostream &out) {
      int m;
      in >> n >> m;
      v = vector<vector<int>>(n);
      REP(i, m) {
        int a, b;
        in >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
      }
      vector<bool> seen(n);
      dfs(0, seen);
      out << ans << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  COneStrokePath solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B, C, X;

int main(void){
    
    scanf("%d %d %d %d", &A, &B, &C, &X);
    
    int ans = 0;
    for(int a = 0; a <= A; ++a){
        for(int b = 0; b <= B; ++b){
            int temp = a * 500 + b * 100;
            if(X - temp >= 0 && (X - temp) / 50 <= C) ++ans;
        }
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_a

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    m, d = map(int, input().split())
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            d1 = int(str(j)[1])
            d10 = int(str(j)[0])
            if d1 < 2 or d10 < 2:
                continue
            if i == d1 * d10:
                # print('{} {} {}'.format(i, d10, d1))
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
let () =
  let days = [|0; 31; 29; 31; 30; 31; 30; 31; 31; 30; 31; 30|] in
  let weekdays = [|"Wednesday"; "Thursday"; "Friday"; "Saturday"; "Sunday"; "Monday"; "Tuesday"|] in
  let solve month day =
    let rec doit i sum =
      if i = month then sum
      else doit (i + 1) (sum + days.(i)) in
    weekdays.((day + doit 1 0) mod 7) in
  let rec main_loop () =
    let (m, d) = Scanf.scanf "%d %d " (fun m d -> m, d) in
    if m = 0 && d = 0 then ()
    else begin
      solve m d |> print_endline;
      main_loop ()
    end in
  main_loop ()

Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Edge {
	int to, cost;
};
bool operator >(const Edge& e1, const Edge& e2) {
	return e1.cost > e2.cost;
}

int main() {
	int n, m;
	while ( cin >> n >> m, n || m ) {
		vector< vector<Edge> > edge(n);
		for (int i = 0; i < m; ++i) {
			int a, b, cost; cin >> a >> b >> cost;
			edge[a].push_back( (Edge){ b, cost } );
			edge[b].push_back( (Edge){ a, cost } );
		}

		int ans = 0;

		priority_queue<Edge, vector<Edge>, greater<Edge> > Q;
		Q.push( (Edge){ 0, 0 } );
		vector<bool> f(n, false);
		while ( !Q.empty() ) {
			Edge e = Q.top(); Q.pop();

			if (f[e.to]) continue;
			f[e.to] = true;

			ans += e.cost;

			for (int i = 0; i < edge[e.to].size(); ++i) {
				Q.push(edge[e.to][i]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1228
#include<iostream>
using namespace std;
int main(){
  int N;
  while(cin >> N){
    if(N == 0) return 0;
    int k[N];
    int count = 0;
    bool ok = false;
    for(int i=0;i<N;i++){
      cin >> k[i];
      if(k[i] > 1) ok = true;
      if(k[i] == 0) count++;
    }
    if(!ok) cout << "NA" << endl;
    else cout << N-count+1 << endl;
  }
}

Measured memory_bytes: 1200
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int ans;

main(){
	int n,mem=INT_MAX;
	int mcnt=0;
	cin>>n;
	//int a[n];
	rep(i,n){
		int t;cin>>t;
		if(t<0)mcnt++;
		t=abs(t);
		ans+=t;
		mem=min(mem,t);
	}
	if(mcnt%2==1){
		ans-=2*mem;
	}
	dans;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int a;
		int i=0;
		Scanner scan = new Scanner(System.in);
		while(true)
		{
			a=scan.nextInt();
			if(a==0)
				break;
			//a= Integer.parseInt(scan.next());
			System.out.println("Case "+(i+1)+": "+a);
			i++;
		}
		
	}


	}

Measured memory_bytes: 45740
#include <bits/stdc++.h>
using namespace std;
#define SYNC                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007s
#define all(c) c.begin(), c.end()
#define endl '\n'

typedef long long int lli;

int main()
{
    SYNC

        string s;

    cin >> s;

    if (s == "Sunny")
        cout << "Cloudy";
    else if (s == "Cloudy")
        cout << "Rainy";
    else if (s == "Rainy")
        cout << "Sunny";

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
M = []
for i in range(H):
    L = list(input())
    if '#' in L:
        M.append(L)
Mt = list(map(list, zip(*M)))
A = []
for i in range(W):
    L = Mt[i]
    if '#' in L:
        A.append(L)
ans = list(map(list, zip(*A)))
for i in range(len(ans)):
    L = ans[i]
    print("".join(L))

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

#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--)

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

int main(void) {
    int x, ans, p, t;
    ans = 1;
    cin >> x;
    FOR(b, 2, x){
        p = 2;
        while(1){
            t = pow(b, p);
            if(t <= x){
                if(ans < t) ans = t;
                p++;
            } else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;



int to(char a[]){
	int ans =0;
	int b =1;
	
	REP(i,sizeof(a))
			{
				if(a[i]=='m'){	ans += b*1000;	b=1;}
				else if(a[i]=='c'){	ans += b*100;	b=1;}
				else if(a[i]=='x'){	ans += b*10;	b=1;}
				else if(a[i]=='i'){	ans += b*1;	b=1;}
				else if(a[i]=='2'){	b=2;}
				else if(a[i]=='3'){	b=3;}
				else if(a[i]=='4'){	b=4;}
				else if(a[i]=='5'){	b=5;}
				else if(a[i]=='6'){	b=6;}
				else if(a[i]=='7'){	b=7;}
				else if(a[i]=='8'){	b=8;}
				else if(a[i]=='9'){	b=9;}}
	return ans;
}

void from(int a)
{
	if(a/1000 == 1 ){	cout << 'm'	;	}
	else if(a/1000 > 1){	cout << a/1000 << 'm'	;}
	a %= 1000;
	
	if(a/100 == 1 ){	cout << 'c'	;	}
	else if(a/100 > 1){	cout << a/100 << 'c'	;}
	a %= 100;
	
	if(a/10 == 1 ){	cout << 'x'	;	}
	else if(a/10 > 1){	cout << a/10 << 'x'	;}
	a %= 10;
	
	if(a/1 == 1 ){	cout << 'i'	;	}
	else if(a/1 > 1){	cout << a/1 << 'i'	;}
	a %= 1;
	
	cout << endl;
}

int main() 
{
	int n;
	cin >> n;
	REP(i,n)
	{
	char a[9]={};
	char b[9]={};
	cin >> a >> b;
	from(to(a)+to(b));
		
	}
	return 0 ;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    ll cnt[5] = {};
    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        switch(S[0]) {
        case 'M':
            cnt[0]++;
            break;
        case 'A':
            cnt[1]++;
            break;
        case 'R':
            cnt[2]++;
            break;
        case 'C':
            cnt[3]++;
            break;
        case 'H':
            cnt[4]++;
            break;
        default:
            break;
        }
    }
    ll ans = 0;
    for(int i = 0; i < 5; i++) {
        for(int j = i + 1; j < 5; j++) {
            ll a = 1;
            for(int k = 0; k < 5; k++)
                if(k != i && k != j) {
                    a *= cnt[k];
                }
            ans += a;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> c(n - 1), s(n - 1), f(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }
  for (int i = 0; i < n; i++) {
    int sum = 0;
    if (i != n - 1) {
      sum += s[i];
      for (int j = i; j < n - 1; j++) {
        if (j != i && sum != s[j] && sum % f[j] != 0) {
          sum = sum + f[j] - sum % f[j];
        }
        sum += c[j];
        if (j != n - 2 && sum < s[j + 1]) {
          // aa
          sum += (s[j + 1] - sum);
        }
      }
    }

    // for (int i = 0; i < n; i++) {
    //    int t = 0;
    //    for (int j = i; j < n -1 ; j++) {
    //        if (t < s[j]) t = s[j];
    //        else if (t % f[j]);
    //        else t = t + f[j] - (t % f[j]);
    //    }
    //  }
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
u=UnionFind(n)
for i in range(m):
    u.union(a[i][0]-1,a[i][1]-1)
print(u.group_count())

Measured memory_bytes: 31760
N,a,b = map(int,input().split())

temp = 0   
sum1 = 0
sum2 = 0
for i in range(N):
  temp = i+1
  sum1 = 0          
  while temp != 0:
    sum1 += temp%10
    temp = int(temp/10)
  if sum1 >= a and sum1 <= b:
    sum2 += i+1
    #print(i)

print(sum2)  

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

using namespace std;

int main() {
    vector<int> H, W;
    int i = 0, n, m;
    
    while(1) {
        cin >> n >> m;
        H.push_back(n);
        W.push_back(m);
        
        if(H[i] == 0 && W[i] == 0) break;

        i++;
    }
    
    for(i = 0; H.size(); i++) {
        if(i != 0) cout << endl;
        if(H[i] == 0 && W[i] == 0) break;
        
        for(int x = 0; x < H[i]; x++) {
            for(int y = 0; y < W[i]; y++) {
                cout << "#";
                
                if(y == W[i]-1) cout << endl;
            }
        }
    }
    
    
}

Measured memory_bytes: 1212
import numpy as np

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

points = []

cnt = 0

for _ in range(n):
  point = np.array(list(map(int, input().split())))
  for p in points:
    d = point - p
    if np.sqrt((d * d).sum()).is_integer():
      cnt += 1
  
  points.append(point)
  
print(cnt)

Measured memory_bytes: 15792
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

s = sys.stdin.buffer.readline().decode().rstrip()

ok = True
ok &= s[0] == 'A'
ok &= s[2:-1].count('C') == 1
uc = 0
for c in s:
    if c in string.ascii_uppercase:
        uc += 1
ok &= uc == 2
if ok:
    print('AC')
else:
    print('WA')


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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	string s, t; 
	cin >> s>> t; 
	int a , b ;
	cin >> a >> b ;
	string u ;
	cin >> u ;
	if(s==u) a-- ;
	else b--;
	cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 998244353
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;
typedef pair<llint, llint> P;

int n;
vector<int> G[100005];
llint a[100005], b[100005];
llint sum[100005];
llint h[100005];

llint dfs(llint v, llint p)
{
	sum[v] = a[v];
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		sum[v] += dfs(G[v][i], v);
	}
	return sum[v];
}

void dfs2(llint v, llint p)
{
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		h[G[v][i]] = h[v] + sum[G[v][i]];
		dfs2(G[v][i], v);
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	int u, v;
	for(int i = 0; i < n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i], a[i] -= b[i];
	
	dfs(1, -1);
	dfs2(1, -1);
	
	llint ans = 0, mn = 0;
	for(int i = 1; i <= n; i++){
		ans += h[i];
		mn = min(mn, h[i]);
	}
	ans -= mn * n;
	cout << ans << endl;
	
	return 0;
}


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

ll max(ll a,ll b){
	if(a>=b)
		return a;
	else
		return b;
}
int main(){
	ll n;
	ll w;
	cin>>n>>w;
	ll Wt[n];
	ll va[n];
	ll cost=0;
	for(ll i=0;i<n;i++){
		cin>>Wt[i]>>va[i];
		cost+=va[i];
	}
	//cout<<Wt[0]<<" "<<va[0]<<endl;
	ll dp[n+1][cost+1];
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=cost;j++){
			dp[i][j]=INT_MAX;
		}
	}
	for(ll j=0;j<=n;j++){
		dp[j][0]=0;
	}
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=cost;j++){
			if(j-va[i-1]>=0){
				//cout<<dp[i-1][j]<<" "<<dp[i-1][j-Wt[i-1]]+va[i-1]<<endl;
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-va[i-1]]+Wt[i-1]);
			}
			else
				dp[i][j]=dp[i-1][j];
				
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	for(ll j=cost;j>=1;j--){
		if(dp[n][j]<=w){
			cout<<j<<endl;
			break;
		}
	}
}

Measured memory_bytes: 82480
#include <iostream>
using namespace std;
 
string s,t;
//string ws="aji";
int main() {
	// your code goes here
	cin >> s>>t;
    int letras=0;
    int c;
    int mejor = t.size();
    int tamt = t.size();
    for(int i=0; i<=(s.size()-t.size());i++){
        c=0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]!=t[j]){
                c++;
            }
        }  
        if(c<mejor){
            mejor=c;
        }
    }
    cout <<  mejor << endl;
  
 
}

Measured memory_bytes: 3180
#include <stdio.h>

int main(){
  int i,j,k,l,key;
  int a[100];

  scanf("%d",&l);
  for(i=0; i<l; i++)
    scanf("%d",&a[i]);

  for(k=0; k<l-1; k++)
      printf("%d ",a[k]);
    printf("%d\n",a[k]);

  for(i=1; i<l; i++){
    key = a[i];
    j = i-1;
    while(j>=0 && a[j]>key){
      a[j+1] = a[j];
      j--;
    }
    a[j+1]=key;
    for(k=0; k<l-1; k++)
      printf("%d ",a[k]);
    printf("%d\n",a[k]);
  }
  return 0;
}
  

  



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long N;
	scanf("%lld",&N);
	long long T[N];
	if(N>=1 && N<=100){
		for(long long i=0;i<N;i++){
			scanf("%lld",&T[i]);
			if(T[i]<0 && T[i]>pow(10,5))
				return 0;
		}
	}
	long long M;
	scanf("%lld",&M);
	long long P[M],X[M];
	if(M>=1 && M<=100){
		for(long long z=0;z<M;z++){
			scanf("%lld %lld",&P[z],&X[z]);
			if(P[z]<0 && P[z]>N && X[z]<0 && X[z]>pow(10,5))
				return 0;
		}
			
		
	}
	long long sum=0;
	for(long long j=0;j<M;j++){
		sum=0;
		for(long long x=0;x<N;x++){
			if(P[j]!=(x+1))
				sum+=T[x];
			else
				sum+=X[j];
		}
		printf("%lld\n",sum);
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int ansTrue[100001];
int main() {
    string S;
    cin >> S;
    int posL = S.size() - 1, posR = 0;
    int ans[100001];
    rep(i, S.size()) {
        if(S[i] == 'R'){
            posR = i;
        }
        else{
            ans[i] = i - posR - 1;
        }
    }
    for(int i = S.size() - 1; i >= 0; --i) {
        if(S[i] == 'R') {
            ans[i] = posL - i - 1;
        }else {
            posL = i;
        }
    }
    rep(i, S.size()){
        if(S[i] == 'R'){
            if(ans[i] % 2 == 0) {
                ++ansTrue[i + ans[i]];
            }else {
                ++ansTrue[i + ans[i] + 1];
            }
        } else {
            if(ans[i] % 2 == 0) {
                ++ansTrue[i - ans[i]];
            }else {
                ++ansTrue[i - ans[i] - 1];
            }
        }
    }
    rep(i, S.size())
        cout << ansTrue[i] << ' ';
}


Measured memory_bytes: 1408
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt(),k=gInt();
		System.out.print(k==100?101:k);
		for(int i:rep(n))
			System.out.print("00");
		System.out.println();
	}
	
	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


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

int main() {
	int n,ans=0;cin>>n;
  	while(n>0){
    	ans+=n%10;
      	n/=10;
    }
  	if(ans==1){
    	cout<<10<<endl;
    }else{
    	cout<<ans<<endl;
    }
}

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

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

  ll x = a-b;
  if (k%2 == 0) cout << x << endl;
  else cout << -x << endl;

  return 0;
}


Measured memory_bytes: 256
room=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]

for i in range(int(input())):
	n=list(map(int,input().split()))
	room[n[0]-1][n[1]-1][n[2]-1]+=n[3]
n=0
for i in room:
	for j in i:
		print(' '+' '.join(list(map(str,j))))
		if n==2 or n==5or n==8:
			print('####################')
		n+=1


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   double r;
   cin>>r;
   cout<<2*pi*r<<endl;

   End;
}


Measured memory_bytes: 3800
#include<iostream>
#define mod 1000000007
using namespace std;
long long dp[3001][3001][2],ans;
int main()
{
  int n,m;
  cin>>n>>m;
  for (int i=1;i<=n;++i)
     dp[0][i][0]=1;
  dp[0][0][1]=1;
  for (int i=1;i<=m;++i)
    for (int j=0;j<=n;++j)
      {
	 if (j>=1)
	   {
	     dp[i][j][1]=(dp[i][j][1]+dp[i-1][j-1][1])%mod;
	     dp[i][j][0]=(dp[i][j][0]+dp[i-1][j-1][0])%mod;
	   }
	 if (j>=1)
	   {
	    dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][1])%mod;
	    if (j==1)
              dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][0])%mod;
            else
	      dp[i][j][0]=(dp[i][j][0]+dp[i-1][j][0])%mod;
	   }
	 if (j<=n-1)
	   {
	     dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][1])%mod;
	     dp[i][j][0]=(dp[i][j][0]+dp[i-1][j][0])%mod;
	   }
	 if (j<=n-1)
	   {
	     dp[i][j][1]=(dp[i][j][1]+dp[i-1][j+1][1])%mod;
	     if (j==0)
       	       dp[i][j][1]=(dp[i][j][1]+dp[i-1][j+1][0])%mod;
             else
	       dp[i][j][0]=(dp[i][j][0]+dp[i-1][j+1][0])%mod;
	   }
      }
  for (int i=0;i<=n;++i)
      ans=(ans+dp[m][i][1])%mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  int a[n+1];
  for(int i=1;i<=n;i++)
    	cin >> a[i];
  sort(a+1,a+n+1);
  int ans=0x7fffffff;
  for(int i=1;i<=n-k+1;i++)
    if((a[i+k-1]-a[i])<ans)ans=a[i+k-1]-a[i];
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<pair<ll, ll>> opr;
    ll low = a[0], high = a[n - 1];
    reps(i, 1, n - 1) {
        if (a[i] > 0) {
            opr.push_back(make_pair(low, a[i]));
            low -= a[i];
        }
        else {
            opr.push_back(make_pair(high, a[i]));
            high -= a[i];
        }
    }
    opr.push_back(make_pair(high, low));
    printf("%lld\n", high - low);
    rep(i, sz(opr)) printf("%lld %lld\n", opr[i].first, opr[i].second);
    return 0;
}


Measured memory_bytes: 4336
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string S;
  cin >> S;
  int Ans = 0;
  if(S[0]=='1') ++Ans;
  if(S[1]=='1') ++Ans;
  if(S[2]=='1') ++Ans;
  printf("%d\n",Ans);
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1010][1010];
int main(){string a,b;cin>>a>>b;
int A=a.size(),B=b.size();
for(int i=0;i<=A;i++)dp[i][0]=i;
for(int i=0;i<=B;i++)dp[0][i]=i;
for(int i=1;i<=A;i++){
for(int j=1;j<=B;j++){
int q=1;if(a[i-1]==b[j-1])q = 0;
dp[i][j]=min(min(dp[i-1][j-1]+q,dp[i][j-1]+1),dp[i-1][j]+1);}}
cout<<dp[A][B]<<endl;return 0;}


Measured memory_bytes: 7096
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;

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

int main()
{
	int N, M, ans = 0;
	cin >> N >> M;

	int j = 0;

	vector<int> s(M), c(M);

	rep(i, M) cin >> s[i] >> c[i];

	rep(k, 1000) {
		string str = to_string(k);
		if (str.size() == N) {
			int j = 0;
			rep(i,M) {
				if (str[s[i] - 1] == c[i]+'0') { ++j; }
			}
			if (j == M) { cout << k << endl; goto xyz; }
		}
	}
	cout << -1 << endl;
xyz:;
}

Measured memory_bytes: 256
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS 
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	int a,b;
    cin >> a >> b;
    (a%3==0 || b%3==0 || (a+b)%3==0) ? cout<<"Possible": cout<<"Impossible";
	return 0;
	// Bye Bye 2019
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,k;
    cin>>h>>w>>k;

    char a[h][w];
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
            cin>>a[i][j];
    int ans=0,black;
    for(int maskr=0;maskr<(1<<h);++maskr)
    {
        for(int maskc=0;maskc<(1<<w);++maskc)
        {
            black=0;
            for(int i=0;i<h;++i)
            {
                for(int j=0;j<w;++j)
                {
                    if(((1<<i)&maskr)==0 && ((1<<j)&maskc)==0 &&a[i][j]=='#')black+=1;
                }
            }
            if(black==k)++ans;
        }
    }
    cout<<ans;

}


Measured memory_bytes: 3520
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define rep0(_i, _n) for(int _i = 0; (_i)<(_n) ;++_i)
#define rep1(_i, _n) for(int _i = 1; (_i)<=(_n) ;++_i)
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multi int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T a){while(n--)cin >> *a, ++a;}
template<typename T1, typename T2> void read(int n, T1 a, T2 b){while(n--)cin >> *a >> *b, ++a, ++b;}
template<typename T> void write(int n, T a){while(n--)cout << *a << " \n"[n==0], ++a;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 300010;
const int p = 998244353;
int n;
int d[maxn];
vector<int> dot[maxn];
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	read(n, d+1);
	rep1(i, n)dot[d[i]].emplace_back(i);
	if(dot[0].empty() || dot[0].size() > 1 || dot[0].front() != 1)rout(0);
	ll res = 1, cnt = 0;
	rep1(i, n){
		if(dot[i].empty())break;
		cnt += dot[i].size();
		// cout << i << ' ' << dot[i].size() << ' ' << dot[i-1].size() << '\n';
		res = (res * pow(dot[i-1].size(), dot[i].size(), p) % p);
	}
	if(cnt != n-1)rout(0);
	rout(res);
}

Measured memory_bytes: 11520
N, X = map(int, input().split())

mn = [0]*N
for i in range(N):
  mn[i] = int(input())
  
ans = N
x = X - sum(mn)

while(x >= min(mn)):
  if x // min(mn) == 0:
    mn[mn.index(min(mn))] = 1000000
  else:
    x -= min(mn)
    ans += 1
      
print(ans)

Measured memory_bytes: 3064
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <iostream>
using namespace std;
string s;
int sum[100005];
int main() {
  int n, q;
  cin >> n >> q >> s;

  for (int i = 0; i < n; i++) {
    sum[i] = sum[i - 1];
    if (s[i] == 'C' && s[i - 1] == 'A') sum[i]++;
  }

  while (q--) {
    int l, r;
    cin >> l >> r;

    cout << sum[r - 1] - sum[l - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
A, B = list(map(int, input().split()))

cd = []

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


for i in range(1,int(A**0.5)+1):
    if A % i == 0:
        if B % i == 0:
            cd.append(i)
        if B % (A / i) == 0:
            cd.append(int(A / i))

ans = 1
for i in cd:
    if is_prime(i):
        ans += 1

print(ans)

Measured memory_bytes: 3280
using System;
using System.Collections.Generic;


class Program
{

    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        int diff = 1000;

        for(int i=0; i <= s.Length - 3; i++)
        {
            int wk = Math.Abs(753 - int.Parse(s.Substring(i, 3)));
            if(wk < diff)
            {
                diff = wk;
            }
            
        }

        Console.WriteLine(diff.ToString());

    }

}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
int main() {
  int N; 
  cin >> N;
  if (N <= 1) {
    cout << "0" << endl;
    return 0;
  }
  ll a[] = {1,1,1};
  FOR(i,0,N) {
    FOR(j,0,3) {
      a[j] *= 10-j;
      a[j] %= 1000000007;
    }
  }
  while (a[0]-2*a[1]+a[2] < 0) {
    a[0] += 1000000007;
  }
  cout << a[0]-2*a[1]+a[2] << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	replace(s.begin(), s.end(), ',', ' ');

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 19:37:48
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if((a+b)%2==0)
        cout << (a+b)/2 << endl;
    else cout << (a+b)/2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 3640