akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static long mod_pow(long a, long e, long m){
		if(e == 0){
		return 1;
		}else if(e % 2 == 0){
			long ret = mod_pow(a, e / 2, m);
			return (ret * ret) % m;
		}else{
			return (mod_pow(a, e - 1, m) * a) % m;
		}
	}
	
	public static long mod_inv(long a, long m){
		return (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);
	}
	
	public static long nCk (long n, long k, final long MOD) {
		long upper = 1;
		long lower = 1;
		
		for(long i = n; i > (n - k); i--) {
			upper *= i;
			upper %= MOD;
		}
		
		for(long i = 1; i <= k; i++) {
			lower *= i;
			lower %= MOD;
		}
		
		//System.out.println(n + " " + k + " " + upper + " " + lower);
		
		return (upper * mod_inv(lower, MOD)) % MOD;
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			
			final long a = sc.nextLong();
			final long b = sc.nextLong();
			
			final long MOD = 1000000007;
			
			long ALL = mod_pow(2, N, MOD);
			ALL = ((ALL + MOD) - 1) % MOD;
			
			final long A = nCk(N, a, MOD);
			final long B = nCk(N, b, MOD);
			
			final long answer = (ALL + MOD - ((A + B) % MOD)) % MOD;
			
			System.out.println(answer);
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
        a[i]--;
    }

    ll res = 1e15;
    REP(p, 100) {
        ll tmp = 0;
        REP(i, n) {
            tmp += (a[i] - p) * (a[i] - p);
        }
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,j,l[2010],ans=0;
  int *lp;
  cin >> n;
  for (i=0;i<n;i++) cin >> l[i];
  sort(l,l+n);
  for (i=0;i<n-2;i++) for (j=i+2;j<n;j++){
    lp=lower_bound(l+i+1,l+j,l[j]-l[i]);
    while (lp!=l+j && *lp==l[j]-l[i]) lp++;
    ans+=l+j-lp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import copy

def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]


    # スタート地点をqueueに追加
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])

    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))

        if nque:
            que = copy.copy(nque)
        else:
            break

    print(count - 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 115560
#include<iostream>
#include<stack>
#include<queue>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;
#define ll long long
const ll inf=1000000007;
vector<ll> fac;
void pfac(ll a);

ll fact(ll x,ll y){
    if(y==1)return x;
    else if(y%2==0)return fact(x*x%inf,y/2);
    else return fact(x*x%inf,y/2)*x%inf;
}
ll C(ll n,ll t){
    ll mul[114514];
    mul[0]=1;
    for(int i=1;i<114514;i++)mul[i]=mul[i-1]*i%inf;
    ll div[114514];
    div[114513]=fact(mul[114513],inf-2);
    for(int i=114512;i>=0;i--)div[i]=div[i+1]*(i+1)%inf;
    return mul[n]*div[t]%inf*div[n-t]%inf;
}


  
  int main(){
    ll n,m,ans=1;
    cin>>n>>m;
    pfac(m);
    sort(fac.begin(),fac.end());
    for(int i=0;i<fac.size();i++){
    ans*=C(fac[i]+n-1,n-1);
      ans%=inf;
    }
cout<<ans<<endl;
    return 0;
}
void pfac(ll a){
  ll memo=sqrt(a);
  for(int i=2;i<=memo;i++){
    ll p=0;//
    while(1){
  if(a%i==0){
    /*
    fac.push_back(i);
    */
    a/=i;
    p++;//
  }
      else{
      if(p!=0)fac.push_back(p);//
        break;
      }
    }
  }
  if(a!=1){
    /*
    fac.push_back(a);
    */
      fac.push_back(1);//
    }
}

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

int main() {
    string A, B, ans = "EQUAL";
    cin >> A >> B;
    if (A.size() == B.size()) {
        if (A > B) ans = "GREATER";
        if (A < B) ans = "LESS";
    } else {
        if (A.size() > B.size()) ans = "GREATER";
        if (A.size() < B.size()) ans = "LESS";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
"""
前処理
"""
import numpy as np
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    ai, bi = map(int, input().split())
    """
    入力したものをそれぞれリストに格納していく、これは真似ていこう
    """
    A.append(ai)
    B.append(bi)

"""
配列に変換
"""
A = np.array(A)
B = np.array(B)

"""
処理
"""
#0からHまで
dp = np.zeros(H+1, dtype=np.int64) 
dp[0] = 0

for i in range(1, H+1):
    dp[i] = np.amin(dp[np.maximum(i-A, 0)] + B)

"""
output
"""
print(dp[H])

Measured memory_bytes: 12488
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int N,D;
    int X[11][11];
    float distance;
    scanf("%d %d\n",&N,&D);
    
    int i,j,k;
    for(i=1;N>=i;i++){
        for(j=1;D>=j;j++){
            scanf("%d",&X[i][j]);
        }
    }
    int count=0;
    for(i=1;N>=i;i++){
        for(j=i+1;N>=j;j++){
            distance = 0;
            for(k=1;D>=k;k++){
                distance += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            distance = sqrt(distance);
            if (distance - (int)distance == 0) count++;
            //printf("%f\n",distance);
        }
    }
    printf("%d",count);
    return 0;
    
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a[]=new int[4];
		int b[]=new int[4];
		while(sc.hasNext()){
			int hit=0,blow=0;
			for(int i=0;i<4;i++)a[i]=sc.nextInt();
			for(int i=0;i<4;i++)b[i]=sc.nextInt();
			for(int i=0;i<4;i++){
				if(a[i]==b[i])hit++;
				for(int j=i+1;j<4;j++){
					if(a[i]==b[j])blow++;
					if(b[i]==a[j])blow++;
				}
			}
			System.out.println(hit+" "+blow);
		}
	}
}

Measured memory_bytes: 16272
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

// O(|V| + |E|)

//    Edges := 重み付き辺の集合
//    WeightedGraph := 重み付きグラフ
//    UnWeightedGraph := 重み無しグラフ
//    Matrix := 距離行列
template< typename T >
struct edge {
  ll src, to;
  T cost;

  edge(ll to, T cost) : src(-1), to(to), cost(cost) {}

  edge(ll src, ll to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator ll() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


struct SCC
{
  vector< vector< int > > gg, rg;
  vector< pair< int, int > > edges;
  vector< int > comp, order, used;

  SCC(size_t v) : gg(v), rg(v), comp(v, -1), used(v, 0) {}

  void add_edge(int x, int y)
  {
    gg[x].push_back(y);
    rg[y].push_back(x);
    edges.emplace_back(x, y);
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  void dfs(int idx)
  {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt)
  {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(vector< vector< int > > &t)
  {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    set< pair< int, int > > connect;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      if(connect.count({x, y})) continue;
      t[x].push_back(y);
      connect.emplace(x, y);
    }
  }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int v,e;
    cin>>v>>e;
    SCC scc(v);
    FOR(i,0,e){
      int in1,in2;
      cin>>in1>>in2;
      scc.add_edge(in1,in2);
    }
    UnWeightedGraph buff;
    scc.build(buff);
    ll q;
    cin>>q;
    while(q--){
      ll in1,in2;
      cin>>in1>>in2;
      cout<<(scc[in1] == scc[in2] ? 1 : 0)<<endl;
    }
}



Measured memory_bytes: 4656
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 5e5;
ll b[N];

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    int n, k; cin >> n >> k;
    int s[4];
    cin >> s[1] >> s[3] >> s[2];
    string a; cin >> a;
    for(int i = 0; i < n; i++) {
        if(a[i] == 'r') b[i] = 2; 
        if(a[i] == 'p') b[i] = 3;
        if(a[i] == 's') b[i] = 1;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(i-k>=0 && b[i-k] == b[i]) b[i] = 0;
        else {
            // cout << i+1 << " " << b[i] << endl;
            ans += s[b[i]];
        }
    }
    cout << ans << "\n";
 
    return 0;
    
}
    


Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long n,d,a;
long long t[200005];
struct kk{

long long pos,h;
	bool operator <(const kk&a)const{
		return pos<a.pos;
	}
}k[200004];

inline
long long lowbit(long long i){
	return i&-i;
}

long long query(long long x){
	long long sum=0;
	while(x){
		sum+=t[x];
		x-=lowbit(x);
	}
	return sum;
}

void update(long long x,long long v){
	if(x>n) return;
	while(x<=n){
		t[x]+=v;
		x+=lowbit(x);
	}
}

long long find(long long x){
	long long l=1,r=n;
	while(l<r){
		long long mid=(l+r)>>1;
		if(k[mid].pos>x) r=mid;
		else l=mid+1;
	}
	if(k[l].pos<=x) return l+1;
	else  return l;
}

int main(){
	cin>>n>>d>>a;long long ans=0;
	for(long long i=1;i<=n;++i)
		cin>>k[i].pos>>k[i].h;
	sort(k+1,k+n+1);
	for(long long i=1;i<=n;++i){
		long long sum=query(i)*a;
		if(k[i].h<=sum) continue;
		long long num=(k[i].h-sum-1)/a+1;
		update(i,num);ans+=num;
		update(find(d+d+k[i].pos),-num);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt(), T = sc.nextInt();
        int[] A = new int[T];
        for (int i=0;i<T;i++){
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        int M = A[T-1];
        for (int i=T-2;i>=0;i--){
            M = Math.abs(M-A[i]);
            A[i] = M;
        }
        System.out.println(Math.max(A[0]-1, 0));
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;

bool is_prime(int num)
{	
	int a = sqrt(num);
	
	for(int i = 2; i <= a; i++){
		
		if(num % i == 0){
			return false;
		}
	}
	return true;
}
int main(void)
{
	int n;
	cin >> n;
	
	int num;
	int prime_count = 0;
	for(int i = 0; i < n; i++){
		cin >> num;
		
	
		if(is_prime(num) == true){
			prime_count++;
		}
	}
	cout << prime_count << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int x = 0;
    for (size_t i = 0; i < 2; i++)
    {
        int k = max(a, b);
        if(k == a) {
            a -= 1;
        } else {
            b -= 1;
        }
        x += k;
    }
    cout << x << endl;
}


Measured memory_bytes: 256
n,m,x = map(int, input().split())
ls = [list(map(int, input().split())) for i in range(n)]
ans=1001001001001
for i in range(1 << n):
    u=[0]*m
    cost=0
    for j in range(n):
        if i & 1 << j:
            for k in range(1,m+1):
                u[k-1] += ls[j][k]
            cost += ls[j][0]
    for k in range(m):
        if u[k] < x:
            break
    else:
        ans = min(ans,cost)

if ans == 1001001001001:
    ans = -1
print(ans)


Measured memory_bytes: 68432
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main(void)
{
	int h,w,n;
	cin >> h >> w >> n;
	int mini[200005];
	for(int i=1;i<=w;i++)
		mini[i-1]=h+1;
	vector<int> wall[200005];
	int cango[200005];
	cango[1-1]=1;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin >> x >> y;
		wall[y-1].push_back(x);
	}
	for(int i=2;i<=w;i++)
	{
		sort(wall[i-1].begin(),wall[i-1].end());
		int count=0;
		cango[i-1]=cango[i-1-1]+1;
		for(int j=1;j<=wall[i-1].size();j++)
		{
//cout << i << ":" << j << ":" << wall[i-1][j-1] << endl;
				int wallx=wall[i-1][j-1];
				if(wallx<=cango[i-1-1])
					continue;
				else if(wallx!=cango[i-1-1]+1+count)
				{
					cango[i-1]=cango[i-1-1]+1+count;
					break;
				}
				cango[i-1]++;
				count++;
		}
	}

	for(int i=1;i<=w;i++)
	{
//		cout << i << ":" << cango[i-1] << endl;
		for(int j=1;j<=wall[i-1].size();j++)
		{
			int wallx=wall[i-1][j-1];
			if(wallx>=cango[i-1])
				mini[i-1]=min(mini[i-1],wallx);
		}
	}
	sort(mini,mini+w);
	cout << mini[0]-1 << endl;

}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
int dp[510][510],cnt[510][510];
signed main(){
	int n,m,q;
	cin>>n>>m>>q;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		cnt[x][y]++;
	}
	for(int i=1;i<=n;i++){
		dp[i][i] = cnt[i][i];
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n-i;j++){
			dp[j][j+i] = dp[j][j+i-1] + dp[j+1][j+i] + cnt[j][j+i];
			if(i>1) dp[j][j+i] -= dp[j+1][j+i-1];
		}
	}
	vector<int> qx,qy;
	for(int i=0;i<q;i++){
		int x,y;
		cin>>x>>y;
		qx.pb(x);qy.pb(y);
	}
	for(int i=0;i<q;i++){
		cout<<dp[ qx[i] ][ qy[i] ]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6636
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        int n = s.length();
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            char ch = s.charAt(i);
            if (i % 2 == 0 && ch == 'L') {
                ok = false;
            } else if (i % 2 == 1 && ch == 'R') {
                ok = false;
            }
        }
        if (ok) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23252
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  bool can = true;
  string s;
  cin >> s;
  ll n = s.size();
  ll m = (n-1)/2;
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n-1-i]){
      can = false;
      break;
    }
  }
  m = n/2;
  for(int i=0;i<m;i++){
    if(s[i]!=s[m-1-i]){
      can = false;
      break;
    }
    if(s[m+1+i]!=s[n-1-i]){
      can = false;
      break;
    }
  }
  if(can) cout <<"Yes\n";
  else cout <<"No\n";
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll a,b,c;cin >>a>>b>>c;
    cout <<min(b/a,c)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

        int sum = 0;
        int a = scan.nextInt();       
        int b = scan.nextInt();
        int c = scan.nextInt();
        

        for (int i = a; i <= b; i++) {
            if (c % i == 0) {
            
                sum++;    
            }  
          }   
        
            
        
        
       
        
        System.out.println(sum);
    }
}



Measured memory_bytes: 26424
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int n, a[110]; cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	sort(a, a + n);
	cout << unique(a, a + n) - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
vector < string > p;
bool used[26];
int main() {
    srand(time(0));
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        memset(used, 0, sizeof used);
        for (int j = 0; j < i; j++) {
            used[s[j] - 'a'] = true;
        }
        for (int k = 0; k < 26; k++) {
            string t = "";
            for (int j = 0; j < i; j++) t += s[j];
            if (!used[k] && k > (int)(s[i] - 'a')) {
                t += (char)(k + 'a');
                p.push_back(t);
                break;
            }
        }
    }
    memset(used, 0, sizeof used);
    for (int i = 0; i < s.size(); i++) {
        used[s[i] - 'a'] = true;
    }
    for (int k = 0; k < 26; k++) {
        if (!used[k]) {
            string t = "";
            t = s + char(k + 'a');
            p.push_back(t);
            break;
        }
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < p.size(); i++) {
        if (p[i] > s) {
            cout << p[i];
            exit(0);
        }
    }
    cout << -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  if (n%2 == 0) {
    ll tmp = 5;
    while (tmp*2 <= n) {
      ans += n/(tmp*2);
      tmp *= 5;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#define MAX 100
using namespace std;
vector<int> zhongxu,qianxu;
struct node{int key;node *p,*l,*r;};
node *root,*NIL;

void insert(int num){
	node *y=NIL;node *x=root;node *z;
	z=(node *)malloc(sizeof(node ));
	while(x!=NIL){
		y=x;
		if(num<x->key){x=(*x).l;}
		else {x=x->r;}
	}
	z->key=num;z->l=NIL;z->r=NIL;z->p=y;
	if(y==NIL){
		root=z;
	}else if(num>y->key){
		y->r=z;
	}else{y->l=z;}
}
void zhong(node *u){
	if(u->l!=NIL) zhong(u->l);
	cout<<" "<<u->key;
	if(u->r!=NIL) zhong(u->r);
	return ;
}
void qian(node *u){
	cout<<" "<<u->key;
	if(u->l!=NIL) qian(u->l);
	if(u->r!=NIL) qian(u->r);
	return;
}
void print(node *u){
	zhong(u);cout<<endl;
	qian(u);cout<<endl;return;
}
node* find(int num){
	node *p=root;
	 while(p!=NIL&&p->key!=num){
	 	if(num<p->key) p=p->l;
	 	else if(num>p->key) p=p->r;
	 }
	 return p;
}
int main(){
	int cnt;int num;
	scanf("%d",&cnt);
	char order[10];
	vector<int> ::iterator it;
	for(int i=0;i<cnt;i++){
		scanf("%s",&order);
		if(order[0]=='i') {
		scanf("%d",&num);insert(num);
		}
		else if(order[0]=='p') {print(root);
		}else{scanf("%d",&num);
		if(find(num)!=NIL){cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;  
		}
			
		}
	}
}


Measured memory_bytes: 21860
/*
 　　　　　／＞　 フ
 　　　　　| 　_　 _|
 　 　　　／`ミ _x 彡
 　　 　 /　　　 　 |
 　　　 /　  ヽ　　 ?
 　／￣|　　 |　|　|
 　| (￣ヽ＿_ヽ_)_)
 　＼二つ
  */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
    static short st[30];short tp=0;
    if(x<0) putchar('-'),x=-x;
    do st[++tp]=x%10,x/=10; while(x);
    while(tp) putchar('0'|st[tp--]);
    putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int P = 998244353;
const int N = 405;
ll inv[N], fac[N], a[N], b[N], A, B, ans, n;
ll fpw(ll x, ll mi) {
    ll res = 1;
    for (; mi; mi >>= 1, x = x * x % P)
        if (mi & 1) res = res * x % P;
    return res;
}
ll g[N][N], f[N][N];
int main() {
    read(n);
    inv[0] = fac[0] = inv[1] = fac[1] = 1;
    for (int i = 2;i <= 400; i++) inv[i] = (P - P / i) * inv[P % i] % P;
    for (int i = 2;i <= 400; i++)
        inv[i] = inv[i-1] * inv[i] % P,
        fac[i] = fac[i-1] * i % P;

    for (int i = 1;i <= n; i++) {
        read(a[i]), read(b[i]);
        A += a[i], B += b[i];
    }
    f[0][0] = -1;
    /* for (int i = 1;i <= 50; i++) write(inv[i], ' '), write(fac[i]); */
    for (int i = 1;i <= n; i++) {
        memcpy(g, f, sizeof(g));
        for (int s = A;s >= 0; s--) {
            for (int j = B;j >= 0; j--) {
                if (s < a[i]) { f[s][j] = 0; continue; }
                ll t = a[i];
                f[s][j] = f[s-a[i]][j];
                for (int k = 1;k < b[i]; k++, t = t * a[i] % P) 
                    f[s][j] = (f[s][j] + t * inv[k] % P * f[s-a[i]][j-k]) % P;
            }
        }
        for (int j = 0;j <= A; j++)
            for (int k = 0;k <= B; k++)
                f[j][k] = (g[j][k] - f[j][k] + P) % P;
    }
    for (int s = 1;s <= A; s++) {
        ll tt = fpw(s, P - 2), t = A * tt % P;
        ll res = 0;
        for (int i = 0;i <= B; i++, t = t * tt % P) 
            res = (res + f[s][i] * fac[i] % P * t) % P;
        res %= P, ans = (ans + res) % P;
    }
    write(ans);
    return 0;
}

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

int main() {
  int A, B;
  int num = 0;                                 //回文数の数
  cin >> A >> B;

  for(int i = A; i <= B; i++){
    int x = i / 1000;                        //上二桁を取得
    int y = i % 100;                        // 下二桁を取得
    if( ( (x / 10) == (y % 10) ) && ( (x % 10) == (y / 10) ) )   //下二桁の構成要素が等しい
      num++;
  }
    
 cout << num << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    int n = s.length();
    int ans = 0;
    rep(i,n) if (s[i]!=t[i]) ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int d,e;
  while(cin >> d >> e,d){
    int x = d;
    int y = 0;
    double p;
    for(int i = 0;i <= d;i++){
      x = d-i;
      y = i;
      if(i == 0)
	p = abs((double)e - (double)sqrt(x*x+y*y));
      else
	p = min(p, abs((double)e - (double)sqrt(x*x+y*y)));
    }
    cout << p << endl;
  }
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,q,s[200010],t[200010],x[200010],d[200010];
	bool ison[200010] = {};
	vector<P> on[600010];
	vector<int> query[600010],off[600010],vec;
	cin >> n >> q;
	for(int i = 0;i < n;i++){
		cin >> s[i] >> t[i] >> x[i];
		vec.pb(s[i] - x[i]);
		vec.pb(t[i] - x[i]);
	}
	for(int i = 0;i < q;i++){
		cin >> d[i];
		vec.pb(d[i]);
	}
	sort(all(vec));
	vec.erase(unique(all(vec)),vec.end());
	for(int i = 0;i < n;i++){
		int ind = lower_bound(all(vec),s[i] - x[i]) - vec.begin();
		on[ind].pb(P(x[i],i));
		ind = lower_bound(all(vec),t[i] - x[i]) - vec.begin();
		off[ind].pb(i);
	}
	for(int i = 0;i < q;i++){
		int ind = lower_bound(all(vec),d[i]) - vec.begin();
		query[ind].pb(i);
	}
	priority_queue<P,vector<P>,greater<P> > que;
	for(int i = 0;i < vec.size();i++){
		for(P p : on[i]){
			que.push(p);
			ison[p.second] = true;
		}
		for(int v : off[i]){
			ison[v] = false;
		}
		for(int v : query[i]){
			while(!que.empty() && !ison[que.top().second]) que.pop();
			if(que.empty()) cout << -1 << endl;
			else cout << que.top().first << endl;
		}
	}
}


Measured memory_bytes: 80616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    ll x; cin >> x;
    for(ll i = -200; i <= 200; i++){
        for(ll j = -200; j <= 200; j++){
            ll a5 = i * i * i * i * i;
            ll b5 = j * j * j * j * j;
            if(a5 - b5 == x){
                cout << i << " " << j << endl;
                //cout << a5 << endl;
                //cout << b5 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> X(n);
    for (auto & x : X) cin >> x;

    ll m = 1e9;
    for (ll i = 0; i + k - 1< n; ++i) {
        ll cur = abs(X[i+k-1] - X[i]);
        cur += min(abs(X[i]), abs(X[i+k-1]));
        m = min(cur, m);
    }
    cout << m << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main(){

  int n;
  cin >> n;
  string s;
  cin >> s;
  int count = 0;
  rep(i, n){
    if(s[i] != s[i + 1])count++;
  }
  cout << count << endl;

}


Measured memory_bytes: 512
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


int D_in;
int T_in;
int S_in;


int main(int argc, char* argv[]){
    int i,j;
    int temp,count;
    count=0;
    scanf("%d %d %d",&D_in,&T_in,&S_in);
    temp = D_in/S_in;
    if(temp<=T_in){
        if(D_in % S_in > 0 && temp == T_in){
            printf("No");
        }else{
            printf("Yes");
        }
    }else{
        printf("No");
    }
    return 0;
}

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

sooted =['S','H','C','D']
list_soot=[]
list_num=[]
for i in range(N):
    a,b=map(str,input().split())
    list_soot.append(a)
    list_num.append(int(b))
    
ans_soot=[]
ans_num=[] 
for j in sooted:
    for k in range(1,14):
        flag =0
        for l,m in zip(list_soot,list_num):
            if j==l and k==m:
                flag=1
                break
        if flag==1:
            continue
        else:
            ans_soot.append(j)
            ans_num.append(k)
            
            
                

for n ,o in zip(ans_soot,ans_num):
    print(n, o)
    
    


Measured memory_bytes: 5608
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;
#define int ll
#define REP(i,e,s) for(register int i=(e); i<=(s); i++)
#define DREP(i,e,s) for(register int i=(e); i>=(s); i--)
#define ll long long
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1000000+10,N=MAXN-10,MOD=1e9+7;

int vis[MAXN],p[MAXN],c[MAXN];

int divide(int n) {
	int cnt=0,sum=0;
	for(int i=2; i*i<=n; i++) {
		if(n%i==0) {
			p[++cnt]=i,c[cnt]=0;
			while(n%i==0) n/=i,c[cnt]++;
			sum+=c[cnt];
		}
	}
	if(n>1) p[++cnt]=n,c[cnt]=1,sum+=c[cnt];

	return cnt;
}

int fac[MAXN],inv[MAXN];

int qpow(int a,int b) {
	int ans=1;
	while(b) {
		if(b&1) ans=ans*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return ans;
}

int C(int n,int m) {return ((fac[m]*inv[n]%MOD)*inv[m-n])%MOD;}

signed main() {
	ll n=read(),m=read();

	fac[0]=1;
	REP(i,1,N) fac[i]=(i*fac[i-1])%MOD;
	inv[N]=qpow(fac[N],MOD-2);
	DREP(i,N-1,0) inv[i]=(inv[i+1]*(i+1))%MOD;
	
	int cnt=divide(m),ans=1;
	REP(i,1,cnt) ans=ans*C(n-1,n+c[i]-1)%MOD%MOD;

	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 18816
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<bool>	vb;



void solve(){
    ll n;
    cin >> n;
    if(n % 1000 == 0) cout << 0;
    else cout << (1000 - n % 1000);
}

int main(){
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}

}

Measured memory_bytes: 3616
function main()
  
  (D,N) = split(chomp(readline())," ")
  
  if N == "100"
    print("101")
  else
    print(N)
  end
  
  if D == "1"
    println("00")
  elseif D == "2"
    println("0000")
  else
    println()
  end
  
end

main()

Measured memory_bytes: 109604
#include <stdio.h>

#define MAX 36

typedef struct{
  int value[MAX];
  char word[MAX];
}data;

int hantei(data,data,int);

int main(){
  data seq,seqs,seqb;
  int len,c=0;
  int temp,chk=1,num;
  char tempc;
  int i,j;

  scanf("%d",&len);
  for(i=0;i<len;i++) scanf(" %c %d",&seq.word[i],&seq.value[i]);
  seqs=seq;
  seqb=seq;

  //bubble
  while(chk==1){
    chk=0;
    for(i=len-1;i>=1;--i){
      if(seqb.value[i-1]>seqb.value[i]){
	temp=seqb.value[i];
	seqb.value[i]=seqb.value[i-1];
	seqb.value[i-1]=temp;
	
	tempc=seqb.word[i];
	seqb.word[i]=seqb.word[i-1];
	seqb.word[i-1]=tempc;
	chk=1;
      }
    }
  }
  

  for(i=0;i<len-1;i++) printf("%c%d ",seqb.word[i],seqb.value[i]);
  printf("%c%d\n",seqb.word[i],seqb.value[i]);
  
  if(hantei(seqb,seq,len)==0) printf("Stable\n");
  else printf("Not stable\n");
  
  //selection
  for(i=0;i<len;i++){
    num=i;
    for(j=i+1;j<len;j++){
      if(seqs.value[num]>seqs.value[j]){
	num=j;
      }
    }
    temp=seqs.value[num];
    seqs.value[num]=seqs.value[i];
    seqs.value[i]=temp;
    tempc=seqs.word[num];
    seqs.word[num]=seqs.word[i];
    seqs.word[i]=tempc;
  }
  
  for(i=0;i<len-1;i++) printf("%c%d ",seqs.word[i],seqs.value[i]);
  printf("%c%d\n",seqs.word[i],seqs.value[i]);

  if(hantei(seqs,seq,len)==0) printf("Stable\n");
  else printf("Not stable\n");
   
  return 0;
}

int hantei(data seq,data seqo,int len){
  int i,j,k,l;
  
  for(i=0;i<len;i++){
    for(j=i+1;j<len;j++){
      for(k=0;k<len;k++){
	for(l=k+1;l<len;l++){
	  if(seq.value[i]==seq.value[j]
	     &&seq.word[i]==seqo.word[l]
	     &&seq.value[i]==seqo.value[l]
	     &&seq.word[j]==seqo.word[k]
	     &&seq.value[j]==seqo.value[k]
	     ){
	      return 1;
	  }
      	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main() {
	int arr[3], count = 0;;
	cin >> arr[0] >> arr[1] >> arr[2];

	sort(arr, arr + 3);
	count += (arr[2] - arr[0]) / 2;
	count += (arr[2] - arr[1]) / 2;
	if((arr[2] - arr[1]) % 2 == 0) {
		arr[1] = arr[2];
	} else {
		arr[1] = arr[2] - 1;
	}

	if((arr[2] - arr[0]) % 2 == 0) {
		arr[0] = arr[2];
	} else {
		arr[0] = arr[2] - 1;
	}
	
	if((arr[2] == arr[1])&&(arr[2] - 1 == arr[0])||(arr[2] == arr[0])&&(arr[2] - 1 == arr[1])) {
		count += 2;
	} else if((arr[2] - 1 == arr[1])&&(arr[2] - 1 == arr[0])) {
		count++;
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,a,b,m,n;
	scanf("%d %d",&a,&b);
	if(a<=b){
		m=a;
		n=b;
	}
	else{
		m=b;
		n=a;
	}	
	for(i=0;i<n;i++){
		printf("%d",m);
	}
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include<iomanip>
#include<bitset>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod

#define N 60
ll n,a[N],b[N];
bool edge[N][N];
bool vis[N];
bool dfs(ll x,ll to){
    if(x==to)return 1;
    if(vis[x])return 0;
    vis[x]=1;
    for(int i=0;i<x;i++){
	if(edge[x][i]){
	    if(dfs(i,to)==1)return 1;
	}
    }
    return 0;
}
bool solve(ll t){
    for(int i=0;i<N;i++){
	for(int j=0;j<N;j++)edge[i][j]=0;
	for(int j=1;j<N;j++){
	    if(t&(1LL<<j))edge[i][i%j]=1;
	}
    }
    for(int i=0;i<n;i++){
	for(int j=0;j<N;j++)vis[j]=0;
	if(dfs(a[i],b[i])==0)return 0;
    }
    return 1;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
	cin>>a[i];
    }
    for(int i=0;i<n;i++){
	cin>>b[i];
    }
    ll t=(1LL<<55)-2;
    if(solve(t)==0){
	cout<<-1<<endl;
	return 0;
    }
    else{
	for(int i=54;i>0;i--){
	    if(solve(t-(1LL<<i))==1){
		t-=(1LL<<i);
	    }
	}
	cout<<t<<endl;
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
  int n;
  cin>>n;
  vector<int> height(n);
  for(int i=0;i<n;i++)
    cin>>height[i];
  vector<int> answer(n,0);
  if(n>1){
  answer[1]=abs(height[1]-height[0]);
  for (int i=2;i<n;i++)
  answer[i]=min(abs(height[i]-height[i-1])+answer[i-1],abs(height[i]-height[i-2])+answer[i-2]);
           
  }
                cout<<answer[n-1];
                return 0;
}


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

using namespace std;

#define mod 1000000007
#define inf 1e18
#define ll long long
#define PI 3.1415926536

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, input;
	cin >> n;
	map<ll, ll> map;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> input;
		sum += input;
		map[input]++;
	}

	int q;
	cin >> q;
	while (q--) {
		int b, c;
		cin >> b >> c;
		sum = sum - (map[b] * b) + (map[b] * c);
		cout << sum << endl;
		map[c] += map[b];
		map[b] = 0;
	}
	return 0;
}

Measured memory_bytes: 9536
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.HashSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int sa = r-l;
		if(sa>=2018) {
			System.out.println(0);
			System.exit(0);
		}
		int ls = l%2019;
		int min = Integer.MAX_VALUE;
		for(int i=ls;i<ls+sa;i++) {
			for(int j=ls+1;j<=ls+sa;j++) {
				if(i*j%2019 < min) {
					min = i*j%2019; 
				}
			}
		}
		System.out.println(min);
	}
	
	static long factr(long n,long p,long q) {
		if(n==p) {
			return 1l;
		}
		long ma = Math.max(p, q);
		long mi = Math.min(p, q);
		ArrayList<Long> mm = new ArrayList<Long>();
		for(int i=1;i<=mi;i++) {
			mm.add((long) i);
		}
		long ret = fact(n,ma,mm);
		return ret;
	}
	static long fact(long n,long m,ArrayList<Long> mm) {
		if(n==m) {
			return 1l;
		}
		long pre = fact(n-1,m,mm);
		for(int i=0;i<mm.size();i++) {
			if(pre%mm.get(i) ==0) {
				pre = pre/mm.get(i);
				mm.set(i, 1l);
			}
		}
		return (n*pre);
	}
}

Measured memory_bytes: 24916
import numpy
import math
n = int(input())
w = list(map(int, input().split()))

sum_w = sum(w)
sum_w = sum_w / 2

res = numpy.cumsum(w)

diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)]
print(int(min(diff)))

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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define int ll
#define endl '\n'
#define mod 1000000007



signed main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	int n,m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;
	int x,y;
	int here = __gcd(n,m);
	x = m/here;
	y = n/here;
	vector<int> present;
	forn(i,n) present.PB(i*x);
	forn(i,m){
		int here = i*y;
		if(binary_search(all(present),here)){
			auto it = lb(all(present),here);
			int pos = it - present.begin();
			if(s[pos]!=t[i]){
				cout << "-1\n";
				return 0;
			}
		}
	}
	cout << x*n << endl;
	return 0;
}

Measured memory_bytes: 1656
use proconio::{fastout, input};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        _: i32,
        cs: Chars,
    }

    let rn = cs.iter().filter(|&x| *x == 'R').count();
    let rr = &cs[..rn].iter().filter(|&x| *x == 'R').count();

    println!("{}", rn - rr);
}


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

int main(){
  int N;  cin >> N;
  int a[100];
  for(int i = 0;i < N;i++){
    cin >> a[i];
  }

  int count = 0;
  sort(&a[0],&a[N-1]+1);

  int here = a[0];
  int ans = 0;
  for(int i = 1;i < N;i++){
    if(here < a[i]){
      ans += a[i] - here;
      here = a[i];
    }
  }

  cout << ans << endl;

}

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

typedef long long ll;
typedef pair<ll,ll> pii;


bool compare(pii x, pii y){
  return x.second < y.second;
}

int main(){
  int N;
  cin >> N;
  
  vector<pii> p;
  for(int i = 0; i < N; i++){
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    p.push_back(make_pair(tmp1, tmp2));
  }
  sort(p.begin(), p.end(), compare);
  
  cerr << p[0].first << " " << p[0].second << endl;
  
  ll time = 0;
  bool flg = true;
  for(auto x: p){
    time += x.first;
    if(x.second < time){
      flg = false;
      break;
    }
  }
  if(flg){
    cout << "Yes" << endl;
  } else { 
    cout << "No" << endl;
  }
}

Measured memory_bytes: 6512