akhauriyash/Code-Regression huggingface dataset:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,M=map(int,input().split())
if N==0 or N==1:
    if M==0 or M==1:
        print(0)
        exit(0)
    else:
        print(combinations_count(M, 2))
        exit(0
        )
if M==0 or M==1:
    if N==0 or N==1:
        print(0)
        exit(0)
    else:
        print(combinations_count(N, 2))
        exit(0)
        

print(combinations_count(N, 2)+combinations_count(M, 2))

Measured memory_bytes: 9208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		if(Character.getNumericValue(s.charAt(0))==9 ||
				Character.getNumericValue(s.charAt(1))==9)System.out.println("Yes");
		else System.out.println("No");

	}

}

Measured memory_bytes: 22612
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int h=sc.nextInt(),w=sc.nextInt(),k=sc.nextInt(),sum=0,res=0;;
	  int[][] a=new int[h][w];
	  for(int i=0;i<h;i++) {
		  String buff=sc.next();
		  for(int j=0;j<w;j++) {
			  if(buff.substring(j, j+1).equals("."))a[i][j]=0;
			  else {
				  sum++;
				  a[i][j]=1;
			  }
		  }
	  }

		for(int i=0;i<Math.pow(2, h);i++) {
			int[] s = new int[h];
			for(int j=0;j<h;j++) {//iを2進数にした場合にどこの桁が1になっているか判定し、1の場合はstatusに代入
				if((1&i>>j)==1) {
					s[j]=1;
				}
			}
			for(int g=0;g<Math.pow(2, w);g++) {
				int[] s2 = new int[w];
				int count=0;
				for(int j=0;j<w;j++) {//iを2進数にした場合にどこの桁が1になっているか判定し、1の場合はstatusに代入
					if((1&g>>j)==1) {
						s2[j]=1;
					}
				}
				Set<Integer> set=new TreeSet<>();
				for(int x=0;x<h;x++) {
					if(s[x]==1) {
						for(int r=0;r<w;r++) {
							if(a[x][r]==1) {
								count++;
								set.add(x);
							}
						}
					}
				}
				for(int y=0;y<w;y++) {
					if(s2[y]==1) {
						for(int r=0;r<h;r++) {
							if(!set.contains(r)) {
								if(a[r][y]==1)count++;
							}
						}
					}
				}
				//System.out.println(Arrays.toString(s));
				//System.out.println(Arrays.toString(s2));
				if(sum-count==k)res++;
			}
		}
	  System.out.println(res);
  }
}


Measured memory_bytes: 39164
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n;
    cout<<(n*n)<<"\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int n = Integer.parseInt(line);

		int Tpt = 0;
		int Hpt = 0;
		for (int i = 0; i < n; i++) {
			String string = sc.nextLine();
			String[] str = string.split(" ");
			String T = str[0];
			String H = str[1];
			if (T.compareTo(H) == 0) {
				Tpt += 1;
				Hpt += 1;

			} else if (T.compareTo(H) > 0) {
				Tpt += 3;

			} else {
				Hpt += 3;

			}

		}
		System.out.println(Tpt + " " + Hpt);
	}

}

Measured memory_bytes: 31292
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;

const int mod = 1e9 + 7;
int add(int a, int b) { return (a + b) % mod; }
void add_self(int & a, int b) { a = add(a, b); }
int mul(int a, int b) { return (ll) a * b % mod; }

int my_pow(int a, int b) {
	int r = 1;
	while(b) {
		if(b % 2) r = mul(r, a);
		a = mul(a, a);
		b /= 2;
	}
	return r;
}
int my_inv(int a) { return my_pow(a, mod - 2); }
int my_div(int a, int b) { return mul(a, my_inv(b)); }

const int nax = 2005;
int factorial[nax*nax];
int dp[nax][nax];

int C(int a, int b) {
	assert(0 <= b && b <= a && a < nax * nax);
	return my_div(factorial[a], mul(factorial[b], factorial[a-b]));
}

int main() {
	factorial[0] = 1;
	for(int i = 1; i < nax * nax; ++i)
		factorial[i] = mul(factorial[i-1], i);
	
	int n, k;
	cin >> n >> k; // k colors, n balls in each color
	swap(n, k);
	if(n == 1) {
		puts("1");
		return 0;
	}
	const int down = n - 2;
	// width = k
	#define n n_dont_use
	debug() << imie(k) imie(down);
	dp[0][0] = 1;
	for(int a = 0; a <= k; ++a)
		for(int b = 0; b <= a; ++b) {
			debug dd;
			dd << imie(a) imie(b) imie(dp[a][b]);
			if(a != k) add_self(dp[a+1][b], dp[a][b]);
			if(b < a) {
				int still = (k - a) + (k - b - 1) + (k - b) * down;
				dd << imie(still);
				add_self(dp[a][b+1], mul(dp[a][b], C(still, down)));
			}
		}
	printf("%d\n", mul(dp[k][k], factorial[k]));
}


Measured memory_bytes: 30720
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'

using namespace std ;

#define MAXN 100010
/*lli spf[MAXN];  
void sieve();
set<lli> factors(lli x);
lli power(lli x,lli y,lli p);
*/
//void getZarr(string str, lli Z[]);
//vll prefix_function(vll s); 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;



int main()
{

    lli n,k;
    cin>>n>>k;

    lli o = (n+1)/2;

    if(k>o) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;    

}


/*vll prefix_function(vll s) 
{
    lli n = (lli)s.size();
    vll pi(n);
    
    for (lli i = 1; i < n; i++)
    {
        lli j = pi[i-1];
        
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        
        if (s[i] == s[j])
            j++;
        
        pi[i] = j;
    }
    return pi;
}
*/
/*void sieve() 
{ 
    spf[1] = 1; 
    loopl(i,2,MAXN) 
        spf[i] = i; 
    for (lli i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (lli i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (lli j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    }

} 

multiset<lli> factors(lli x) 
{ 
    multiset<lli> pr; 
    while (x != 1) 
    { 
        pr.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return pr; 
}

*/

/*
void dfs(lli q,lli root) 
{
    vis[q]=1;
    
    ans[q]=1;

    for(auto x: v[q])
    {
        if(!vis[x])
        {
            if(a[x]==a[root] && x<root) continue;
            if(a[x]<a[root] || a[x]>a[root]+d) continue;
            dfs(x,root);
            ans[q]=(ans[q]*((ans[x]+1)%mod))%mod ;
        }
    }
        
}
*/



/*void getZarr(string str, lli Z[])
{
    lli n = str.length();
    lli L, R, k;
    L = R = 0;
    for (lli i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}


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

Measured memory_bytes: 256
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	n := getStdinInt()
	p := getStdinIntArr()

	cnt := 0
	for i := 1; i < n-1; i++ {
		p1 := p[i-1]
		p2 := p[i]
		p3 := p[i+1]
		if p1 < p2 && p2 < p3 {
			cnt++
		} else if p3 < p2 && p2 < p1 {
			cnt++
		}
	}
	fmt.Printf("%d\n", cnt)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
priority_queue<pii, vector<pii>, greater<pii> > pq;
vector<multiset<int> > c;
vector<int> G[100001];
int a[100001];
int n, m;

bool vis[100001];
void bfs(int s, multiset<int>& sx)
{
	queue<int> q;
	q.push(s);
	vis[s] = true;
	while (!q.empty())
	{
		int u = q.front();
		sx.insert(a[u]);
		q.pop();
		for (int i = 0; i < G[u].size(); i++)
		{
			int v = G[u][i];
			if (!vis[v])
			{
				vis[v] = true;
				q.push(v);
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	for (int i = 0; i < m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}

	int comp = 0;
	for (int i = 0; i < n; i++)
	{
		if (!vis[i])
		{
			multiset<int> sx;
			bfs(i, sx);
			if (sx.size() > 1)
			{
				pq.push(make_pair(*(++sx.begin()), c.size()));
			}
			else
			{
				pq.push(make_pair(INT_MAX - 1, c.size()));
			}
			c.push_back(sx);
			comp++;
		}
	}

	ll ans = 0;
	for (int i = 0; i < comp - 1; i++)
	{
		int saidx = pq.top().second;
		pq.pop();
		int sbidx = pq.top().second;
		pq.pop();
		multiset<int>& sa = c[saidx];
		multiset<int>& sb = c[sbidx];
		if (sa.size() == 0 || sb.size() == 0)
		{
			cout << "Impossible" << endl;
			return 0;
		}
		ans += 0LL + *sa.begin() + *sb.begin();
		sa.erase(sa.begin());
		sb.erase(sb.begin());
		if (sa.size() < sb.size()) 
		{
			swap(sa, sb);
		//	swap(saidx, sbidx);
		}
		for (auto it:sb)
		{
			sa.insert(it);
		}
		sb.clear();
		if (sa.size() > 1)
		{
			pq.push(make_pair(*(++sa.begin()), saidx));
		}
		else if (sa.size() == 1)
		{
			pq.push(make_pair(INT_MAX - 1, saidx));
		}
		else
		{
			pq.push(make_pair(INT_MAX, saidx));
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 15920
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string a,b;
    cin >>a>>b;
    int d;
    for(int i = 0;i<3;i++){
     if(a[i] == b[i]) d++;
    }
    cout<<d;
    return 0;
}

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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> x(N), y(N);
    vector<ll> xv(N), yv(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        xv[i] = x[i];
        yv[i] = y[i];
    }
    sort(xv.begin(), xv.end());
    sort(yv.begin(), yv.end());

    ll ans = (xv[N-1] - xv[0]) * (yv[N-1] - yv[0]);
    for(int xi = 0; xi < N; xi++) {
        for(int xj = xi + 1; xj < N; xj++) {
            for(int yi = 0; yi < N; yi++) {
                for(int yj = yi + 1; yj < N; yj++) {
                    ll l = xv[xi], r = xv[xj];
                    ll d = yv[yi], u = yv[yj];

                    int cnt = 0;
                    for(int i = 0; i < N; i++) {
                        if(l <= x[i] && x[i] <= r && d <= y[i] && y[i] <= u) cnt++;
                    }
                    if(cnt >= K) ans = min(ans, (r-l) * (u-d));
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  string a;
  cin >> a; 
  if(a=="SUN"){
  cout << 7 << endl;
  }
  else if(a=="MON"){
  cout << 6 << endl;
  }
  else if(a=="TUE"){
  cout << 5 << endl;
  }
  else if(a=="WED"){
  cout << 4 << endl;
  }
  else if(a=="THU"){
  cout << 3 << endl;
  }
  else if(a=="FRI"){
  cout << 2 << endl;
  }
  else if(a=="SAT"){
  cout << 1 << endl;
  }
}

Measured memory_bytes: 256
L,R=map(int, input().split())
minimum=2020
Calc_flag=True

for i in range (L,R):
  if Calc_flag==True:
    if i+2020<=R+1:
      for j in range(i+1,i+2020):
        a=(i*j)%2019
        minimum=min(minimum,a)
        if minimum==0:
          Calc_flag=False
          break
    if i+2020>R+1:
      for j in range(i+1,R+1):
        a=(i*j)%2019
        minimum=min(minimum,a)
        if minimum==0:
          Calc_flag=False
          break
          
  else:
    break

print(minimum)

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S;
	cin >> S;
	int w;
	cin >> w;

	for (int i = 0; i < S.length(); i++) {
		if (i % w == 0) {
			cout << S[i];
		}
	}
	cout << endl;

}





Measured memory_bytes: 3588
#include <stdio.h>

int main()
{
  int n, i, j, k;
  int *A;
  int cnt, m, G[12], v;
  
  scanf("%d", &n);
  
  A = (int *)malloc(sizeof(int) * n);
  
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  
  cnt = 0;
  m = 1;
  G[0] = 1;
  while (3 * G[m-1] + 1 < n) {
    G[m] = 3 * G[m-1] + 1;
    m++;
  }
  
  for (i = 0; i < m / 2; i++) {
    v = G[i];
    G[i] = G[m-1-i];
    G[m-1-i] = v;
  }
  
  printf("%d\n", m);
  for (i = 0; i < m; i++) {
    if (i != m - 1) printf("%d ", G[i]);
    else printf("%d\n", G[i]);
  }
  
  for (i = 0; i < m; i++) {
    for (j = G[i]; j < n; j++) {
      v = A[j];
      k = j - G[i];
      while (k >= 0 && A[k] > v) {
    A[k+G[i]] = A[k];
    k -= G[i];
    cnt++;
      }
      A[k+G[i]] = v;
    }
  }
  
  printf("%d\n", cnt);
  for (i = 0; i < n; i++) printf("%d\n", A[i]);
  
  return 0;
}

Measured memory_bytes: 4508
#include <stdio.h>
int main(void){
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a == b){
        printf("%d\n", c);
    }else if(b == c){
        printf("%d\n", a);
    }else if(a == c){
        printf("%d\n", b);
    }
}


Measured memory_bytes: 1732
//                                              Question ki ma ki chut !!
#include<bits/stdc++.h>
using namespace std;
#define Going_supersonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define allr(v) v.rbegin(),v.rend()
#define sz() size()
#define l() length()
#define lli long long int
#define ed endl
#define iv vector<lli>
#define bg() begin()
#define e() end()
#define ff first
#define ss second
lli sti(string s)
{
    lli num=0;
    lli p=1;
    for(lli it=s.l()-1;it>=0;p*=10)
        num+=(s[(it--)]-48)*p;
    return num;
}
lli n,m,cnt,mx,mn,l,sm,r;
lli  dp[102][100002];
iv a(102),b(102);
lli solve(lli n,lli w)
{
    //cout<<b[n]<<" "<<" "<<n<<" "<<w<<ed;
    if(n==0||w==0)
    {
        return 0;
    }
    if(dp[n][w])
        return dp[n][w];
    if(w>=a[n-1]){
           return dp[n][w]=max(b[n-1]+solve(n-1,w-a[n-1]),solve(n-1,w));
    }
    else
    {
        return solve(n-1,w);
    }
}
int main(){
    Going_supersonic
    lli T=1;
    //cin>>T;
    while(T--){
            lli i,j,k,p;
            cin>>n>>k;
            for(i=0;i<n;i++)
            {
                cin>>a[i]>>b[i];
            }
            cout<<solve(n,k);

    }

    return 0;
}


Measured memory_bytes: 69996
n, k= map(int,input().split())
if k > (n-1)*(n-2)/2:
    print(-1)
elif n == 2:
    if k == 0:
        print(1)
        print(1,2)
    else:
        print(-1)
else:
    l = []
    for i in range(2,n+1):
        l.append([1,i])
    ima = (n-1)*(n-2) / 2
    #print(ima)
    hajime = 2
    owari = 3
    while(ima > k):
        l.append([hajime ,owari])
        ima -= 1
        if(owari < n):
            owari += 1
        else:
            hajime += 1
            owari = hajime + 1
    print(len(l))
    for i,j in l:
        print(i,j)


Measured memory_bytes: 43504
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll N,K;
using mat=vector<vector<ll>>;
mat p(mat A,mat B){
mat C(A.size(),vector<ll>(B[0].size(),0));
  for(int i=0;i<A.size();i++)
    for(int j=0;j<B[0].size();j++)
      for(int k=0;k<A[0].size();k++)
        C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
  
  return C;
}
mat pow(mat X,ll y){
if(y==0){
mat C(X.size(),vector<ll>(X.size(),0));
  for(int i=0;i<X.size();i++)
    C[i][i]=1;
  return C;

}else if(y%2==0){
 mat C=pow(X,y/2);
  return p(C,C);

}else{
mat C=pow(X,y/2);
  return p(X,p(C,C));

}

}
int main(){
 cin>>N>>K; 
  mat G(N,vector<ll>(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      cin>>G[i][j];
  mat ans=pow(G,K);
  ll Ans=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      Ans=(Ans+ans[i][j])%mod;
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 4988
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 998244353
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[300005],a(300005),b(300005,0),f(500005,0);
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
void fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        f[k]=(f[k-1]*k)%mod;
    }
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
lli comb(lli n,lli i)
{
    lli g=f[n]*(bpow(f[i],mod-2))*bpow(f[n-i],mod-2);
    return g%mod;
}
lli permute(lli n, lli i)
{
    lli h=f[n-i];
    lli g=f[n]*(bpow(h,mod-2));
    return g%mod;
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    lli c=0,ans=1e18;
    for(lli i=0;i<=s.size()-t.size();i++)
    {
        c=0;
        for(lli j=0;j<t.size();j++)
        {
            if(s[i+j]!=t[j])c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 18636
#include<iostream>
#include<vector>
using namespace std;
vector<int> A,B;
int main(){
	int n,m;
	while(cin>>n>>m,n,m){
		int sum=0,t=0,min=0,ans1=0,ans2=0,a;
		A.clear();
		B.clear();
		for(int i=0;i<n;i++){
			cin>>a;
			A.push_back(a);
			t+=a;
			sum+=a;
		}
		for(int i=0;i<m;i++){
			cin>>a;
			B.push_back(a);
			t+=a;
		}
		if(t*1.0/2.0!=t/2){
			cout<<-1<<endl;
			continue;
		}
		t/=2;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(B[j]-A[i]==t-sum){
					if(min==0){
						min=A[i]+B[j];
						ans1=A[i];
						ans2=B[j];
					}else if(min>A[i]+B[j]){
						min=A[i]+B[j];
						ans1=A[i];
						ans2=B[j];
					}
				}
			}
		}
		if(ans1==0 && ans2==0)
		cout<<-1<<endl;
		else
		cout<<ans1<<' '<<ans2<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N,D,X;cin>>N>>D>>X;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int ans=X;
    for(int i=0;i<N;i++){
        ans+=1+(D-1)/A[i];        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>


using namespace std;

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

    int ans = 0;
    if (N%10 == 0) {
        cout << 10 << endl;
        goto l1;
    }

    else while (N) {
        ans += N % 10;
        N /= 10;
    }
    cout << ans << endl;
l1:
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N + 1);
  for (int i = 1; i <= N; i++) cin >> v[i];

  vector<int> diff;
  vector<int> diff_idx;
  for (int i = 1; i <= N; i++) {
    if (v[i] != i) {
      diff.push_back(v[i]);
      diff_idx.push_back(i);
    }
  }
  if (diff.size() == 0 || (diff.size() == 2 && diff[0] == diff_idx[1] && diff[1] == diff_idx[0]))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int f(int N,int x){
        if(N==-1) return 0;
        else return 1+N/x;
}

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


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    int n;
    cin >> n;
    int x[n];
    int y[n];
    int h[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    int pos = -1;
    for (int i = 0; i < n; ++i) {
        if (h[i] > 0) {
            pos = i;
            break;
        }
    }

    for(int cx = 0; cx <= 100; ++cx) {
    for(int cy = 0; cy <= 100; ++cy) {
        int refh=h[pos]+abs(cx-x[pos])+abs(cy-y[pos]);
        bool jud=true;
        for(int i = 0; i < n; i++) {
            if (h[i] != max(refh - abs(x[i] - cx) - abs(y[i] - cy), 0)) jud = false;
        }
        if(jud){
            cout << cx << " " << cy << " " << refh << "\n";
            return 0;
        }
    }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int x = n % 1000;
    cout << (1000 - x) % 1000 << endl;

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string a[105];
int main()
{
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
        cout<<a[i];
    cout<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		long X = input.nextLong();
		long[] ans = SOLVE(X);
		System.out.println(ans[0]+" "+ans[1]);
	}
	public static long[] SOLVE(long X) {
		long[] ans = new long[2];
		for (long A = 0;;A++) {
			long START = (long)(Math.pow(A,5));
			long diff = START-X;
			for (int B = 0;;B++) {
				if (Math.pow(B, 5)==Math.abs(diff)) {
					if (diff<0) {
						ans[0]=A;
						ans[1]=-B;
					} 
					else {
						ans[0]=A;
						ans[1]=B;
					}
					return ans;
				}
				if (Math.pow(B, 5)>Math.abs(diff)) break;
			}
		}
	}
}

Measured memory_bytes: 27108
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);

#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main()
{
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
    char s[100000+10];
    scanf("%s", s+1);
    int n = strlen(s+1);
    if(s[n] != '0' || s[1] != '1') puts("-1");
    else {
        int flag = 1;
        for(int i=1;i<n;i++) {
            if(s[i] != s[n-i]) {
                puts("-1");
                return 0;
            }
        }
        int st = 1, cnt = 1;
        for(int i=1;i<n;i++) {
            printf("%d %d\n", st, i+1);
            if(s[i] == '1') st = i+1;
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(void){
int a[31],b,c,i,j,k,l;
for(i=1;i<=30;i++){
    a[i]=i;
}
for(j=1;j<=28;j++){
    scanf("%d",&c);
    a[c]=0;
}


for(l=1;l<=30;l++){
    if(a[l]>0){
       printf("%d\n",a[l]);
    }
}
return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int digit(int num)
{
    int dig;
    int sum = 0;
    while(num){
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    return sum;
}

int atcoder(){
    //入力
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    REP(i,1,n+1){
        if(digit(i)>=a && digit(i)<=b) ans += i;
    }
    //処理
    //出力
    cout << ans << ENT;
    return 0;
}

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


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

int main(void){
    int n;
    cin >> n;
    long long int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++ ){
                int t = __gcd(i, j);
                ans  += __gcd(t, k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
//#define TEST
using System;
using System.Collections.Generic;
using System.Linq;
class P{
    static void Main(){
        int[] abcdef = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a,b,c,d,e,f;
        a = abcdef[0];
        b = abcdef[1];
        c = abcdef[2];
        d = abcdef[3];
        e = abcdef[4];
        f = abcdef[5];
        List<int> sugar = new List<int>(); //ありうる砂糖の量
        List<int> water = new List<int>(); //ありうる水の量
        for (int i = 0;i < f / c;i++)
            for (int j = 0;j < f / d;j++)
                if (c * i + d * j <= f)
                    sugar.Add(c * i + d * j);
#if TEST
        Console.WriteLine("sugar");
        foreach (var i in sugar)
            Console.WriteLine(i);
#endif
        for (int i = 0;i <= f / (100 * a);i++)
            for (int j = 0;j <= f / (100 * b);j++)
                if (100 * a * i + 100 * b * j <= f)
                    water.Add(100 * a * i + 100 * b * j);
#if TEST
        Console.WriteLine("water");
        foreach (var i in water)
            Console.WriteLine(water);
#endif
        List<SugarWater> sw = new List<SugarWater>();
        foreach (var w in water){
            foreach (var s in sugar){
                if (w == 0 && s == 0)
                    continue;
                if (w * e / 100 < s)
                    continue;
                if (w + s > f)
                    continue;
                sw.Add(new SugarWater(w,s));
            }
        }
#if TEST
        Console.WriteLine("water sugar Conc");
        foreach (var i in sw)
            Console.WriteLine("{0} {1} {2}",i.water,i.sugar,i.Conc);
        Console.WriteLine("result");
#endif
        var query = sw.OrderByDescending(suwa => suwa.Conc);
        foreach (var i in query){
            Console.WriteLine("{0} {1}",i.sugar + i.water,i.sugar);
            return;
        }
    }
}
struct SugarWater {
    public int water;
    public int sugar;
    public SugarWater(int water, int sugar){
        this.water = water;
        this.sugar = sugar;
    } 
    public double Conc {get { return 100.0 * sugar / (sugar + water);}}
}

Measured memory_bytes: 33036
s = input()
t = input()
n = len(s)

a = [0 for i in range(26)]
b = [0 for i in range(26)]

for i in range(n):
    a[ord(s[i])-ord("a")] += 1
    b[ord(t[i])-ord("a")] += 1
#print(a)
#print(b)

a.sort()
b.sort()

if a == b:
    print("Yes")
else:
    print("No")

"""
from collections import Counter
S=input()
T=input()
SS=Counter(S)
TT=Counter(T)
if sorted(SS.values())==sorted(TT.values()):
  print('Yes')
else:
  print('No')

"""


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b;
    if(a>b)swap(a,b);
    if(a==1&&b==2)cout<<3;
    if(a==1&&b==3)cout<<2;
    if(a==2&&b==3)cout<<1;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

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

nums = {}
for i in a:
  nums[i] = nums.get(i, 0) + 1
  nums[i+1] = nums.get(i+1, 0) + 1
  nums[i-1] = nums.get(i-1, 0) + 1

ans = 0
for i in nums.values():
  ans = max(ans, i)

print(ans)

Measured memory_bytes: 18748
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> a(m);
	for(int i = 0; i < m; i++) scanf("%d", &a[i]);

	int ans = std::max(-1, n - std::accumulate(begin(a), end(a), 0));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3784
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
    vector<int> a(3);
    for(int i=0;i<3;i++) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());

    cout << 10*a.at(2) + a.at(1) + a.at(0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	const double PI=acos(-1);
	const double r=6378.1;
	for(double a,b,c,d;cin>>a>>b>>c>>d,a!=-1;){
		double x1=r*cos(b*PI/180)*cos(a*PI/180);
		double y1=r*sin(b*PI/180)*cos(a*PI/180);
		double z1=r*sin(a*PI/180);
		double x2=r*cos(d*PI/180)*cos(c*PI/180);
		double y2=r*sin(d*PI/180)*cos(c*PI/180);
		double z2=r*sin(c*PI/180);
		double e=sqrt(pow(x1-x2,2)+pow(y1-y2,2)+pow(z1-z2,2));
		double t=acos((2*r*r-e*e)/(2*r*r));
		double dist=r*t;
		cout<<round(dist)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<stack>
struct p{
	int x;
	int y;
};
using namespace std;
int main(){
	int w,h,sx,sy,gx,gy,n,c,d,x,y,i,j,k,o;
	int map[100][100];
	int used[100][100];
	int mx[4]={-1,0,1,0};
	int my[4]={0,-1,0,1};
	p v,u;
	stack<p> s;
	while(1){
		scanf("%d %d",&w,&h);
		if(w==0&&h==0){
			break;
		}
		memset(map,0,sizeof(map));
		memset(used,0,sizeof(used));
		scanf("%d %d",&sx,&sy);
		sx--;
		sy--;
		scanf("%d %d",&gx,&gy);
		gx--;
		gy--;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d %d %d",&c,&d,&x,&y);
			x--;
			y--;
			if(!d){
				for(j=y;j<y+2;j++){
					for(k=x;k<x+4;k++){
						map[j][k]=c;
					}
				}
			}
			else{
				for(j=y;j<y+4;j++){
					for(k=x;k<x+2;k++){
						map[j][k]=c;
					}
				}
			}
		}
		if(map[sy][sx]!=map[gy][gx]){
			printf("NG\n");
			continue;
		}
		v.x=sx;
		v.y=sy;
		s.push(v);
		o=0;
		while(!s.empty()){
			v=s.top();
			s.pop();
			if(used[v.y][v.x]){
				continue;
			}
			else{
				used[v.y][v.x]=1;
			}
			if(v.x==gx&&v.y==gy){
				o=1;
				while(!s.empty()){
					s.pop();
				}
				break;
			}
			for(i=0;i<4;i++){
				u=v;
				u.x+=mx[i];
				u.y+=my[i];
				if(u.x>=0&&u.x<w&&u.y>=0&&u.y<h&&map[u.y][u.x]==map[sy][sx]){
					s.push(u);
				}
			}
		}
		if(o){
			printf("OK\n");
		}
		else{
			printf("NG\n");
		}
	}
	return 0;
}

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

#define ll long long

int main() {

    ll a,b,x,f = 0LL,g = 0LL, ct = 0LL;

    cin >> a >> b >> x;

    f = a/x;
    g = b/x;

    ct= g - f;

    if(a%x==0) ct++;

    cout << ct << endl;

    return 0;
}




Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[1100000];

int main(){
	int a;scanf("%d",&a);
	init_C(2100000);
	scanf("%s",in);
	int n=strlen(in);
	long long ret=0;
	for(int i=0;i<=a;i++){
		ret+=pw(25,i)*pw(26,a-i)%mod*Comb(n-1+i,i)%mod;
	}
	ret%=mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 51916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n,a[500010],bit[22],ans;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	int l=0,r=0;
	while(l<n&&r<n){
		rep(i,20){
			if((a[r]>>i)&1){
				if(bit[i]){
					rep(j,20)if((a[l]>>j)&1)bit[j]=0;
					ans+=r-l;
					l++;
					goto sh;
				}
			}
		}
		rep(i,20)if((a[r]>>i)&1)bit[i]=1;
		r++;
		sh:;
		if(r==n)ans+=(1+n-l)*(n-l)/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
    int x, y, z, temp;
    
    cin >> x >> y >> z;
    
    temp = x;
    x = y;
    y = temp;
    
    temp = x;
    x = z;
    z = temp;
    
    cout << x << " " << y << " " << z << endl;
    
    return 0;
}


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

const int kMaxValue = 1000;

int main() {
    int n, g; cin >> n >> g;
    vector<int> v(n, 0), w(n, 0);
    for (int i = 0; i < n; i += 1)
        cin >> w[i] >> v[i];
    
    vector<int64_t> dp(n * kMaxValue + 1, numeric_limits<int64_t>::max() / 2);
    dp[0] = 0;

    for (int i = 0; i < n; i += 1)
        for (int j = n * kMaxValue; j >= 0; j -= 1)
            if (j - v[i] >= 0)
                dp[j] = min(dp[j], dp[j - v[i]] + w[i]);

    
    for (int i = n * kMaxValue; i >= 0; i -= 1)
        if (dp[i] <= g) {
            cout << i << "\n";
            return 0;
        }

    assert(false);
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int dp[100100];

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

	int N=in();
	vector<int> h(N);
	REP(i,N) h[i] = in();
	for(auto& x:dp) x = 1e9;
	dp[0] = 0;

	for(int i=0;i<N;i++){
		if(i<N-1) chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		if(i<N-2) chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}
	
	cout << dp[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int A,B;
    cin >> A >> B;
    int ans;
    REP(i,3){
        if(i!=A-1 && i != B-1) ans = i;
    }
    ans++;
    cout << ans << endl;
}

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

#define MAXN (100010)
#define mod (1000000007)

int n;
int a[MAXN];

int powmod(int a, int b){
	int ret = 1;
	while(b){
		if(b & 1) ret = (1ll) * ret * a % mod;
		b >>= 1;
		a = (1ll) * a * a % mod;
	}
	return ret;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		int t;
		scanf("%d", &t);
		a[t] ++;
	}
	for(int i = n - 1; i > 0; i -= 2){
		if(a[i] != 2){
			return printf("0\n"), 0;
		}
	}
	if((n & 1) && a[0] != 1){
		return printf("0\n"), 0;
	}
	printf("%d\n", powmod(2, n / 2));
	return 0;
}

Measured memory_bytes: 640
# 0:30
n = int(input())
h = list(map(int,input().split()))

ans = 0
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
        if count > ans:
            ans  = count
    else:
        count = 0
if count > ans:
    ans = count
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main()
{
 
// OJ;
 string a,b;
 cin>>a>>b;
 for(int i=0;i<a.size();i++)
 {
     if(a[i]!=b[i])
     {
         cout<<"No";return 0;
     }
 }
 cout<<"Yes";
 
 
 
 
 
return 0;
   
}

Measured memory_bytes: 3600
N = int(input())
H = list(map(int, input().split()))

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include<stdio.h>

int main(void) {

	int x, y,tmp;

	while (1) {

		scanf("%d %d", &x, &y);

		if (x == 0 && y == 0)
			break;

		else if (x > y) {
			tmp = x;
			x = y;
			y = tmp;
		}

		printf("%d %d\n", x, y);

	}
	
	return(0);

}


Measured memory_bytes: 2024
#include <bits/stdc++.h>
using namespace std;
int n,m,b[100010],d[100010],c[100010];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		b[x%m]++;
		c[x]++;
		if(c[x]%2==0)d[x%m]++;
	}
	int ans=0;
	for(int x=0;x<m;x++){
		int y=m-x;
		if(y==x||y==m)ans+=b[x]/2;
		else{
			ans+=min(b[x],b[y]);
			if(b[x]<b[y])ans+=min((b[y]-b[x])/2,d[y]);
			else ans+=min((b[x]-b[y])/2,d[x]);
		}

		//printf("%d %d %d %d %d %d %d\n",x,y,b[x],b[y],d[x],d[y],ans);
		b[x]=b[y]=0;
		d[x]=d[y]=0;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int[] p = new int[A];
    int[] q = new int[B];
    int[] r = new int[C];
    for (int i = 0; i < A; i++) p[i] = sc.nextInt();
    for (int i = 0; i < B; i++) q[i] = sc.nextInt();
    for (int i = 0; i < C; i++) r[i] = sc.nextInt();
    sc.close();

    Arrays.parallelSort(p);
    Arrays.parallelSort(q);

    int[] xyc = new int[X + Y + C];
    System.arraycopy(p, A - X, xyc, 0, X);
    System.arraycopy(q, B - Y, xyc, X, Y);
    System.arraycopy(r, 0, xyc, X + Y, C);
    Arrays.parallelSort(xyc);

    long ans = 0;
    for (int i = C; i < X + Y + C; i++) ans += xyc[i];

    System.out.println(ans);
  }
}

Measured memory_bytes: 92164
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1e9;
const ll LLINF = 1e16;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    
    int h, w;
    cin >> h >> w;
    
    vector<vector<char>> s(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> s[i][j];
        }
    }
    
    int ans = -1;

    vector<int> d1 = {1, 0, -1, 0};
    vector<int> d2 = {0, 1, 0, -1};

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            
            if(s[i][j] == '.'){//それぞれの場所について見ていく
                int maxd = -1;
                vector<vector<int>> d(h, vector<int>(w));
                for(int ii=0; ii<h; ii++){
                    for(int jj=0; jj<w; jj++){
                        d[ii][jj] = -INF;
                    }
                }
                queue<i_i> que;
                que.push({i, j});
                d[i][j] = 0;

                while(!que.empty()){ //bfs
                    i_i p = que.front();
                    que.pop();
                    for(int k=0; k<4; k++){
                        int n1 = p.first+d1[k];
                        int n2 = p.second+d2[k];
                        if(0 <= n1 && n1 < h && 0 <= n2 && n2 < w && s[n1][n2] == '.' && d[n1][n2] == -INF){
                            que.push({n1, n2});
                            d[n1][n2] = d[p.first][p.second]+1;
                        }
                    }

                }
                
                for(int ii=0; ii<h; ii++){
                    for(int jj=0; jj<w; jj++){
                        maxd = max(maxd, d[ii][jj]);
                    }
                }
                ans = max(ans, maxd);
            }
        }
    }

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

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

int main()
{
  string S, T;
  cin >> S >> T;
  bool OK = true;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] != T[i])
    {
      OK = false;
      break;
    }
  }
  if (OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3548