akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);

    let mut set = HashSet::with_capacity(100_000);

    for _ in 0..n {
        let x = get!(u32);

        if !set.remove(&x) {
            set.insert(x);
        }
    }

    println!("{}", set.len());
}


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

long int gcd(long int x, long int y) {
  if(x <= 0) return y;
  return gcd(y%x, x);
}

int main() {
  long int a, b;
  scanf("%ld%ld", &a, &b);
  long int g = gcd(a, b);
  int ans = 1;
  /*for (int i=1; i<=sqrt((double)g); i++) {
    if(g%i!=0) continue;
    int boo=1;
    for (int j=2; j<=sqrt((double)i); j++) {
      if(i%j!=0) continue;
      boo = 0;
      break;
    }
    if(boo) ans++;

    int l=g/i;
    if (l==i) continue;
    boo=1;
    for (int j=2; j<=sqrt((double)l); j++) {
      if(l%j!=0) continue;
      boo = 0;
      break;
    }
    if(boo) ans++;
  }*/
  for (int i=2; i<=sqrt((double)g); i++) {
    if (g%i!=0) continue;
    ans++;
    while (g%i==0) g/=i;
  }
  if(g>1) ans++;
  printf("%d\n", ans);
  return 0;
}


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

const int MAX = 1000000;
const int MOD = 1000000007;

signed main() {
 int n,ans=0;
 cin>>n;
 vector<int> k;
 while(n!=0){
     k.push_back(n%10);
     ans+=n%10;
     n/=10;
 }
 int ans2=ans;
 for(int i=0;i<k.size()-1;i++){
     if(k[i+1]==0)continue;
     ans2=(i+1)*9-1;
     for(int j=i+1;j<k.size();j++)ans2+=k[j];

     ans=max(ans,ans2);
 }
 cout<<ans;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < p.size(); i++) {
    cin >> p[i];
  }

  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if (max({p[i - 1], p[i], p[i + 1]}) > p[i] &&
        min({p[i - 1], p[i], p[i + 1]}) < p[i])
      ans++;
  }

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

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
long long a[100010];
long long cmp(long long x,long long y){
	return x>y;
}
int main(){
	long long i,j,k,m,n;
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	long long flag=a[1],cnt=1,ans=0;
	for (i=2;i<=n;i++){
		if (a[i]==flag)
			cnt++;
		if (cnt>=2){
			cnt=0;
			if (ans!=0){
				printf("%lld\n",ans*flag);
				return 0;
			}
			ans=flag;
		}
		if (flag!=a[i]){
			flag=a[i];
			cnt=1;
		}
	}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 896
import 'dart:convert';
import 'dart:io';
import 'dart:async';

Future main() async {
  int n = int.parse(stdin.readLineSync());
  Stream<String> sLines =
      stdin.transform(utf8.decoder).transform(LineSplitter()); // ここ大事（複数行入力）
  int count = 0;
  int c0 = 0;
  int c1 = 0;
  int c2 = 0;
  int c3 = 0;

  await for (var line in sLines) {
    // print("22$line");
    count++;
    // print("count$count");
    // print(line);

    if (line.startsWith("AC")) {
      c0++;
      // print("o0");
    } else if (line.startsWith("WA")) {
      c1++;
      // print("o1");
    } else if (line.startsWith("TLE")) {
      c2++;
      // print("o2");
    } else if (line.startsWith("RE")) {
      c3++;
      // print("o3");
    }
    if (c0 + c1 + c2 + c3 == n) break;
    if (count >= n) break;
  }
  print("AC x $c0");
  print("WA x $c1");
  print("TLE x $c2");
  print("RE x $c3");
}

Measured memory_bytes: 18144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long d = scan.nextInt();
		int count = 0;
		for(int i = 0; i < n; i++) {
			long x = scan.nextLong();
			long y = scan.nextLong();
			long xx;
			long yy;
			xx = (long)Math.pow(x,2);
			yy = (long)Math.pow(y,2);

			if(d>=Math.sqrt(xx+yy)) {
				count = count + 1;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 59132
#include<bits/stdc++.h>
using namespace std;
#define For(n) for(int i=0;i<n;i++)
#define Forj(n) for(int j=0;j<n;j++)
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define in1(n,c) c n;cin>>n
#define in2(a,b,c) c a,b;cin>>a>>b
#define ina(a,n,c) c a[n];rep(i,0,n)cin>>a[i]
#define ins(s) string s;cin>>s
#define mset(a,n) memset(a,n,sizeof a)
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define lbd lower_bound
#define ubd upper_bound
#define ll  long long
#define ull unsigned long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl

int main ()
{
    in1(n,int);
    ina(a,n,int);
   vector<pair<int,int>> v;
   For(n)
   {
       v.pb(mp(a[i],i+1));
   }
   sort(all(v));
   For(n)
   {
       out(v[i].se);
   }
}


Measured memory_bytes: 2164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h, w, a, b; cin >> h >> w >> a >> b;
    vector<string> v;
    string s = string(a,'0') + string(w-a,'1');
    string s2 = string(a,'1') + string(w-a,'0');

    rep(i,h-b) {
        cout << s << endl;
    }
    rep(i,b) {
        cout << s2 << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int n;
bool a[30][30];
ll dp[2][2097160];

ll go(int pos, int mask) {
    if(pos == n) return 1;

    ll ans = 0;

    if(dp[pos & 1][mask] != -1) return dp[pos & 1][mask];

    for(int i = 0; i < n; i++) {
        if(a[pos][i] && !(mask & (1 << i))) {
            ans += go(pos + 1, mask | (1 << i)) % MOD;
            ans %= MOD;
        }
    }

    return dp[pos & 1][mask] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n;

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

    memset(dp, -1, sizeof dp);

    cout << go(0, 0) << endl;
}

/*
 * O
 **/


Measured memory_bytes: 33024
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 

using namespace std;
typedef long long ll;


int main()
{
	int m,n;
	cin >> n;
	if (n % 2==0)
	{
		m = n * (n - 2) / 2;
	}
	else
	{
		m = ((n - 1) * (n - 2) + n - 1) / 2;
	}
	printf("%d\n", m);
	if(n%2==0)
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if (i + j == n + 1)continue;
			else printf("%d %d\n", i, j);
		}
	}
	else
		for (int i = 1; i <= n; i++)
		{
			for (int j = i + 1; j <= n; j++)
			{
				if (i + j == n)continue;
				else printf("%d %d\n", i, j);
			}
		}
}




Measured memory_bytes: 256
using System;
using System.Linq;
public class Program {
    public static void Main() {
        int n = int.Parse(Console.ReadLine());
        for(int i = 0; i < n; i++) {
            string[] s = Console.ReadLine().Split();
            int[] a = new int[3];
            for(int j = 0; j < 3; j++) a[j] = int.Parse(s[j]);
            Array.Sort(a);
            Console.WriteLine(((a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) ? "YES" : "NO"));
        }
    }
}


Measured memory_bytes: 13840
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>
#include <numeric>

#define LOP(N) for(int i=0; i<N; i++)
#define LOOP(i, N) for(int i=0; i<N; i++)
#define LOOP_s(i, start, end) for(int i=start; i<end; i++)

typedef long long ll;

using namespace std;


int main() {
    int N; cin >> N;
    vector<int> a(N+1);
    LOOP(i, N) cin >> a[i+1];
    
    int now = 1, old, count = 0;
    while (a[now] != 0) {
        ++count;
        if (a[now] == 2) {
            cout << count;
            return 0;
        }
        
        old = now;
        now = a[now];
        a[old] = 0;
    }
    cout << -1;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define double long double
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P,point;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
 
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
typedef L line;
typedef vector<P> G,polygon;
 
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};
 
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
 
vector<P> convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}
 
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}
 
double extreme(const vector<point> &P, const line &l) {
  double mi = 1e18;
  double mx = -1e18;
  for (int i = 0; i < P.size(); ++i){
    mi = min(mi,distanceLP(l,P[i]));
    mx = max(mx,distanceLP(l,P[i]));
     
  }
  return mx - mi;
}
 
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
 
double pi = acos(-1);
 
P pos[100010];
int main(){
    int N;
    cin >> N;
    vector<P> ps;
    pos[0] = P(0,0);
    for(int i = 1 ; i < N ; i++){
        int n,d;
        cin >> n >> d;
        pos[i] = pos[n] + P(dx[d],dy[d]);
    }
    for(int i = 0 ; i < N ; i++){
        ps.push_back(pos[i]+P(0.5,0.5));
        ps.push_back(pos[i]+P(-0.5,-0.5));
        ps.push_back(pos[i]+P(-0.5,0.5));
        ps.push_back(pos[i]+P(0.5,-0.5));
    }
    auto ch = convex_hull(ps);
    double ans = 1e18;
     
    for(int i = 0 ; i < ch.size() ; i++){
        L l = L(ch[i],ch[(i+1)%ch.size()]);
		P vec = (l[1]-l[0]) / abs(l[1]-l[0]);
		P vec2 = vec * exp(P(0,pi/2));
        L far1=l;
        far1[0] += (double)1000000.0 * vec2;
        far1[1] += (double)1000000.0 * vec2;
        L far3=l;
         
        far3[0] *= exp(P(0,pi/2));
        far3[1] *= exp(P(0,pi/2));
         
        far3[0] += (double)1000000.0 * vec;
        far3[1] += (double)1000000.0 * vec;
         
        double D1 = extreme(ch,far1);
        double D2 = extreme(ch,far3);
         
        ans = min( ans, D1 * D2 );
         
    }
    printf("%.10Lf\n",ans);
     
}

Measured memory_bytes: 56124
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
using ll = long long;

int main(){ 
  int  h1, m1, h2, m2 ,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h3 = h2 -1;
  int m3 = m2 + 60;
  int a = (h3-h1)*60+(m3-m1);
  cout << max(a-k, 0) << endl;
  return 0;
} 

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	scanf("%d%d",&n,&k);
	ll x=1;
	while(x<=n){
		ans++;
		x*=k;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  vector<ll> x(5);
  int ans = 0;
  for (int i=0; i<5; i++){
    cin >> x[i];
    if (x[i] == 0) ans = i+1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    private void solve() {
        String string = in.next();
        boolean s = false, e = false, n = false, w = false;
        for (char ch : string.toCharArray()) {
            switch (ch) {
                case 'S':
                    s = true;
                    break;
                case 'E':
                    e = true;
                    break;
                case 'N':
                    n = true;
                    break;
                case 'W':
                    w = true;
                    break;
            }
        }

        if (s ^ n || e ^ w) {
            out.println("No");
        } else {
            out.println("Yes");
        }
    }

    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private FastScanner in;
    private PrintWriter out;


    private void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(new BufferedOutputStream(System.out));
            solve();
        } catch (Exception e) {
            throw e;
        } finally {
            out.close();
        }
    }


    public static void main(String[] arg) {
        new Main().run();
    }
}





Measured memory_bytes: 8020
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>

#if __cplusplus >= 201103 //C++11~
#include <tuple>

#endif



using namespace std;

typedef pair<int,int> Paint;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
YesNo大文字小文字間違えてないか
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
tupleはC++11以降

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int n;cin>>n;
  int a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    for(int j = i; n > j; j++){
      if(i==j)continue;
      ans += a[i]*a[j];
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;    
#define int long long        
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar) for(int pen=0;pen<sizeof(ar)/8;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rt return 0;
#define mod 1000000007
const int N= 1e5+ 10;
int st[N]={0};
const int INF = 1e16;
void update(int ss, int se, int i, int diff, int si)  
{  
    // Base Case: If the input index lies outside the range of  
    // this segment  
    if (i < ss || i > se)  
        return;  
  
    // If the input index is in range of this node, then update  
    // the value of the node and its children  
    st[si] = st[si] + diff;  
    if (se != ss)  
    {  
        int mid = (ss+se)/2;  
        update(ss, mid, i, diff, 2*si);  
        update(mid+1, se, i, diff, 2*si + 1);  
    }  
}  
int get_sum(int ss, int se, int qs, int qe, int si)  
{  
    // If segment of this node is a part of given range, then return  
    // the sum of the segment  
    if (qs <= ss && qe >= se)  
        return st[si];  
  
    // If segment of this node is outside the given range  
    if (se < qs || ss > qe)  
        return 0;  
  
    // If a part of this segment overlaps with the given range  
    int mid = (ss+se)/2;
    return get_sum(ss, mid, qs, qe, 2*si) +  
        get_sum(mid+1, se, qs, qe, 2*si+1);  
}
signed main()
{
    fastio;
    int n,m;
    cin>>n>>m;
    string str[n];
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
    }
    int dp[n][m];
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i==0 && j==0)
            continue;

            if(i==0)
            {
                if(str[i][j]=='.')
                {
                    dp[i][j]=dp[i][j-1]%mod;
                }
                else
                {
                    dp[i][j]=0;
                } 
            }
            else if(j==0)
            {
                if(str[i][j]=='.')
                {
                    dp[i][j]=dp[i-1][j]%mod;
                }
                else
                {
                    dp[i][j]=0;
                } 
            }
            else
            {
                if(str[i][j]=='.')
                {
                    dp[i][j]=(dp[i-1][j] + dp[i][j-1])%mod;
                }
                else
                {
                    dp[i][j]=0;
                } 
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}

Measured memory_bytes: 9088
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n, p;
  scanf("%d%d", &n, &p);
  char s[n+5];
  scanf("%s", s);
  long ans = 0;
  if (10%p == 0) {
    for (int i = 0; i < n; i++)
    {
      if ((s[i] - '0') % p == 0)
        ans += i + 1;
    }
  } else {
    long dig = 1, r[p], t = 0;
    for (int i = 0; i < p; i++)
      r[i] = 0;
    r[0]++;
    for (int i = n; i > 0; i--)
    {
      t += (s[i-1] - '0') * dig;
      t %= p;
      r[t]++;
      dig *= 10;
      dig %= p;
    }
    for (int i = 0; i < p; i++)
      ans += (r[i] * (r[i] - 1)) / 2;
  }
  printf("%ld\n", ans);
  return 0;
}


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

int main()
{


	int n, m; cin >> n >> m;
	long long int ara[n], vote = 0;
	long double adds = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> ara[i];
		vote += ara[i];
	}

	sort(ara, ara + n, greater<int>());
	adds = (vote*1.0) / (4 * m);
	
	for (int k = 0; k < m; ++k)
	{
		if (ara[k] < adds)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3596
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var a , b = sc.nextInt()
  var s = sc.next()
  if (s.take(a).indexOf('-') != -1){println("No");sys.exit()}
  s = s.drop(a)
  if (s(0) != '-'){println("No");sys.exit()}
  s = s.drop(1)
  if (s.take(b).indexOf('-') != -1){println("No");sys.exit()}
  s = s.drop(b)
  println(if(s == "") "Yes" else "No")
}


Measured memory_bytes: 55336
import itertools
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]

sosuu=[1 for i in range(10**5+1)]
#sosuuのindexの値が1の時素数とする。
sosuu[0]=0
sosuu[1]=0
for i in range(2,int((10**5+1)**0.5)+1):
  if sosuu[i]==0:continue
  elif sosuu[i]==1:
    for j in range(2*i,10**5+1,i):
      sosuu[j]=0
like_n=[]
like_n+=sosuu
#奇数なので、2を削除。
like_n[2]=0
for i in range(3,10**5+1):
  if sosuu[i]==0:continue
  elif sosuu[i]==1 and sosuu[(i+1)//2]==0:
    like_n[i]=0
ans= list(itertools.accumulate(like_n))
for ans_d in d:
  print(ans[ans_d[1]]-ans[ans_d[0]-1])



Measured memory_bytes: 32012
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		 Scanner sc = new Scanner(System.in);
		 String word=sc.next();
		 if(word.equals("ABC"))
			 System.out.println("ARC");
		 else if(word.equals("ARC"))
			 System.out.println("ABC");
	     sc.close();
	 }
}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n;
long long a[200002], b[200002], aib[200002];
void upd(int poz, long long val)
{
    for(; poz <= n; poz += poz & (-poz))
        aib[poz] = max(aib[poz], val);
}
long long compute(int poz)
{
    long long ans = 0;
    for(; poz; poz -= poz & (-poz))
        ans = max(ans, aib[poz]);
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 1; i <= n; ++i)
        cin >> b[i];
    long long ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        long long sum = compute(a[i] - 1) + b[i];
        ans = max(ans, sum);
        upd(a[i], sum);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>

using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

void precalc() {}

//#define solvsh
//#define multi

#ifdef solvsh

void solve() {

}

#else
typedef vector<int> vi;
#define INF 0x3f3f3f3f
#define FOR(i, n) for(int i = 0; i < n; i++)
template<class T>
T rnd(T l,T r){	//[l,r)
    using D = uniform_int_distribution<T>;
    static random_device rd;
    static mt19937 gen(rd());
    return D(l,r-1)(gen);
}
const int MAXN = 90;

ll dt[9][9];

bool cool[8][8];

void solve() {
    int n, m;
    cin >> n >> m;

    map<int, int> mp;

    for (int i = 0; i < m; ++ i){
        int s, c;
        cin >> s >> c;

        if (s == 1 && c == 0 && n != 1){
            cout << -1;
            return;
        }

        if (mp.find(s) != mp.end()){
            if (mp[s] != c){
                cout << -1;
                return;
            }
        }
        mp[s] = c;
    }
    for (int i = 1; i <= n; ++ i) {
        if (mp.find(i) != mp.end()) {
            cout << mp[i];
        } else if (i == 1 && n != 1)
            cout << 1;
        else
            cout << 0;
    }
}

#endif


void multisolve() {
    int t;
    cin >> t;

    while (t--)
        solve();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

    precalc();

#ifdef multi
    multisolve();
#else
    solve();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
s = input()
ans = 0

for i in range(len(s)-2):
    if s[i:i+3] == "ABC":
        ans += 1

print(ans)

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

int main()
{
    int s[3];
    for(int i=0; i<3; i++)
        cin>>s[i];
    sort(s,s+3);
//    for(int i=0;i<3;i++)
//        cout<<s[i]<<' ';
    int ans=0;
    while(s[0]!=s[1]||s[1]!=s[2])
    {
        while(s[1]<s[2])
        {
            s[0]++;
            s[1]++;
            ans++;
        }
        sort(s,s+3);
//        for(int i=0; i<3; i++)
//            cout<<s[i]<<' ';
        if(s[1]==s[2])
        {
            while(s[0]<s[1])
            {
                ans++;
                s[0]+=2;
            }
            if(s[0]>s[1])
            {
                ans++;
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	char s1[7],s2[7],s3[7];
	scanf("%s %s %s",s1,s2,s3);
	printf("%c%c%c",s1[0],s2[1],s3[2]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define isz(x) (int)(x).size()
using ll = long long;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
const int mod = (int)1e9+7;
int dot(const vi& a, const vi& b) {
    assert(isz(a) == isz(b));
    int res = 0;
    for (int i = 0; i < isz(a); i++) {
        res = int((res + 1LL * a[i] * b[i]) % mod);
    }
    return res;
}
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    int n; ll k; std::cin >> n >> k;
    vi v(n,1);
    vvi a(n, vi(n,0));
    for (auto &row : a) for (auto &it : row) std::cin >> it;
    while (k > 0) {
        if (k % 2) {
            vi tmp(n,0);
            for (int i = 0; i < n; i++) {
                tmp[i] = dot(a[i], v);
            }
            v = tmp;
        }
        k /= 2;
        vvi b(n,vi(n,0)), c(n, vi(n,0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                b[i][j] = a[j][i];
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                c[i][j] = dot(a[i], b[j]);
            }
        }
        a = c;
    }
    std::cout << dot(vi(n,1), v) << std::endl;
    return 0;
}

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

const int offset[4][2] = {{1, 1},{1, -1}, {-1, 1}, {-1,-1}};

int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k, queen[8];
    memset(queen, -1, 8 * sizeof(int));
    cin >> k;
    while (k--) {
        int r, c;
        cin >> r >> c;
        queen[r] = c;
    }
    
    
    int permutation[8];
    iota(permutation, permutation + 8, 0);
    int grid[8][8];
    do {
        memset(grid, 0,8 * 8 * sizeof(int));
        bool skip = false;
        for (int i = 0; i < 8; i++) {
            if (queen[i] != -1) {
                if (permutation[i] == queen[i]) {
                    grid[i][permutation[i]] = 1;
                    continue;
                }
                skip = true;
                break;
            }
            grid[i][permutation[i]] = 1;
        }
        if (skip) {
            continue;
        }
        bool valid = true;
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                if (!grid[i][j]) {
                    continue;
                }
                for (int k = 0; k < 4; k++) {
                    int ii = i + offset[k][0], jj = j + offset[k][1];
                    while (ii >= 0 && ii < 8 && jj >= 0 && jj < 8) {
                        if (grid[ii][jj]) {
                            valid = false;
                            break;
                        }
                        ii += offset[k][0];
                        jj += offset[k][1];
                    }
                    if (!valid) {
                        break;
                    }
                }
                if (!valid) {
                    break;
                }
            }
            if (!valid) {
                break;
            }
        }
        if (valid) {
            break;
        }
    } while (next_permutation(permutation, permutation + 8));
    
    
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            if (grid[i][j]) {
                cout << "Q";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    
    return 0;
}



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

signed main(){
	int n;cin>>n;
	vector<int> march(5,0);
	string s;
	for(int i=0;i<n;i++){
		cin >>s;
		if(s[0]=='M')march[0]++;
		else if(s[0]=='A')march[1]++;
		else if(s[0]=='R')march[2]++;
		else if(s[0]=='C')march[3]++;
		else if(s[0]=='H')march[4]++;
	}
//  	for(auto&& w:march)cout<<w<<" ";
	int ans=0;
	for(int i=0;i<1<<6-1;i++){
	int s=0;int t=1;	
	for(int j=0;j<5;j++){
		int k=(i>>j)&1;
		if(k==1){
			t*=march[j];
			s++;
		}
	}
	if(s==3)ans+=t;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
  
int main(void)
{  
    int x , y;
    scanf("%d %d", &x, &y);
    while( !( x == 0 && y == 0) ){
        if( y >= x ){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
        scanf("%d %d", &x, &y);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	string s; int k;
	cin >> s >> k;
	// s = string(5000, 'a');
	vector<string> al;
	int n = s.size();
	rep(i, n) rep1(j, min(n - i, k)) {
		al.push_back(s.substr(i, j));
	}
	sort(all(al));
	al.erase(unique(all(al)), al.end());
	cout << al[--k] << endl;
	return 0;
}

Measured memory_bytes: 1660
number = gets.to_i

t1,x1,y1 = 0,0,0

judge = "Yes"

number.times do
  s = gets
  
  t2,x2,y2 = s.strip.split.map(&:to_i)
  t = t2 - t1
  d = (x2 - x1).abs + (y2 - y1).abs
  if d <= t && (t - d).even?
    t1 = t2
    x1 = x2
    y1 = y2
  else
    judge = "No"
    break
  end
end
puts judge

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

typedef struct{
  double p;
  double q;
}koch;

int kock(int, koch,koch);

int main()
{

  int n;
  koch X={0.0,0.0},Y={100.0,0.0};

  scanf("%d",&n);

  printf("%f %f\n",X.p,X.q);
  kock(n,X,Y);
  printf("%f %f\n",Y.p,Y.q);

  return 0;
}

int kock(int n, koch X, koch Y)
{
  koch a,b,c;

  if(n==0) return 0;

  a.p=(2*X.p+Y.p)/3;
  a.q=(2*X.q+Y.q)/3;
  b.p=(X.p+2*Y.p)/3;
  b.q=(X.q+2*Y.q)/3;
  c.p=(b.p-a.p)*cos(M_PI/3)-(b.q-a.q)*sin(M_PI/3)+a.p;
  c.q=(b.p-a.p)*sin(M_PI/3)+(b.q-a.q)*cos(M_PI/3)+a.q;

  kock(n-1,X,a);
  printf("%f %f\n",a.p,a.q);
  kock(n-1,a,c);
  printf("%f %f\n",c.p,c.q);
  kock(n-1,c,b);
  printf("%f %f\n",b.p,b.q);
  kock(n-1,b,Y);
  return 1;
}



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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var incList = new List<Tuple<int, int>>[n + 1];
        for (int i = 0; i < incList.Length; ++i)
        {
            incList[i] = new List<Tuple<int, int>>();
        }
        for (int i = 0; i < n - 1; ++i)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var a = ab[0];
            var b = ab[1];
            incList[a].Add(Tuple.Create(i, b));
            incList[b].Add(Tuple.Create(i, a));
        }

        var cs = new int[n - 1];
        var vs = new HashSet<int>[incList.Length];
        for (int i = 0; i < vs.Length; ++i)
        {
            vs[i] = new HashSet<int>();
        }
        var queue = new Queue<int>();
        queue.Enqueue(1);
        while (queue.Any())
        {
            int i = queue.Dequeue();
            var c = 1;
            for (int j = 0; j < incList[i].Count; ++j)
            {
                var e = incList[i][j];
                if (cs[e.Item1] > 0)
                {
                    continue;
                }
                queue.Enqueue(e.Item2);
                while (vs[e.Item2].Contains(c) || vs[i].Contains(c))
                {
                    ++c;
                }
                vs[i].Add(c);
                vs[e.Item2].Add(c);
                cs[e.Item1] = c;
            }
        }
        Console.WriteLine(cs.Max());
        Console.WriteLine(string.Join(Environment.NewLine, cs));
    }
}


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

using namespace std;
using ll = long long;

int main() {
	ll n, x = 0, y = 0, ans = 100000000000;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		x += a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		x -= a[i];
		y += a[i];
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace  std;

struct StCst
{
  int m_nNo;
  int m_nSeq;
  bool m_bDone;

  static bool AsdNo(const StCst &cnroLeft, const StCst &cnroRight) 
  { return cnroLeft.m_nNo < cnroRight.m_nNo; }
};

void fnInput(int &rnMaxSiz, vector<StCst> &rvoSort)
{
  int nCnt = 0;
  cin >> rnMaxSiz;

  rvoSort.resize(rnMaxSiz);
  for (int i = 0; i < rnMaxSiz; i++)
  {
    cin >> rvoSort[i].m_nNo;
    rvoSort[i].m_nSeq = nCnt++;
  }
}

void fnMinCostSort(vector<StCst> &rvoSort, int &rnSwpCnt)
{
  sort(begin(rvoSort), end(rvoSort), StCst::AsdNo);
  int nMinNo = rvoSort[0].m_nNo;

  int nCost;
  for (int i = 0; i < rvoSort.size(); i++)
  {
    if (rvoSort[i].m_bDone)  continue;

    int nTotal = rvoSort[i].m_nNo;
    int nCurSize = 1;
    int nCurMin = rvoSort[i].m_nNo; 
    rvoSort[i].m_bDone = true;

    int j = rvoSort[i].m_nSeq;
    while  (rvoSort[j].m_nNo != rvoSort[i].m_nNo)
    {
      nTotal += rvoSort[j].m_nNo;
      nCurSize++;
      nCurMin = min(nCurMin, rvoSort[j].m_nNo);
      rvoSort[j].m_bDone = true;
      j = rvoSort[j].m_nSeq;
    }

    if (nCurSize == 1)
        nCost = 0;
    else
        nCost = min(nTotal + (nCurSize - 2) * nCurMin, 
                    nTotal + nCurMin + (nCurSize + 1) * nMinNo);
    rnSwpCnt += nCost;
  }
}

void fnResult(int nSwpCnt)
{
  cout << nSwpCnt << endl;
}

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

  int nMaxSiz;
  vector<StCst> voSort;

  fnInput(nMaxSiz, voSort);

  int nSwpCnt = 0;
  fnMinCostSort(voSort, nSwpCnt);

  fnResult(nSwpCnt);
  return 0;
}

Measured memory_bytes: 1224
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

map<int, int> mp;

int main() {
    int n = read();
    for (int i = 0; i < n; ++i) {
        ++mp[read()];
    }

    bool flag = mp.size() == 1 && mp[0] == n;
    if (mp.size() <= 3) {
        set<int> s;
        for (auto &pr : mp) {
            s.emplace(pr.first);
        }
        for (int a : s) {
            for (int b : s) {
                set<int> t;
                t.emplace(a);
                t.emplace(b);
                t.emplace(a ^ b);
                if (s != t) continue;

                map<int, int> np;
                np[a] += n / 3;
                np[b] += n / 3;
                np[a ^ b] += n / 3;
                flag |= mp == np;
            }
        }
    }

    puts(flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

int lol(string& s, string& t,int& x)
{
	int tmp = 0;
	for (int i = x; i < x+t.length(); i++)
	{
		if (s[i] == t[i - x])
			tmp++;
	}
	return tmp;
}

int main()
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.length()-t.length()+1; i++)
	{
		ans = max(ans, lol(s, t, i));
	}
	cout << t.size() - ans;
}

Measured memory_bytes: 3568
N, M = map(int, input().split())
p = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]

class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x
        
        self.par[y] = x
                
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def __repr__(self):
        return ', '.join(str(x) for x in self.par)

t = UnionFind(N)
for x, y in X:
    t.unite(x - 1, y - 1)
    
cnt = 0
for i in range(N):
    cnt += int(t.same(i, p[i] - 1))
print(cnt)


Measured memory_bytes: 101612
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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 MOD = 1000000007;
ll INF =1<<30;

bool dp[100100];
int main(){
   int x;
   cin >> x;
   memset(dp,false,sizeof(dp));
   dp[100] = true;
   dp[0]=true;
   rep(i,100100){
      if(!dp[i]) continue;
      if(dp[i]) {
         dp[i+100]=true;
         dp[i+101]=true;
         dp[i+102]=true;
         dp[i+103]=true;
         dp[i+104]=true;
         dp[i+105]=true;
      }
   }
   if(dp[x])cout << 1<<endl;
   else cout << 0 <<endl;
}

Measured memory_bytes: 3728
n,k = map(int, input().split())
p = list(map(int, input().split()))


exp = [0 for i in range(n+1)]

for i in range(1, n+1):
    exp[i] = (1+p[i-1])/2 + exp[i-1]

ans = 0
for i in range(k, n+1):
    ans = max(ans, exp[i] - exp[i-k])
print("{:.12f}".format(ans))

Measured memory_bytes: 24812
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){
  int n;
  scanf("%d",&n);
  char s[10];
  int len;
  int count = 0;
  for(int i=1;i<=n;i++){
    sprintf(s,"%d",i);
    len = strlen(s);
    if(len % 2 == 1){
      count++;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if p == []:
        print(x)
    else:
        for i in range(0, 100):
            if not x-i in p:
                if x-i >= 0:
                    print(x-i)
                    break
            else:
                if not x+i in p:
                    if x+i <= 101:
                        print(x+i)
                        break
                    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0 
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                ans += 1
print(ans)

Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;
  std::cin >> n;
  std::vector<ll> a(n), s(n, 0);
  for(int i=0;i<n;i++){
    std::cin >> a[i];
    s[i] = (i==0?0:s[i-1]) + a[i];
  }
  ll en = s[n-1];
  ll ans = 100000000000000000;
  for(int i=0;i<n;i++){
    ans = min(ans, abs(en-s[i]-s[i]));
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> DP;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;
ll N;
DP p[3];
db a,b,c;
db dist(DP a,DP b){
  return sqrt((a.fr-b.fr)*(a.fr-b.fr)+(a.sc-b.sc)*(a.sc-b.sc));
}
db r;
db ans;
db d;
// rd/(2r+d) > x
int main()
{
  rep(i,3) cin>>p[i].fr>>p[i].sc;
  a = dist(p[0],p[1]);
  b = dist(p[1],p[2]);
  c = dist(p[2],p[0]);
  d = max(max(a,b),c);
  db s = (a+b+c)/2.0;
  db S = sqrt( s*(s-a)*(s-b)*(s-c) );
  r = S/s;

  printf("%.100f\n",r*d/(2*r+d));
}


Measured memory_bytes: 256
#include<cstdio>
inline int min(int a,int b){return a<b?a:b;}
inline int max(int a,int b){return a>b?a:b;}
const int N=103,M=100003,INF=0x3f3f3f3f;
int w[N],v[N],dp[M],n,m,s,ans;
signed main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	  scanf("%d%d",w+i,v+i),s+=v[i];
	for(int j=0;j<=s;j++)dp[j]=INF;
	dp[0]=0;
	for(int i=1;i<=n;i++)
	  for(int j=s;j>=v[i];j--){
		dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		if(dp[j]<=m)ans=max(ans,j);
	  }
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512