akhauriyash/Code-Regression huggingface dataset:
def check(x,y):
	if A[y][x] == "*":
		A[y][x] = "."
		return True
	if A[y][x] == "#":
		return True
	return False

for _ in range(input()):
	if _ > 0: print
	H,W = map(int,raw_input().split())
	A = [list(raw_input()) for i in range(H)]
	for h in range(H):
		for w in range(W):
			if A[h][w] in "^<v>":
				x,y = w,h
				d = A[h][w]
				A[h][w] = "."
	input()
	cmd = raw_input()
	for c in cmd:
		if   c == "S":
			if d == "^":
				for h in range(y-1,-1,-1):
					if check(x,h): break
			if d == "<":
				for w in range(x-1,-1,-1):
					if check(w,y): break
			if d == "v":
				for h in range(y+1,H):
					if check(x,h): break
			if d == ">":
				for w in range(x+1,W):
					if check(w,y): break
		elif c == "U":
			d = "^"
			if y-1 >= 0 and A[y-1][x] == ".": y = y-1
		elif c == "L":
			d = "<"
			if x-1 >= 0 and A[y][x-1] == ".": x = x-1
		elif c == "D":
			d = "v"
			if y+1 <  H and A[y+1][x] == ".": y = y+1
		elif c == "R":
			d = ">"
			if x+1 <  W and A[y][x+1] == ".": x = x+1
	A[y][x] = d
	for h in range(H):
		print "".join(A[h])

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
 	int n;
 	cin>>n;
 	mapii mps;
 	vi vec;
 	for(int i=0; i<n; ++i)
 	{
 		int x;
 		cin>>x;
 		if(!mps[x])
 			vec.pb(x);
 		++mps[x];
 	}
 	if(mps.size()%2) cout<<mps.size()<<"\n";
 	else cout<<mps.size()-1<<"\n";
}

Measured memory_bytes: 12408
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int A[N]; rep(i, N) cin >> A[i];

  int result = 0;
  rep(i, N) result += A[i];
  result -= N;
  cout << result << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int a, x = 0, y = 0, z = 0;
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a % 4 == 0) x++;
    else if(a % 2 == 0) y++;
    else z++;
  }
  
  if(x + y == n){
    cout << "Yes" << endl;
    return 0;
  }
  
  if(y > 0) z++;
  
  if(x + 1 >= z) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    vector<bool> a(n,false);
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int x;
            cin>>x;
            x --;
            a[x]=true;
        }
    }
    int cnt=0;
    rep(i,n){
        if(a[i]) continue;
        cnt ++;
    }
    cout<<cnt<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3652
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int N=100005;

int n,a[N],b[N],c[N];
int dp[N][3];

int main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i]>>b[i]>>c[i];
	for (int i=1;i<=n;++i)
	    dp[i][0]=max(dp[i-1][1]+b[i],dp[i-1][2]+c[i]),
	    dp[i][1]=max(dp[i-1][0]+a[i],dp[i-1][2]+c[i]),
	    dp[i][2]=max(dp[i-1][0]+a[i],dp[i-1][1]+b[i]);
	cout<<*max_element(dp[n],dp[n]+2);
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    int x,y,i,j;
    while (cin >>x>>y) {
        if(x==0 && y==0) break;
        for (j=0; j<x; j++) {
            for (i=0; i<y; i++) {
                if (j ==0 || j == (x-1)) cout<<"#";
                else if(i == 0 || i==(y-1))cout << "#";
                else if (i >0 && i<(y-1))cout <<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, b;
        cin >> n >> b;
        int ans = 0;
        while(n){
            ans++;
            n /= b;
        }
        cout << ans << '\n';
    } 
}

Measured memory_bytes: 31488
N = int(input().strip())

stot = 0
mins = 0
for _ in range(N):
  s = int(input().strip())
  stot += s
  if s % 10 != 0:
    if mins == 0:
      mins = s
    else:
      mins = min(s, mins)

if stot % 10 == 0:
  if mins == 0:
    print(0)
  else:
    print(stot-mins)
else:
  print(stot)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
constexpr auto MOD = 998244353;
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    int a, b;
    vector<VI> edge(n);
    FOR(i, 0, n - 1) {
        cin >> a >> b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }

    VI dis(n, 0);
    vector<bool> ever(n, false);
    queue<pair<int, int>> bfs;
    bfs.push({ 0,0 });
    ever[0] = true;
    while (!bfs.empty()) {
        int now = bfs.front().first;
        int num = bfs.front().second + 1;
        bfs.pop();
        for (int next : edge[now]) {
            if (ever[next])continue;
            ever[next] = true;
            dis[next] = num;
            bfs.push({ next,num });
        }
    }

    int p, x;
    VI X(n, 0);
    FOR(i, 0, q) {
        cin >> p >> x;
        X[--p] += x;
    }
    VI cnt(n, 0);
    bfs.push({ 0,X[0] });
    while (!bfs.empty()) {
        int now = bfs.front().first;
        int point = bfs.front().second;
        cnt[now] += point;
        bfs.pop();
        for (auto& next : edge[now]) {
            if (dis[next] < dis[now])continue;
            bfs.push({ next,point + X[next] });
        }
    }

    cout << cnt[0];
    FOR(i, 1, n)cout << " " << cnt[i];
    cout << "\n";
}


Measured memory_bytes: 17908
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！

int main(){
    string s;
    std::cin >> s;
    if(s=="ABC")std::cout << "ARC" << std::endl;
    else std::cout << "ABC" << std::endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll h, w, a[510][510];
vector<P> vec, ans1, ans2;
int main(void){
    // Your code here!
    cin >> h >> w;
    for (ll i = 0; i < h; i++){
        for (ll j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    for (ll i = 0; i < h; i++){
        for (ll j = 0; j < w; j++){
            if (i % 2){
                if (a[i][w - j - 1] % 2){
                    vec.push_back(P(i, w - j - 1));
                }
            } else {
                if (a[i][j] % 2){
                    vec.push_back(P(i, j));
                }
            }
        }
    }
    for(ll i = 0; i < vec.size() - (vec.size() % 2); i += 2){
        ll e = vec[i].first, f = vec[i].second;
        while(e != vec[i + 1].first || f != vec[i + 1].second){
            ans1.push_back(P(e + 1, f + 1));
            if (e % 2 == 0){
                if (f == w - 1){
                    e++;
                } else {
                    f++;
                }
            } else {
                if (f == 0){
                    e++;
                } else {
                    f--;
                }
            }
            ans2.push_back(P(e + 1, f + 1));
        }
    }
    cout << ans1.size() << endl;
    for (ll i = 0; i < ans1.size(); i++){
        cout << ans1[i].first << ' ' << ans1[i].second << ' ';
        cout << ans2[i].first << ' ' << ans2[i].second << endl;
    }
}


Measured memory_bytes: 13420
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int g = 0, p = 0;
    for (int i = 0; i < s.length(); i++) (s[i] == 'g' ? g : p)++;

    cout << s.length() / 2 - p << endl;

    return 0;
}


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

const int MAXN = 1e5 + 10;
bool dp[MAXN];
string t;

int main() {
	cin >> t;
	dp[0] = 1;
	for (int i = 1; i <= t.size(); i++) {
		if (i >= 5 && t.substr(i - 5, 5) == "dream")
			dp[i] |= dp[i - 5];
		if (i >= 7 && t.substr(i - 7, 7) == "dreamer")
			dp[i] |= dp[i - 7];
		if (i >= 5 && t.substr(i - 5, 5) == "erase")
			dp[i] |= dp[i - 5];
		if (i >= 6 && t.substr(i - 6, 6) == "eraser")
			dp[i] |= dp[i - 6];
	}
	if (dp[t.size()])
		cout << "YES";
	else
		cout << "NO";
}

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

const int INF = 2e9;

int main(){
    ll n;
    cin >> n;
    vector<string>  s(n);
    rep(i,n){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    ll ans = 0;
    ll cnt = 1;
    rep(i,n-1){
        if(s[i] == s[i+1]) cnt++;
        else {
            ans += cnt*(cnt-1)/2;
            cnt = 1;
        }
    }
    ans += cnt*(cnt-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 6380
using System;

namespace Atc_0015
{
    class Program
    {
        static void Main(string[] args)
        {
            const string LARGE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
           
            var rStr = Console.ReadLine();

            if (LARGE.Contains(rStr))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
        }
    }
}


Measured memory_bytes: 25804
import java.io.*;
class Main{
    public static boolean IsPrime(int n){
	int i;
	if(n<2)
	    return false;
	else if(n==2)
	    return true;

	if(n%2==0)
	    return false;
	for(i=3;i*i<=n;i+=2){
	    if(n%i==0)
		return false;
	}
	return true;
    }
    public static void main(String[] args)throws IOException{
	BufferedReader br=
	    new BufferedReader(new InputStreamReader(System.in));
	String buf;

	while(true){
	    int comb=0;
	    if((buf=br.readLine())==null)break;;
	    if(buf.length()==0)break;
	    int n=Integer.parseInt(buf);
	    for(int i=2;i<=n;i++){
		if(IsPrime(i))comb++;
	    }
	    System.out.println(comb);
	}
    }
}

Measured memory_bytes: 9476
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;


int main()
{
	ll d, l;
	cin >> d >> l;

	int ans = 0;
	while (d >= l) {
		d -= l;
		ans++;
	}
	ans += d;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
typedef pair <ll,ll> pii;
int N;
long double PI = acos(-1);
pii displace[105];

bool upperHalf(pii a){
    if (a.y > 0) return true;
    return a.x > 0 && a.y == 0;
}

bool cmp(pii a, pii b){
    if (upperHalf(a) && !upperHalf(b)) return true;
    else if (!upperHalf(a) && upperHalf(b)) return false;
    ll c = a.x*b.y - a.y*b.x;
    return c > 0;
}

int main() {
    cin >> N;
    int cont = 0;
    while (cont < N){
        scanf("%lld %lld", &displace[cont].first, &displace[cont].second);
        if (displace[cont].first != 0 || displace[cont].second != 0) cont++;
        else N--;
    }
    sort(displace, displace+N, cmp);
    long double ans = 0;
    for (int i=0; i<N; i++){
        for (int j=0; j<N; j++){
            pii sum = {0,0};
            for (int k=i; k%N != j; k++){
                sum.first += displace[k%N].first;
                sum.second += displace[k%N].second;
            }
            sum.first += displace[j].first;
            sum.second += displace[j].second;
            ans = max(ans, sqrtl(sum.first*sum.first + sum.second*sum.second));
        }
    }
    printf("%.10Lf\n", ans);
    return 0;
}

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

using namespace std;
typedef long long ll;


int main(){
	ll n;
	cin >> n;
	
	int al[5] = {0};
	for(int i = 0;i < n;i++){
		string ts;
		cin >> ts;
		if(ts[0] == 'M'){
			al[0]++;
		}else if(ts[0] == 'A'){
			al[1]++;
		}else if(ts[0] == 'R'){
			al[2]++;
		}else if(ts[0] == 'C'){
			al[3]++;
		}else if(ts[0] == 'H'){
			al[4]++;
		}
	}
	
	ll ans;
	ans = 0;
	
	for(int i = 0;i < (1<<5);i++){
		int dig = 0;
		for(int j = 0;j < 5;j++){
			if((i >> j) % 2 == 1){
				dig++;
			}
		}
		ll comb = 1;
		if(dig == 3){
			for(int j = 0;j < 5;j++){
				if((i >> j) % 2 == 1){
					comb *= al[j];
				}
			}
		}else{
			comb = 0;
		}
		ans += comb;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, a, b;
    
        char buf[256];
        fgets(buf,256,stdin);
        sscanf(buf, "%d %d %d", &n, &a, &b);
        if( n < 1| n > 20| a < 1| a > 50| b < 0| b >50){
            return 0;
        }else{
            
            int m;
            m = a * n;
            if(m > b){
                printf("%d\n", b);
            }else{
                printf("%d\n", m);
            }
        }

    return 0;
}

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

main(){
  int X,N,p[100],i,A,P[100],q[102];
  cin >> X >> N;
  i=0;
  while(i<102){
    q[i]=1;
    i++;
  }
  i=0;
  while(i<N){
    cin >> p[i];
    q[p[i]]=0;
    i++;
  }
  i=0;
  while(i<102){
    if(X-i>=0){
      if(q[X-i]==1){
        cout << X-i <<endl;
        i=102;
      }
    }
    if(X+i<=101){
      if(q[X+i]==1){
        cout << X+i <<endl;
        i=102;
      }
    }
    i++;
  }
}

Measured memory_bytes: 3620
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=LI()
  l2=LI()

  sm1=sum(l1)
  sm2=sum(l2)

  nm=sm2-sm1
  if nm<0:
    return 'No'

  nm1=0
  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a<b:
      _a=(b-a+1)//2
      l1[i]+=_a*2
      nm1+=_a

  nm2=0
  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a>b:
      _a=a-b
      nm2+=_a

  # print(nm,nm2)
  if nm<max(nm1,nm2):
    return 'No'

  return 'Yes'

# main()
print(main())


Measured memory_bytes: 6580
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<map>
#define LL long long
#define LD long double
using namespace std;
const int NN=250000 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("99f.in","r",stdin);
	//freopen(".out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
map<pair<LL,LL>,int> a;
char s[NN]={};
LL mod[2]={998244353,2281701377};
LL ksm(LL a,LL b,LL mod){
	LL ret=1;
	while(b){
		if(b&1){
			ret*=a;
			ret%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return ret;
}
inline void mop(LL &x,LL y,LL mod){
	x=(x+y>=mod?x+y-mod:x+y);
}
int main(){
	//open();
	n=read();
	scanf("%s",s);
	LL res[2]={0,0};
	LL rev[2];
	rev[0]=ksm(mod[0],mod[1]-2,mod[1]);
	rev[1]=ksm(mod[1],mod[0]-2,mod[0]);
	LL p[2]={1,1};
	for(int i=0;i<n;++i){
		if(s[i]=='+'){
			for(int i=0;i<2;++i){
				mop(res[i],p[i],mod[i]);
			}
		}
		else if(s[i]=='-'){
			for(int i=0;i<2;++i){
				
				mop(res[i],mod[i]-p[i],mod[i]);
			}
		}
		else if(s[i]=='<'){
			for(int i=0;i<2;++i){
				p[i]*=rev[i^1];
				p[i]%=mod[i];
			}
		}
		else if(s[i]=='>'){
			for(int i=0;i<2;++i){
				p[i]*=mod[i^1];
				p[i]%=mod[i];
			}
		}
	}
	p[0]=1;
	p[1]=1;
	LL tp[2]={0,0};
	LL ans=0;
	for(int i=0;i<n;++i){
		a[make_pair((tp[0]+p[0]*res[0])%mod[0],(tp[1]+p[1]*res[1])%mod[1])]++;;
		if(s[i]=='+'){
			for(int i=0;i<2;++i){
				mop(tp[i],p[i],mod[i]);
			}
		}
		else if(s[i]=='-'){
			for(int i=0;i<2;++i){
				mop(tp[i],mod[i]-p[i],mod[i]);
			}
		}
		else if(s[i]=='<'){
			for(int i=0;i<2;++i){
				p[i]*=rev[i^1];
				p[i]%=mod[i];
			}
		}
		else if(s[i]=='>'){
			for(int i=0;i<2;++i){
				p[i]*=mod[i^1];
				p[i]%=mod[i];
			}
		}
		ans+=a[make_pair(tp[0],tp[1])];
	}
	printf("%lld\n",ans);
	close();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

 vl a;
 vl b;
 vl c;
 vl ab;
 ll n;
 ll ans = 0;

int main(){
  cin >> n;
  a = vl(n);
  b = vl(n);
  c = vl(n);
  for(ll i = 0;i < n;i++) cin >> a.at(i);
  for(ll i = 0;i < n;i++) cin >> b.at(i);
  for(ll i = 0;i < n;i++) cin >> c.at(i);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ab = vl(n+1);
  for(ll i = 0,j = 0;i < n;i++){
    while(j < n && a.at(j) < b.at(i)) j++;
    ab.at(i+1) = j;
  }
  for(ll i = 1;i <= n;i++) ab.at(i) += ab.at(i-1);
  for(ll i = 0,j = 0;i < n;i++){
    while(j < n && b.at(j) < c.at(i)) j++;
    ans += ab.at(j);

  }
  cout << ans << endl;

}


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

int main() {
  string s;
  int ans;
  while(true) {
    cin >> s;
    if(s == "0") break;
    vector<int> v(s.size());
    for(int i = 0; i < s.size(); ++i) {
      v.at(i) = s[i];
    }
    for(int i = 0; i < v.size(); ++i) {
      ans += v.at(i) - '0';
    }
    cout << ans << endl;
    ans = 0;
  }
}



Measured memory_bytes: 3120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
const ll mod=1e9+7;

int main(){
	ll A,B,C,tmp,ans;

	scanf("%lld%lld%lld",&A,&B,&C);
	tmp=A; A=B; B=tmp; //A,B入れ替え
	tmp=A; A=C; C=tmp; //A,C入れ替え

	printf("%lld %lld %lld",A,B,C);

	return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array

main = do

   n <- readLn :: IO Int
   k <- readLn :: IO Int
   xn <- map read . words <$> getLine
   
   let ans = map (solve k) xn
   print (sum ans)
   


solve :: Int -> Int -> Int
solve k xi = if (k-xi) > xi
             then 2 * xi
             else 2 * (k-xi)

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int N;
   cin >>N;
   vector<int> vec(N);
   for(int i=0;i<N;i++) cin >> vec.at(i);
   bool ans;
   ans=true;
   for(int x : vec){
     if(x%2==0) {
       if(x%3!=0&&x%5!=0) {
         ans=false;
         break;
      }
     }
   }
   if(ans) cout << "APPROVED" << endl;
   else cout << "DENIED" << endl;
 }


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();
		sc.close();

		a = a.multiply(b).setScale(0, BigDecimal.ROUND_DOWN);
		System.out.println(a.toPlainString());
	}
}


Measured memory_bytes: 37216
#include <iostream>

int main()
{
    int a,b;
    std::cin >> a >> b;
    
    if(a == b)
        std::cout << "a == b" << std::endl;
    else if(a > b)
        std::cout << "a > b" << std::endl;
    else if(a < b)
        std::cout << "a < b" << std::endl;

}


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

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

const int N = 1e5 + 5, inf = 1e9;

int n, deg[N][2], num, root, col[N];
bool vis[N];
vector <int> adj[N], g[N];

void reset() {
	for (int i = 0; i < n; i++)
		adj[i].clear();
	num++;
}

int dfs_1(int v) {
	vector <int> uno;
	if((deg[v][0] % 2 == 0))
		uno.push_back(v);
	for (auto e : adj[v]) {
		int u = dfs_1(e);
		if(u != inf)
			uno.push_back(u);
	}
	int sz = uno.size();
	while(sz > 1) {
		int x = uno[sz - 1], y = uno[sz - 2];
		uno.pop_back();
		uno.pop_back();
		g[x].push_back(y);
		g[y].push_back(x);
		sz -= 2;
	}
	if(sz)
		return uno[0];
	else
		return inf;
}

void dfs_2(int v) {
	vis[v] = 1;
	for (auto u : g[v]) {
		if(!vis[u]) {
			col[u] = col[v] * -1;
			dfs_2(u);
		}
	}
}

void build() {
	for (int i = 0; i < n; i++) {
		int par;
		cin >> par;
		par--;
		if(par == -2)
			root = i;
		else
			adj[par].push_back(i), deg[par][num]++;
	}
	if(num) {
		for (int i = 0; i < n; i++) {
			if((deg[i][0] & 1) != (deg[i][1] & 1)) {
				cout << "IMPOSSIBLE\n";
				exit(0);
			}
			deg[i][0] &= 1;
		}
	}
	dfs_1(root);
	reset();
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n;
	build();
	build();
	for (int i = 0; i < n; i++) {
		if(!deg[i][0] && !vis[i]) {
			col[i] = 1;
			dfs_2(i);
		}
	}
	cout << "POSSIBLE\n";
	for (int i = 0; i < n; i++)
		cout << col[i] << " ";
	cout << "\n";
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
#define vpii vector< pair<int,int> >
void dijkstra(int source,vector<int>& dist,vector< vpii >& g,int n)
{
	priority_queue< int,vpii,greater< pair<int,int> > > q;
	vector<int> vis(n,0);
	dist[source]=0;
	q.push(make_pair(0,source));
	while(!q.empty())
	{
		int u = q.top().second;
		q.pop();
		if(!vis[u])
		{
			for(auto& c : g[u])
			{
				int v = c.second,cost = c.first;
				if( dist[v] > dist[u] + cost ) dist[v] = dist[u] + cost;
				q.push(make_pair(dist[v],v));
			}
		}
		vis[u]=1;
	}
}
int main()
{
	int n,m,r,s,d,cost,source;
	scanf("%d%d%d",&n,&m,&r);
	vector< vpii > g(n);
	vector<int> dist(n,1e8);
	vector<int> town(r);
	std::map<int,std::map<int,int> > mp;
	for(int i=0;i<r;i++) { scanf("%d",&town[i]); --town[i]; }
	while(m--)
	{
		scanf("%d%d%d",&s,&d,&cost);
		--s;--d;
		g[s].push_back(make_pair(cost,d));
		g[d].push_back(make_pair(cost,s));
	}
	for(int i=0;i<r;i++)
	{
		fill(dist.begin(),dist.end(),INT_MAX);
		dijkstra(town[i],dist,g,n);
		for(int j=0;j<r;j++) mp[town[i]][town[j]]=dist[town[j]];
	}
	//for(int i=0;i<r;i++) for(int j=0;j<r;j++) printf("%d %d\n",town[i],mp[town[i]][town[j]]);
	sort(town.begin(),town.end());
	int ans = INT_MAX,sum = 0;
	do
	{
		sum=0;
		for(int i=0;i<r-1;i++)
		{
			//printf("%d %d %d\n",town[i],town[i+1],mp[town[i]][town[i+1]]);
			sum+=mp[town[i]][town[i+1]];
		}
		ans = min(ans,sum);
	}while(next_permutation(town.begin(),town.end()));
	printf("%d\n",ans);
}

Measured memory_bytes: 976
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    LL N, K;
    cin >> N >> K;
    LL cnt = 0;
    while (N > 0)
    {
        N /= K;
        cnt++;
    }

    cout << cnt << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

int main() {
    double a,b,x,r,t,z=0;
    cin >> a >> b >> x;

    if(x < (a*a*b)/2) {
        r = (2*x)/(a*b);
        t = 90-(atan(r/b)*180)/M_PI;
    } else {
        r = 2*b-(2*x)/(a*a);
        t = (atan(r/a)*180)/M_PI;
    }

    cout << setprecision(12) << t << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  int a[n]; rep(i, n) cin >> a[i];
  sort(a, a+n);
  int ans = 1e9;
  rep(i, n-k+1) {
    ans = min(ans, a[i+k-1]-a[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
while True:
    n, x = list(map(int, input().split()))

    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    count += 1
    print(count)



Measured memory_bytes: 5596
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

n = int(input())
prime = is_prime(n)
if prime:
    con = 0
    while n  > 0:
        n = n//10
        #print(n)
        con += 1
else:
    a = int(math.sqrt(n))
    for i in range(a,1,-1):
        if n % i == 0:
            n = n // i
            break
    con = 0
    while n  > 0:
        n = n//10
        #print(n)
        con += 1
    
print(con)

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

int main() {
  long long N,W;
  cin>>N>>W;
  long long wt[110];
  long long v[110];
  for(int i=0;i<N;i++){
    cin>>wt[i]>>v[i];
  }
  long long dp[110][100010];
  
  for(int i=0;i<100000;i++){
    dp[0][i]=0;
  }
  
  for(int i=0;i<N;i++){
    for(int w=0;w<=W;w++){
      if(w>=wt[i]){
        dp[i+1][w]=max(dp[i][w-wt[i]]+v[i],dp[i][w]);
      }
      else{
        dp[i+1][w]=dp[i][w];
      }
    }
  }
  cout<<setprecision(18)<<dp[N][W]<<endl;
  return 0;
}

    
    
  
   
  
    

  
                       
                   




Measured memory_bytes: 80768
#include <iostream>

using namespace std;

int adja[101][101];
int d[101], f[101], cnt;

void dfs(int u) {
    d[u] = ++cnt;
    for (int i = 0, v; (v = adja[u][i]) > 0; ++i) {
        if (d[v] > 0)
            continue;
        dfs(v);
    }
    f[u] = ++cnt;
}

int main() {
    int n, k, u;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> adja[u][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (d[i] == 0)
            dfs(i);
        cout << i << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
#D
N = int(input())
A = list(map(int, input().split()))
A.sort()

temp = [0] * (10 ** 6 + 1)
for i in A:
    j = i
    while j <= A[-1]:
        temp[j] += 1
        j += i

result = 0
for i in A:
    if temp[i] == 1:
        result += 1

print(result)

Measured memory_bytes: 32004
#include <cstdio>
#include <stdlib.h>
using namespace std;
int gcd(int x, int y) {
    return y ? gcd(y, x%y) : x;
}

int main() {
	int K;
	scanf("%d", &K);
    int sum = 0;
    for (int a=1; a<=K; a++) {
        for (int b=1; b<=K; b++) {
            for (int c=1; c<=K; c++) {
                int x;
                x = gcd(a, b);
                int y;
                y = gcd(x, c);
                sum += y;
            }
        }
    }
	printf("%d\n", sum);
}



Measured memory_bytes: 1732
#include<stdio.h>

int main(void){
    int x,y,z;
    scanf("%d",&x);
    scanf("%d",&y);
    if(x<y){
        z=x;
        x=y;
        y=z;
    }
    while(1){
        z=x%y;
        if(z==0){
            printf("%d\n",y);
            break;
        }
        x=z;
        z=y%x;
        if(z==0){
            printf("%d\n",x);
            break;
        }
        y=z;
    }
    
    return 0;
}


Measured memory_bytes: 2040
(let* ((n (read))
       (lst (loop :repeat n :collect (read)))
       (ans 0))
  (defun secondp (a b c)
    (if (or (and (> a b) (>= b c)) (and (> c b) (>= b a)))
        (incf ans)))
  (mapcar #'secondp lst (cdr lst) (cddr lst))
  (princ ans))

Measured memory_bytes: 16228
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    string res[3] = {"Sunny", "Cloudy", "Rainy"};
    int ans;
    rep(i, 3){
        if(s[0]==res[i][0]){
            ans = i+1;
            break;
        }
    }
    cout << res[ans%3] << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

		int a[];
		a = new int[7];
		
		int n;
				
		for(int i = 1; i < 7; i++){
			
			n = scan.nextInt();
			a[i] = n;
		}
		
		String s = scan.next();
		char c[] = s.toCharArray();
		
		for(int i = 0; i < c.length; i++){
			if(c[i] == 'N'){
				a[0] = a[1];
				a[1] = a[2];
				a[2] = a[6];
				a[6] = a[5];
				a[5] = a[0];
			}else
			if(c[i] == 'S'){
				a[0] = a[1];
				a[1] = a[5];
				a[5] = a[6];
				a[6] = a[2];				
				a[2] = a[0];
			}else
			if(c[i] == 'E'){
				a[0] = a[1];
				a[1] = a[4];
				a[4] = a[6];
				a[6] = a[3];
				a[3] = a[0];
			}else
			if(c[i] == 'W'){
				a[0] = a[1];
				a[1] = a[3];
				a[3] = a[6];
				a[6] = a[4];
				a[4] = a[0];
			}
		}
		System.out.println(a[1]);
	}
}

Measured memory_bytes: 26408
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;
int main()
{
    int n,l;
    in n>>l;
    vector<string> s(n);
    string ans="";
    rep(i,n)in s[i];
    sort(s.begin(), s.end());
    for(int i=0;i<n;i++)
    {
        ans+=s[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize;n],
    }

    let mut z = 0;
    for &e in &a {
        z ^= e;
    }

    for e in a {
        print!("{} ", e ^ z);
    }
    println!("");
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    if( (N+2)%2 != 0 )
    {
        cout << "No" << endl;
    }
    else
    {
        string t = "";
        rep(i,N/2) t += s[i];
        string tmp = "";
        rep(i,N/2) tmp += s[i + N/2];
        if(t == tmp ) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


}


Measured memory_bytes: 256
/*
 * atcoder/dp_2nd/s.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long
#define MOD 1000000007

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX_K = 10100;
const int MAX_D = 120;
int D, N;
string K;

ll dp[2][MAX_K][MAX_D];

void input() {
  cin >> K >> D;
  N = K.size();
}

/*
 * n: 今何桁目
 * d: 今までの合計 (MOD D)
 * l: 次の桁の数字を制限するか
 */
ll rec(int n = 0, int d = 0, bool l = true) {
  ll &cache = dp[l][n][d];
  if (~cache) return cache;
  if (n == N) return cache = d == 0;
  int u = l ? K[n] - '0' : 9;
  ll ways = 0;
  for (int i=0; i<=u; i++) {
    ways += rec(n + 1, (d + i) % D, l && i == u);  // 一度でも制限解除されると最後の桁まで制限なし.
    ways %= MOD;
  }
  return cache = ways;
}

/*
 * 解1: メモ化再帰
 */
void memoRec() {
  memset(dp, -1, sizeof(dp));
  ll ways = (rec() - 1 + MOD) % MOD; // 1<= なので0の分を引く
  cout << ways << endl;
}

/*
 * 解2: 配るDP
 */
void give() {
  memset(dp, 0, sizeof(dp));
  dp[1][0][0] = 1; // スタートの状態: 制限あり, 左から0桁目, 合計0 から始まる
  for (int n=0; n<N; n++) { // n桁目
    for (int d=0; d<D; d++) { // 現在の合計
      for (int l=0; l<=1; l++) { // 制限ありか否か
        for (int i=0; i<=9; i++) { // 0-9 列挙
          if (l && i > K[n] - '0') continue; // 制限中ならn桁の数字よりも大きいiは不要
          int nl = (l && i == K[n] - '0') ? 1 : 0; // 次も制限中か := 今制限中 and 桁上限数
          dp[nl][n+1][(d+i)%D] += dp[l][n][d];
          dp[nl][n+1][(d+i)%D] %= MOD;
        }
      }
    }
  }

  ll ans = dp[0][N][0]; // 最後には制限が解除された場合の数
  ans += dp[1][N][0]; // 最後まで制限中だった場合の数
  ans--; // 0
  ans = (ans + MOD) % MOD;
  cout << ans << endl;
}

void solve() {
  give();
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 19328
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<tapu, Vtapu, greater<tapu> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
 
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
signed main(){
  LL A,B,X;
  string s;
  LL N;
  cin >> N;
  cin >> s;
  LL x=0,y=0;
  char st[]={'A','N','a','n'};
  char ed[]={'M','Z','m','z'};
  REP(i,N){
    REP(j,4)
     if(st[j]<=s[i] and s[i]<=ed[j]){
      x+=dx[j];
      y+=dy[j];
     }
  }
//  cout << x << "" << y << endl;
  cout << abs(x)+abs(y) << endl;
  REP(j,4){
    FOR(i,1,SIZE) if((dx[j]*i== x and dx[j]) or (dy[j] and dy[j]*i==y)){
    //  cout << i << " " << j << endl;

      REP(k,i) cout <<st[j];
    }
  }
  cout << endl;
 	return 0;
}



Measured memory_bytes: 3312
#include <iostream>
using namespace std;
int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long int n = 0;
    for(int r = 0; r*R <= N; ++r) {
        for(int g = 0; r*R+g*G <= N; ++g) {
          if((r*R+g*G == N) || ((N-r*R-g*G) % B == 0)) {
              n += 1;
            }
        }
    }
    cout << n << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
  ll n, a, b; cin >> n >> a >> b;
  ll d = b - a;
  if(d % 2 == 0) {
    cout << d / 2LL << '\n';
    return 0;
  }
  ll cur = ((b - a + 1) / 2LL) + min(n - b, a - 1);
  cout << min({max(a - 1LL, b - 1LL), max(n - a, n - b), cur}) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define endl        '\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  300005
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";


ll fc[N];
ll me(ll a,ll b){
	a%=hell;
	if(b==0) return 1;
	if(b%2) return (a*me((a*a)%hell,b/2))%hell;
	return me((a*a)%hell,b/2)%hell;
}
ll ncr(ll n,ll r){
	ll an=(fc[n]*me(fc[r]*fc[n-r],hell-2)%hell)%hell;
	return an;

}
// class MemoryGame{
// public:
// // vs construct(int n){
void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[n+5]={0};
	a[0]=0;
	fc[0]=1;
	fc[1]=1;
	a[1]=m;
	rep(i,2,n+5){
	a[i]=(a[i-1]*(m-1))%hell;
	fc[i]=(fc[i-1]*i)%hell;
	}
	ll an=0;
	rep(i,0,k+1){
		// cout<<ncr(n-1,i)<<endl;
		an=(an+(ncr(n-1,i)*a[n-i])%hell)%hell;
	}
	cout<<an;
}
// };
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll TESTS=1,an=1,a,b;
    // cin>>TESTS;
    while(TESTS--){
        // cout<<"Case #"<<an<<": ";
        an++;
        solve();

    }
    return 0;
}


Measured memory_bytes: 6760
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

bool solve() {
    ll N;
    cin >> N;
    if(N & 1) return false;
    string S;
    cin >> S;
    string a = S.substr(0, N / 2);
    string b = S.substr(N / 2);
    return a == b;
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		List<Integer> list = new ArrayList<Integer>();
		list.add(1);
		list.add(2);
		list.add(4);
		list.add(8);
		list.add(16);
		list.add(32);
		list.add(64);
		list.add(128);
		list.add(256);
		list.add(512);

		while (sc.hasNext()){

			int num = sc.nextInt();

			List<Integer> outputList = new ArrayList<Integer>();

			for(int i = list.size() - 1; i >= 0; i--){

				if(num == 0) break;

				if(num >= list.get(i)){
					num -= list.get(i);

					outputList.add(list.get(i));
				}
			}
			Collections.sort(outputList);

			for(int i = 0; i < outputList.size() - 1; i++){
				System.out.print(outputList.get(i) + " ");
			}

			System.out.println(outputList.get(outputList.size() - 1));
		}
	}

}

Measured memory_bytes: 26408
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int value = sc.nextInt();
			int value2 = sc.nextInt();
			if(value == 0 && value2 == 0){
				break;
			}
			else{
				calc(value, value2);
			}
		}
	}
	public void calc(int n, int m){
		int[] tarou = new int[n];
		int[] hanako = new int[m];
		int Tsum = 0;
		int Hsum = 0;
		for(int i = 0; i < n; i++){
			int j = sc.nextInt();
			tarou[i] = j;
			Tsum = Tsum + j;
		}
		for(int i = 0; i < m; i++){
			int j = sc.nextInt();
			hanako[i] = j;
			Hsum = Hsum + j;
		}
		boolean owari = false;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				int nextTsum = Tsum - tarou[i] + hanako[j];
				int nextHsum = Hsum - hanako[j] + tarou[i];
				if(nextTsum ==nextHsum){
					System.out.println(tarou[i] + " " + hanako[j]);
					owari = true;
					break;
				}
			}
			if(owari) break;
		}
		if(!owari){
			System.out.println(-1);
		}
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 21044