akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

struct Dice{
  vector<int> D;
  string dir;
  int roll(){
    int top = D.at(0);
    for(int i = 0; i < dir.size(); i++){
      if(dir.at(i) == 'N'){
        top = D.at(1);
        D.at(1) = D.at(5);
        D.at(5) = D.at(4);
        D.at(4) = D.at(0);
        D.at(0) = top;
      }
      else if(dir.at(i) == 'E'){
        top = D.at(3);
        D.at(3) = D.at(5);
        D.at(5) = D.at(2);
        D.at(2) = D.at(0);        
        D.at(0) = top;        
      }
      else if(dir.at(i) == 'W'){
        top = D.at(2);
        D.at(2) = D.at(5);
        D.at(5) = D.at(3);       
        D.at(3) = D.at(0);      
        D.at(0) = top;              
      }
      else if(dir.at(i) == 'S'){
        top = D.at(4);
        D.at(4) = D.at(5);
        D.at(5) = D.at(1);
        D.at(1) = D.at(0);
        D.at(0) = top;        
      }
    }
    return top;
  }
};

int main(){
  Dice x;
  for(int i = 0; i < 6; i++){
    int a;
    cin >> a;
    x.D.push_back(a);
  }
  cin >> x.dir;
  cout << x.roll() << endl;  
}


Measured memory_bytes: 3208
s = input()
result_sum = 0
plus_count = len(s) - 1

for bit in range(1 << plus_count):
  splitted_string = s[0]
  for iter_plus in range(plus_count):
    if bit & (1 << iter_plus):
      splitted_string += '+'
    splitted_string += s[iter_plus+1]
  result_sum += eval(splitted_string)

print(result_sum)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
	// write your code here
        Scanner scan = new Scanner(System.in);
        int L = scan.nextInt();
        int R = scan.nextInt();
        int d = scan.nextInt();
        int ans = 0;
        for(int i=L;i<=R;i++){
            if(i%d==0) ans++;
        }
        System.out.println(ans);
        }
    }


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

#define MAXN 100010

struct Edge
{
	int u,v;
	Edge(){}
	Edge(int a,int b):u(a),v(b){}
	bool operator<(Edge e)const
	{
		return u==e.u?v<e.v:u<e.u;
	}
};

int n,fa[MAXN];
set<int> edge[MAXN];
set<Edge> s;

void proc(int u,int v)
{
	if(edge[u].find(v)!=edge[u].end())
	{
		edge[u].erase(edge[u].find(v));
		s.insert(Edge(min(u,v),max(u,v)));
	}
	else edge[u].insert(v);
}

int getfa(int x)
{
	return x==fa[x]?x:fa[x]=getfa(fa[x]);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)fa[i]=i;
	for(int i=1;i<n;++i) 
	{
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].insert(v);
		edge[v].insert(u);
	}
	for(int i=1;i<n;++i)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		proc(u,v);
		proc(v,u);
	}
	int cnt=0;
	while(!s.empty())
	{
		Edge now=*s.begin();s.erase(s.begin());
//		printf("%d %d\n",now.u,now.v);
		int u=getfa(now.u),v=getfa(now.v);
		if(edge[u].size()>edge[v].size())swap(u,v);
		fa[u]=v;
		for(auto x:edge[u])
		{
			edge[x].erase(u);
			proc(v,x);
			proc(x,v);
		}
		edge[u].clear();
		++cnt;
	}
	puts(cnt==n-1?"YES":"NO");
}

Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
#ifdef _DEBUG
	printf( "debug\n" );
#endif
	for ( int i = 1; i < 10; i++ ) {
		for ( int j = 1; j < 10; j++ ) {
			printf( "%dx%d=%d\n", i, j, i * j );
		}
	}
	return 0;
}

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

void printV(vector<int> &v);
void printVV(vector<vector<int>> &vv);

int main() {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> vv(M);
  for(int i = 0; i < M; i++) {
    int k;
    cin >> k;
    vv.at(i).push_back(0);
    for(int j = 0; j < k; j++) {
      int s;
      cin >> s;
      vv.at(i).push_back(s);
    }
  }

  // 偶数奇数入力
  for(int i = 0; i < M; i++) {
    cin >> vv.at(i).at(0);
  }

  int ans = 0;

  for(int bits = 0; bits < (1<<N); bits++) { // スイッチの組合わせ
    for(int j = 0; j < M; j++) { // 電球
      int sum = 0;
      for(int n = 1; n < (int)vv.at(j).size(); n++) {
        int mask = (1 << (vv.at(j).at(n)-1));
        if(bits & mask) sum++;
      }
      if(sum % 2 != vv.at(j).at(0)) break;
      if(j == M-1) ans++;
    }
  }

  cout << ans << endl;
}

// ベクターの中身を全部出力
void printV(vector<int> &v) {
  cout << "  [ ";
  for(int i = 0; i < (int)v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << "]" << endl;
}

void printVV(vector<vector<int>> &vv) {
  cout << "{" << endl;
  for(int i = 0; i < (int)vv.size(); i++) {
    cout << "  [ ";
    for(int j = 0; j < (int)vv.at(i).size(); j++) {
      cout << vv.at(i).at(j) << " ";
    }
    cout << "]," << endl;
  }
  cout << "}" << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
x10 = n
x2 = Base_10_to_n(x10, k)
print(len(x2))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax (T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD = 1e9+7;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

int main() {
    using mint = ModInt<MOD>;
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for (auto& e : l) cin >> e;
    for (auto& e : r) cin >> e;
    
    int idl = -1 , idr = -1, h = *max_element(l.begin(), l.end());
    for (int i = 0; i < n; i++) if (l[i] == h) { idl = i; break; }
    for (int i = n-1; i >= 0; i--) if (r[i] == h) { idr = i; break; }
    if (idl == -1 || idr == -1 || idr < idl) {
        cout << 0 << endl; return 0;
    }
    
    mint ansl = 1, ansr = 1;
    int mxl = -1, mxr = -1;
    for (int i = 0; i < idl; i++) {
        if (!chmax(mxl, l[i])) ansl *= mxl;
    }
    for (int i = n-1; i > idr; i--) {
        if (!chmax(mxr, r[i])) ansr *= mxr;
    }
    
    mint ans = ansl * ansr;
    for (int i = idl+1; i < idr; i++) ans *= h;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, R;
	cin >> N >> R;

	if (N >= 10) cout << R << "\n";
	else cout << R + 100 * (10 - N) << "\n";

	return 0;
}

Measured memory_bytes: 256
/* 
 * Author: pawanmsr
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
int x, y, z;

// Functions //
void swap(int &a, int &b) {
    a = a + b;
    b = a - b;
    a = a - b;
}

// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

import static java.lang.Math.max;

public class Main {

    static void run() throws IOException {
        file("", "");
        solution();
        end();
    }


    static void solution() throws IOException {
        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        out.println(c+" "+a+" "+b);
    }


    static mem create_mem(int u, int v) {
        mem y = new mem();
        y.u = u;
        y.v = v;
        return y;
    }

    static class t {
        long value;
        int index;

    }

    static class mem {
        int u, v;
    }

    static long pow(long a, long b) {
        long h = 1;
        while (b > 0) {
            if (b % 2 != 0) {
                h *= a;
                b--;
            }
            b /= 2;
            a *= a;
        }
        return h;
    }

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

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    static void end() {
        out.flush();
        out.close();
    }

    static BufferedReader br;
    static PrintWriter out;

    static void file(String input, String output) {
        if (input.equals("")) {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            try {
                br = new BufferedReader(new FileReader(input));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            try {
                out = new PrintWriter(output);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }

    static StringTokenizer in = new StringTokenizer("");

    public static String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) return null;
            in = new StringTokenizer(s);
        }
        return in.nextToken();
    }


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

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

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

    public static void main(String[] args) throws IOException {
        run();

    }

}

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

int main(){
    int N;
    cin >> N;
    int64_t counter = 0;
    unordered_map<string,int> check;
    for(int i = 0; i < N; i++) {
        string a;
        cin >> a;
        sort(a.begin(),a.end());
        if(check.count(a)){
            counter += check.at(a);
            check.at(a)++;
        }
        else check[a] = 1;
    }
    
    cout << counter << endl;
}

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

int main()
{
    int N;
    cin >> N;

    if( N == 1 ){
        cout << "Hello World" << endl;
        return 0;
    } else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
K,A,B = map(int,input().split())
 
ans = K+1
if A+2 >= B:
    print(ans)
    exit()
 
K -= (A-1)
if K < 0:
    print(ans)
    exit()
 
b = A
b += (K//2) * (B-A)
b += K%2
print(max(ans, b))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 1e18L+5
#define mod 1000000007
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n, m;
   cin>>n>>m;
    string s[n];
   ll dp[n][m];
   for(int i=0;i<n;i++){
           cin>>s[i];
   }
  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++)dp[i][j]=0;
  }
   for(int i=0;i<n;i++){
       for(int j=0;j<m;j++){
           if(i==0&&j==0) dp[i][j]=1;
          else if(s[i][j]=='.'&&(i>0&&j>0)) dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
          else if(s[i][j]=='.'&&(i==0)){
              dp[i][j]=dp[i][j-1]%mod;
          }
          else if(s[i][j]=='.'&&(j==0)){
              dp[i][j]=dp[i-1][j]%mod;
          }
          else dp[i][j]=0;
       }
   }
   
   cout<<dp[n-1][m-1];
}




Measured memory_bytes: 9088
fn main() {
    let n = readln();
    let a: Vec<isize> = readlns(n);
    let b: Vec<isize> = a.iter().enumerate().map(|(i, x)| i as isize - *x).collect();

    let mut ok = true;
    for i in 0..n - 1 {
        if b[i] <= b[i + 1] {
        } else {
            ok = false;
        }
    }
    for i in 0..n {
        if 0 <= b[i] && b[i] < n as isize {
        } else {
            ok = false;
        }
    }

    if !ok {
        println!("{}", -1);
        return;
    }

    let mut answer = 0;
    for i in 0..n {
        if i == n - 1 || b[i] != b[i + 1] {
            answer += i as isize - b[i] as isize;
        }
    }
    println!("{}", answer);
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 8572
/**
 *  Hi, I'm Arpan.
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

/*******************************************/
//
void solve()
{
    int n;
    cin >> n;
    int a,b,c,d;
    a=b=c=d=0;
    while(n--){
		string x;
		cin >> x;
		if(x == "AC")a++;
		if(x == "WA")b++;
		if(x == "TLE")c++;
		if(x == "RE")d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--)
        solve();
    return 0;
}




Measured memory_bytes: 3660
#include<stdio.h>

int H, A[2000000 + 1];

void maxHeapify(int A[], int i){
  int l, r, largest, temp;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])         largest = l;
  else                              largest = i;

  if(r <= H && A[r] > A[largest])   largest = r;

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int A[]){
  int i;

  for(i = H / 2; i >= 1; i--){
    maxHeapify(A, i);
  }
}

int main(){
  int i;
  
  scanf("%d", &H);
  for(i = 1; i <= H; i++){
    scanf("%d", &A[i]);
  }

  buildMaxHeap(A);

  for(i = 1; i <= H; i++)
    printf(" %d", A[i]);
  printf("\n");
  
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> imos(100010,0);
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >> b;
        imos[a]++; imos[b+1]--;
    }
    int ans = 0;
    for(int i=1;i<=100002;i++){
        imos[i] += imos[i-1];
        if(i-1<=imos[i]) ans = i-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}

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

#define st first
#define nd second
#define mp make_pair
#define space << " " <<
#define END << endl
#define pb push_back
#define fo(i,n) for(int i = 0; i<n; ++i)
#define ff(i,n) for(int i = 1; i<n; ++i)

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pi;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> pl;
typedef vector<pil>vil;

const int N = 4002;

short U[N][N] , L[N][N] , R[N][N] , D[N][N];
bool board[N][N];
int bit[N][2];
ll ans = 0; int h,w,p,l;

void update(int u,int id,int val) {
    while(u < N) { bit[u][id] += val; u += (u & (-u)); }
}
int get(int u,int id) {
    int ans = 0; while(u > 0) { ans += bit[u][id]; u -= (u & (-u)); } return ans;
}
void up(int id , int le , int ri) {
    if(le > ri) return;
    update(le,id,1); update(ri+1,id,-1);
}

void work(int x,int y)
{
    vector< pair<int,pii> > a; fo(i,N) fo(j,3) bit[i][j] = 0;
    while(x <= h && y <= w ) {
        a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x)));
        a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x)));
        x++; y++;
    } sort(a.begin(),a.end());
    fo(i,a.size()) {
        pair<int,pii> u = a[i];
        if(u.nd.st == 1)
        {
            ans += 1LL * get(u.nd.nd , 1);
            up(0,u.nd.nd - u.st + 1 , u.nd.nd - l + 1);
        }
        else
        {
            ans += 1LL * get(u.nd.nd , 0);
            up(1,u.nd.nd + l - 1 , u.nd.nd + u.st - 1);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> h >> w >> l >> p;
    fo(i,p) { int u,v; cin >> u >> v; board[u][v] = 1; }
    ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } }
    for(int i=h; i >= 1; --i) for(int j=w; j>= 1; --j) {
        if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; }
    }
    ff(i,h+1) work(i,1); for(int j=2; j<=w; ++j) work(1,j); cout << ans << endl;
}

Measured memory_bytes: 141996
from collections import defaultdict
mod=10**9+7
n=int(input())
A=tuple(map(int,input().split()))
Acc=[0]*n
for i,a in enumerate(A):
    if i==0:
        Acc[0]=a
    else:
        Acc[i]=Acc[i-1]^a

def solve(Acc):
    total_0=0
    dp_0=defaultdict(lambda: 1)
    dp_x=defaultdict(int)
    cnt_0=defaultdict(int)
    for a in Acc:
        if a:
            if a not in dp_x:
                dp_x[a]=1
                cnt_0[a]=total_0
            else:
                dp_0[a]=(dp_0[a]+dp_x[a]*(total_0-cnt_0[a]))%mod
                cnt_0[a]=total_0
                dp_x[a]=(dp_x[a]+dp_0[a])%mod
        else:
            total_0+=1
    if Acc[-1]:
        return dp_0[Acc[-1]]
    return (sum(dp_x.values())+pow(2,total_0-1,mod))%mod

print(solve(Acc))

Measured memory_bytes: 138952
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll k, x;
    cin >> k >> x;
    if(k*500 >= x)cout << "Yes";
    else cout << "No";
}

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

int main() {
    int n;
    cin >> n;

    vector<ll> f(n);
    for (int i = 0; i < n; i++) {
        ll x = i + 1;
        while (x <= n) {
            f[x - 1]++;
            x += i + 1;
        }
    }

    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += (i + 1) * f[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 81388
#include <iostream>
#include <stdio.h>
using namespace std;

int f[50001],pr[5500];

int main() {
	int i,j,n=0,cn;
	for (i=2;i<50001;i++) if (f[i]==0) { f[i]=1; pr[n++]=i; for (j=i+i;j<50001;j+=i) f[j]=2;}
	while(cin >> n) {
		if (n==0) break;
		cn=0;
		for (i=0;n/2>=pr[i];i++) if (f[n-pr[i]]==1) cn++;
		cout << cn << endl;
	}
	return 0;
}

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

int main() {
	
	int D;
	cin >>D;
	
	if(D==25){
		
		cout <<"Christmas" <<endl;
		
	}
	if(D==24){
		
		cout <<"Christmas Eve" <<endl;
		
	}
	if(D==23){
		
		cout <<"Christmas Eve Eve" <<endl;
		
	}
	if(D==22){
		
		cout <<"Christmas Eve Eve Eve" <<endl;
		
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,sum1,sum2,a[11000],b[11000];
int main()
{
	cin>>n;
	for(int  i=1;i<=n;i++ ) scanf("%lld",&a[i]);
	for(int  i=1;i<=n;i++ ) scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]>b[i]) sum1+=a[i]-b[i];
		if(a[i]<b[i]) sum2+= (b[i]-a[i])/2;
	}
	if(sum1<=sum2) cout<<"Yes\n";
	  else cout<<"No\n";
	return 0;
 } 

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
struct WeightUnionFind{
	//
	vector<int> ran,par,wei;
	//
	WeightUnionFind(int n=1){
		init(n);
	}
	//
	void init(int n=1){
		for(int i=0;i<n;i++){
			par.push_back(i);
			ran.push_back(0);
			wei.push_back(0);
		}
	}
	//
	int find(int x){
		if(par[x]==x){
			return x;
		}else{
			int r=find(par[x]);
			wei[x]+=wei[par[x]];
			return par[x]=r;
		}
	}
	//
	int weight(int x){
		find(x);
		return wei[x];
	}
	//
	bool same(int x,int y){
		return find(x)==find(y);
	}
	//
	bool unite(int x,int y,int w){
		w+=weight(x);
		w-=weight(y);
		x=find(x);
		y=find(y);
		if(x==y){
			return false;
		}else if(ran[x]<ran[y]){
			swap(x,y);
			w=-w;
		}else if(ran[x]==ran[y]){
			ran[x]++;
		}
		par[y]=x;
		wei[y]=w;
		return true;
	}
	//
	int diff(int x,int y){
		return weight(y)-weight(x);
	}
	//
};
int main(){
	int N,Q;
	cin>>N>>Q;
	WeightUnionFind UF(N);
	while(Q--){
		int C;
		cin>>C;
		if(C==1){
			int X,Y;
			cin>>X>>Y;
			if(UF.same(X,Y)){
				cout<<UF.diff(X,Y)<<endl;
			}else{
				cout<<"?"<<endl;
			}
		}else{
			int X,Y,Z;
			cin>>X>>Y>>Z;
			UF.unite(X,Y,Z);
		}
	}
	return 0;
}


Measured memory_bytes: 4312
n, m, Q = map(int, input().split())

ts = [[0] * (n+1) for _ in range(n+1)]
for _ in range(m):
    l, r = tuple(map(int, input().split()))
    ts[l][r] += 1
# 二次元累積和
for i in range(1, n+1):
    for j in range(1, n+1):
        ts[i][j] += ts[i][j-1]

for i in range(1, n+1):
    for j in range(1, n+1):
        ts[i][j] += ts[i-1][j]

for _ in range(Q):
    p, q = tuple(map(int, input().split()))
    print(ts[q][q] - ts[p-1][q] - ts[q][p-1] + ts[p-1][p-1])



Measured memory_bytes: 14932
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
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;}
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  while(ans<n)ans+=1000;
  cout<<ans-n;
  return 0;
}


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

int main(void)
{
	vector<long long>res;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		long long temp;
		cin >> temp;
		res.push_back(temp);
	}
	long long q;
	cin >> q;
	while (q--)
	{
		long long op, b, e;
		cin >> op >> b >> e;
		if (op == 0)
			cout << *min_element(res.begin() + b, res.begin() + e) << endl;
		else if (op == 1)
			cout << *max_element(res.begin() + b, res.begin() + e) << endl;
	}
	return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i32 a, b;
    cin >> a >> b;
    for (i32 i = 1; i <= 1001; i++) {
        i32 na = i * 0.08;
        i32 nb = i * 0.10;
        if (na == a && nb == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

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





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

ll p(ll n) {
	if (n == 0) { return 1; }
	return 2 * p(n - 1);
}


int main() {

	string S;
	cin >> S;

	string ans = "Yes";

	rep(i, S.size()) {
		if (i % 2 == 0 && S[i] == 'L') { ans = "No"; }
		if (i % 2 == 1 && S[i] == 'R') { ans = "No"; }
	}
	
	cout << ans;
	

	system("PAUSE");

}


Measured memory_bytes: 504
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a = N % 2;
    if(a == 1){
      System.out.println(((N / 2) + 1));
    }else{
      System.out.println((N / 2));
    }
  }
}

Measured memory_bytes: 23764
import numpy as np

K, N = map(int, input().split())

a_l = list(map(int, input().split()))

a_l = np.array(a_l)

b_l = np.empty(a_l.shape[0])

b_l[1:] = a_l[:-1]

b_l[0] = a_l[-1]

c_l = a_l - b_l

c_l[0] = K - a_l[-1] + a_l[0]

print(int(K - np.max(c_l)))


Measured memory_bytes: 42956
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i++)
using namespace std;
signed main(){
  ll n,a,b,sum=0,cum=0;
  string s;
  cin>>n>>a>>b;
  cin>>s;
  rep(i,n){
    if(s[i]=='a'){
      if(sum<a+b){
      sum++;
      cout<<"Yes\n";
      }else{
        cout<<"No\n";
      }
    }else if(s[i]=='b'){
      if(sum < a+b && cum < b){
        sum++;
        cum++;
        cout<<"Yes\n";
      }else{
        cout<<"No\n";
      }
    }else if(s[i]=='c'){
      cout<<"No\n";
    }
  }
  return(0);
}


Measured memory_bytes: 896
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] colorPositions = new int[300000];//各色の最終地点
		int[] colorMemos = new int[n];//各位置の最初の色
		for(int i = 0; i < n; i++) colorMemos[i] = int.Parse(Console.ReadLine())-1;
		long mod = 1000000007;
		long[] dp = new long[n+1];
		dp[0] = 1;

		for(int i = 1; i <= n; i++)
		{
			//Console.WriteLine(dp[i-1]);
			dp[i] = dp[i-1];

			if(colorPositions[colorMemos[i-1]] <= i-2 && colorPositions[colorMemos[i-1]] != 0)
			{
				dp[i] += dp[colorPositions[colorMemos[i-1]]];
				dp[i] %= mod;
			}

			colorPositions[colorMemos[i-1]] = i;
		}
		
		Console.WriteLine(dp[n]);
	}
}

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

int R(int a, vector<bool> y) {
	int ans = 0;
	rep(i, a + 1) {
		if (y.at(a - i)) break;
		else ans++;
	}
	return ans;
}

int L(int a, vector<bool> y) {
	int ans = 0;
	for (int i = a; i < y.size(); i++) {
		if (!(y.at(i))) break;
		else ans++;
	}
	return ans;
}

int main() {
	vector<bool> y;
	string s; cin >> s;
	for (char i : s) {
		if (i == 'R') y.push_back(0);
		else y.push_back(1);
	}
	vector<int> ans(s.size(), 0);
	rep(i, s.size() - 1) {
		if (!(y.at(i)) && y.at(i + 1)) {
			int r = R(i, y); int l = L(i + 1, y);
			ans.at(i) = l / 2 + (r + 1) / 2;
			ans.at(i + 1) = r / 2 + (l + 1) / 2;
		}
	}
	for (int i : ans) cout << i << ' ';
}

Measured memory_bytes: 1024
#include<iostream>
using ll = long long;
using namespace std;

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll cdm(ll a, ll b){
	ll g = gcd(a, b);
	return a / g*b;
}
int main(void){
	ll ans=1LL;
	int N;
	cin >> N;
	for (int i=0; i < N; i++){
		ll T;
		cin >> T;
		ans = cdm(ans, T);
	}
	
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
int main(void)
{
	int i,j,num[100];
	//char read[100000];
	
	scanf("%d",&i);
	
	for(j=0;j<i-1;j++)
		scanf("%d ",&num[j]);
	scanf("%d",&num[j]);
	
	for(j=i-1;j>0;j--)
		printf("%d ",num[j]);
	printf("%d",num[j]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
use proconio::input;

fn main() {
  input! {
    K: usize,
    N: usize,
    mut arr: [usize;N]
  }

  let mut next = arr.clone().into_iter().map(|v| v + K).collect();
  let concated = [arr, next].concat();
  let mut result = usize::max_value();
  for i in (N-1)..(2*N) {
    result = std::cmp::min(result, concated[i] - concated[i - (N - 1)]);
  }

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


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

int main(){
	int x;
  	int ans;
  	rep(i, 5){
    	cin >> x;
      	if(x == 0) ans = i+1; 
    }
  
  	cout << ans << endl;	
}

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

const double eps = 1e-8;
double x[4], y[4], r;

double distSq(double x1, double y1, double x2, double y2) {
	return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}

double perpDist(double x1, double y1, double x2, double y2, double cx, double cy) {
	double a, b, x, y;
	double res = min(distSq(x1, y1, cx, cy), distSq(x2, y2, cx, cy));
	if (x1 == x2) {
		if (min(y1, y2) <= cy && cy <= max(y1, y2)) {
			res = (cx - x1) * (cx - x1);
		}
	} else {
		a = (y2 - y1) / (x2 - x1);
		b = y1 - a * x1;
		x = (cx + a * (cy - b)) / (1 + a * a);
		y = a * x + b;
		if (min(x1, x2) <= x && x <= max(x1, x2) && min(y1, y2) <= y && y <= max(y1, y2)) {
			res = distSq(x, y, cx, cy);
		}
	}
	return res;
}

bool A() {
	int c = 0;
	for (int i=0; i<3; ++i) {
		if (0 <= (x[(i+1)%3] - x[i]) * (y[3] - y[i]) - (y[(i+1)%3] - y[i]) * (x[3] - x[i])) {
			++ c;
		}
	}
	if (c % 3 != 0) return false;
	for (int i=0; i<3; ++i) {
		if (perpDist(x[i], y[i], x[(i+1)%3], y[(i+1)%3], x[3], y[3]) + eps < r * r) {
			return false;
		}
	}
	return true;
}

bool B() {
	for (int i=0; i<3; ++i) {
		if (r * r < distSq(x[i], y[i], x[3], y[3])) {
			return false;
		}
	}
	return true;
}

bool C() {
	for (int i=0; i<3; ++i) {
		if (perpDist(x[i], y[i], x[(i+1)%3], y[(i+1)%3], x[3], y[3]) <= r * r + eps) {
			return true;
		}
	}
	return false;
}

int main() {
	while (cin >> x[0] >> y[0], (x[0] || y[0])) {
		for (int i=1; i<4; ++i) cin >> x[i] >> y[i];
		cin >> r;
		if (B()) {
			cout << "b" << endl;
		} else if (A()) {
			cout << "a" << endl;
		} else if (C()) {
			cout << "c" << endl;
		} else {
			cout << "d" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
A, B, K = map(int, input().split())
for i in range(0, K):
    if(i & 1):
        if(B & 1):
            B -= 1
        A += B//2
        B //= 2
    else:
        if(A & 1):
            A -= 1
        B += A//2
        A //= 2
print("{0} {1}".format(A, B))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    int N;
    cin>>N;
    VEC(int,A,N+1);
    VEC(int,B,N);
    REP(i,N+1){
        cin>>A[i];
    }
    REP(i,N){
        cin>>B[i];
    }
    
    ll m=0;
    REP(i,N){
        int t=min(A[i],B[i]);
        m+=t;
        m+=min(A[i+1],max(B[i]-A[i],0));
        B[i]=max(B[i]-A[i],0);
        A[i+1]=max(A[i+1]-B[i],0);
        //sl(A[i],A[i+1],m)
    }
    //cout<<ac<<" "<<wa;
    cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    string S;
    string T;
    llong ans=MOD;
    llong temp;
    cin >> S >> T;
    for(int i=0; i<S.size()+1-T.size(); i++){
        temp = 0;
        for(int j=0; j<T.size(); j++){
            if(S[i+j]!=T[j]){
                temp++;
            }
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
      string S;
      cin >> S;
      int ans = false;
      if(S[0] == S[2])ans = true;
      if(ans)cout << "Yes" << endl;
      else cout << "No" << endl;
        return 0;
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,m,x[100010],y[100010];

signed main(){
    cin>>n>>m;
    rep(i,0,n)cin>>x[i];
    rep(i,0,m)cin>>y[i];
    
    int ans1=0,ans2=0;
    rep(i,0,n){
        ans1+=i*x[i]-(n-i-1)*x[i];
        ans1%=MOD;
    }
    rep(i,0,m){
        ans2+=i*y[i]-(m-i-1)*y[i];
        ans2%=MOD;
    }
    cout<<(ans1*ans2)%MOD<<endl;
    
    
    
    
    
    
    
}

Measured memory_bytes: 1792
s = input()
n = len(s)
a = "BDEFHIJKLMNOPQRSUVWXYZ"
cnt = []
for i in range(0, n):
    for j in range(i,n+1):
    	fr = s[i:j]
    	value = 1
    	for k in a:
    		if k in fr:
    			value = 0
    	if value:
    		cnt.append(len(fr))
    		
print(max(cnt))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

/**
 * stringをintに変換
 */
int strToInt(string str) {
    int size = str.size();
    int ret = 0;
    for (int i = 0; i < size; i++) {
	int tmp = str[size - i - 1] - '0';
	for (int j = 0; j < i; j++) {
	    tmp *= 10;
	}
	ret += tmp;
    }
    return ret;
}

signed main() {
	string S;
	cin >> S;

	int ret = 0;
	for (int i = 0; i < (1 << (S.size() - 1)); i++) {
		string T = S;
		int pt = 1;
		for (int j = 0; j < S.size() - 1; j++, pt++) {
			if ((i & (1 << j)) == 0) continue;
			T.insert(T.begin() + pt, '+');
			pt++;
		}
		string tmp = "";
		for (int j = 0; j < T.size(); j++) {
			if (T[j] != '+') {
				tmp += T[j];
			} else {
				ret += strToInt(tmp);
				tmp = "";
			}
		}
		ret += strToInt(tmp);
	}
	
	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void insertionSort(int a[],int num,int b,int &cnt){
    int key,j;
    for(int i=b;i<num;i++)
    {
        key=a[i];
        j=i-b;
        while(j>=0&&a[j]>key)
        {
            a[j+b]=a[j];
            cnt=cnt+1;
            j=j-b;
        }
        a[j+b]=key;
    }}
void shellsort(int a[],int num)
{
    int m,cnt=0;
    for (int i=0;pow(3,i)*1.5-0.5<num;i++)
        m=i+1;
    cout<<m<<endl;
    int g[m];
    for (int i=0;i<m;i++)
        g[i]=pow(3,i)*1.5-0.5;
    for(int i=m-1;i>=0;i--)
        insertionSort(a,num,g[i],cnt);
    for(int i=m-1;i>=0;i--)
        if(i==0) cout<<g[i]<<endl;
        else cout<<g[i]<<" ";
    cout<<cnt<<endl;
    for(int i=0;i<num;i++) cout<<a[i]<<endl;
}
int main()
{
    int num;
    cin>>num;
    int a[num];
    for(int i=0;i<num;i++) {
        cin>>a[i];
    }
    shellsort(a,num);
    return 0;
}



Measured memory_bytes: 7136
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
using namespace std;
ll n, m;
const int Mod = 1e9 + 7;
char arr[1005][1005];
ll dp[1005][1005];
ll solve(int i, int j)
{
    if(i == n - 1 && j == m - 1)
        return 1;
    if(~dp[i][j])
        return dp[i][j];
    ll ans = 0;
    if(i + 1 < n && arr[i + 1][j] == '.')
        ans += solve(i + 1, j);
    ans %= Mod;
    if(j + 1 < m && arr[i][j + 1] == '.')
        ans += solve(i, j + 1);
    return dp[i][j] = ans % Mod;
}
int main()
{
    IO
    cin >> n >> m;
    REP(i, 0, n)
        REP(j, 0, m)
            cin >> arr[i][j];
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 9216