akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
const int inf = 0x7f7f7f;
//const int maxn = ;
int dx[] = {-1, 1, -4, 4};
map<string, int> m;

void prework() {
	queue<string>que;
	string temp, now;
	temp = "01234567";
	que.push(temp);
	m[temp] = 1;
	while(!que.empty()) {
		now = que.front();
		que.pop();
		int pos = 0;
		for(int i = 0; i < 8; i++)
			if(now[i] == '0')
				pos = i;
		for(int i = 0; i < 4; i++) {
			int x = pos + dx[i];
			//if(x < 0 || x >= 8 || (x == 3 && dx[i] == 1) || (x == 4 && dx[i] == -1)) continue;
			if(0 <= x && x < 8 && !(pos == 3 && dx[i] == 1) && !((pos == 4 && dx[i] == -1))) {
				temp = now;
				swap(temp[pos], temp[x]);
				if(m[temp] == 0) {
					que.push(temp);
					m[temp] = m[now] + 1;
				}
			}
		}
	}
}
int main() {
//ios::sync_with_stdio(false);
#ifdef LOCAL
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif
	prework();
	while(true) {
		string s;
		int in;
		for(int i = 0; i < 8; i++) {
			if(!(cin >> in)) return 0;
			s += (in + '0');
		}
		cout << m[s] - 1 << endl;
	}
}




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

bool alltrue(vector<bool> &a) {
    bool b = true;
    for (auto A : a) if (A != b) return false;
    return true;
}

int main() {
    int n, m; cin >> n >> m;
    int A[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    int l = 0, r = n;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        bool flag = false;
        vector<bool> blist(m, false);
        while (!alltrue(blist)) {
            bool tmp = true;
            vector<int> cnt(m, 0);
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (!blist[A[i][j] - 1]) {
                        cnt[A[i][j] - 1]++;
                        break;
                    }
                }
            }

            int mx = 0;
            for (int i = 0; i < m; i++) {
                mx = max(mx, cnt[i]);
                if (cnt[i] > mid) blist[i] = true;
            }

            if (mx <= mid) {
                flag = true;
                break;
            }
        }
        if (flag) r = mid;
        else l = mid;
    }
    cout << r << endl;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    bool ok = true;
    if (a[(int)a.size()-1] != b[0]){
        ok = false;
    } else if (b[(int)b.size()-1] != c[0]){
        ok = false;
    }

    if (ok){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std ;
int main()
{
	int N,M,X,Y;
	cin >> N >> M >> X >>Y;
	int x[105],y[105];
	for(int i=0;i<N;i++) cin >> x[i] ;
	sort(x,x+N) ;
	for(int i=0;i<M;i++) cin >> y[i] ;
	sort(y,y+M) ;
	int f=0;
	if(x[N-1]<y[0]){
		if(x[N-1]+1>X&&x[N-1]+1<=Y) {
		cout << "No War" ;f=1;
		}
	}
	if(f==0) cout << "War" ;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   int w = 0;
   for(int i = 0; i < n; i++){
      if(s[i] == '.'){
         w++;
      }
   }
   int ans = w;
   for(int i = 0; i < n; i++){
      if(s[i] == '.'){
         w--;
      }
      else{
         w++;
      }
      ans = min(w, ans);
   }
   cout << ans << endl;

   return 0;
}

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

int main() {
  int l, r, d,ans=0;
  cin>>l>>r>>d;
  for(int i=1;i<150;i++){
    if(i*d>=l&&i*d<=r) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 3616
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,t = LI()
    k = t//a
    print(k*b)
    return

#B
def B():
    n = I()
    v = LI()
    c = LI()
    ans = 0
    for i in range(n):
        if v[i] > c[i]:
            ans += (v[i]-c[i])
    print(ans)
    return

#C
def C():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)
    n = I()
    a = LI()
    ans = 1
    for i in range(n):
        b = a[:i]+a[i+1:]
        g = b[0]
        for j in range(a):
            print()
    return

#D
def D():
    n = I()
    a = LI()
    k = 0
    for i in a:
        if i < 0:
            k += 1
    ans = 0
    m = float("inf")
    for i in a:
        ans += abs(i)
        m = min(m,abs(i))
    if k%2:
        ans -= 2*m
    print(ans)
    return


#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 60528
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	string A, B;
	cin >> A >> B;
	int a = A.size(), b = B.size();
	if (a < b) cout << "LESS\n";
	else if (a > b) cout << "GREATER\n";
	else if (A < B) cout << "LESS\n";
	else if (A > B) cout << "GREATER\n";
	else cout << "EQUAL\n";

	return 0;
}

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

int main() {
    int N,m=0,i,H,c=0;
    cin >> N;

    for(i=0; i<N; i++) {
        cin >> H;
        if(H >= m)
            c++;
        m = max(m,H);
    }
    
    cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int a[1002],b[1002],cx[1002*1002],cy[1002*1002],px[1002*1002],py[1002*1002];
int main()
{
	memset(px,-1,sizeof(px));
	memset(py,-1,sizeof(py));
	int n,m;
	long long ans=1;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		int input;
		cin>>input;
		cx[input]++;
		px[input]=i;
	}
	for(int i=1;i<=m;i++)
	{
		int input;
		cin>>input;
		cy[input]++;
		py[input]=i;	
	}
	for(int i=1;i<=n*m;i++)
	{
		if(cx[i]>2||cy[i]>2)
		{
			cout<<0;
			return 0;
		}
	}
	int nn=0,mm=0,icount=0;
	for(int i=n;i>=1;i--)
	{
		for(int j=m;j>=1;j--)
		{
		int tmp=(i-1)*m+j;
		if(px[tmp]!=-1&&py[tmp]!=-1)
		{
			nn++;
			mm++;
			icount++;
		}
		else if(px[tmp]!=-1)
		{
			if(!mm)
			{
				cout<<0;
				return 0;	
			}
			nn++;
			icount++;
			ans=(ans*mm)%MOD;
		}
		else if(py[tmp]!=-1)
		{
			if(!nn)
			{
				cout<<0;
				return 0;	
			}
			mm++;
			icount++;
			ans=(ans*nn)%MOD;
		}
		else
		{
			if(nn*mm-icount==0)
			{
				cout<<0;
				return 0;
			}
			ans=(ans*(nn*mm-icount))%MOD;
			icount++;
		}
		if(nn>n||mm>m)
		{
			cout<<0;
			return 0;
		}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 10496
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
    };
    let c = s.iter().filter(|&&c| c == 'R').count();
    let ans = if c == 2 {
        if s[0] == s[1] || s[1] == s[2] {
            c
        } else {
            1
        }
    } else {
        c
    };
    println!("{}", ans);
}


Measured memory_bytes: 2140
import java.util.Scanner;
    
class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int s;
        int i = 1;
        do{
            s = stdIn.nextInt();
            if(s == 0) return;
            else{
                System.out.println("Case " +i+ ": " +s);
                i++;
            }
        }while(s!=0);
    }
}

Measured memory_bytes: 41132
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int x_max = 100004;
const int n_max = 205;

signed main(){
    int n,x;
    cin >> n >> x;
    int A[n];
    REP(i,n) cin >> A[i];
    sort(A,A+n);

    int dp[2][x_max];
    REP(j,x_max) dp[0][j] = j % A[0];
    FOR(i,1,n){
        REP(j,x_max){
            dp[i%2][j] = 0;
            Add(dp[i%2][j],dp[(i-1)%2][j % A[i]]);
            Add(dp[i%2][j],i * dp[(i-1)%2][j]);
        }
    }
    cout << dp[(n-1)%2][x] << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int a, b; cin >> a >> b;
    if(a <= 0 && b >= 0) cout << "Zero" << endl;
    else if(a > 0 && b > 0) cout << "Positive" << endl;
    else cout << (((b - a) % 2) ? "Positive" : "Negative") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b;
    cin >> a >> b;
    if(a+b == 15) cout << "+" << endl;
    else if(a*b == 15) cout <<"*" << endl;
    else cout << "x" << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, K) = nextLongList()
    val ans = K * Math.pow(K - 1.0, N - 1.0).toLong()
    println(ans)
}

Measured memory_bytes: 36328
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while( (line = br.readLine()) != null){
            String[] input = line.split(" ");

            int a = Integer.parseInt(input[0]);
            int b = Integer.parseInt(input[1]);

            int x = getGCD(Math.max(a,b) , Math.min(a,b));
            long y = (long)a*(long)b/x;

            System.out.println(x + " " + y);
        }
    }

    static int getGCD(int b , int s){
        return (b%s == 0) ? s : getGCD(s , b%s);
    }

}

Measured memory_bytes: 24264
n = int(input())
l = []

def prime(n):
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      return False
  else:
    return True
    

for i in range(2,55556):
  if prime(i) and i%5==1:
    l.append(i)
for i in range(n):
  print(l[i],end=" ")

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

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=5e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,K,mi = INF;
	P ps[50];
	cin >> n >> K;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		ps[i] = P(x,y);
	}
	if(n == 2){
		cout << abs(ps[0].first - ps[1].first) * abs(ps[0].second - ps[1].second) << endl;
		return 0;
	}
	sort(ps,ps + n);
	for(int i = 0;i < n;i++){
		for(int j = i;j < n;j++){
			int miy = min(ps[i].second,ps[j].second),may = max(ps[i].second,ps[j].second);
			for(int k = 0;k < n;k++){
				int cnt = 0;
				for(int l = k;l < n;l++){
					if(miy <= ps[l].second && ps[l].second <= may) cnt++;
					if(cnt >= K) mi = min(mi,(may - miy) * (ps[max(j,l)].first - ps[min(k,i)].first));
				}
			}
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def clockangles(hour, minute):
    ans = abs((hour * 30 + minute * 0.5) - (minute * 6))
    return min(360-ans,ans)


def main():
    A, B, H, M = MI()

    if M == 0 and H == 0:
        print(abs(A - B))
        return

    d = clockangles(H, M)
    r = math.radians(d)
    ans = A**2 + B**2 - 2 * A * B * math.cos(r)
    print(math.sqrt(ans))

    # if M == 0:
    #     m = 0
    # else:
    #     m = M * 360 / 60

    # if H == 0:
    #     h = 0
    # else:
    #     h = H * 360 / 12
    #     # print(h, 360 / 12)
    #     h += (360 / 12) * (M / 60.0)

    # if h > m:
    #     d = 0
    #     if abs(h - m) >= 180:
    #         d = 360 - abs(h - m)
    #     else:
    #         d = abs(h - m)
    #     r = math.radians(d)
    #     ans = A**2 + B**2 - 2 * A * B * math.cos(r)
    #     # print('A', A, 'B', B, 'm', m, 'h', h)
    #     print(d, r)
    #     print(math.sqrt(ans))
    # else:
    #     # print('ssssssss')
    #     d = 0
    #     if abs(h - m) >= 180:
    #         d = 360 - abs(h - m)
    #     else:
    #         d = abs(h - m)
    #     r = math.radians(d)
    #     ans = A**2 + B**2 - 2 * A * B * math.cos(r)
    #     # print('A', A, 'B', B, 'm', m, 'h', h)
    #     # print(d, r)
    #     print(math.sqrt(ans))



if __name__ == '__main__':
    main()


Measured memory_bytes: 68824
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	a := scanner.Text()
	scanner.Scan()
	b := scanner.Text()

	aInt, err := strconv.Atoi(a)
	if err != nil {
		log.Fatal(err)
	}

	bInt, err := strconv.Atoi(b)
	if err != nil {
		log.Fatal(err)
	}

	answer := ""

	if aInt > bInt {
		for i := 0; i < aInt; i++ {
			answer += b
		}
		fmt.Println(answer)
	} else {
		for i := 0; i < bInt; i++ {
			answer += a
		}
		fmt.Println(answer)
	}
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
char s[100005];
long long dp[100005][4];
int main()
{
    scanf("%s",s+1);
    int l=strlen(s+1);
    dp[0][0]=1;
    for(int i=1;i<=l;i++)
    {
        for(int j=0;j<=3;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(s[i]=='?') dp[i][j]*=3;
            if(j&&(s[i]=='?'||"AABC"[j]==s[i]))
                dp[i][j]+=dp[i-1][j-1];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[l][3]<<endl;
}


Measured memory_bytes: 3456
// 3_abc128_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(m);
    rep(i, m){
        int k;
        cin >> k;
        v[i].resize(k);
        rep(j, k){
            cin >> v[i][j];
        }
    }
    vector<int> p(m);
    rep(i, m){
        cin >> p[i];
    }

    ll ans = 0;
    for(int i = 0; i < (1 << n); i++){
        int flag = 1;
        rep(j, m){
            int cnt = 0;
            rep(k, v[j].size()){
                int h = v[j][k];
                h--;
                if(i & (1 << h)) cnt++;
            }
            if(cnt % 2 != p[j]) flag = 0;
        }
        if(flag) ans++;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int X,N;cin >> X >> N;
    vector<int> p(N);rep(i,N)cin >> p[i];
    map<int,int> m;
    rep(i,N)m[p[i]]++;

    int ans = 90000000;
    int res = 90000000;

    for(int i = -150;i <= 150;i++){
        if(m[i] == 0){
            if(ans > abs(X-i)){
                ans = min(ans,abs(X - i));
                res = i;
            }

        }
    }

    cout << res<< endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		char c1 = s1.charAt(0);
		char c2 = s2.charAt(0);
		if (c1==c2) {
			System.out.println("=");
		}
		if (c1>c2) {
			System.out.println(">");
		}
		if (c1<c2) {
			System.out.println("<");
		}
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define ll      long long int   
#define ld      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define all(v)  v.begin(),v.end()
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define MP      make_pair
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf     1000000000000000007
const int N=300006;

void run(){
	ll n;
    cin>>n;
    n=n*n*n;
    cout<<n;
 
 
}
 
 
void setup(){
    ios;
    //cout << setprecision(20);
    // #ifndef ONLINE_JUDGE
    // freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    // #endif
}
 
signed main(){
    setup();
    int tests = 1;
    //cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}

Measured memory_bytes: 256
/* ex9_1
   key_tree */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 11

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}


int main(void){
    stack stk;
    int i;
    char input_str[SIZE], *str;
    scanf("%s", input_str);
    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);
    
    str = input_str;
    while(*(str) != '\0'){
        //0か1であれば追加
        if(*(str) == '1' || *(str) == '0'){
            push(&stk, *(str));
        }
        //それ以外（B）であれば削除
        else if(stk.count > 0){
            pop(&stk);
        }
        str++;
    }
    //スタックを逆順で出力
    for(i = 0; i < stk.count; i++){
        printf("%c", stk.data[SIZE - i - 1]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
#define chmax(p,q)(p=max(p,q))
int H,W,M;
int main(){
    cin>>H>>W>>M;
    int mh=0,mw=0;
    map<int,int>cnt_H,cnt_W;

    set<pair<int,int>>P;
    vector<int>max_h,max_w;
    for(int i=0;i<M;i++){
        int h,w;
        cin>>h>>w;
        chmax(mh,++cnt_H[--h]);
        chmax(mw,++cnt_W[--w]);
        P.emplace(make_pair(h,w));
    }
    for(auto x:P){
        int h=x.first,w=x.second;
        // if(cnt_H[h]==mh)max_h.push_back(h);
        // if(cnt_W[w]==mw)max_w.push_back(w);
    }

    for(auto tmp : cnt_H) {
        if(mh == tmp.second) max_h.push_back(tmp.first);
    }
    for(auto tmp : cnt_W) {
        if(mw == tmp.second) max_w.push_back(tmp.first);
    }


    for(auto h:max_h){
        for(auto w:max_w){
            //cout<<"max:"<<h<<" "<<w<<endl;
            if(P.find(make_pair(h,w))==P.end()){cout<<mh+mw<<endl;return 0;}
        }
    }
    cout<<mh+mw-1<<endl;
    return 0;
}

Measured memory_bytes: 49596
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
l = []
for i in range(n):
    if v[i]/c[i] > 1:
        l.append(i)
if l:
    vt,ct=0,0
    for j in l:
        vt += v[j]
        ct += c[j]
    print(vt-ct)
else:print(0)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    char s1, s2, s3;
    int ans = 0;
    scanf("%c%c%c", &s1, &s2, &s3);
    if (s1 == '1') {
        ans ++;
    }
    if (s2 == '1') {
        ans ++;
    }
    if (s3 == '1') {
        ans ++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int solve(int,int);

int A[20];
int n;

int main()
{

  int i,q,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  int m[q];
  
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<q;i++){
    j=solve(0,m[i]);
    if(j==0)printf("no\n");
    if(j==1)printf("yes\n");
  }

  return 0;
}

int solve(int i,int m){

  int res;
  
  if(m==0) return 1;
  if(i>=n) return 0;

  res=solve(i+1,m)||solve(i+1,m-A[i]);

  return res;
}



Measured memory_bytes: 2100
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	int n;
	int d[100][2];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i][0]>>d[i][1];
	}
	for(int i=0;i<n-2;i++){
		if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>

int main()
{
    int n,cnt=0,box;
    scanf("%d",&n);
    int A[n];
    for(int x=0;x<n;x++){
        scanf("%d",&A[x]);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(A[j] < A[j-1]){
                box = A[j];
                A[j] = A[j-1];
                A[j-1] = box;
                cnt +=1;
            }
        }
    }
    for(int x=0;x<n;x++){
        if(x != n-1){
            printf("%d ",A[x]);
        }else {
            printf("%d\n",A[x]);
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2060
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] ab = new int[n][2];
        long sum=0;
        boolean isAble = true;

        for (int i = 0; i < n; i++) {
            ab[i][0] = scanner.nextInt();
            ab[i][1] = scanner.nextInt();
        }

        Arrays.sort(ab, Comparator.comparingInt(t -> t[0]));
        Arrays.sort(ab, Comparator.comparingInt(t -> t[1]));

        for (int i = 0; i < n; i++) {
            sum += ab[i][0];
            if(sum > ab[i][1]){
                isAble=false;
                break;
            }
        }

        if(isAble){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 111900
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
    char c;
    cin >> c;
    switch (c)
    {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
        cout << "vowel" << endl;
        break;
    default:
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	if(S.at(K-1) ==  'A') {
		S.at(K-1) = 'a';
	}
	else if(S.at(K-1) ==  'B') {
		S.at(K-1) = 'b';
	}
	else {
		S.at(K-1) = 'c';
	}
	cout << S << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int m = sc.nextInt();
		
		int[] ax = new int[a];
		int[] by = new int[b];
		
		int amin = 100000;
		int bmin = 100000;
		
        for(int i=0; i<a; i++){
        	ax[i] = sc.nextInt();
        	if(ax[i] < amin){
        	    amin = ax[i];
        	}
        }
      	
      	for(int i=0; i<b; i++){
      	    by[i] = sc.nextInt();
      	    if(by[i] < bmin){
        	    bmin = by[i];
        	}
      	}
      	
      	int ans = amin + bmin;
      	
      	for(int i=0; i<m; i++){
      	    int mx = sc.nextInt();
      	    int my = sc.nextInt();
      	    int mc = sc.nextInt();
      	    
      	    int mans = ax[mx-1] + by[my-1] - mc;
      	    if(mans<ans){
      	        ans = mans;
      	    }
      	}
      	
      	System.out.println(ans);
    }
}

Measured memory_bytes: 60224
n, m, x = gets.split(' ').map(&:to_i)
list = []
n.times do
  list << gets.split(' ').map(&:to_i)
end

min = nil;

(2**n).times do |i|
  t = sprintf("%0#{n}b", i).split("").map.with_index { |v, i| v == "1" ? list[i] : nil }.compact
  next if min && min <= t.map(&:first).sum
  arr = t.transpose.map(&:sum)
  next unless arr.drop(1).all? { |s| s >= x }
  min = arr.first if min.nil? || min > arr.first
end

p min || -1


Measured memory_bytes: 14256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <complex>
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

int main() {
  int N=si(), Q=si();
  string S=ss();
  vector<char> T(Q), D(Q);
  REP(i, Q) scanf(" %c %c", &T[i], &D[i]);
  int ans = N;
  {
    int l = -1;
    int r = N;
    while (r - l > 1) {
      int m = (l + r) / 2;
      int x = m;
      REP(i, Q) {
        if (S[x] == T[i]) {
          if (D[i]=='L') x--;
          if (D[i]=='R') x++;
        }
        if (x<0||x>=N) break;
      }
      if (x<0) {
        l = m;
      } else {
        r = m;
      }
    }
    ans -= l + 1;
  }
  {
    int l = -1;
    int r = N;
    while (r - l > 1) {
      int m = (l + r) / 2;
      int x = m;
      REP(i, Q) {
        if (S[x] == T[i]) {
          if (D[i]=='L') x--;
          if (D[i]=='R') x++;
        }
        if (x<0||x>=N) break;
      }
      if (x>=N) {
        r = m;
      } else {
        l = m;
      }
    }
    ans -= N-r;
  }
  pi(ans);br();
}


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

#define loop(i,n) for(int i=1;i<=n;i++)
int jj[1002][1002];
int oo[1002][1002];
int ii[1002][1002];

int main(){
  int m,n,k;
  cin>>m>>n>>k;
  char e;
  loop(i,m)loop(j,n){
    cin>>e;
    jj[i][j]=jj[i-1][j]+jj[i][j-1]-jj[i-1][j-1];
    oo[i][j]=oo[i-1][j]+oo[i][j-1]-oo[i-1][j-1];
    ii[i][j]=ii[i-1][j]+ii[i][j-1]-ii[i-1][j-1];
    if(e=='J')jj[i][j]++;
    if(e=='O')oo[i][j]++;
    if(e=='I')ii[i][j]++;
  }
  int a,b,c,d;
  loop(i,k){
    cin>>a>>b>>c>>d;
    a--;
    b--;
    cout<<(jj[c][d]-jj[a][d]-jj[c][b]+jj[a][b]);
    cout<<" ";
    cout<<(oo[c][d]-oo[a][d]-oo[c][b]+oo[a][b]);
    cout<<" ";
    cout<<(ii[c][d]-ii[a][d]-ii[c][b]+ii[a][b]);
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 14712
# ABC157 B
import numpy as np
a = [[input().split() for l in range(3)]]
a = np.ravel(a)
n = int(input())
b = [input() for i in range(n)]
ans = 'No'

def check(a,b):
    return set(a).issubset(b)

for i in range(3):
    if check(a[i*3:(i*3)+3],b) or check(a[i:i+7:3],b) or check(a[0:9:4],b) or check(a[2:7:2],b):
        ans = 'Yes'

print(ans)

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

int main() {

  int X; //入力
  cin >> X;
  
  int S0, S1, S2, S3, S4, S5, S6, S7, S8; 
  S1 = X / 100000000;
  S0 = X - S1*100000000;
  S2 = S0 / 10000000;
  S0 -= S2*10000000;
  S3 = S0 / 1000000;
  S0 -= S3*1000000;
  S4 = S0 / 100000;
  S0 -= S4*100000;
  S5 = S0 / 10000;
  S0 -= S5*10000;
  S6 = S0 / 1000;
  S0 -= S6*1000;
  S7 = S0 / 100;
  S0 -= S7*100;
  S8 = S0 / 10;
  S0 -= S8*10;
  
//  cout << S1 << endl;  
//  cout << S2 << endl;  
//  cout << S3 << endl;  
//  cout << S4 << endl;  
//  cout << S5 << endl;  
//  cout << S6 << endl;  
//  cout << S7 << endl;  
//  cout << S8 << endl;  
//  cout << X << endl;  
  
  int Y;
  Y = S1+S2+S3+S4+S5+S6+S7+S8+S0;

  int Z;
  Z = X % Y;

  if (Z == 0) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

int main()
{
  int N; string S;
  cin >> N; cin >> S;
 
  int now = 0, st = 0;
  rep(i,N) {
    int delta = S[i] == '(' ? 1 : -1;
    now += delta;
    st = min(st, now);
  }
  string s = S;
  while(st < 0) s = "(" + s, ++st, ++now;
  while(now < 0) s = "(" + s, ++now;
  while(now > 0) s += ")", now--;
  cout << s << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int P = Integer.parseInt(sc.get());
		int odd = 0;
		int even = 0;
		for (int i = 0; i < N; i++) {
			int A = Integer.parseInt(sc.get());
			if ((A & 1) == 0) even += 1;
			else odd += 1;
		}
		if (odd == 0 && P == 1){
			System.out.println(0);
			return;
		}
		long ans = (1L << even) * Math.max(1L << (odd - 1), 1);
		System.out.println(ans);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct line{
  int p1,p2,h;
  bool operator<(const line& another) const {
    return h > another.h;
  }
};
int main(){
  int n,m,a,h,p,q,i,j,k,c;
  
  cin >> n >> m >> a;
  while(n!=0){
    vector <line> ls;
    line l;
    for(i=0;i<m;i++) {
      cin >> h >> p >> q;
      l.h=h;l.p1=p;l.p2=q;
      ls.push_back(l);
    }
    sort(ls.begin(),ls.end());
    c=a;
    for(i=0;i<m;i++){
      if(ls[i].p1==c) c=ls[i].p2;
      else if(ls[i].p2==c) c=ls[i].p1;
    }
    cout << c << endl;
    cin >> n >> m >> a;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

int mod = 1e7;

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

  //int tc;
  //cin >> tc;

  float d, t, s;
  cin >> d >> t >> s;
  cout << (d / s <= t ? "Yes\n" : "No\n");
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,dp[200005],presum[200005];
vi v;
void solve(){
    cin>>n;
    rep(i,1,n+1){
        int x;
        cin>>x;
        v.pb(x);
    }
    v.resize(unique(all(v))-v.begin());
    rep(i,0,sz(v)){
        dp[i]=(i?dp[i-1]:0)+presum[v[i]];
        presum[v[i]]=(presum[v[i]]+(i?dp[i-1]:0)+1)%hell;
    }
    cout<<(dp[sz(v)-1]+1)%hell<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5104
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan. nextInt();
        if(a < b && a < c){
            if(b < c){
                System.out.println(a + " " + b + " " + c);
            }
            else{
                System.out.println(a + " " + c + " " + b);
            }
        }
        else if(b < a && b < c){
            if(a < c){
                System.out.println(b + " " + a + " " + c);
            }
            else{
                System.out.println(b + " " + c + " " + a);
            }
        }
        else {
            if(b < a){
                System.out.println(c + " " + b + " " + a);
            }
            else{
                System.out.println(c + " " + a + " " + b);
            }
        }


    }
}



Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
int main () {
  string s, t;
  cin >> s >> t;
  int ans = 1000000;
  int sn = (int)s.size();
  int tn = (int)t.size();
  for (int i = 0; i <= sn - tn; i ++) {
    int kj = 0;
    for (int j = 0; j < tn; j ++) {
      if (s[i + j] != t[j]) kj ++;
    }
    ans = min(ans, kj);
  }
  cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 100001
vector<PINT> p[MAX_V];
int n,ddfs,sum;
bool cdfs[MAX_V];
ll dis[MAX_V];

bool dfs(int from){
    REP(i,p[from].size()){
        int to = p[from][i].first;
        if(!cdfs[to]){
            cdfs[to] = true;
            dis[to] = dis[from] + p[from][i].second;
            if(!dfs(to)) return false;
        }else if(dis[to]!=dis[from]+p[from][i].second) return false;
    }
    return true;
}

#define MAX_N 100001
int par[MAX_N]; //親
int rnk[MAX_N]; //木の深さ

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    rnk[i] = 0;
  }
}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

//xとyの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rnk[x] == rnk[y]) ++rnk[x];
  }
}

//xとyが同じ集合に属するか
bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int m;
    bool ans=true;
    cin >> n >> m;
    vector<bool> used(n+1,false);
    init(n+1);
    REP(i,m){
        int l,r,d;
        cin >> l >> r >> d;
        p[l].push_back({r,d});
        p[r].push_back({l,-d});
        unite(l,r);
    }

    set<int> abc;
    FOR(i,1,n+1) abc.insert(find(i));
    FOR(i,1,n+1) cdfs[i] = false;
    for(auto itr=abc.begin();itr!=abc.end();++itr){
        dis[*itr] = 0; cdfs[*itr] = true;
        ans = dfs(*itr);
        if(!ans) break;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
    
	
    	
        FastIO

        int n,h,i,sum=0,x;
        cin>>h>>n;

        for(i=0;i<n;i++)
        	{cin>>x;sum+=x;}
        if(sum>=h)
        	cout<<"Yes";
        else
        	cout<<"No";
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
int main(){
	int r,c,rwa,cwa,i,j;
	std::cin>>r>>c;
	if(c==0)return 1;
	int ans[101][101]={0};
	//r*c????´??????????????????¨??????????¨????
	for(i=0;i<r;i++){
		cwa=0;
		for(j=0;j<c;j++){
			std::cin>>ans[i][j];
			cwa+=ans[i][j];
		}
		ans[i][j]=cwa;
	}	
	//?????????????¨????
	for(i=0;i<c+1;i++){
		rwa=0;
		for(j=0;j<r;j++){
			rwa+=ans[j][i];	
		}
		ans[j][i]=rwa;
	}
	//??????
	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			std::cout<<ans[i][j];
			if(j!=c)std::cout << " ";
		}
		std::cout<<std::endl;
	}	
	return 0;
}

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

using namespace std;

int main(){
  long long int a, b[100010],c[100010],d[100010],ans=0,res=0;
  
  cin >> a ;
  
 for(int i=0;i<a;i++)  cin >> b[i];
  
  for(int i=0;i<a;i++){
    c[i] = 2*b[i];
    res += b[i];
  }
  
  for(int i=0;i<a;i++){
    
    if(i % 2 == 1){
      
      ans += c[i];
      
    }
    
  }
  
  res -= ans;
  
  d[0] = res;
  
  for(int i=1;i<a;i++){
    d[i] = c[i-1] -d[i-1];
  }
  
  for(int i=0;i<a;i++)
    cout << d[i] << " " ;
  
  cout << endl;
  
}
  
      
      
    

Measured memory_bytes: 3712
#include <stdio.h>
#define BUF_CLEAR (scanf("%*[^\n]"))
#define BUF_AFTERC (getchar())

int main(void)
{
	char tbl[256];
	int n, i;
	char cbuf;
	
	while (1){
		scanf("%d", &n);
		BUF_CLEAR;BUF_AFTERC;
		if (!n) break;
		for (i = 0; i < 256; i++) tbl[i] = i;
		while (n--){
			scanf("%c", &cbuf);
			scanf(" %c", tbl + cbuf);
			BUF_CLEAR;BUF_AFTERC;
		}
		
		scanf("%d", &n);
		BUF_CLEAR;BUF_AFTERC;
		while (n--){
			scanf("%c", &cbuf);
			BUF_CLEAR;BUF_AFTERC;
			printf("%c", tbl[cbuf]);
		}
		puts("");
	}
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(size_t i = (j); i < (n); ++i)
#define rrep(i, j, n) for(size_t i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	
	string a, b;
	cin >> a >> b;
	int n = a.size();
	int m = b.size();
	if (n > m) cout << "GREATER" << endl;
	else if (n < m) cout << "LESS" << endl;
	else {
		rep(i, 0, n) {
			if (a[i] < b[i]) {
				cout << "LESS" << endl;
				return 0;
			}
			else if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}

		}
		cout << "EQUAL" << endl;
	}
	return 0;

}


Measured memory_bytes: 3640