akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define li long 
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
void optimize()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll power(ll x, ll y, ll p) 
{ 
   ll res = 1;       
  
    x = x % p;   
  
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = (res*x) % p; 
  
        
        y = y>>1;  
        x = (x*x) % p;   
    } 
    return res; 
} 
void test_case()
{
	int a,b;
	cin>>a>>b;
	unordered_set<int> st = {1,2,3};
	st.erase(a);
	st.erase(b);
	cout<<*st.begin();
	
}

int main()
{
	optimize();
	test_case();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, r;
    while (1)
    {
        cin >> n >> r;
        if (n == 0 && r == 0)
            break;
        vector<int> v(n);
        rep(i, n) v[i] = n - i;
        rep(i, r)
        {
            int p, c;
            cin >> p >> c;
            vector<int> tmp1(p - 1), tmp2(c);
            rep(i, p - 1) tmp1[i] = v[i];
            for (int i = p - 1; i < p + c - 1; i++)
                tmp2[i - p + 1] = v[i];
            for (int i = 0; i < c; i++)
                v[i] = tmp2[i];
            for (int i = c; i < c + p - 1; i++)
                v[i] = tmp1[i - c];
        }
        cout << v[0] << endl;
    }
}


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

int main() {
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	sort(a, a+5);
	cout << a[4] <<" "<< a[3] <<" "<< a[2] <<" "<< a[1] <<" "<< a[0]<<endl;
	return 0;
}

Measured memory_bytes: 3092
import sys
sys.setrecursionlimit(10 ** 7)


def longdist(p, dp_l, out_l):
    if len(out_l[p]) == 0:
        return 0
    for q in out_l[p]:
        if dp_l[q] == -1:
            dp_l[q] = longdist(q, dp_l, out_l)
        dp_l[p] = max(dp_l[p], dp_l[q]+1)
    return dp_l[p]


n, m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]

input, output = [[] for _ in range(n)], [[] for _ in range(n)]
for x, y in xy:
    input[y - 1].append(x - 1)
    output[x - 1].append(y - 1)

dp = [-1] * n
for i in range(n):
    if dp[i] == -1:
        dp[i] = longdist(i, dp, output)

print(max(dp))


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

using namespace std;

const int N = 200005;

int n, k;

int a[N], ans[N];

int main() {

	cin >> k >> n;

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

	for (int i = 1; i <= n; i ++) {
		int a1 = 2 * (a[i] - a[1]) + a[n] - a[i];
		int a2 = 2 * (a[n] - a[i]) + a[i] - a[1];
		int a3 = 0;
		if (i == 1) {
			a3 = a[n] - a[1];
		}
		else {
			a3 += k - a[i];
			a3 += a[i - 1];
		}
		int a4 = 0;
		if (i == n) {
			a4 = a[n] - a[1];
		}
		else {
			a4 += a[i];
			a4 += k - a[i + 1];
		}
		ans[i] = min(a1, min(a2, min(a3, a4)));
	}

	int minn = INT_MAX;
	for (int i = 1; i <= n; i ++) {
		minn = min(minn, ans[i]);
	}

	cout << minn << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100000
int n,tot=1;
int f[MAXN+5],kd[MAXN+5];
void Init()
{
	memset(f,0x3f,sizeof f);
	f[0]=0;
	kd[tot]=1;
	int i=1;
	while(i<=n)
		kd[++tot]+=(i*=6);
	i=1;
	while(i<=n)
		kd[++tot]+=(i*=9);
}
int main()
{
	scanf("%d",&n);
	Init();
	for(int i=1;i<=tot;i++)
		for(int j=kd[i];j<=n;j++)
			f[j]=min(f[j],f[j-kd[i]]+1);
	printf("%d\n",f[n]);
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/


signed main()
{
    showoff;
    int n,k;
    cin >> n >> k;
    if(k == 1)cout << 0;
    else cout << n-k << "\n";
    return 0;     
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...    

Measured memory_bytes: 256
fun main(args: Array<String>) = ABC164A.main()

object ABC164A {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (S,W)= readInts()
        val ans = if (S<=W) "unsafe" else "safe"
        println(ans)
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 36364
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    rep (i, N) { cin >> A[i]; }

    for (ll i=K;i<N;++i)
    {
        cout << (A[i - K] < A[i] ? "Yes" : "No") << endl;

    }

    return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#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()
using ll = long long;
using Pair = pair<int, int>;
const ll mod = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0): x((x%mod+mod)%mod) {}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct Sieve {
  vector<int> table;
  Sieve(int n=2): table(n+1) {
    table[0] = table[1] = -1;
    for (int i=2; i<=n; i++) {
      if (table[i]) continue;
      for (int j=i+i; j<=n; j+=i) {
        table[j] = i;
      }
    }
  }

  void print() {
    for (auto e: table) {
      cout << e << " ";
    }
    cout << endl;
  }

  map<int, int> primes(int i) {
    map<int, int> m;
    if (i < 2) return m;
    // (素数, カウント)
    // ex. primes(12) == {(2, 2), (3, 2)}
    while(table[i]) {
      m[table[i]]++;
      i /= table[i];
    }
    m[i]++;
    return m;
  }
};

ll power(ll base, ll exponent, ll module) {
  if (!exponent) return 1;
  if (exponent%2 == 1) {
    return base * power(base, exponent-1, module) % module;
  } else {
    ll root_ans = power(base, exponent/2, module);
    return root_ans * root_ans % module;
  }
}


int main(int argc, char const* argv[])
{
  int n;
  cin >> n;

  int max_ = 0;
  vector<int> as;
  REP(i, n) {
    int a;
    cin >> a;
    as.push_back(a);
    if (max_ < a) max_ = a;
  }

  Sieve sieve(max_);

  map<int, int> lcm_map;
  for (auto a: as) {
    map<int,int> ps = sieve.primes(a);
    for (auto p: ps) {
      if (lcm_map[p.first] < p.second) lcm_map[p.first] = p.second;
    }
  }

  mint c = 1;
  for (auto e: lcm_map) {
    c *= power(e.first, e.second, mod);
  }

  mint ans = 0;
  for (auto a: as) {
    mint b = c/a;
    ans += b;
  }

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 4608
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0011
	Drawing Lots
*/

#include <stdio.h>
int main(void)
{
	int w, n;
	scanf("%d", &w);

	int num[w], i;
	scanf("%d", &n);
	for (i = 1; i <= w ; ++i)
	{
		num[i] = i;
	}

	int a, b, j, temp;
	for (j = 1; j <= n ; ++j)
	{
		a = 0;
		b = 0;
		temp = 0;
		scanf("%d,%d", &a, &b);
		temp = num[b];
		num[b] = num[a];
		num[a] = temp;
	}
	
	int k;
	for (k = 1; k <= w; ++k)
	{
		printf("%d\n", num[k]);
	}


	return 0;
}

Measured memory_bytes: 596
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                           bye                         cout<<"-1"<<endl;return 0;



using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=200009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int a[M+6];

 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)cin>>a[i];
    if(a[0]>1){bye}
    f(i,1,n-1)
    {
        if(a[i+1]-a[i]>1){bye;}
    }
    f(i,1,n)
    {
        if(a[i]>i-1){bye}
    }
    int ses=0;
    for(int i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]+1)
        {
            ses+=a[i-1];
        }
    }
    ses+=a[n];
    cout<<ses<<endl;
    return 0;

}













Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,s;
	cin>>a>>b;
	s=__gcd(a,b);
	int cnt=1;
	for(ll i=2;i*i<=s;i++){
		if(s%i==0){
			while(s%i==0) s/=i;
			cnt++;
		}
	}
	if(s>1){
		cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}

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

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    ans = []
    if N % 2 == 1:
        for i in range(1, N + 1):
            j = N - i
            for k in range(1, i):
                if k not in (i, j):
                    ans.append([i, k])
    else:
        for i in range(1, N + 1):
            j = (N + 1) - i
            for k in range(1, i):
                if k not in (i, j):
                    ans.append([i, k])
    print(len(ans))
    for a, b in ans:
        print(a, b)

    return 0

main()

Measured memory_bytes: 4144
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n - m + 1):
    for j in range(n - m + 1):
        tmp = 0
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] == b[k][l]:
                    tmp += 1
        if tmp == m ** 2:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int digits(ll n) {
	int count = 0;
	while (n > 0) {
		n /= 10;
		count++;
	}
	return count;
}
int main() {
	ll n;
	cin >> n;
	
	int ans = 11;
	for (int i = 1; i <= pow(n, 0.5); i++) {
		if (n%i == 0) {
			int tmp = max(digits(n / i), digits(i));
			if (ans > tmp) {
				ans = tmp;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

vector<vector<pair<int,int> > >adj;
int mm[100005];
int val[200005];

int vis[100005];
int col[100005];
void dfs(int ver,int x)
{
    col[ver]=x;
    vis[ver]=1;
    for(auto i:adj[ver])
    {
        if(!vis[i.first])
            dfs(i.first,(x+1)%2);
    }
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>mm[i];
    adj.resize(n+1);
    int x,y;
    vector<pair<int,int> >pp;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back({y,i});
        adj[y].push_back({x,i});
    }

    for(int i=1;i<=n;i++)
    {
        pair<int,int> ind={n+1,0};
        for(auto j:adj[i])
        {
            if(mm[j.first]<=mm[i])
            {
                ind=min(ind,j);
            }
        }

        if(ind.first==n+1)
        {
            cout<<-1;
            return 0;
        }
        val[ind.second]=mm[i];
        pp.push_back({i,ind.first});
    }

    adj.clear();
    adj.resize(n+1);
    for(auto i:pp)
    {
        adj[i.first].push_back({i.second,0});
        adj[i.second].push_back({i.first,0});
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i,0);
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(col[i])
            cout<<'B';
        else
            cout<<'W';
    }
    cout<<'\n';
    for(int i=0;i<m;i++)
    {
        if(val[i]==0)
            val[i]=1e9;
        cout<<val[i]<<'\n';        
    }

}       


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

int main () {
  int N, K;
  int count = 0;
  cin >> N >> K;

  int a[100] = {0};

for (int l = 0; l < K; l++) {
  int d;
  cin >> d;
  count += d;
  for(int i = 0; i < d; i++) {
    int j;
    cin >> j;
    if(a[j-1] == 0) {
      a[j-1] = 1;
    } else {
      count--;
    }
  }
}

int ans;
ans = N - count;

cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, t, ti;
	vector<int> v;
	int x = 0;
	int tt;

	cin >> n >> t;

	for (int i = 0; i < n; i++) {
		cin >> ti;
		v.push_back(ti);
	}

	tt = t;

	if (n == 1) {
		x += t;
	}

	for (int i = 1; i < n; i++) {
		if (v[i] >= tt) {
			x += t;
			tt = v[i] + t;
		}
		else if (v[i] < tt) {
			x += v[i] - v[i - 1];
			tt = v[i] + t;
		}

		if (i == n - 1) {
			x += t;
		}
	}

	cout << x << endl;
}

Measured memory_bytes: 1400
let s = process.openStdin();
s.addListener("data",(d) => {
  let l = d.toString().split('\n'),
    an = l[1].split(' ').map((v) => Number(v));

  an.push(0);
  an.sort((a, b) => b - a);

  const add = (a, b) => a + b;
 
  let alice = an.filter((v, i, a) => { return i % 2 == 0; }).reduce(add),
    bob = an.filter((v, i, a) => { return !(i % 2 == 0); }).reduce(add);
 
  console.log(alice - bob);
});

Measured memory_bytes: 7628
#!/usr/bin/env python

N, M, X, Y = map(int, input().split())
X_arr = list(map(int, input().split()))
Y_arr = list(map(int, input().split()))

if not(X < Y):
    print("War")
else:
    Z = list(range(X + 1, Y + 1))
    out = "War"
    for num in Z:
        if (max(X_arr) < num and num <= min(Y_arr)):
            out = "No War"
            break
    print(out)


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

 using namespace std;

 int main() {
 int N, D; cin >> N >> D;
 vector<vector<int>> X(N, vector<int>(D));
 for (int i = 0; i < N; ++i) {
 for (int j = 0; j < D; ++j) {
 cin >> X[i][j];
 }
 }
 int ans = 0;
 for (int i = 0; i < N; ++i) {
 for (int j = i+1; j < N; ++j) {
 int norm = 0;
 for (int k = 0; k < D; ++k) {
 int diff = abs(X[i][k] - X[j][k]);
 norm += diff * diff;
 }
 // check whether norm = k for some k
 bool flag = false;
 for (int k = 0; k <= norm; ++k) {
 if (k * k == norm) {
 flag = true;
 }
 }
 if (flag) ++ans;
 }
 }
 cout << ans << endl;
 }

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

double myabs(double a){
	if(a>0)return a;
	else return -a;
}

double minkov(int *x, int *y, int n, double p){
	double dif[100];
	double dist;
	int i;
	dist = 0;
	for(i = 0;i < n;i++){
		dist += pow(myabs(x[i]-y[i]), p);
	}
	dist = pow(dist, 1.0/p);
	return dist;
} 
double cheb(int *x, int *y, int n){
	double dist;
	int i;
	double t;
	dist = myabs(x[0]-y[0]);
	for(i = 1;i < n;i++){
		t = myabs(x[i] - y[i]);
		if(t > dist)dist = t;
	}
	return dist;
}

int main(){
	int n;
	int x[101], y[101];
	int i;
	scanf("%d" ,&n);
	for(i = 0;i < n; i++)
		scanf("%d", &x[i]);
	for(i = 0;i < n; i++)
		scanf("%d", &y[i]);
	printf("%lf\n", minkov(x, y, n, 1.0));
	printf("%lf\n", minkov(x, y, n, 2.0));
	printf("%lf\n", minkov(x, y, n, 3.0));
	printf("%lf\n", cheb(x, y, n));
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll solve(ll A){
    if(A%2 == 1){
        return ((A+1)/2)%2;
    }
    else{
        return (A^((A/2)%2));
    }
}
int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    if(A == 0){
        cout << solve(B) << endl;
        return 0;
    }
    ll SUMA = solve(A-1);
    ll SUMB = solve(B);

    cout << (SUMA^SUMB) << endl;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, b[4];
string a[100000];

int main()
{
	
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] == "AC") {
			b[0]++;
		}
		else if (a[i] == "WA") {
			b[1]++;
		}
		else if (a[i] == "TLE") {
			b[2]++;
		}
		else {
			b[3]++;
		}
	}

	cout << "AC x " << b[0] << endl;
	cout << "WA x " << b[1] << endl;
	cout << "TLE x " << b[2] << endl;
	cout << "RE x " << b[3] << endl;



}

Measured memory_bytes: 6756
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
//typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=54;

int main()
{
	//int t; scn(t);

	//while(t--)
	{
		string s; cin>>s;

		int n=(int)s.size();

		rep(i,0,n)
		if(s[i]=='?')
		s[i]='D';

		cout<<s<<"\n";
	}

    return 0;
}

Measured memory_bytes: 3724
using System;
 
public class AtCoderA
{
    static void Main()
    {
        int p;
        int q;
        int r;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            p = int.Parse(words[0]);
            q = int.Parse(words[1]);
            r = int.Parse(words[2]);
        }
 
        Console.WriteLine(p + q + r - Math.Max(Math.Max(p, q), r));
    }
}

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

const int maxn=2e5+6;
int a[maxn],f[maxn],n;
long long t,ans;

bool cmp(int a,int b) {return a>b;}

bool check(long long x)
{
	long long cnt=0;
	for(int i=1;i<=n;++i) {
		cnt+=max(a[i]-x/f[i],0ll);
	}
	return cnt<=t;
}

int main()
{
	scanf("%d %lld",&n,&t);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	for(int i=1;i<=n;++i) scanf("%d",f+i);
	sort(f+1,f+n+1,cmp);
	sort(a+1,a+n+1);
	long long l=0,r=1e12;
	while(l<r) {
		long long mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld",l);
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var S = GetStr();
            var T = GetStr();
            S += S;
            var ans = "No";
            for(int i = 0; i < T.Length; i++)
            {
                var res = true;
                for(int j = 0; j < T.Length; j++)
                {
                    if (S[i + j] != T[j])
                    {
                        res = false; 
                        break;
                    }
                }
                if (res)
                {
                    ans = "Yes";
                    break;
                }
                
            }

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <stack>

using namespace std;

int main()
{
    string S;
    cin>>S;
    int length = S.length(), count =0;
    stack<char> chars;
    char temp;
    for(int i = 0;i<length; i++){
        if(chars.empty()){
            chars.push(S[i]);
        }else if(chars.top() != S[i]){
            chars.pop();
            count +=2;
        }else{
            chars.push(S[i]);
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 512
N = int(input())
ans = []
if N%2 == 0:
    for k in range(1,N):
        for l in range(k+1,N+1):
            if k+l != N+1:
                ans.append([k,l])
else:
    for k in range(1,N):
        for l in range(k+1,N+1):
            if k+l != N:
                ans.append([k,l])
print(len(ans))
for e in ans:
    print(*e)


Measured memory_bytes: 4124
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define pb push_back
 
 
ll max(ll a,ll b)
{
    if(a>=b)
    return a;
    
    else
    return b;
}
 
int main(){
ll n,k;
  cin>>n>>k;
  vector<ll>v;
  
  while(n--)
  {
    ll temp;
    cin>>temp;
    v.pb(temp);
  }
  
  n=v.size();
  
  sort(v.begin(),v.end());
  ll sum=0;
  for(ll i=0;i<max(n-k,0);i++)
  sum+=v[i];
  
  cout<<sum;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str,str1;
    cin>>str>>str1;
    if(str1.substr(0,str1.length()-1)==str)puts("Yes");
    else puts("No");
    
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define repe(i,n) for (int i = 1; i <= (int)(n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define ll long long
using namespace std;
typedef vector<vector<int> > Graph;

int main(){

    int N,K;
    cin >> N >> K;
    vector<bool> exist(N,false);
    rep(i,K){
        int d;
        cin >> d;
        rep(j,d){
            int A;
            cin >> A;
            exist.at(A-1) = true;
        }
    }
    int cnt = 0;
    rep(i,N){
        if(!exist.at(i)) cnt++;
    }
    cout << cnt << endl;

}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int gcd(int a, int b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (a % b != 0) {
    int tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> as;
  for (int i = 0; i < N; ++i) {
    int ai;
    cin >> ai;
    as.push_back(ai);
  }

  int ans = *min_element(as.begin(), as.end());
  for (int i = 0; i < N; ++i) {
    ans = gcd(ans, as[i]);
  }

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

Measured memory_bytes: 892
# encoding: utf-8
N, M = map(int, input().split())
ab_tmp = [list(map(int, input().split())) for i in range(M)]

ab = []
for ai, bi in ab_tmp:
    if ai == 1 or bi == N: ab.append([ai, bi])

ab.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1] if x[0] == 1 else x[0]) # oh...?

view = 0
for ai, bi in ab:
    if ai < 2: # search for new available 2nd dept.
        view = bi
        continue
    elif ai > view: continue # ignore unavailable 2nd dept.
    elif bi == N: # successful
        print("POSSIBLE")
        break
    else: continue # still evaluating
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 65956
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define rrep(i,s,e) for(int (i) = (s);(i) >= (e);(i)--)

vector<int> u;
vector<int> v;
vector<int> w;


signed main() {
  int l;cin>>l;
  int tmp = l;
  int cnt = 0;
  int cost = 1;
  while(tmp/2)
  {
    tmp/=2;
    cnt++;
    u.push_back(cnt);
    v.push_back(cnt+1);
    w.push_back(0);
    u.push_back(cnt);
    v.push_back(cnt+1);
    w.push_back(cost);
    cost *= 2;
  }
  int endN = cnt+1;
  cnt = 0;
  l -= cost;

  while(l){
    tmp = l;
    cnt = 0;
    while(tmp/2)
    {
      tmp/=2;
      cnt++;
    }
    u.push_back(cnt+1);
    v.push_back(endN);
    w.push_back(cost);
    int a=1;
    rep(i,0,cnt-1) a*=2;
    cost += a;
    l -= a;
  }

  cout << endN << " " << u.size() << endl;

  rep(i,0,u.size()-1) cout << u[i] <<" "<<v[i]<<" "<<w[i]<<endl;
}


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

int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long ans =0,num=0;
    long long rem;
    rem = n%(a+b);
    ans += (n-rem)/(a+b);
    ans *= a;
    if(rem <= a)ans+=rem;
    else ans += a;
    cout << ans << endl;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))
//  cout.precision(15); cout << fixed;


int main() {
  string s; cin >> s;
  map<char, int> M;
  for (auto c: s) {
    M[c]++;
  }
  
  for (auto c: s) {
    if (M[c]%2==0) continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner; public class Main { public static void main(String[] args) { Solve.run(); } } class Solve { private static int N; private static int[] vec; static void run() { input(); solve(); } static void input() { Scanner sc = new Scanner(System.in); N = sc.nextInt(); vec = new int[N]; for (int i = 0; i < N; i++) { vec[i] = sc.nextInt(); } } static void solve() { int tmp; for (int i = 0, j; i < N; i++) { tmp = vec[i]; j = i - 1; while (j >= 0 && vec[j] > tmp) { vec[j + 1] = vec[j]; j--; } vec[j + 1] = tmp; for (int i1 = 0; i1 < vec.length; i1++) { System.out.print(vec[i1]); if (i1 != vec.length - 1) { System.out.print(" "); } } System.out.println(); } } } 


Measured memory_bytes: 34064
n = int(input())

w = input()
p = w[-1]

l = {w}

ans = 'Yes'
for _ in range(n - 1):
    w = input()

    if p != w[0] or w in l:
        ans = 'No'

    p = w[-1]
    l.add(w)

print(ans)

Measured memory_bytes: 3060
main = interact $ show . sol . map read . words

sol [h,w] 
  | h*w `mod` 3==0  = 0
  | otherwise       = minimum $ concatMap f [(h,w), (w,h)]

f (x,y) = [x, x*a - (x `div` 2)*(y-a), ((x+1) `div` 2)*(y-a') - x*a']
  where
  a = (y+2) `div` 3
  a' = y `div` 3

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int K = nextInt();
  if (N % K == 0) cout << 0 << endl; else cout << 1 << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<malloc.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int x[100][2],n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>x[i][0]>>x[i][1];
	for(int i=0;i<n-2;i++)
	{
		if(x[i][0]==x[i][1]&&x[i+1][0]==x[i+1][1]&&x[i+2][0]==x[i+2][1])
		{cout<<"Yes"<<endl;return 0;}
	}
	cout<<"No"<<endl;return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL A, B, C; cin >> A >> B >> C;
		UL ans = 0;
		while (ans < C && A <= B) {
			ans++;
			B -= A;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main(){
  int n;  cin >> n;
  
  int rnum = 0, wnum = 0;
  vector<int> color(n+1, 0);
  for(int i=1; i<=n; i++){
    char c;  cin >> c;
    if(c == 'W'){
      color[i] = 1;
      wnum++;
    }else{
      rnum++;
    }
  }

  int ans = min(wnum, rnum);

  int pl = 1, pr = n, cnt = 0;
  while(pl < pr){
    while(pl < n && color[pl] == 0)  pl++;
    while(pr > 1 && color[pr] == 1)  pr--;
    if(pl < pr)  cnt++;
    pl++, pr--;
  }
  ans = min(ans, cnt);

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


Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,l;cin>>n>>l;
  vector<string> s;
  for(int i = 0; n > i; i++){
    string tmp;cin>>tmp;s.push_back(tmp);
  }
  sort(s.begin(),s.end());
  for(int i = 0; n > i; i++){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1LL << 30;

// dp[i][j] := i個目の品物までで重さjを作るときの価値(最大化)
int dp[101][10101];
    
int main() {
    int N, W;
    cin >> N >> W;
    vector< int > v(N), w(N);
    for (int i=0; i<N; ++i) cin >> v[i] >> w[i];
    
    for (int i=0; i<N; ++i) {
        for (int j=0; j<=W; ++j) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (j >= w[i]) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    
    int ans = 0;
    for (int i=0; i<=W; ++i) ans = max(ans, dp[N][i]);
    
    cout << ans << endl;
    
    
    return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y, m;
string s, t;

ll rem;
ll cnt[3];


// < ----------- func eh ---------------- ? //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	ld ans = ((ld)(n - n / 2)) / ((ld)n);
	cout << ans;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
  string s;
  cin >> s;
  int num = s.length();
  int half = num/2;
  int ans = 0;
  for (int i=0; i<half; i++){
    if(s[i]!=s[num-1-i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,b[5],cnt;
set <int> s;
map <int,int> mp;

int main()
{
	n=read();
	for(int i=1;i<=n;i++) {int x=read(); s.insert(x); mp[x]++;}
	if(s.size()==1)
	{
		if(*s.begin()==0) puts("Yes");
		else puts("No");
	}
	else if(s.size()==2)
	{
		if(*s.begin()!=0||n%3!=0||mp[*s.begin()]!=n/3) puts("No");
		else puts("Yes");
	}
	else if(s.size()==3)
	{
		if(*s.begin()==0||n%3!=0) puts("No");
		else
		{
			int f=0;
			for(set <int>::iterator it=s.begin();it!=s.end();it++)
			{
				b[++cnt]=*it;
				if(mp[*it]!=n/3) f=1;
			}
			if(f==0&&b[1]==(b[2]^b[3])) puts("Yes");
			else puts("No");
		}
	}
	else puts("No");
	return 0;
}

Measured memory_bytes: 7552
h, w, k = map(int, input().split())

s = []

for i in range(h) :
    s.append(list(input()))

tmp = 0
ichigoFlag = False

for i in range(h) :
    for j in range(w) :
        if s[i][j] == '#' :
            tmp += 1
            ichigoFlag = True
            s[i][j] = tmp
        elif ichigoFlag == True :
            s[i][j] = tmp
        else :
            s[i][j] = 0
    ichigoFlag = False

for i in range(h) :
    for j in range(w-1) :
        if s[i][w-2-j] == 0 :
            s[i][w-2-j] = s[i][w-1-j]

for i in range(1,h) :
    if s[i][0] == 0 :
        s[i] = s[i-1]

for i in range(h-1, -1, -1) :
    if s[i][0] == 0 :
        s[i] = s[i+1]

for i in range(h) :
    print(*s[i])

Measured memory_bytes: 7504
import Data.List

solve :: Int -> (Int, Int) -> [Int] -> Int
solve _	(a, b) [] = abs	$ a - b
solve n	(a, b) (x:xs)
  | even n = solve (n+1) (a+x, b) xs
  | otherwise = solve (n+1) (a, b+x) xs

main = getLine >> getContents >>= print . solve 1 (0,0) . reverse . sort . map read . words

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
const static int MAXN=5000+10; 
char str[MAXN];
long long arr[MAXN][2];
long long inv[MAXN][2];
int nnn;
inline long long pow ( long long a, long long b, long long m ) {
    long long res = 1 % m;
    a = a % m;
    while ( b ) {
        if ( b & 1 ) res = ( res * a ) % m;
        a = ( a * a ) % m;
        b >>= 1;
    }
    return res;
}

const long long mod1=1000000007;
const long long mod2=1000000009;
const long long base=31;


void pre()
{
	// nnn=strlen(str);
	long long p1=1,p2=1;
	long long a1=0,a2=0;
	for(int i=0;i<nnn;i++)
	{
		a1=(a1+p1*str[i])%mod1;p1=(p1*base)%mod1;
		a2=(a2+p2*str[i])%mod2;p2=(p2*base)%mod2;
		arr[i][0]=a1;
		arr[i][1]=a2;
	}
	inv[nnn-1][0]=pow(base,mod1-nnn,mod1);
	inv[nnn-1][1]=pow(base,mod2-nnn,mod2);
	for(int i=nnn-2;i>=0;i--)
	{
		inv[i][0]=(inv[i+1][0]*base)%mod1;
		inv[i][1]=(inv[i+1][1]*base)%mod2;
	}
}

inline long long getHash(int n,int m)
{
	if(n==0)return arr[m][0]*mod2+arr[m][1]*mod1;
	else
	{
		long long k1=(((((arr[m][0]-arr[n-1][0])%mod1)
			*inv[n][0])%mod1)+mod1)%mod1;
		long long k2=((((arr[m][1]-arr[n-1][1])
			*inv[n][1])%mod2)+mod2)%mod2;
		return k1*mod2+k2*mod1;
	}
}

inline bool solve(int k)
{
	unordered_map<long long,int> mp;
	for(int i=0;i+k-1<nnn;i++)
	{
		long long h=getHash(i,i+k-1);
		if(mp.find(h)==mp.end())mp[h]=i;
		else if(mp[h]+k<=i)return 1;
	}
	return 0;
}

int main(int argc, char const *argv[])
{
	scanf("%d %s",&nnn,str);
	pre();
	for(int i=nnn/2;i>0;i--)if(solve(i))
	{
		printf("%d\n", i);
		return 0;
	}
	printf("0\n");
	return 0;
}


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

int main()
{
    int bingo[3][3];
    rep(i,3) rep(j,3) cin >> bingo[i][j];

    int n;
    cin >> n;
    vector<int> targets(n);
    rep(i,n) cin >> targets[i];

    bool ans[3][3];
    rep(i,3) rep(j,3) ans[i][j] = false;

    for(int target: targets){
        rep(i,3) {
            bool isTrue = false;
            rep(j,3){
                if(bingo[i][j] == target){
                    isTrue = ans[i][j] = true;
                    break;
                }  
            }
            if(isTrue) break;
        }
    }

    if( (ans[0][0] && ans[0][1] && ans[0][2])
      ||(ans[1][0] && ans[1][1] && ans[1][2])
      ||(ans[2][0] && ans[2][1] && ans[2][2])
      ||(ans[0][0] && ans[1][0] && ans[2][0])
      ||(ans[1][0] && ans[1][1] && ans[1][2])
      ||(ans[0][2] && ans[1][2] && ans[2][2])
      ||(ans[0][0] && ans[1][1] && ans[2][2])
      ||(ans[0][2] && ans[1][1] && ans[0][2]))
      {
          cout << "Yes" << endl;
      }else{
          cout << "No" << endl;
      }
} 

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);

    let mut start = vec![vec![]; m + 1];
    let mut end = vec![vec![]; m + 1];
    for i in 1..n {
        let from = a[i - 1];
        let to = a[i];
        start[from].push(to);
        end[to].push(from);
    }

    // initialize
    let mut total = 0;
    let mut segments = 0;
    for from in 0..(m + 1) {
        for &to in start[from].iter() {
            if from > to {
                segments += 1;
                total += to;
            } else {
                total += to - from;
            }
        }
    }

    let mut ans = total;
    for x in 1..m {
        for &from in end[x].iter() {
            segments -= 1;
            total -= 1;
            total += (x + m - from) % m;
        }
        total -= segments;
        ans = cmp::min(ans, total);
        segments += start[x].len();
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 16636
s=input()
n=len(s)
list1=['R','U','D']
list2=['L','U','D']
listg=[]
listk=[]
for i in range(n):
  if i%2!=0:
    listg.append(i)
  else:
    listk.append(i)
list3=[]
for g in listg:
  if s[g] in list2:
    list3.append(g)
list4=[]
for k in listk:
  if s[k] in list1:
    list4.append(k)
if len(list3)==len(listg) and len(list4)==len(listk):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
int main(){
    int n,a,b;
    cin >> n>>a >>b;

    cout<<min(n*a,b)<<endl;
    return 0;
}

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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n,m;
	cin>>n>>m;
	vint v(n,0);
	vector<pii> w(m);
	rep(i,m){
		cin>>w[i].F>>w[i].S;
		w[i].F--;
		w[i].S--;
		reep(j,w[i].F,w[i].S+1){
			v[j]++;
		}
	}
	rep(i,n){
		if(v[i]==0){
			cout<<"Impossible"<<endl;
			return;
		}
	}
	int ans=0;
	int pos=0;
	while(pos<n){
		int t=0;
		ans++;
		rep(i,m){
			if(w[i].F<=pos&&pos<=w[i].S){
				t=max(t,w[i].S);
			}
		}
		pos=t+1;
	}
	cout<<ans<<endl;
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(0);
    mainmain();
}

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


int main(){
        int a[10000];
        int i,avg,n,sum,count;

        while(1) {
                sum=0;
                count=0;

                cin>>n;

                if(n==0) {
                        break;
                }

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

                avg=sum/n;

                for(i=0; i<n; i++) {
                        if(avg>=a[i]) {
                                count++;
                        }
                }

                cout<<count<<endl;
        }
}



Measured memory_bytes: 3100