akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll mod = ll(1e9)+7;

ll powpow(ll x, ll n) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return powpow(x * x, n / 2);
  else
    return x * powpow(x, n - 1);
}

int main() {
  ll x, a, b, p1, p2;
  cin >> x;
  rep(i, 9500) {
    rep (j, 9500) {
      p1 = powpow(i,  5);
      p2 = powpow(j, 5);
      if (p1 - p2 == x) {
        cout << to_string(i) << ' ' << to_string(j) << endl;
        return 0;
      }
      if (p1 + p2 == x) {
        cout << to_string(i) << ' ' << to_string(-1 * j) << endl;
        return 0;
      }
    }
  }
}


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

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	
	char A[h][w];
	for(int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < w; j++) {
			A[i][j] = s[j];
		}
	}
	
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(A[i][j] != '#') {
				int count = 0;
				if(i > 0) {
					if(j > 0) {
						if(A[i - 1][j - 1] == '#') count++;
					}
					if(A[i - 1][j] == '#') count++;
					if(j + 1 < w) {
						if(A[i - 1][j + 1] == '#') count++;
					}
				}
				
				if(j > 0) {
					if(A[i][j - 1] == '#') count++;
				}
				
				if(j + 1 < w) {
					if(A[i][j + 1] == '#') count++;
				}
				
				if(i + 1 < h) {
					if(j > 0) {
						if(A[i + 1][j - 1] == '#') count++;
					}
					if(A[i + 1][j] == '#') count++;
					if(j + 1 < w) {
						if(A[i + 1][j + 1] == '#') count++;
					}
				}
				
				A[i][j] = '0' + count;
			}
			
			cout << A[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#136c
N = int(input())
H_list = [int(e) for e in input().split()]

H_list[0] -= 1 #最初の奴は減らしても影響なし。

for i in range(1,N):
    #print(H_list)
    #print(H_list[i-1],H_list[i])
    
    if H_list[i-1] < H_list[i]:
        H_list[i] -= 1
    
    if H_list[i-1] > H_list[i]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 14252
from itertools import accumulate
N = int(input())
s = input()
w = list(map(lambda x: 1 if x == 'W' else 0, s))
e = list(map(lambda x: 1 if x == 'E' else 0, s))
e.reverse()
w = list(accumulate(w))
e = list(accumulate(e))
e.reverse()
# print(w)
# print(e)
ans = []
for i in range(N):
    num = 0
    if 0 < i: num += w[i - 1]
    if i < N - 1: num += e[i + 1]
    ans.append(num)
# print(ans)
print(min(ans))

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    string N; cin >> N;
    string copy = N;
    reverse(N.begin(), N.end());
    if(N == copy) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) {solve();line1;}
	printf("Time : %fms\n", (1000*(double)clock())/CLOCKS_PER_SEC);
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	string a,b;
	cin >> a >> b;
	int la = a.size();
	int lb = b.size();

	// dp[i][j] : 
	// Length of LCS when we consider the first i characters 
	// of string_a and first j characters of string_b.
	vector<vi> dp(la+1, vi(lb+1,0));

	// rep(i,0,la+1) dp[i][0] = 0;
	// rep(i,0,lb+1) dp[0][i] = 0;

	rep(i,1,la+1){
		rep(j,1,lb+1){
			if(a[i-1] == b[j-1]) dp[i][j] = max(dp[i-1][j-1]+1, dp[i][j]);
			dp[i][j] = max({dp[i][j], dp[i-1][j], dp[i][j-1]});
		}
	}

	int i=la, j=lb;
	string ans = {};
	while(i != 0 || j != 0){

		if(j>0 && dp[i][j] == dp[i][j-1]) j--;
		else if(i>0 && dp[i][j] == dp[i-1][j]) i--;
		else if(i>0 && j>0 && dp[i][j] == dp[i-1][j-1]+1){
			ans += a[i-1];
			i--, j--;
		}		
	}

	reverse(all(ans));
	cout<<ans<<endl;
}


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n;
vector<ll> ans;
int main() {
	cin >> n;
	if (n == 3) cout << "2 5 63" << endl;
	else if (n == 4) cout << "2 5 20 63" << endl;
	else if (n < 15000) {
		ll t6 = n % 4, t2 = n / 4 * 2, t3 = n / 4 * 2;
		vector<ll>s2, s3, s6;
		REPO(i, 30000) {
			if (i % 6 == 0)s6.push_back(i);
			else if (i % 2 == 0)s2.push_back(i);
			else if (i % 3 == 0)s3.push_back(i);
		}
		if (t3 > 5000) {
			t6 += t3 - 5000;
			t3 = 5000;
		}
		REP(i, t6)ans.push_back(s6[i]);
		REP(i, t2)ans.push_back(s2[i]);
		REP(i, t3)ans.push_back(s3[i]);
	}
	else {
		ll t6 = 20000 - n;
		REPO(i, 30000) {
			if (i <= t6 * 6 and i % 6 == 0)continue;
			else if (i % 2 == 0 or i % 3 == 0)ans.push_back(i);
		}
	}
	REP(i, ans.size()) {
		if (i != 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 640
using System;

class Program{
  static void Main(){
    int cardsize = int.Parse(Console.ReadLine());
    int cnumber = int.Parse(Console.ReadLine());
    int ctype;
    int[] card = new int[cardsize*2];
    int[] subcard = new int[cardsize*2];
    for(int m = 0;m<cardsize*2;m++){
      card[m] = m+1;
    }
    for(int n = 0;n<cnumber;n++){
      ctype = int.Parse(Console.ReadLine());
      if(ctype == 0){
        for(int i = 0;i<cardsize;i++){
            subcard[i*2] = card[i];
            subcard[i*2+1] = card[i+cardsize];
        }
        for(int l = 0;l<cardsize*2;l++){
          card[l] = subcard[l];
        }
      }else{
        for(int i = 0;i<cardsize*2-ctype;i++){
            subcard[i] = card[ctype+i];
        }
        for(int i = cardsize*2-ctype,c = 0;i<cardsize*2;i++,c++){
            subcard[i] = card[c];
        }
        for(int l = 0;l<cardsize*2;l++){
          card[l] = subcard[l];
        }
      }
    }
    for(int n = 0;n<cardsize*2;n++){
      Console.WriteLine(card[n]);
    }
  }
}

Measured memory_bytes: 9192
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
const string YES = "Yes";
const string NO = "No";
ll gK;
bool isGood = false;
void solve(long long A, long long B, long long C, ll K){
    if(A < B && B < C) {
        isGood = true;
        return;
    }
    if(K == 0)  return;
    solve(A*2, B, C, K-1);
    solve(A, B*2, C, K-1);
    solve(A, B, C*2, K-1);
}
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    scanf("%lld",&gK);
    solve(A, B, C, gK);
    if(isGood) cout<<YES<<endl;
    else cout<<NO<<endl;
    return 0;
}


Measured memory_bytes: 3096
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
else:
    tmp = [0 for _ in range(10 ** 5)]
    for i in range(N):
        tmp[D[i]] += 1

    if tmp[0] != 1:
        print(0)
    else:
        ans = 1
        flag = False
        flag2 = False
        for i in range(1, 10 ** 5 - 1):

            if flag2 and tmp[i+1] != 0:
                ans = 0
                break

            if tmp[i+1] == 0:
                flag2 = True

            ans = (ans * (tmp[i] ** tmp[i+1])) % 998244353

        print(ans) 


Measured memory_bytes: 20656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    string S;
    cin >> S;
    bool s = false, e = false, n = false, w = false;
    rep(i, S.size()) {
        if (S[i] == 'S') s = true;
        if (S[i] == 'E') e = true;
        if (S[i] == 'N') n = true;
        if (S[i] == 'W') w = true;
    }
    if ((s && !n) || (!s && n) || (e && !w) || (!e && w)) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

int main(int argc, char* argv[])
{
	string					szOperationStr;
	deque<char>				dqWordQueue;
	
	cin >> szOperationStr;

	for (int i = 0; i < szOperationStr.size(); i++)
	{
		if (dqWordQueue.empty() && szOperationStr[i] == 'B')
		{
			continue;
		}
		if (szOperationStr[i] == 'B')
		{
			dqWordQueue.pop_back();
		}
		else
		{
			dqWordQueue.push_back(szOperationStr[i]);
		}
	}

	while (!dqWordQueue.empty())
	{
		cout << dqWordQueue.front();
		dqWordQueue.pop_front();
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int n, arr[21];

int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return  0;
    int res = solve(i+1, m) || solve(i+1, m-arr[i]);
    return res;
}

int main()
{
    int q, M;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &M);
        (solve(0, M)) ? printf("yes\n") : printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2692
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int s[100010], t[100010], c[100010];
int T[32][100020] = {};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C; cin >> N >> C;
    rep(i, N) {
        cin >> s[i] >> t[i] >> c[i];
    }
    rep(i, N) {
        T[c[i]][s[i]]++;
        T[c[i]][t[i] + 1]--;
    }
    rep(j, C + 1) rep(i, 100010) T[j][i + 1] += T[j][i];
    int ans = 0;
    rep(i, 100010) {
        int tmp = 0;
        rep(j, C + 1) tmp += (T[j][i] > 0);
        ans = max(ans, tmp);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 13696
#include<iostream>
#include<math.h>

using namespace std;


int main(){
	long long N,total = 0,menor = 0;
	
	cin>>N;
	
	int X[N];
	
	for(int i= 0; i < N; i++){
		cin>>X[i];
	}
	
	for(int j = 1; j < 100; j++){
		int total = 0;
		for(int i = 0; i < N;i++){	
			total += pow((X[i]-j),2);
		}
		
		if(total < menor || j == 1){
			menor = total;
		}
	}
	
	cout<<menor;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray()
    {
        Next();
        Index = S.Length;
        return S.ToArray();
    }
    public int[] IntArray()
    {
        return StringArray().Select(int.Parse).ToArray();
    }
    public long[] LongArray()
    {
        return StringArray().Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

class Magatro
{
   
    private void Scan()
    {
       
    }

    public void Solve()
    {
        Scan();
        var s = Console.ReadLine().Split(' ');
        Console.WriteLine(new string(s.Select(ss => (char)(ss[0] + 'A' - 'a')).ToArray()));
    }

}



Measured memory_bytes: 13396
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=sorted(list(map(int,input().split())))
    i=0
    cnt=0
    while True:
        try:
            cnt+=A[N+2*i]
            i+=1
        except:
            break
    print(cnt)




resolve()

Measured memory_bytes: 109968
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9;

int ew[2000][2000];
int ns[2000][2000];

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }

    for (int i = 0; i < H; i++) {
        int j = 0;
        while (j < W) {
            if (S[i][j] == '.') {
                int tmp = j;
                int num = 0;
                while (j < W && S[i][j] != '#') {
                    num++;
                    j++;
                }
                for (int k = tmp; k < j; k++) {
                    ew[i][k] = num;
                }
            } else {
                ew[i][j] = 0;
                j++;
            }
        }
    }

    for (int i = 0; i < W; i++) {
        int j = 0;
        while (j < H) {
            if (S[j][i] == '.') {
                int tmp = j;
                int num = 0;
                while (j < H && S[j][i] != '#') {
                    num++;
                    j++;
                }
                for (int k = tmp; k < j; k++) {
                    ns[k][i] = num;
                }
            } else {
                ns[j][i] = 0;
                j++;
            }
        }
    }

    int res = -1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            chmax(res, ew[i][j]+ns[i][j]-1);
        }
    }
    cout << res << endl;


    

}


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

int main(void){

    int numA, numB, numM;
    int minA = INT_MAX, minB = INT_MAX;
    int price;
    cin >> numA >> numB >> numM;

    int *A = new int[numA];
    int *B = new int[numB];
    int *M = new int[3];

    for(int i=0; i<numA; i++){
        cin >> A[i];
        if(A[i] < minA){
            minA = A[i];
        }
    }
    
    for(int i=0; i<numB; i++){
        cin >> B[i];
        if(B[i] < minB){
            minB = B[i];
        }
    }

    price = minA + minB;

    for(int i=0; i<numM; i++){
        cin >> M[0] >> M[1] >> M[2];
        price = min(price, A[M[0]-1] + B[M[1]-1] - M[2]);
    }

    cout << price << endl;

    delete[] A;
    delete[] B;
    delete[] M;

    return 0;
}

Measured memory_bytes: 1024
import numpy as np
import math

A, B, H, M = map(int, input().split())

time = H + (M / 60.0)
a_rot = (time / 12.0) * np.pi * 2
b_rot = (M / 60.0) * np.pi * 2

rot = a_rot - b_rot
if rot < 0:
    rot = b_rot - a_rot


ans = math.sqrt(A**2 + B**2 - (2 * A * B * np.cos(rot)))

print(ans)


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    string s;
    cin>>n>>s;
    s+=s[0];
    // cout<<s<<endl;
    n++;
    vector<string> a(4,"");
    a[0]+="SS";
    a[1]+="SW";
    a[2]+="WS";
    a[3]+="WW";
    rep(i,4){
        for(int j=1;j<n;j++){
            if(a[i][j]=='S'&&s[j]=='o'&&a[i][j-1]=='S') a[i]+="S";
            if(a[i][j]=='S'&&s[j]=='x'&&a[i][j-1]=='S') a[i]+="W";
            if(a[i][j]=='W'&&s[j]=='o'&&a[i][j-1]=='S') a[i]+="W";
            if(a[i][j]=='W'&&s[j]=='x'&&a[i][j-1]=='S') a[i]+="S";
            if(a[i][j]=='S'&&s[j]=='o'&&a[i][j-1]=='W') a[i]+="W";
            if(a[i][j]=='S'&&s[j]=='x'&&a[i][j-1]=='W') a[i]+="S";
            if(a[i][j]=='W'&&s[j]=='o'&&a[i][j-1]=='W') a[i]+="S";
            if(a[i][j]=='W'&&s[j]=='x'&&a[i][j-1]=='W') a[i]+="W";
        }
        if(a[i][0]==a[i][a[i].size()-2]&&a[i][1]==a[i][a[i].size()-1]){
            rep(j,a[i].size()-2){
                cout<<a[i][j];
            }
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

long long int fac(long long int n){
  long long int m=1;
  while(n>=1) m*=n,m%=1000000007,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int a=0,b=0,c=0,d=0,n=0,count=0,ans=0;
  string s;
  cin>>a>>b;
  if(abs(a-b)>1){
    cout<<0<<endl;
    return 0;
  }else if(abs(a-b)==1){
    cout<<(fac(a)*fac(b))%1000000007<<endl;
    return 0;
  }else if(abs(a-b)==0){
    cout<<(fac(a)*fac(b)*2)%1000000007<<endl;
    return 0;
  }
}
///////////////////////////




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> x(m); for (int i = 0; i < m; ++i) cin >> x[i];
  if (n >= m) return cout << 0 << '\n', 0;
  sort(begin(x), end(x));
  V<> d(m - 1);
  for (int i = 0; i < m - 1; ++i) {
    d[i] = x[i + 1] - x[i];
  }
  sort(rbegin(d), rend(d));
  lint res = x.back() - x.front();
  for (int i = 0; i < n - 1; ++i) {
    res -= d[i];
  }
  cout << res << '\n';
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int res;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=a;j++){
            if(b>=i+j && i+j>=b-a){
                res++;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	l := io.NextFloat()
	a := l / 3
	io.Printf("%.12f\n", a*a*a)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextFloat returns a float64 number from stdin
func (io *Io) NextFloat() float64 {
	f, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

// Printf is awapper of fmt.Fprintf
func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}


Measured memory_bytes: 1748
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

int main() {
  string s;
  cin >> s;
  int X, Y;
  cin >> X >> Y;

  bool x[2][18000];
  bool y[2][18000];

  rep(i, 18000) {
    x[0][i] = false;
    y[0][i] = false;
  }

  int pos = 0;
  while (pos < s.size() && s.at(pos) != 'T') {
    pos++;
  }
  x[0][8000+pos] = true;
  y[0][8000] = true;
  pos++;

  bool isY = true;
  while (pos < s.size()) {
    int now = pos;
    while (pos < s.size() && s.at(pos) != 'T') {
      pos++;
    }
    now = pos - now;
    if (isY) {
      rep(i, 18000) {
        if (i-now < 0) {
          y[1][i] = y[0][i+now];
        } else if (i+now > 17000) {
          y[1][i] = y[0][i-now];
        } else {
          y[1][i] = y[0][i-now] || y[0][i+now];
        }
      }
      rep(i, 18000) {
        y[0][i] = y[1][i];
      }
      isY = false;
    } else {
      rep(i, 18000) {
        if (i-now < 0) {
          x[1][i] = x[0][i+now];
        } else if (i+now > 17000) {
          x[1][i] = x[0][i-now];
        } else {
          x[1][i] = x[0][i-now] || x[0][i+now];
        }
      }
      rep(i, 18000) {
        x[0][i] = x[1][i];
      }
      isY = true;
    }
    pos++;
  }

  if (x[0][8000+X] && y[0][8000+Y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	string S;
	cin >> S;
	if (S[0] == S[1] && S[1] == S[2])cout << "No";
	else cout << "Yes";
}

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

int main() {
    int N, x;
    cin >> N >> x;
    int a[N];
    rep(i, N) {
        cin >> a[i];
    }
    sort(a, a+N);
    int ans = 0;

    rep(i, N) {
        if(i == N-1) {
            if(x == a[i]) {
                ans++;
                break;
            }
            break;
        }

        if(x < a[i]) {
            break;
        }
        else if(a[i] <= x) {
            ans++;
            x -= a[i];
        }
    }
    
    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		int v = sc.nextInt();
		int e = sc.nextInt();

		E[] edges = new E[e * 2];
		for (int i = 0; i < e; i++) {
			E ed = new E();
			ed.from = sc.nextInt();
			ed.to = sc.nextInt();
			ed.cap = sc.nextInt();

			E ed2 = new E();
			ed2.from = ed.to;
			ed2.to = ed.from;
			ed2.cap = 0;

			edges[i] = ed;
			edges[i + e] = ed2;

		}

		long ans = 0;
		int[] depth = new int[v];
		boolean[] visited = new boolean[v];
		for (;;) {
			Arrays.fill(depth, v + 100);
			Arrays.fill(visited, false);
			if (!bfs(edges, depth, visited, 0, v - 1)) {
				break;
			}

			for (;;) {
				Arrays.fill(visited, false);
				visited[0] = true;
				int flow = dfs(10000,edges, depth,visited, 0, v - 1,0);
				if(flow == 0){
					break;
				}
				ans += flow;
			}
		}

		System.out.println(ans);
	}

	int dfs(int flow ,E[] edges, int[]depth,boolean[] visited, int now,int to,int d){
		if(now == to){
			return flow;
		}
		long ans = 0;
		for(int ii = 0 ; ii < edges.length; ii++){
			E e =edges[ii];
			if(e.from == now && !visited[e.to] && depth[e.to] > depth[e.from] && e.cap > 0){
				visited[e.to] = true;
				
				int res = dfs(Math.min(flow,e.cap),edges,depth,visited,e.to,to,d+1);
				if(res > 0 ){
					e.cap -= res;
					edges[(ii+edges.length/2)%edges.length].cap += res;
					return res;
				}
				visited[e.to] = false;
			}
		}
		return 0;
	}
	
	
	boolean bfs(E[] edges, int[] depth, boolean[] visited, int from, int to) {

		PriorityQueue<EE> q = new PriorityQueue<>((ee1, ee2) -> Integer.compare(ee1.depth, ee2.depth));
		EE init = new EE();
		init.depth = 0;
		init.pos = from;
		q.add(init);

		for (; !q.isEmpty();) {

			EE x = q.poll();
			if (x.pos == to) {
				depth[x.pos] = x.depth;
				return true;
			}

			if (depth[x.pos] <= x.depth) {
				continue;
			}
			depth[x.pos] = x.depth;
			visited[x.pos] = true;

			for (E e : edges) {
				if (e.from == x.pos && !visited[e.to] && e.cap > 0) {
					EE ex = new EE();
					ex.depth = x.depth + 1;
					ex.pos = e.to;
					q.add(ex);
				}
			}
		}
		return false;
	}

	class EE {
		int pos;
		int depth;
	}

	class E {
		int from;
		int to;
		int cap;
	}

}


Measured memory_bytes: 38196
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define N 100100
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(x, a, b) for(int x=a; x<=b; x++)
#define drp(x, a, b) for(int x=a; x>=b; x--)
int deg[N], d[N], n, vis[N], a[N], num[N], l[N], ans=1, fac[N], inv[N];
vector<pair<int, int> > fu;
queue<int> q;
int power(int a, int k){
	int ret=1;
	while(k)
	{
		if(k&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod; k>>=1;
	}
	return ret;
}
int C(int n, int m){
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int pr(int n){
	return 1ll*fac[2*n]*inv[n]%mod*power((mod+1)>>1, n)%mod;
}
void init(){
	fac[0]=1;
	rep(i, 1, n) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=power(fac[n], mod-2);
	drp(i, n, 1) inv[i-1]=1ll*inv[i]*i%mod;
}
int main(){
	scanf("%d", &n);
	init();
	rep(i, 1, n)
	{
		scanf("%d", a+i);
		deg[a[i]]++;
	}
	rep(i, 1, n) if(deg[i]>2) return puts("0"), 0;
	rep(i, 1, n) d[i]=deg[i];
	rep(i, 1, n) if(!d[i]) q.push(i);
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		vis[u]=1;
		if(--d[a[u]]==0) q.push(a[u]);
	}
	rep(i, 1, n) if(vis[i] && deg[i]>1) return puts("0"), 0;
	rep(i, 1, n) if(vis[i] && !deg[i])
	{
		int x=i, cnt=0;
		for(; vis[x]; x=a[x]) cnt++;
		l[x]=cnt;
	}
	rep(i, 1, n) if(!vis[i])
	{
		int x=i, fl=0, ass=1, tot=0;
		for(; !vis[x]; x=a[x]) ++tot, fl|=bool(l[x]), vis[x]=1;
		if(!fl){ num[tot]++; continue; }
		fu.clear();		
		int p=1; x=i;
		do{
			if(l[x]) fu.pb(mp(l[x], p));
			x=a[x]; p++;
		}while(x!=i);
		fu.pb(mp(fu[0].fi, fu[0].se+tot));
		int sz=fu.size();
		rep(j, 1, sz-1)
		{
			if(fu[j].fi>fu[j].se-fu[j-1].se) ass=0;
			if(fu[j].fi<fu[j].se-fu[j-1].se) ass=2ll*ass%mod;
		}
		ans=1ll*ans*ass%mod;
	}
	rep(i, 1, n) if(num[i])
	{
		int m=num[i], ass=0;
		rep(j, 0, m/2)
		{
			int tmp=1ll*C(m, 2*j)*pr(j)%mod*power(i, j)%mod;
			if(i>1 && (i&1)) tmp=1ll*tmp*power(2, m-2*j)%mod;
			ass=(ass+tmp)%mod;
		}
		ans=1ll*ans*ass%mod;
	}
	printf("%d\n", ans);
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int x,y; cin >> x >> y;
	int ans = 2e9+3;
	if(x <= y) ans = min(ans,y-x);
	if(-x <= y) ans = min(ans,x+y+1);
	if(x <= -y) ans = min(ans,-y-x+1);
	if(-x <= -y) ans = min(ans,-y+x+2);
	cout << ans << endl;
}


Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: i, n, res, fact(1000)
  integer(8), parameter :: md = 1000000007
  read(*, *) n

  fact(:) = 0
  do i = 1, n
    call factorial(i, fact)
  end do

  res = 1
  do i = 1, n
    res = mod(res * (fact(i) + 1), md)
  end do
  write(*, "(i0)") res

  contains

  subroutine factorial(n, fact)
    implicit none
    integer(8), intent(in) :: n
    integer(8), intent(inout) :: fact(:)
    integer(8) :: rest, i
    rest = n
    i = 2
    do while (i <= rest)
      if (mod(rest, i) == 0) then
        rest = rest / i
        fact(i) = fact(i) + 1
      else
        i = i + 1
      end if
    end do
  end subroutine factorial
end


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Trunk Road
 */
public class Main {

	static final int INF = 1 << 29;

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

		line = br.readLine();

		int H, W;
		H = parseInt(line.substring(0, line.indexOf(' ')));
		W = parseInt(line.substring(line.indexOf(' ') + 1));

		int[][] map = new int[H][W];

		for (int i = 0; i < H; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int j = 0; j < W; j++) {
				map[i][j] = parseInt(st.nextToken());
			}
		}

		int ans = INF;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				int sum = 0;
				for (int m = 0; m < H; m++) {
					for (int n = 0; n < W; n++) {
						sum += Math.min(Math.abs(i - m), Math.abs(j - n)) * map[m][n];
					}
				}
				ans = Math.min(ans, sum);
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 25272
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#include <cmath>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> i_i;


int main(){
    string S;
    int n;
    cin >> S >> n;
    int a=0,b=0;
    vector<int> cal1(1000),cal2(1000);
    int c1=0,c2=0;
    for (int i=0; i<S.length(); i++) {
        if (S[i]=='+') {
            int c = cal1[c1];
            int num = c + (int)S[i+1]-(int)'0';
            cal1[c1]=num;
            i++;
            continue;
        }
        if (S[i]=='*') {
            int a = cal1[c1];
            int num = a *((int)S[i+1]-(int)'0');
            cal1[c1]=num;
            i++;
            continue;
        }
        c1++;
        cal1[c1]= (int)S[i]-(int)'0';
    }
    a = cal1[c1];
    for (int i=0; i<S.length(); i++) {
        if (S[i]=='+') {
            c2++;
            cal2[c2]=-1;
            continue;
        }
        if (S[i]=='*') {
            int a = cal2[c2];
            int num = a *((int)S[i+1]-(int)'0');
            cal2[c2]=num;
            i++;
            continue;
        }
        c2++;
        cal2[c2] = (int)S[i]-(int)'0';
    }
    while (c2>0) {
        if(cal2[c2]!=-1) {
            b+= cal2[c2];
        }
        c2--;
    }
    if (a==n and b == n) {
        cout <<"U"<<endl;
    }else{
        if (b==n) {
            cout << "M"<<endl;
        }else{
            if (a==n) {
                cout << "L"<<endl;
            }else{
                cout << "I"<<endl;
            }
        }
    }
}

Measured memory_bytes: 1212
#include <iostream>
#include <stdio.h>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;

int cal_GCD(int x, int y){
  int a,b,c;
  if(x>y){
    a = x;
    b = y;
  }else{
    a = y;
    b = x;
  }
  while(b>0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

int main(){
  int x,y;
  scanf("%d %d", &x, &y);
  cout << cal_GCD(x,y) << endl;
}



Measured memory_bytes: 3216
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 c = sc.nextInt();

		sc.close();

		int ans = 0;
		int a2, b2, c2;

		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			if (a == b && b == c) {
				ans = -1;
				break;
			}

			a2 = b / 2 + c / 2;
			b2 = a / 2 + c / 2;
			c2 = a / 2 + b / 2;

			a = a2;
			b = b2;
			c = c2;

			ans++;
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 35624
// ---------- begin chmin, chmax ----------
trait ChangeMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}

impl<T: PartialOrd> ChangeMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
// ---------- end chmin, chmax ----------

use proconio::*;
use std::cmp::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        p: [(i64, i64, i64); n],
    }
    let mut cost = vec![0; 1 << n];
    for (i, cost) in cost.iter_mut().enumerate().skip(1) {
        let mut q = vec![];
        for (j, &(x, y, p)) in p.iter().enumerate() {
            if (i >> j) & 1 == 1 {
                q.push((x, y, p));
            }
        }
        let mut val = std::i64::MAX;
        for &(z, _, _) in q.iter() {
            let mut s = 0;
            for &(x, y, p) in q.iter() {
                s += min(x.abs(), min(y.abs(), (z - x).abs())) * p;
            }
            val.chmin(s);
        }
        for &(_, z, _) in q.iter() {
            let mut s = 0;
            for &(x, y, p) in q.iter() {
                s += min(x.abs(), min(y.abs(), (z - y).abs())) * p;
            }
            val.chmin(s);
        }
        *cost = val;
    }
    let mut dp = vec![std::i64::MAX / 2; 1 << n];
    dp[(1 << n) - 1] = 0;
    let ini = p.iter().map(|&(x, y, p)| min(x.abs(), y.abs()) * p).sum::<i64>();
    println!("{}", ini);
    for i in (1..=n).rev() {
        for bit in (1usize..(1 << n)).filter(|p| p.count_ones() as usize <= i) {
            let v = dp[bit];
            let mut j = bit;
            while j > 0 {
                let x = bit ^ j;
                dp[x].chmin(v + cost[j]);
                j = (j - 1) & bit;
            }
        }
        println!("{}", dp[0]);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 2508
i=61,c=100,f[],m,x,s;main(y){for(;s?++f[y*12+x+"=>?2J13IK<@V&"[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:++i<180?i%12>1?m=fmax(m,f[i]),f[i]?c--:1:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
N=int(input())
if N<=9:
    print(N)
elif 10<=N<=99:
    print(9)
elif 100<=N<=999:
    print(N-90)
elif 1000<=N<=9999:
    print(909)
elif 10000<=N<=99999:
    print(N-9090)
else:
    print(90909)

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

int main() {
  int N,M,X,Y;
    cin>>N>>M>>X>>Y;
  int maxi=X;
  int mini=Y;
for(int i=0;i<N;i++){
  int x;
    cin>>x;
  if(maxi<x){
    maxi=x;
  }
}
  for(int j=0;j<M;j++){
    int y;
      cin>>y;
    if(y<mini){
      mini=y;
    }
  }
  if(maxi<mini){
    cout<<"No War"<<endl;
  }
  else{
    cout<<"War"<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct p
{
    int num;
    int p;
    int state[20];
} a[20];
int w[20],n,m,ans=0;
void check()
{
    int flag=1;
    for(int i=1;i<=m;i++)
    {
        int sum=0;
        for(int j=1;j<=a[i].num;j++)
            if(w[a[i].state[j]])
                sum++;
        if(sum%2!=a[i].p)
        {
            flag=0;
            break;
        }
    }
    if(flag)
        ans++;
}
void dfs(int x)
{
    if(x==n+1)
    {
        check();
        return ;
    }
    for(int i=0;i<=1;i++)
    {
        w[x]=i;
        dfs(x+1);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&a[i].num);
        for(int j=1; j<=a[i].num; j++)
            scanf("%d",&a[i].state[j]);
    }
    for(int i=1;i<=m;i++)
        scanf("%d",&a[i].p);
    dfs(1);
    printf("%d",ans);
    return 0;
}


/*
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
*/


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

int main(){
  string S; cin >> S;
  sort(S.begin(),S.end());
  if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) cout << "Yes";
  else cout << "No";
}

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

int main(){
  int count=0;
  int color;
  
  vector<int> vec(4);
  for(int i=0; i<3; i++){
    cin >> vec.at(i); 
  }
  for(int i=0; i<2; i++){
    for(int j=0; j<3; j++){
      if(i<j && vec.at(i) == vec.at(j)){
      count += 1;
      }
    }
  }
  if(3-count == 0){
    color=1;
  }
  else{
    color=3-count;
  }
    
  cout << color << endl;
}

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

ten = [0]*20
nin = [0]*20
egt = [0]*20

for i in range(0,20):
    a = (10 ** (2**i)) % (10**9 +7)
    ten[i] = a

for i in range(0,20):
    a = (9 ** (2**i)) % (10**9 +7)
    nin[i] = a

for i in range(0,20):
    a = (8 ** (2**i)) % (10**9 +7)
    egt[i] = a

l = bin(n)
m = len(l)
tens   = 1
nines  = 1
eights = 1
for i in range(0,m-2):
    if l[i+2] == '1':
        tens = (tens*ten[m-3-i])%(10**9 + 7)

for i in range(0,m-2):
    if l[i+2] == '1':
        nines = (nines*nin[m-3-i])%(10**9 + 7)

for i in range(0,m-2):
    if l[i+2] == '1':
        eights = (eights*egt[m-3-i])%(10**9 + 7)

ans = (tens - nines*2 + eights)%(10**9 + 7)
print(ans)

Measured memory_bytes: 9996
import java.util.*;
public class Main {
	public static void main(String[] args){
    
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double d = sc.nextDouble();
		double t = sc.nextDouble();
		double s = sc.nextDouble();
		
    
    /*--------------------------------*/
   if(t >= d/s){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }
	

	}
}



Measured memory_bytes: 37184
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr uint64_t INF = 1e18;

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

  int64_t A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  if (A <= B) {
    int64_t btgt = B + W * T;
    int64_t atgt = A + V * T;
    if (atgt >= btgt) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    int64_t btgt = B - W * T;
    int64_t atgt = A - V * T;
    if (atgt <= btgt) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string a;
    cin >> a;
    if (a[0] == a[1] && a[1] == a[2] || a[1] == a[2] && a[2] == a[3]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        List<Integer> primes = primeList(200);

        int N = scanner.nextInt();

        int[] nums = new int[201];

        for(int i=1; i<=200; i++){
            for(int j=1; j<=i; j++){
                if(i%j == 0){
                    nums[i]++;
                }
            }
        }

        int cnt = 0;
        for(int i=1; i<=N; i+=2){
            if(nums[i] == 8){
                cnt++;
            }
        }

        System.out.println(cnt);


    }

    static List<Integer> primeList(int n) {
        List<Integer> list = new ArrayList<>();
        boolean[] prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 2; i < Math.sqrt(n); i++) {
            if (!prime[i]) continue;
            for (int j = 2; i * j <= n; j++) {
                prime[i * j] = false;
            }
        }
        for (int i = 0; i < prime.length; i++) {
            if (prime[i]) list.add(i);
        }

        return list;
    }
}


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

int main(){
    int N;
    cin >> N;
    for (int i=0; i <= N/4+1; i++){
        for (int j=0; j <= N/7+1; j++){
            if (i*4 + j*7 == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double real;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
static inline ll mod_inv(ll a, ll p){ return pow_mod(a,p-2,p); }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
static const int Mod = 1000000000;

int main()
{
  map<string, int> cnt;
  string word;
  while (cin >> word){
    cnt[word]++;
  }
  int freq, length;
  string freq_s, length_s;
  length = freq = -1;
  for (const auto& v : cnt){
    if (freq < v.second){
      freq = v.second;
      freq_s = v.first;
    }
    if (length < (int)v.first.size()){
      length = v.first.size();
      length_s = v.first;
    }
  }
  cout << freq_s << " " << length_s << endl;
  return (0);
}

// priority_queue queue deque first second front top push pop map set stringstream max_element min_element insert count find

Measured memory_bytes: 1196
n, m = list(map(int, input().split()))
k, s = [], []

for i in range(m):
  tmp = list(map(int, input().split()))
  k.append(tmp[0])
  s.append(tmp[1:])

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

count = 0

for i in range(1<<n):
  tmp = [0] * m
  for j in range(n):
    if i & (1<<j):
      for k in range(m):
        if j+1 in s[k]:
          tmp[k] += 1
  c = 0
  for i in range(m):
    if tmp[i] % 2 == p[i]:
      c += 1
  if c == m:
    count += 1

print(count)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int a[5],b[5],i,j,t,mt,sum=0;
	for(i=0;i<5;i++)
		scanf("%d",&a[i]);
	for(i=0;i<5;i++)
	{
		b[i]=a[i]%10;
		sum=sum+a[i]-b[i];
	}
	for(i=0;i<4;i++)
	{
		for(j=i+1;j<5;j++)
		{
			if(b[i]<b[j])
			{
				t=b[j];
				b[j]=b[i];
				b[i]=t;
			}
		}
	}
	for(i=0;i<4;i++)
	{
		if(b[i+1]==0)
		{
			mt=sum+10*i+b[i];
			break;
		}
		else
			mt=sum+40+b[4];
	}
	printf("%d\n",mt);
	return 0;
}













Measured memory_bytes: 128