akhauriyash/Code-Regression huggingface dataset:
/* 
  Krishnakant Tiwari
  Problem Link:
  
 */
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define eb	emplace_back
#define ppb	pop_back
#define pf	push_front
#define ppf	pop_front
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define precise(x)	cout<<fixed<<setprecision(x)
const ll MAX=1000004;
const ll INF = 1e18L + 5;
template <typename Arg1>
void pn(Arg1&& arg1) {
    cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) {
    cout << arg1 << "\n";
    pn(args...);
}
template <typename Arg1>
void ps(Arg1&& arg1) {
    cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) {
    cout << arg1 << " ";
    ps(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
    cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
    cin >> arg1;
    read(args...);
}

ll g[MAX];
ll a[MAX];

void solve(){
    string s;
    read(s);
    ll ans=0;
    rep(i,0,3){
        if(s[i]=='R') ans++;
    }
    if(ans==3) pn(ans);
    else if(ans==2){
        if(s[1]!='R') pn(1);
        else pn(ans);
    }
    else pn(ans);

}


int main(){

    _cin
    // ll tc;
    // cin>>tc;
    // while(tc--){
            solve();
    // }

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
using namespace std;

int a[100]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    printf("%d\n",a[n-1]);


}



Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
csm = [0] * (N+1)

for i in range(1, N):
    csm[i + 1] += csm[i]
    if S[i-1:i+1] == 'AC':
        csm[i + 1] += + 1
for i in range(Q):
    l, r = LR[i]
    print(csm[r] - csm[l])

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

#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 > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k; cin>>n>>k;
  vector<int>a(n+1);
  rep(i, n)cin>>a[i];

  rep(i, k){
    vector<int>na(n+1);
    rep(ci, n){
      int l = ci-a[ci];
      if(l < 0)l=0;
      na[l]++;

      int r = ci+a[ci]+1;
      if(r > n)r = n;
      na[r]--;

//cout<<i<<' '<<r<<endl;
//rep(i, n+1)cout<<na[i]<<' ';cout<<endl;

    }
    rep(i, n)na[i+1]+=na[i];
    bool f=true;
    rep(i, n)if(a[i]!=na[i])f=false;
    if(f)break;

    swap(na, a);
//    rep(i, n+1)cout<<a[i]<<' ';cout<<endl;

  }
  rep(i, n)cout<<a[i]<<' ';cout<<endl;

  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int a, b, k;
  cin >> k >> a >> b;

  bool ok = false;
  for(int i = a; i <= b; i++){
    if(i % k == 0){
      ok = true;
      break;
    }
  }

  if(ok){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }



  return 0;
}


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

using namespace std;
#define Vi vector<int>
#define FOR(i,n) for(int i=0;i<n;i++)

int main(){
  int n,mi=0,ma=0;
  cin>>n;
  Vi a(n),arr(9,0);
  FOR(i,n)
    cin>>a[i];
  FOR(i,n){
    if(a[i]<400){
      arr[0]=1;
    }else if(a[i]<800){
      arr[1]=1;
    }else if(a[i]<1200){
      arr[2]=1;
    }else if(a[i]<1600){
      arr[3]=1;
    }else if(a[i]<2000){
      arr[4]=1;
    }else if(a[i]<2400){
      arr[5]=1;
    }else if(a[i]<2800){
      arr[6]=1;
    }else if(a[i]<3200){
      arr[7]=1;
    }else{
      arr[8]++;
    }
  }
  FOR(i,8)
    mi+=arr[i];
  if(mi==0){
    mi=1;
    ma=arr[8];
  }else{
    ma=mi+arr[8];
  }
  cout<<mi<<" "<<ma<<endl;

}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            ll ar[n+1];
            for(i=1;i<=n;++i)
                cin>>ar[i];
            sort(ar+1,ar+n+1,greater<int>());
            ll ans=ar[1];
            for(i=2,j=3;i<=n && j<=n;++i)
            {
                ans=ans+ar[i];
                ++j;
                if(j<=n)
                    ans=ans+ar[i];
                ++j;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 5236
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    string odd, even;
    cin >> odd;
    cin >> even;

    for(int i = 0; i < odd.size(); i++){
        cout << odd[i];
        if(i < even.size()) cout << even[i];
    }
    cout << endl;
}

Measured memory_bytes: 764
S=input()
a,b,c=0,0,0
for i in S:
  if i=='a':
    a+=1
  elif i=='b':
    b+=1
  else:
    c+=1
d=max(a,b,c)-min(a,b,c)
if d==0 or d==1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[9]={ 1,0,-1,0,1,1,-1,-1,0 };
const int dy[9]={ 0,1,0,-1,1,-1,1,-1,0 };

ll H, W;
int N;

set<pair<int, int>> p, vis;
vector<pair<int, int>> v;
ll ans[10] ={};

signed main(){
	cin >> H >> W >> N;
	rep(i, N){
		int a, b;
		cin >> a >> b;
		a--; b--;
		p.insert({ a, b });
		rep(j, 9){
			if(a+dx[j] >= 1 && a+dx[j] < H-1 && b+dy[j] >= 1 && b+dy[j] < W-1){
				v.pb({ a+dx[j], b+dy[j] });
			}
		}
	}

	rep(i, v.size()){
		if(vis.count(v[i])) continue;
		vis.insert(v[i]);
		int cnt = 0;
		rep(j, 9){
			if(p.count({ v[i].first+dx[j], v[i].second+dy[j] })) cnt++;
		}
		ans[cnt]++;
	}
	ans[0] = (H-2)*(W-2);
	for(int i=1; i<=9; i++) ans[0] -= ans[i];
	rep(i, 10) cout << ans[i] << endl;
}

Measured memory_bytes: 57104
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char [] odd = sc.next().toCharArray();
		char[] even = sc.next().toCharArray();
		
		for(int i = 0;i < even.length; i++) {
			System.out.print(odd[i]);
			System.out.print(even[i]);
		}
		if(odd.length-even.length==1) {
			System.out.print(odd[odd.length-1]);
		}
	}

}

Measured memory_bytes: 23764
use std::io;
use std::cmp;

fn read_line() -> String {
	let mut line = String::new();
	let _ = io::stdin().read_line(&mut line);
	line.trim().to_string()
}

fn rd() -> Vec<String> {
	let mut vs : Vec<String> = vec![];
	for s in read_line().as_str().split(' ') {
//		println!("A {}", s);
		vs.push(s.to_string())
	}
	vs
}

fn to_i(s : &str) -> Result<i64, std::num::ParseIntError> {
	s.parse::<i64>()
}

fn sign(v:i32, idx:i32) -> i64 {
	if (v>>idx)&1==1 {
		-1
	} else {
		1
	}
}

fn main() {
	loop {
		let n_m = rd();
		if n_m.len() < 2 {
			break
		}
		let n = to_i(n_m[0].as_str()).unwrap() as usize;
		let m = to_i(n_m[1].as_str()).unwrap() as usize;
		let mut x = vec![0i64; n];
		let mut y = vec![0i64; n];
		let mut z = vec![0i64; n];
		for i in 0..n {
			let s = rd();
//			println!("{:?}", s);
			x[i] = to_i(s[0].as_str()).unwrap() as i64;
			y[i] = to_i(s[1].as_str()).unwrap() as i64;
			z[i] = to_i(s[2].as_str()).unwrap() as i64;
		}
		let mut ans = 0;
		for bits in 0..8 {
			let mut w = vec![0i64; n];
			for i in 0..n {
				w[i] = sign(bits, 0)*x[i] + sign(bits, 1)*y[i] + sign(bits, 2)*z[i];
			}
			w.sort();
			w.reverse();
			if w.len() >= m {
				let lans = w[0..m].iter().sum();
				ans = cmp::max(ans, lans);
			}
		}
		println!("{}", ans);
	}
}



Measured memory_bytes: 4352
# include <bits/stdc++.h>
# define ll long long int
# define ld long double
# define pb push_back
# define mp make_pair
# define mod 1000000007
# define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#else
// online submission
	#endif
	IOS
	int t;
	cin >> t;
	map<string,int> mpp;
	while(t--){
		string s;
		cin >> s;
		mpp[s]++;
	}
	cout << "AC x " << mpp["AC"] << "\n";
	cout << "WA x " << mpp["WA"] << "\n";
	cout << "TLE x " << mpp["TLE"] << "\n";
	cout << "RE x " << mpp["RE"] << "\n";
	return 0;
}

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

int main(){
  
  int n,m,k;
  cin>>n>>m>>k; 
  int i,j;
  bool judge=false;
  
  for(i = 0;i <= n; i++){
    for(j = 0;j <= m; j++){
      if(i*m + j*n - 2*i*j == k){
        judge = true;
      }
    }
  }
  
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


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

int main(){
	int num=0;
	string s,tar;
	cin >> tar;
	for(int i=0;i<tar.size();i++)
		tar[i]=tolower(tar[i]);
	while(cin >> s){
		for(int i=0;i<s.size();i++)
			s[i]=tolower(s[i]);
		if (s == tar)
			num++;
	}
	cout << num << endl;
}


Measured memory_bytes: 3116
while str = STDIN.gets
  n = str.split(" ")
  a = n[0].to_i
  op = n[1]
  b = n[2].to_i
  if op == "?"
    break
  elsif op == "+"
    ans = a + b
  elsif op == "-"
    ans = a - b
  elsif op == "*"
    ans = a * b
  elsif op == "/"
    ans = a / b
  end
  puts "#{ans}"
end


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

struct Edge{
    ll dst;
    ll weight;
    Edge(ll dst, ll weight): dst(dst), weight(weight) {}
};

struct TmpDist{
    ll vertex;
    ll dist;
    TmpDist(ll vertex, ll dist): vertex(vertex), dist(dist) {}
    bool operator< (const TmpDist& right)const{
        return dist > right.dist;
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const ll INFLL = LLONG_MAX/3;

vector<ll> dijkstra(Graph &G, ll r){
    ll V = G.size();
    vector<ll> dist(V, INFLL);
    priority_queue<TmpDist> pq;
    vector<bool> check(V, false);
    TmpDist init(r, 0);
    pq.push(init);
    while(!pq.empty()){
        TmpDist td = pq.top();pq.pop();
        ll now = td.vertex;
        if(!check[now]){
            check[now] = true;
            dist[now] = td.dist;
            for (int i=0;i<G[now].size();i++){
                if(dist[G[now][i].dst] > td.dist + G[now][i].weight){
                    TmpDist tdCandidate(G[now][i].dst, td.dist + G[now][i].weight);
                    pq.push(tdCandidate);
                }
            }
        }
    }
    return dist;
}

int main(){
	ll N, M;
	cin >> N >> M;
	Graph G(N);
	REP(i, M){
		ll a, b;
		cin >> a >> b;
		a--;b--;
		G[a].push_back((Edge){b, 1});
		G[b].push_back((Edge){a, 1});
	}
	auto dist = dijkstra(G, 0);
	cout << (dist[N-1]==2?"POSSIBLE":"IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 18912
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
#include<tuple>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define fi first
#define se second
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> s >> t;
	rep(i, n) {
		if (s[i] == t[0]) {
			flag = true;
			REP(j, i, n) {
				if (s[j] != t[j - i]) {
					flag = false;
					ans = 0;
					break;
				}
				ans++;
			}
			if (flag) {
				//cout << ans << endl;
				cout << n * 2 -ans << endl;
				return 0;
			}
		}
	}
	cout << n * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
ab = input().split()
ab[0] = int(ab[0])
ab[1] = int(ab[1])
coin = 0
for i in range(2):
  if ab[0] >= ab[1]:
    coin += ab[0]
    ab[0] = ab[0] - 1 
  else:
    coin += ab[1]
    ab[1] = ab[1] - 1 
print(coin)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int isprime(int);

int main(){
  int n,m=0,s,i;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&s);

    if(isprime(s)==1) m++;
    
  }

  printf("%d\n",m);

  return 0;
}

int isprime(int x){
  int i;
  if(x==2) return 1;

  if(x<2 || x%2==0) return 0;

  i=3;
  
  while(i<=sqrt(x)){
    if(x%i==0) return 0;
    i=i+2;
  }
  
  return 1;
  
}



Measured memory_bytes: 2068
# -*- coding: utf-8 -*-

w, h, n = map(int, input().split())

wn = 0
hn = 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and wn < x:
        wn = x
    elif a == 2 and w > x:
        w = x        
    elif a == 3 and hn < y:
        hn = y
    elif a == 4 and h > y:
        h = y

if (w - wn) > 0 and (h - hn) > 0:
    print((w - wn) * (h - hn))
else:
    print(0)


Measured memory_bytes: 9096
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    ls = list(map(int, readline().split()))
    n = int(readline())
    ls[1] = min(ls[1], ls[0] * 2)
    ls[2] = min(ls[2], ls[1] * 2)
    ls[3] = min(ls[3], ls[2] * 2)
    t = 0
    for i in range(3, -1, -1):
        if i == 3:
            t += n // 2 * ls[i]
            n -= n // 2 * 2
        elif i == 2:
            t += n // 1 * ls[i]
            n -= n // 1 * 1
        elif i == 1:
            t += n / 0.5 * ls[i]
            n -= n // 0.5 * 0.5
        else:
            t += n // 0.25 * ls[i]
            n -= n // 0.25 * 0.25
        if n == 0:
            break
    print(int(t))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    int N,L;
    int ans=0;
    cin>>N>>L;
    if(L>=0){
        for(int b=0;b<N;b++){
            ans +=L+b;
        }
        cout<<ans-L<<endl;
        return 0;
    }else if(L<0 && abs(L)<N){
        for(int b=0;b<N;b++){
            ans +=L+b;
        }
        cout<<ans<<endl;
        return 0;

    }else{
         for(int b=0;b<N;b++){
            ans +=L+b;
        }
        cout<<ans-L-N+1<<endl;
        return 0;

    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[100010], B[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
	ll ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		A[i] += ans;
		if (A[i] % B[i] != 0) ans += B[i] - (A[i] % B[i]);
	}
	cout << ans << endl;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005, mod = 998244353;
int n, k, p[MX], a[MX];
ll ft[MX], res;

void update (int i, int k) {
	while (i < MX) {
		(ft[i] += k) %= mod;
		i += i & -i;
	}
}

ll query (int i) {
	ll s = 0;
	while (i) {
		(s += ft[i]) %= mod;
		i -= i & -i;
	}
	return s;
}

ll pot (ll b, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> k;
	forn (i, n) cin >> p[i];
	forn (i, n) a[i] = max(0, i - k + 1);

	forn (i, n) {
		res += i - query(p[i]);
		update(p[i], 1);
	}

	res %= mod;

	memset(ft, 0, sizeof(ft));

	ll f = (k - 1) * pot(k, mod - 2) % mod;
	ll inv2 = pot(2, mod - 2);

	forn (i, n) {
		ll x = query(p[i]);
		ll y = query(n) - x;

		(res += pot(f, a[i]) * x % mod * inv2) %= mod;
		(res -= pot(f, a[i]) * y % mod * inv2) %= mod;

		update(p[i], pot(pot(f, mod - 2), a[i]));
	}

	cout << MOD(res, mod) << endl;

	return 0;
}


Measured memory_bytes: 6772
def main():
    h,w = map(int,input().split())
    s = [list(input()) for _ in range(h)]

    cnt = [[0]*w for _ in range(h)]
    for i in range(h):
        prev = [0]*w
        for j in range(w):
            if s[i][j] == '#':
                continue
            if prev[j] == 1:
                continue
            ln = 0
            while j+ln < w:
                if s[i][j+ln] == '#':
                    break
                ln += 1
            for k in range(ln):
                cnt[i][j+k] += ln
                prev[j+k] = 1
    for j in range(w):
        prev = [0]*h
        for i in range(h):
            if s[i][j] == '#':
                continue
            if prev[i] == 1:
                continue
            ln = 0
            while i+ln < h:
                if s[i+ln][j] == '#':
                    break
                ln += 1
            for k in range(ln):
                cnt[i+k][j] += ln
                prev[i+k] = 1
    res = 0
    for i in range(h):
        for j in range(w):
            res = max(res, cnt[i][j]-1)
    print(res)

if __name__ == '__main__':
    main()


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

int main(void){
	int i,n,x;
	
	scanf("%d",&n);
	for(i=1; i<=n; i++){
		x=i;
		if(x%3 == 0){
			printf(" %d",i);
		}else{
			while(x){
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /= 10;
			}
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x * y // gcd(x, y)


def lcmm(l):
    return reduce(lcm, l)


print(lcmm(t))


Measured memory_bytes: 3700
N = int(input())
Array1 = []
Array2 = []

for i in range(N):
    next_x, next_y = map(int, input().split())
    s = next_x + next_y
    t = next_x - next_y
    Array1.append(s)
    Array2.append(t)

print(max(max(Array1)-min(Array1),max(Array2)-min(Array2)))

Measured memory_bytes: 97396
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] A = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            A[i] = scanner.nextInt();
            if (A[i] > max) {
                max = A[i];
            }
        }

        int[] B = countingSort(A, max);

        StringBuilder sb = new StringBuilder("");
        sb.append(B[0]);
        for (int i = 1; i < B.length; i++) {
            sb.append(" ").append(B[i]);
        }
        System.out.println(sb);
    }

    public static int[] countingSort(int[] A, int k) {
        int[] B = new int[A.length];
        int[] C = new int[k + 1];
        int i;
        for (i = 0; i < A.length; i++) {
            C[A[i]]++;
        }
        for (i = 1; i <= k; i++) {
            C[i] += C[i - 1];
        }
        for (i = A.length - 1; i >= 0; i--) {
            B[C[A[i]] - 1] = A[i];
            C[A[i]]--;
        }
        return B;
    }
}


Measured memory_bytes: 508712
#problem3
N=int(input())
from collections import deque
#入力は2**N個からなる
d=[int(input()) for _ in range(2**N)]
def battle(x,y):
    if x!=y:
        return x+y-min(x,y)*2
    else:
        return x
d=deque(d)
for i in range(N):
    for i in range(2**(N-1-i)):
        x=d.popleft()
        y=d.popleft()
        d.append(battle(x,y))
print(d[0])

Measured memory_bytes: 15876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll t, a;
    if (A > K) {
        t = A - K;
        a = B;
    } else if (A + B > K) {
        t = 0;
        a = A + B - K;
    } else {
        t = 0;
        a = 0;
    }
    printf("%lld %lld\n", t, a);
    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

string S, T;
int ans;

int main(){
	cin >> S >> T;
	ans = T.size();

	for (int i = 0; i <= S.size() - T.size(); i++){
		int diff = 0;
		for (int j = 0; j < T.size(); j++){
			if (T[j] != S[i + j]){
				diff++;
			}
		}
		ans = min(ans, diff);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
S = input()
K = int(input())
ns = []
c = S[0]
n = 1
for i in range(1, len(S)):
  if c == S[i]:
    n += 1
  else:
    ns.append(n)
    n = 1
  c = S[i]
ns.append(n)
#print(ns)
if len(ns) == 1:
  r = ns[0]*K//2
  print(r)
  exit()
r = 0
for i in range(1, len(ns)-1):
  r += K*(ns[i]//2)
if S[0] == S[-1]:
  r += (ns[0]//2)+(ns[-1]//2)
  r += (K-1)*((ns[0]+ns[-1])//2)
else:
  r += K*(ns[0]//2)+K*(ns[-1]//2)
print(r)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, K;
string s;

int main()
{
    cin >> N >> K >> s;
    vector<int> v;
    if (s[0] == '0')
        v.push_back(0);
    int p = 1;
    for (int i = 1; i < N; i++)
    {
        if (s[i] != s[i - 1])
        {
            v.push_back(p);
            p = 1;
        }
        else
            p++;
    }
    v.push_back(p);
    if (s[N - 1] == '0')
        v.push_back(0);
    vector<int> s;
    s.push_back(v[0]);
    int pre = v[0];
    for (int i = 1; i < v.size(); i += 2)
    {
        pre += v[i] + v[i + 1];
        s.push_back(pre);
    }
    int ans = 0;
    if (s.size() <= K + 1)
    {
        cout << s[s.size() - 1] << endl;
    }
    else
    {
        int m = 0;
        for (int i = K; i < s.size(); i++)
        {
            ans = max(ans, s[i] - s[i - K] + v[(i - K) * 2]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;

struct SegmentTree {
private:
    int n;
    vector<int> node;
    //int nとvector<int> nodeの2つを変数に持つ。
    //nは扱う配列の要素数で、nodeはまさにsegtree本体

public:
    //初期化処理。segtreeを使うときは最初にこれを宣言する。
    SegmentTree(vector<int> v) {
        int sz = v.size(); //vは扱う配列の長さ
        n = 1; while(n < sz) n *= 2; //nはvの配列を全て入れるために必要なseg treeの葉の数
        node.resize(2*n-1, INF); //★演算によって単位元を変える。segtreeでは全部で2n-1の配列が必要。最小値を求めるのであれば、最初は単位元であるINFで初期化しておく
        //例えばv.size()が2のべき乗で無かった場合は、最終的な計算結果に影響のないような単位元の葉を用意しておく必要がある
        for(int i=0; i<sz; i++) node[i+n-1] = v.at(i); //segtreeの葉の部分に扱う配列を埋め込む
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1],node[2*i+2]); //★演算によって変える場所　segtreeを作る(注目しているnode iの子ノードを見て二項演算をして、node iの値を決定する)
    }

    void update(int x, int val) {
        //一点更新処理。x番目の要素をvalに変更する
        x += (n - 1); //配列のx番目の要素を更新しようとするとき、segtreeで対応する要素はx+n-1番目である
        node[x] = val; //segtree上で値を更新
        while(x > 0) { //葉から根に向かってsegtreeの要素を更新していく
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1],node[2*x+2]); //★演算によって変える
        }
    }

    int getor(int a, int b, int k=0, int l=0, int r=-1) {
        //区間取得処理。求めたいのは区間[a,b)の中で演算しつづけた結果(たとえばこの区間の最小値)
        //自分がいるノードのindex(何階にいるか？)
        //ノードkは元の配列でいうとどの区間をカバーしているか？
        if(r < 0) r = n; //最初に呼び出す時はノードk=0はsegtreeの根なので区間は[0,n)を指す
        if(r <= a || b <= l) return INF; //今のノードが求める区間と無関係の場合は、最終的な答えに影響しない単位元(最小値を求めたい場合は単位元はINF)を返す 演算によって変える
        if(a <= l && r <= b) return node[k]; //今見ている区間[l,r)が答えを求めたい区間[a,b)に完全に含まれるなら、この区間について演算し続けた結果(=node[k];例えば最小値)を返す

        //上記に当てはまらない場合
        //kの子ノードを見に行って、再帰的に処理を行う k=0の場合はノード1と2を見る
        int vl = getor(a, b, 2*k+1, l, (l+r)/2); //kの子ノード(left)の子孫のうち、求めたい区間に含まれる要素について演算し続けた結果を返す
        int vr = getor(a, b, 2*k+2, (l+r)/2, r); //kの子ノード(right)の子孫のうち、求めたい区間に含まれる要素について演算し続けた結果を返す
        return min(vl,vr); //演算によって変える場所 子ノードの子孫のうち、演算しつづけた結果を返す
    }
};

int main(){
    int N; cin >> N;
    vector<int> a(N,INF);
    SegmentTree tree(a);
    int Q; cin >> Q;
    for(int i=0;i<Q;i++){
        bool type; cin >> type;
        if(!type){
            int first,second; cin >> first >> second;
            tree.update(first,second);
        }else{
            int first,second;
            cin >> first >> second;
            cout << tree.getor(first,second+1) << endl;
        }
    }
}



Measured memory_bytes: 4680
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int W=in.nextInt(),H=in.nextInt(), C=in.nextInt();
		
		int n=gcd(W,H);
		System.out.println((W/n)*(H/n)*C);
	}
	
	static int gcd(int x,int y){
		int r=x;
		if(y!=0) r=gcd(y,x%y);
		return r;
	}

}



Measured memory_bytes: 26252
/**
 *  author: Haunted_Cpp
**/
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
 
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
 
#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr.begin(), arr.end());
  //~ arr.erase(unique(arr.begin(), arr.end()), arr.end());
  n = arr.size();
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int x = j + 1; x < n; x++) {
        if (arr[i] != arr[j] && arr[j] != arr[x]) {
          if (arr[i] + arr[j] > arr[x] && arr[i] + arr[x] > arr[j] && arr[x] + arr[j] > arr[i]) {
            ++res;
          }
        }
      }
    }
  }
  cout << res << '\n';
  return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
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; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    ll res = 0;
    if (A + B > 2 * C) {
        if ( X > Y ) {
            res = 2 * C * Y + A * (X-Y);
            chmin(res, 2 * C * X);
        }
        else {
            res = 2 * C * X + B * (Y-X);
            chmin(res, 2 * C * Y);
        }
    }else{
        res = A * X + B * Y;
    }
    cout << res << endl;
}

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

struct e{int a,b;};
int A=500,G=500,n,a[40],T,p,q;
e v[20];
stack<int> s;
#define R(i,n) for(int i=0;i<(n);i++)

signed main(){
  cin>>n;
  R(i,n*2)cin>>a[i];
  R(i,1<<n){
    T=0;
    R(j,n)v[j]={a[j+n*((i>>j)&1)],j};
    R(j,n){
      p=j;
      while(p--&&v[p+1].a<v[p].a)swap(v[p+1],v[p]),T++;
    }
    R(j,n)if(((i>>v[j].b)+v[j].b-j)&1)s.push(v[j].a*G+j);
    if(s.size()&1)T=G,s.pop();
    while(s.size()){
      p=s.top();s.pop();q=s.top();s.pop();
      T+=((p-q)&1?p-q:G);
    }
    if(A>T)A=T;
  }
  cout<<(A<G?A:-1)<<endl;
}


Measured memory_bytes: 256
class Q1041
  def doIt
    n = gets.to_i / 4
    while n > 0
      calc n
      n = gets.to_i / 4
    end
  end
  
  def calc(n)
    sum = 0
    for i in 1..n
      sum += gets.to_i
    end
    puts sum
  end
end

Q1041.new.doIt

Measured memory_bytes: 2312
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    if(a.size() > b.size()) {
        out("GREATER");
    }
    else if(a.size() < b.size()) {
        out("LESS");
    }
    else {
        rep(i, a.size()) {
            ll x = a[i] - '0';
            ll y = b[i] - '0';
            if(x > y) {
                out("GREATER");
                re0;
            }
            else if(x < y) {
                out("LESS");
                re0;
            }
        }
        out("EQUAL");
    }

    re0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>

int main(){
	int n;
	std::cin>>n;
	
	std::map<int, int> mp;

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

	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		std::cout << itr->second + 1 << std::endl;
	}
	//std::cout<<n<<std::endl;
	return 0;
}

Measured memory_bytes: 5504
// problem: "https://atcoder.jp/contests/abc127/tasks/abc127_a"

import java.util.Scanner;

class Main {
    public static void main (String args[]) {
        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        int b = in.nextInt();

        if(a>=13)
            System.out.print(b);

        else if(a>=6)
            System.out.print(b/2);

        else
            System.out.print(0);
    }
}


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

int main()
{ 
  int w, h, n ;
  cin >> w >> h >> n ;
  vector< tuple<int, int, int> > data(n) ;
  for(int i = 0 ; i < n ; i++)
  {
    int x, y, a ;
    cin >> x >> y >> a ;
    data.at(i) = make_tuple(a, x, y) ;
  }
  sort(data.begin(), data.end()) ;

  int min_x = 0 ;
  int max_x = w ;
  int min_y = 0 ;
  int max_y = h ;
  for(int i = 0 ; i < n ; i++)
  {
    int a, x, y ;
    tie(a, x, y) = data.at(i) ;
    if(a == 1)
    {
      min_x = max(min_x, x) ;
    }
    if(a == 2)
    {
      max_x = min(max_x, x) ;
    }
    if(a == 3)
    {
      min_y = max(min_y, y) ;
    }
    if(a == 4)
    {
      max_y = min(max_y, y) ;
    }
  }

  //cout << max_x << " " << min_x << " " << max_y << " " << min_y << endl ;

  if(min_x >= max_x || min_y >=max_y)
  {
    cout << 0 << endl ;
  }
  else
  {
    cout << (max_x - min_x) * (max_y - min_y) << endl ;
  }
  
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    E = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        E[a].append((b,i))
        E[b].append((a,i))
    
    def dfs(s, g):
        par = [(-1,-1)] * N
        par[s] = (s,-1)
        stack = [s]
        while stack:
            v = stack.pop()
            for to, i in E[v]:
                if par[to][0] >= 0: continue
                par[to] = (v, i)
                if to == g: break
                stack.append(to)
        r = set()
        v = g
        while v != s:
            v, i = par[v]
            r.add(i)
        return r
    
    M = int(input())
    path = [None] * M
    for i in range(M):
        u, v = map(int, input().split())
        u, v = u-1, v-1
        path[i] = dfs(u, v)

    def calc(s): return 1<<(N-1-len(s))

    i_ans = 0
    for p in range(1, 1<<M):
        is_odd = bin(p).count('1') & 1
        s = set()
        for i in range(M):
            if p&1: s |= path[i]
            p >>= 1
        if is_odd: i_ans += calc(s)
        else: i_ans -= calc(s)

    print((1<<(N-1)) - i_ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 44580
#include<iostream>
using namespace std;
int main() {
	char b;
	cin >> b;
	if (b == 'A') cout << 'T' << endl;
	else if (b == 'C')cout << 'G' << endl;
	else if (b == 'T')cout << 'A' << endl;
	else if (b == 'G')cout << 'C' << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>

#define N 100005
#define UNDEFINED -1

int n, m, s, t, q;
std::vector<int> adj[N];
int group[N];

void dfs(int x, int g) {
    std::stack<int> S;
    S.push(x);
    group[x] = g;
    while(!S.empty()) {
        int u = S.top(); S.pop();
        for(int i = 0; i < adj[u].size(); i++) {
            int v = adj[u][i];
            if(group[v] == UNDEFINED) {
                group[v] = g;
                S.push(v);
            }
        }
    }
}

int main() {
    for(int i = 0; i < N; i++) {
        group[i] = UNDEFINED;
    }

    std::cin >> n >> m;
    for(int i = 0; i < m; i++) {
        std::cin >> s >> t;
        adj[s].push_back(t);
        adj[t].push_back(s);
    }

    int g = 0;
    for(int i = 0; i < n; i++) {
        if(group[i] == UNDEFINED) {
            dfs(i, g++);
        }
    }


    std::cin >> q;
    for(int i = 0; i < q; i++) {
        std::cin >> s >> t;
        if(group[s] != UNDEFINED && group[t] != UNDEFINED && group[s] == group[t]) {
            puts("yes");
        } else {
            puts("no");
        }
    }
    return 0;
}



Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;


string s,t;

int get(int id){
    int cnt = 0 , sz = t.size() - 1 ;
    for(int i=1;i<=sz;i++) cnt += ( s[id - sz + i ] != t[ i ] );
    return cnt;
}

void _sol(){
    cin >> s >> t;
    int n = s.size();
    int k = t.size();
    s = '$' + s;
    t = '$' + t;
    int ans = INT_MAX;
    for(int i=k;i<=n;i++){
        ans  = min(ans , get(i));
    }
    cout << ans;

}


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


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <string>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    char a;
    cin >> a;
    if(a >= 97){
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N, s, t = map(int, input().split())
dists = [0]*(N+1)
distt = [0]*(N+1)
for i in range(1, N+1):
    if i == s:
        continue
    print('?', s, i, flush = True)
    dists[i] = int(input())

for i in range(1, N+1):
    if i == t:
        continue
    print('?', t, i, flush = True)
    distt[i] = int(input())

D = dists[t]
U = []
for i in range(1, N+1):
    if dists[i] + distt[i] == D:
        U.append(i)
Q = sorted([(dists[u], u) for u in U])
Q = [q[1] for q in Q][::-1]
Q.remove(s)
Q.remove(t)
Ans = [s]
while Q:
    q = Q.pop()
    pre = Ans[-1]
    print('?', q, pre, flush = True)
    e = int(input())
    if dists[pre] + e + distt[q] == D:
        Ans.append(q)
Ans.append(t)
print('!', *Ans, flush = True)



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

#define int long long

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 305;
int h[N], f[N][N];

signed main()
{
	int n = read();
	int k = read();
	for (int i = 1; i <= n; ++i) h[i] = read();
	
	memset(f, 0x3f, sizeof(f));
	for (int i = 1; i <= n; ++i) f[i][1] = h[i];
	for (int i = 2; i <= n; ++i)
		for (int j = 2; j <= i; ++j)
			for (int p = 1; p < i; ++p)
				f[i][j] = min(f[i][j], f[p][j - 1] 
					+ max(0LL, h[i] - h[p]));
	
	int ans = f[0][0];
	for (int i = n - k; i <= n; ++i) ans = min(ans, f[i][n - k]);
	if (k == n) puts("0"); else printf("%lld\n", ans);
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const lb PI=3.14159265359;

int main(){

  ll n,m;cin>>n>>m;
  vector<vector<ll>>v(m);
  rep(i,0,m){
    ll k;cin>>k;
    rep(j,0,k){
      ll s;cin>>s;
      v[i].push_back(--s);
    }
  }
  ll p[m];rep(i,0,m)cin>>p[i];

  ll ans=0;
  rep(i,0,(1<<n)){
    bool e=true;
    rep(j,0,m){
      ll count=0;
      rep(k,0,v[j].size()){
        if((i>>v[j][k])&1)count++;
      }
      if(count%2!=p[j])e=false;
    }

    if(e)ans++;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    onoffs = [int(j) for j in list(bin(i)[2:].zfill(n))]
    Flag = True
    for lamp in range(m):
        k = a[lamp][0]
        info = [l - 1 for l in  a[lamp][1:]]
        tmp = 0
        for index in info:
            if onoffs[index]:
                tmp += 1
        if tmp % 2 != p[lamp]:
            Flag = False
            break
    if Flag:
        ans += 1
print(ans)

Measured memory_bytes: 9112
#include <iostream>
#include <algorithm>
using namespace std;
int a[100100];
int main() {
	int n;cin >> n;
	bool enable = 1;
	for (int i = 0;i < n;i++)cin >> a[i];
	sort(a, a + n);
	if (n % 2 == 1) {
		if (a[0] != 0)enable = 0;
		if (n != 1) {
			for (int k = 1;k < n;) {
				if (a[k] != k + 1 || a[k + 1] != k + 1)enable = 0;
				k += 2;
			}
		}
	}
	if (n % 2 == 0) {
		for (int k = 0;k < n;) {
			if (a[k] != k + 1 || a[k + 1] != k + 1)enable = 0;
			k += 2;
		}
	}
	int ans=1;
	if (enable) {
		if (n == 1) {
			cout << 1 << endl;
			return 0;
		}
		if (n % 2 == 1) {
			for (int j = 0;j < (n - 1) / 2;j++) {
				ans *= 2;
				ans %= 1000000007;
			}
			
			cout << ans << endl;
			return 0;
		}
		if (n % 2 == 0) {
			for (int j = 0;j < n / 2;j++) {
				ans *= 2;
				ans %= 1000000007;
			}
			
			cout << ans << endl;
			return 0;
		}
	}
	else {
		cout << 0 << endl;
		return 0;
	}
}

Measured memory_bytes: 640
#include <cstdio>
#define ll long long int

int main(void){
		int a, b;
		char op;
		scanf("%d %c %d", &a, &op, &b);
		while(op != '?'){
				if(op == '+')printf("%d\n", a + b);
				else if(op == '-')printf("%d\n", a - b);
				else if(op == '*')printf("%lld\n", (ll)a * b);
				else if(op == '/')printf("%d\n", a / b);
				scanf("%d %c %d", &a, &op, &b);
		}

		return 0;
}



Measured memory_bytes: 2740
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    bool a[n], b[n];
    vector<int> ans;
    for (auto &ai:a) cin >> ai;
    for (int i=n; i>0; i--) {
        b[i-1] = a[i-1];
        for (int j=2*i; j<=n; j+=i)
                b[i-1] ^= b[j-1];
        if (b[i-1])
            ans.push_back(i);
    }
    cout << ans.size() << endl;
    for (int i=ans.size()-1; i>=0; i--) cout << ans[i] << (i > 0 ? ' ' : '\n');
    return 0;
}

Measured memory_bytes: 2040
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){ 
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		if(op.equals("?")) break;
		else if(op.equals("+")) System.out.println(a+b);
		else if(op.equals("-")) System.out.println(a-b);
		else if(op.equals("*")) System.out.println(a*b);
		else System.out.println(a/b); 
		}
	}
}

Measured memory_bytes: 18004
#include <stdio.h>
int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(B>=A*C){
        printf("%d",C);
    }
   
    if(B<A*C){
        int i;
        for(i=0;i<C;i++){
            if(B<(i+1)*A){break;}
        }
        printf("%d",i);
    }
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

vector<ll> x;

int main() {
    ll n, k;
    ll tmp;

    cin >> n >> k;

    rep(i, n) {
        cin >> tmp;
        x.push_back(tmp);
    }
    
    ll ans = (ll) INF;
    rep(i, n-k+1) {
        ll l, r;

        l = x[i];
        r = x[i+k-1];

        tmp = min(abs(l)+abs(l-r), abs(r)+abs(r-l));

        ans = min(ans, tmp);
    }

    cout << ans << endl;


}



Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    char c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(i == j){
                cout << c[i][j];
            }
        }
    }



    return 0;
}

Measured memory_bytes: 256