akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int gcd2(int A, int B)
{
    if(A > B) return gcd2(B, A);
    int r = B % A;
    if(r == 0) return A;
    else return gcd2(r, A);
}

int gcd3(int A, int B, int C)
{
    return gcd2(C, gcd2(A, B));
}

int main()
{
    int K, ans = 0;
    cin >> K;
    for(int i = 1; i < K + 1; ++i)
    {
        for(int j = 1; j < i + 1; ++j)
        {
            for(int k = 1; k < j + 1; ++k)
            {
                if(i == j && j == k) ans += gcd3(i, j, k);
                else if(i != j && j != k && k != i) ans += gcd3(i, j, k) * 6;
                else ans += gcd3(i, j, k) * 3;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        ll N=s.size();
        ll ans=N;
        for(ll i=0;i<N;i++){
            if(s[i]==t[i])
                ans--;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3812
/* ex6_2
    suuxxu */

#include <stdio.h>
#include <string.h>

#define SIZE 101

int main(void){
    int length;
    char word[SIZE];

    // get input
    scanf("%s", word); // s

    length = (int)strlen(word);

    // output answer
    printf("%c", word[0]);
    printf("%d", length - 2);
    printf("%c\n", word[length - 1]);

    return 0;
}

Measured memory_bytes: 128
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9) + 7

n=int(data())
a = mdata()
N=10**6 + 1
lpf = [0 for i in range(N)]
mobius = [0 for i in range(N)]


# Function to calculate least
# prime factor of each number
def least_prime_factor():
    for i in range(2, N):

        # If it is a prime number
        if (lpf[i] == 0):

            for j in range(i, N, i):

                # For all multiples which are not
                # visited yet.
                if (lpf[j] == 0):
                    lpf[j] = i

                # Function to find the value of Mobius function


# for all the numbers from 1 to n
def Mobius():
    for i in range(1, N):

        # If number is one
        if (i == 1):
            mobius[i] = 1
        else:

            # If number has a squared prime factor
            if (lpf[(i // lpf[i])] == lpf[i]):
                mobius[i] = 0

            # Multiply -1 with the previous number
            else:
                mobius[i] = -1 * mobius[i // lpf[i]]

            # Function to find the number of pairs


# such that gcd equals to 1
def gcd_pairs(a, n):
    # To store maximum number
    maxi = 0

    # To store frequency of each number
    fre = [0 for i in range(N)]

    # Find frequency and maximum number
    for i in range(n):
        fre[a[i]] += 1
        maxi = max(a[i], maxi)

    least_prime_factor()
    Mobius()

    # To store number of pairs with gcd equals to 1
    ans = 0

    # Traverse through the all possible elements
    for i in range(1, maxi + 1):
        if (mobius[i] == 0):
            continue

        temp = 0
        for j in range(i, maxi + 1, i):
            temp += fre[j]

        ans += temp * (temp - 1) // 2 * mobius[i]

        # Return the number of pairs
    return ans


# Driver code


# Function call
g=a[0]
for i in range(n):
    g=math.gcd(g,a[i])
    if g==1:
        break
if gcd_pairs(a, n) == (n*(n-1))//2:
    out("pairwise coprime")
elif g==1:
    out("setwise coprime")
else:
    out("not coprime")

Measured memory_bytes: 256804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A,B;
    cin >> A >> B;
    int N = A.size();
    if(count(B.begin(),B.end(),'1')==0){
        cout << (count(A.begin(),A.end(),'1')==0? 0:-1) << "\n";
        return 0;
    }
    vec<int> L(N),R(N);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) if(B[(i+j)%N]=='1'){
            R[i] = j;
            break;
        }
        for(int j=0;j<N;j++) if(B[(i-j+N)%N]=='1'){
            L[i] = j;
            break;
        }
    }

    int inf = 1e9;
    auto calc = [&](vec<int>& l,vec<int>& r,int br){
        map<int,int> ml,mr;
        int n = l.size();
        if(!n) return br;
        for(int i=0;i<n;i++){
            if(ml.count(l[i])) ml[l[i]] = max(ml[l[i]],r[i]);
            else ml[l[i]] = r[i];
        }
        int ans = br-ml.begin()->first;
        int rmax = br;
        for(auto& [a,b]:ml){
            ans = min(ans,rmax-a);
            rmax = max(rmax,b);
        }
        return ans;
    };

    int ans = inf;
    for(int j=0;j<=N;j++){
        int now = j;
        vec<int> l,r;
        for(int i=0;i<N;i++){
            if(A[i]!=B[(i+j)%N]){
                now++;
                if(L[i]>0 && j<R[i]){
                    l.push_back(-L[i]);
                    r.push_back(R[i]);
                }
            }
        }
        now += 2*(calc(l,r,j)-j);
        ans = min(ans,now);
    }

    for(int j=0;j<=N;j++){
        int now = j;
        vec<int> l,r;
        for(int i=0;i<N;i++){
            if(A[i]!=B[(i-j+N)%N]){
                now++;
                if(j<L[i] && R[i]>0){
                    l.push_back(-R[i]);
                    r.push_back(L[i]);
                }
            }
        }
        now += 2*(calc(l,r,j)-j);
        ans = min(ans,now);
    }
    cout << ans << "\n";
}

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

using ll = long long;

vector<ll> calc(ll n)
{
    vector<ll> ans;
    for(ll i=1;i<=n;i++)
    {
        if(n/i<i)break;
        if(n%i==0)
        {
            ll num=n/i;
            ans.push_back(num);
            ans.push_back(i);
        }
    }

    return ans;
}

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

    ll n;cin>>n;

    vector<ll> v=calc(n);

    ll ans=0;
    for(auto iv:v)
    {
        if(n/iv<iv-1)ans+=iv-1;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int seiyaku_check(double i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	string s;
	cin >> s;
	
	if(s == "Sunny")cout << "Cloudy" << endl;
	if(s == "Cloudy")cout << "Rainy" << endl;
	if(s == "Rainy")cout << "Sunny" << endl;
	
return 0;
}


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

int n, x[100010], l, q, a, b, dp[100010][20];

int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &x[i]);
    scanf("%d", &l);
    for(int i = n-1; i >= 0; i--) {
        int L = i, R = n;
        while(L + 1 < R) {
            int M = (L + R)/2;
            if(x[M] - x[i] > l) R = M;
            else L = M;
        }
        dp[i][0] = L;
    }
    for(int j = 1; (1<<j) < n; j++) {
        for(int i = 0; i < n; i++) {
            if(dp[i][j-1] != -1) dp[i][j] = dp[dp[i][j-1]][j-1];
        }
    }
    scanf("%d", &q);
    while(q--) {
        scanf("%d%d", &a, &b); int ans = 0;
        if(a > b) swap(a, b);
        a--, b--;
        for(int i = 19; i >= 0; i--) {
            if(dp[a][i] != -1 && x[dp[a][i]] < x[b]) ans += (1<<i), a = dp[a][i];
        }
        printf("%d\n", ans+1);
    }
}


Measured memory_bytes: 9088
import java.util.*;

public class Main {
  public static long MOD = (long)Math.pow(10, 9) + 7;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    
    long[] kai = new long[(int)(2 * n)];
    kai[0] = 1;
    for(int i = 1; i < (int)(2 * n); i++) {
      kai[i] = (i * kai[i - 1]) % MOD;
    }
    // comb[i] = (n + i - 1, n - 1)
    long[] comb = new long[(int)n];
    for(int i = 0; i < (int)n; i++) {
      long t1 = func(kai[(int)n - 1], MOD - 2);
      long t2 = func(kai[i], MOD - 2);
      long t3 = (kai[(int)n + i - 1] * t1) % MOD;
      t3 = (t3 * t2) % MOD;
      comb[i] = t3;
    }
    long inv = func(a + b, MOD - 2);
    long pa = (a * inv) % MOD;
    long pb = (b * inv) % MOD;
    long ans = 0;
    for(int i = 0; i < (int)n; i++) {
      long q1 = func(pa, n);
      long q2 = func(pb, i);
      long r1 = func(pa, i);
      long r2 = func(pb, n);
      long p1 = (q1 * q2) % MOD;
      long p2 = (r1 * r2) % MOD;
      long p3 = (p1 + p2) % MOD;
      long t = (comb[i] * p3) % MOD;
      t = (t * (n + i)) % MOD;
      ans = (ans + t) % MOD;
    }
    long s = func(100 - c, MOD - 2);
    ans = (ans * 100) % MOD;
    ans = (ans * s) % MOD;
    System.out.println(ans);
  }
  
  public static long func(long a, long x) {
    if(x == 0) {
      return 1;
    } else {
      if(x % 2 == 0) {
        long t = func(a, x / 2);
        return (t * t) % MOD;
      } else {
        return (a * func(a, x - 1)) % MOD;
      }
    }
  }
}

Measured memory_bytes: 27420
// g++ -std=c++14

/*
     
    Today might be the chance to grasp the chance to let your talent bloom.
    May be tomorrow, the day after, or next year...
    May be even when you are 30. I'm not sure if physique has anything to do with it
    but if you think that it will never come, it probably never will.
     
    - Tooru Oikawa.
     
    */

#include <bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define MEMS(a, b) memset(a, b, sizeof(a))
#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define __                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define all(c) c.begin(), c.end()
#define inf 1000000000000000001
#define pii pair<int, int>
#define tr(...)                                       \
    cout << __FUNCTION__ << ' ' << __LINE__ << " = "; \
    trace(#__VA_ARGS__, __VA_ARGS__)

template <typename S, typename T>
ostream &operator<<(ostream &out, pair<S, T> const &p)
{
    out << '(' << p.fi << ", " << p.se << ')';
    return out;
}

template <typename T>
ostream &operator<<(ostream &out, vector<T> const &v)
{
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++)
        out << v[i] << ' ';
    if (l > 0)
        out << v[l - 1];
    return out;
}

template <typename T>
void trace(const char *name, T &&arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args>
void trace(const char *names, T &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    trace(comma + 1, args...);
}

#define int ll

void solve()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1 ; i <= n ; i++) {
        if(i%15 != 0 and i%3 != 0 and i%5 != 0) ans += i;
    }
    cout << ans << endl;

}
int32_t main()
{
    _
        ll t;
    // cin >> t;
    t = 1;
    while (t--)
        solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
ll f[514][514],isj[514],icnt[514],allj[514];
signed main(){
	int n;
	cin>>n;
	int c = 0;
	for(int i=0;i<n;i++){
		string st;
		cin>>st;
		for(int j=0;j<n;j++){
			if(st[j]=='#'){ f[i][j]=1; c++; isj[j]=1; icnt[i]++;}
			else{ allj[j]=1; }
		}
	}
	if( c == 0 ){
		cout<<-1<<endl;
		return 0;
	}
	ll ans = 0;
	for(int i=0;i<n;i++){
		ans += allj[i]-1;
	}
	vector<int> v;
	for(int i=0;i<n;i++){
		v.pb( n-icnt[i]+(1-isj[i]) );
	}
	sort(v.begin(),v.end());
	ans += v[0];
	ans += n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M, K;
    cin >> N >> M >> K;
    vl A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    vl bcc(M + 1);
    rep(i, M) bcc[i + 1] += bcc[i] + B[i];

    ll sum = 0, ans = upper_bound(all(bcc), K) - bcc.begin() - 1;
    rep(i, N){
        sum += A[i];
        if (sum > K) break;
        ll b = upper_bound(all(bcc), K - sum) - bcc.begin() - 1;
        chmax(ans, i + 1 + b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k);
	
	if(k == 1) printf("0\n");
	else printf("%d\n", n - k);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 998244353
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
int main()
{
    fastio;
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=10000;i++)
    {
        int f = i*8;
        f/=100;
        int s = i*10;
        s/=100;
        if(f==a && b==s)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a[4][13],i,j,k,x,n;
  char m;
  
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      a[i][j]=0;
    }
  }
 
  scanf("%d",&n);
  
  for(k=0;k<n;k++){
    scanf(" %c%d",&m,&x);
    if(m=='S')a[0][x-1]=1;
    else if(m=='H')a[1][x-1]=1;
    else if(m=='C')a[2][x-1]=1;
    else if(m=='D')a[3][x-1]=1;
  }
   
  
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(a[i][j]==0){
	if(i==0)printf("S %d\n",j+1);
      else if(i==1)printf("H %d\n",j+1);
      else if(i==2)printf("C %d\n",j+1);
      else if(i==3)printf("D %d\n",j+1);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int n,nr,nra,nrb,i,a,b,Viz[20];

void solve(int n, int a, int b)
{
    if(n==1)
    {
        cout<<a<<" "<<b<<" ";
        return;
    }
    int i,fb=0,sb=0;
    for(i=0; i<nr; i++)
        if(((((1<<i)&a)!=0)^(((1<<i)&b)!=0))==1)
        {
            fb=i;
            break;
        }
    Viz[fb]=1; //daca pun un bit facut deja 1 atunci o sa-i anuleze efectul si
               //o sa am repretitii
    for(i=0; i<nr; i++)
        if(!Viz[i])
        {
            sb=i;
            break;
        }
    solve(n-1,a,a^(1<<sb));
    solve(n-1,a^(1<<sb)^(1<<fb),b);
    Viz[fb]=0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n>>a>>b;
    for(i=0; i<n; i++)
        if(a&(1<<i))
            nra++;
    for(i=0; i<n; i++)
        if(b&(1<<i))
            nrb++;
    if(nra%2==nrb%2) //paritatile alterneaza
    {
        cout<<"NO\n";
        return 0;
    }
    cout<<"YES\n";
    nr=n;
    solve(n,a,b);
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let m = get();
    let mut x: Vec<i64> = vec![0; n];
    let mut y: Vec<i64> = vec![0; n];
    let mut z: Vec<i64> = vec![0; n];
    for i in 0 .. n {
        x[i] = get();
        y[i] = get();
        z[i] = get();
    }
    let mut ma = 0;
    for a in [-1, 1].iter() {
        for b in [-1, 1].iter() {
            for c in [-1, 1].iter() {
                let mut iroha = vec![0; n];
                for i in 0 .. n {
                    iroha[i] = a * x[i] + b * y[i] + c * z[i];
                }
                iroha.sort();
                iroha.reverse();
                let mut tot = 0;
                for i in 0 .. m {
                    tot += iroha[i];
                }
                ma = max(ma, tot);
            }
        }
    }
    println!("{}", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

map <string,bool> m;
int k,i,j;
string s; 

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>s;
	cin >>k;
	int l=s.size();
	if (l>5) l=5;
	for (i=1;i<=l;i++)
	{
		for (j=0;j+i-1<s.size();j++)
		{
			m[s.substr(j,i)]=true;
		}
	}
	map <string,bool>::iterator it=m.begin();
	for (i=1;i<k;i++) it++;
	cout <<it->first<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 1920
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n % 10 == 7 || ((n / 10) % 10 == 7) || ((n / 100) % 100 == 7))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
#include <stdio.h>
using namespace std;

int main()
{
    int x, i = 1, max = 1;
    scanf("%d", &x);
    while(true) {
        if((i+1)*(i+1) <= x)i++;
        else break;
    }

    while(i > 1){
        int pro = i*i;
        while(true){
            if(pro*i <= x) pro *= i;
            else break;
        }
        if(max < pro) max = pro;
        i--;
    }

    printf("%d", max);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	static long f(long A) {
		if(A % 4 == 0) return A;
		if(A % 4 == 1) return 1;
		if(A % 4 == 2) return A + 1;
		return 0;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong(), B = sc.nextLong();
		System.out.println(f(B) ^ f(A - 1));
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int n,ans;
string s;
bool OK(int m) {
    map<string,int> d;
    for(int i=1;i<=n+1-m;i++) {
        string str=s.substr(i-1,m);
        if(d.count(str)) {
            if(i-d[str]>=m) return true;
        } else
            d[str]=i;
    }
    return false;
}
int main() {
    cin>>n>>s;
    int l=0,r=n/2;
    while(l<=r) {
        int mid=l+(r-l)/2;
        if(OK(mid))
            l=mid+1,ans=mid;
        else r=mid-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6668
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;




int main(){
  int N;
  while(cin >> N){
    vector<LLI> P(N); cin >> P;

    vector<pair<int,int>> a(N);
    REP(i,N){
      a[i] = make_pair(P[i],i);
    }
    sort(RALL(a));
    
    set<int> s;
    LLI ans = 0;

    for(auto &e : a){
      LLI p = e.fst;
      int i = e.snd;

      dump(s);

      if(s.size()){

        LLI l1,l2,r1,r2;

        {
          auto it = s.upper_bound(i);
          if(it == s.end()) r1 = N;
          else r1 = *it;

          auto it2 = s.upper_bound(r1);
          if(it2 == s.end()) r2 = N;
          else r2 = *it2;
        }

        {
          auto it = s.upper_bound(i);
          if(it == s.begin()){
            l1 = -1;
          }
          else{
            it = prev(it);
            l1 = *it;
          }

          auto it2 = s.lower_bound(l1);
          if(it2 == s.begin()) l2 = -1;
          else{
            it2 = prev(it2);
            l2 = *it2;
          }
        }

        dump(l1,l2,r1,r2);
      
      
        ans += p * ((r1-i) * (l1-l2) + (i-l1) * (r2-r1));
        //ans += p * (r1-l1-1) * (l1-l2+r2-r1);
      }

      s.insert(i);
    }
    


    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 6528
def abc071_d():
    N = int(input())
    S1 = str(input())
    S2 = str(input())
    MOD = 10**9 + 7
    if len(S1) == 1: return 3

    ans, sidx, prev = -1, -1, -1
    if S1[0] == S1[1]:  # 横
        ans = 6
        sidx = 2
        prev = 2
    else:  # 縦
        ans = 3
        sidx = 1
        prev = 1

    if N <= sidx: return ans
    S = S1 + '_'

    for i in range(sidx, N):
        if S[i-1] == S[i]:  # 横置きの2つ目
            continue
        if S[i] == S[i+1]:  # 横
            if prev == 1: x = 2
            else: x = 3
            prev = 2
        else:  # 縦
            if prev == 1: x = 2
            else: x = 1
            prev = 1
        ans = ans * x % MOD
    return ans

if __name__ == '__main__':
    print(abc071_d())

Measured memory_bytes: 9236
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <functional>

const int32_t sig[3][8] = 
    {{1,-1,1,-1,1,-1,1,-1},
    {1,1,-1,-1,1,1,-1,-1},
    {1,1,1,1,-1,-1,-1,-1} };

using cake_vect_type = std::vector<std::vector<int64_t>>; 

void calc_score(int64_t x, int64_t y, int64_t z, cake_vect_type& cakes, int32_t n){
    for(int32_t i = 0; i < 8; i++){
        cakes[i][n] = sig[0][i] * x + sig[1][i] * y + sig[2][i] * z;
    }
    return;
}


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

    int32_t N, M;
    std::cin >> N >> M;

    cake_vect_type cake_vec(8,std::vector<int64_t>(N, 0));
    for(int32_t n = 0; n < N; n++){
        int64_t x,y,z;
        std::cin >> x >> y >> z;
        calc_score(x, y, z, cake_vec, n);
    }

    //NlogN x 8
    for(int32_t i = 0; i < 8; i++){
        std::sort(cake_vec[i].begin(), cake_vec[i].end(), std::greater<>());
    }

    int64_t max = 0;
    for(int32_t i = 0; i < 8; i++){
        int64_t max_candiate = 0;
        for(int32_t j = 0; j < M; j++){
            max_candiate += cake_vec[i][j];
        }
        max = std::max(max, max_candiate);
    }

    std::cout << max << std::endl;
    return 0;

}


Measured memory_bytes: 384
def BubbleSort(C,N):
  for _ in C:
    for i in range(len(C)-1, 0, -1):
      if C[i][-1:] < C[i-1][-1:]:
        C[i], C[i-1] = C[i-1], C[i]
  return C

def SelectionSort(C,N):
  for i in range(len(C)):
    min_pos = i
    for j in range(i+1, len(C)):
      if int(C[j][-1]) < int(C[min_pos][-1]):
        min_pos = j
    C[i], C[min_pos] = C[min_pos], C[i]
  return C

N = int(raw_input())
card = map(str, raw_input().split())

card0 = card
card1 = card[:]
card0 = BubbleSort(card0,N)
card1 = SelectionSort(card1,N)

print ' '.join(card0)
print "Stable"
print ' '.join(card1)
if card0 == card1:
  print "Stable"
else:
  print "Not stable"


Measured memory_bytes: 4684
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  long long N;
  long long K;
  long long S;
  cin >> N >> K >> S;
 
  long long num = 0LL;
  
  long long num2;
  
  vector<long long> A(N);
  
  if(!(S == 1e9 || K == 0)){
    for(long long i = 0LL;i < N;++i){
      A[i] = 0;
    }
  
    for(long long i = 0LL;i < N;++i){
      if(num < K || num == 0){
        A[i] = S;
        num++;
      }
      else{
        A[i] = 1e9;
      }
    }
  
    for(long long i = 0LL;i < N;++i){
      cout << A[i] << " ";
    }
  }
  else if(!(K == 0)){
    for(long long i = 0LL;i < N;++i){
      A[i] = 0;
    }
  
    for(long long i = 0LL;i < N;++i){
      if(num < K || num == 0){
        A[i] = S;
        num++;
      }
      else{
        A[i] = 1;
      }
    }
  
    for(long long i = 0LL;i < N;++i){
      cout << A[i] << " ";
    }
  }
  else{
    for(long long i = 0LL;i < N;++i){
      A[i] = S - 1;
      cout << A[i] << " ";
    }
  }
}


Measured memory_bytes: 2048
<?php

fscanf(STDIN, "%d", $n);

fscanf(STDIN, "%s", $temp);
$map = str_split($temp);
$memory = [];
$ans = [];
for($i=0;$i<$n-2;$i++){
    $hundreds =$map[$i];
    if(isset($memory[$hundreds][10])){
        continue;
    }else{
        $memory[$hundreds][10] = 1;
    }
    for($j=$i+1;$j<$n-1;$j++){
        $ten = $map[$j];
        if(isset($memory[$hundreds][$ten][10])){
            continue;
        }else{
            $memory[$hundreds][$ten][10] = 1;
        }
        for($k = $j+1;$k<$n;$k++){
            $one = $map[$k];
            $answer = $hundreds * 100 + $ten * 10 + $one;
            if(isset($ans[$answer])){
                continue;
            }else{
                $ans[$answer] = 1;
            }
        }
    }
}

echo count($ans);


Measured memory_bytes: 6648
import java.util.*;
class Main {
	public static void main(String[] args) {
		int big=20;
		int sml=19;
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[][] dat=new int[n][3];
		int[] ans=new int[n];
		for (int i=0;i<dat.length;i++){
			for(int j=0;j<3;j++){
				dat[i][j]=scn.nextInt();
			}
			int cnt=dat[i][0]+1;
			int bcnt=0;
			int scnt=0;
			int a=0;
			if(dat[i][1]%2==0){
				if(dat[i][0]%3==0){a++;}
				for(int d=dat[i][2];d<=sml;d++) a++;
			}else{
				for(int d=dat[i][2];d<=big;d++) a++;
			}
			for(int m=dat[i][1]+1;m<=10;m++){
				if(m%2==0&&dat[i][0]%3!=0){scnt++;}
				else{bcnt++;}
			}
			while(cnt<1000){
				if(cnt%3==0){
					bcnt+=10;
				}else{
					bcnt+=5;
					scnt+=5;
				}
				cnt++;
			}
			ans[i]=bcnt*big+scnt*sml+a;
		}

		for(int i=0;i<ans.length;i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 27032
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	long long int  a, b = 0, c = 0, count = 0, ans = 0, n = 0, h = 0, l = 0, d = 0, e = 0, f = 0, g = 0, m, v, p, k;
	string s, t;
	cin >> a >> b >> k;
	if (a <= k) {
		k -= a;
		a = 0;
		if (b > k)b -= k;
		else b = 0;
	}
	else a -= k;

	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
   int n, k;
   string s;
   cin >> n >> s >> k;
   char a = s[k-1];
   for(int i = 0; i < n; i++){
       if(s[i] != a) s[i] = '*';
       }
       
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int h, w;

void bfs(vector<vector<int>> &cnt, int i, int j){
    vector<vector<int>> chk(cnt.size(), vector<int>(cnt[0].size(), INF));
    queue<pair<int, int>> que;

    que.push(make_pair(i, j));
    chk[i][j] = 0;
    int ret = 0;

    while(!que.empty()){
        auto p = que.front();
        que.pop();
        // 上に移動を考える。
        if(p.first != 0 && cnt[p.first-1][p.second] != -1 && chk[p.first-1][p.second] == INF){
            chk[p.first-1][p.second] = min(chk[p.first][p.second]+1, chk[p.first-1][p.second]);
            que.push(make_pair(p.first-1, p.second));
            ret = max(ret, chk[p.first-1][p.second]);
        }
        // 下に移動を考える。
        if(p.first != h-1 && cnt[p.first+1][p.second] != -1 && chk[p.first+1][p.second] == INF){
            chk[p.first+1][p.second] = min(chk[p.first][p.second]+1, chk[p.first+1][p.second]);
            que.push(make_pair(p.first+1, p.second));
            ret = max(ret, chk[p.first+1][p.second]);
        }
        // 左に移動を考える。
        if(p.second != 0 && cnt[p.first][p.second-1] != -1 && chk[p.first][p.second-1] == INF){
            chk[p.first][p.second-1] = min(chk[p.first][p.second]+1, chk[p.first][p.second-1]);
            que.push(make_pair(p.first, p.second-1));
            ret = max(ret, chk[p.first][p.second-1]);
        }
        // 右に移動を考える。
        if(p.second != w-1 && cnt[p.first][p.second+1] != -1 && chk[p.first][p.second+1] == INF){
            chk[p.first][p.second+1] = min(chk[p.first][p.second]+1, chk[p.first][p.second+1]);
            que.push(make_pair(p.first, p.second+1));
            ret = max(ret, chk[p.first][p.second+1]);
        }
    }
    cnt[i][j] = ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    cin >> h >> w;
    // -1: Wall Other:Cost
    vector<vector<int>> cnt(h, vector<int>(w, 0));

    rep(i, h){
        string s;
        cin >> s;
        rep(j, w){
            if(s.at(j) == '.') cnt[i][j] = 0;
            else cnt[i][j] = -1;
        }
    }

    int ans = 0;
    rep(i, h){
        rep(j, w){
            if(cnt[i][j] == -1) continue;
            bfs(cnt, i, j);
            ans = max(ans, cnt[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[20000],b[20000];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i],a[i]-=b[i];
	sort(a+1,a+1+n,greater<int>());
	int pos=1;
	long long ans=0;
	while(pos<=n&&a[pos]>0)ans+=a[pos++];
	while(pos<=n&&!a[pos])pos++;
	while(pos<=n)ans+=a[pos++]/2;
	cout<<(ans>0?"No":"Yes")<<endl;
}

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


int main() {
  int a, b;
  cin >> a >> b;
  if (a < 10 && b < 10) {
    cout << a*b << endl;
  } else {
    cout << -1 << endl;
  }
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  string s, t, u;
  u64 a, b;
  cin >> s >> t >> a >> b >> u;

  if (s == u) {
    printf("%d %d\n", a - 1, b);
  } else if (u == t) {
    printf("%d %d\n", a, b - 1);
  }

  return 0;
}


Measured memory_bytes: 3692
import sys
input = sys.stdin.readline

def main():
    s = input()
    min_a_index = min([i for i, c in enumerate(s) if c == "A"])
    max_z_index = max([i for i, c in enumerate(s) if c == "Z"])
    print(max_z_index - min_a_index + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7208
a, b, c, d = gets.split.map(&:to_i)

lcm = c.lcm(d)

n_c = lcm / c
n_d = lcm / d
n = n_c + n_d - 1

q_a = a / lcm
q_b = b / lcm
r_a = a % lcm
r_b = b % lcm

a_to_lcm = unless r_a == 0 then n - ((r_a-1)/c + (r_a-1)/d) else n+1 end
lcm_to_b = r_b/c + r_b/d

division = a_to_lcm + (q_b - q_a - 1)*n + lcm_to_b

puts (b - a + 1) - division


Measured memory_bytes: 1788
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import numpy as np

d = ni()
c = na()
s = []

for i in range(d):
    ss = na()
    s.append(ss)

c = np.array(c) # 満足度の下がりやすさ
s = np.array(s) # i日目jコン
s_t = s.T # iコンj日目
last = np.zeros(26)

# 評価関数
# 得になった分+その日の満足度
# n: 日数, 
def eva(n, cc, ss):
    return (d-n)*cc + 20*ss

score = 0

for i in range(d): # i日目(0-indexed)
    last += 1 # 一日分追加
    tow = c * last # 満足下がる値 
    sc = -100000
    M = -1
    for j in range(26):
        k = eva(i, tow[j], s[i][j])
        if sc < k:
            sc = k
            M = j
    last[M] = 0
    score -= np.dot(c,last)
    score += s[i][M]
    print(M+1)

Measured memory_bytes: 27516
using System;
using System.Collections.Generic;

namespace LeetCodeProblem
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> numbers = GetList();

            bool isT = true;

            while(true)
            {
                if(isT)
                {
                    numbers[2] -= numbers[1];
                    if(numbers[2] <= 0)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
                else
                {
                    numbers[0] -= numbers[3];
                    if(numbers[0] <= 0)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }

                isT = isT ? false : true;
            }
        }

        private static List<int> GetList()
        {
            string[] array = Console.ReadLine().Split(" ");

            List<int> numbers = new List<int>();

            foreach(var ele in array)
            {
                numbers.Add(int.Parse(ele));
            }

            return numbers;
        }
    }
}


Measured memory_bytes: 27828
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  string a;
  cin>>a;
  if((a[0]==a[1]&&a[1]==a[2])||(a[2]==a[1]&&a[3]==a[2]))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = 1 << 15, mod = (int) 1e9 + 7;
int cnt[N][16], valid[N], dp[N], mask_in[N], out[N], in[N];
int main() {
	valid[0] = valid[3] = 1;
	int n, m;
	cin >> n >> m;
	for (int j = 0; j < m; ++j) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		out[u] |= 1 << v;
		in[v] |= 1 << u;
	}
	for (int mask = 0; mask < (1 << n); ++mask) {
		for (int v = 0; v < n; ++v)
			if (mask >> v & 1)
				mask_in[mask] |= in[v];
		for (int v = 0; v < n; ++v) if (mask >> v & 1)
			for (int u = 0; u < n; ++u)
				if (in[v] & (1 << u))
					cnt[mask][u]++;
		int ways = 1;
		for (int u = 0; u < n; ++u)
			if (~mask >> u & 1)
				ways = (LL) ways * ((1 << cnt[mask][u]) - 1) % mod;
		if (valid[mask & 3] && (mask_in[mask] & (((1 << n) - 1) ^ mask)) == (((1 << n) - 1) ^ mask)) dp[mask] = ways;
	}
	for (int mask = 1; mask < (1 << n); ++mask) {
		for (int sub = (mask - 1) & mask; sub; sub = (sub - 1) & mask) {
			if (valid[sub & 3] && (mask_in[sub] & (((1 << n) - 1) ^ mask)) == (((1 << n) - 1) ^ mask)) {
				int ways = 1;
				for (int j = 0; j < n; ++j)
					if (~sub >> j & 1)
						ways = ((LL) ways * ((1 << cnt[sub][j]) - (~mask >> j & 1))) % mod;
				dp[mask] = (dp[mask] + (LL) ways * dp[sub ^ mask]) % mod;
			}
		}
	}
	int all = 1;
	for (int j = 0; j < m; ++j) all = (all + all) % mod;
	cout << (all - dp[(1 << n) - 1] + mod) % mod << endl;
}














Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

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

	vector<int> res(n + 1, 0);
	for (int i = n; i >= 1; i--) {
		int c = 0;
		for (int j = 1; i * j <= n; j++) {
			c += res[i * j];
		}
		if (c % 2 != a[i]) {
			res[i]++;
		}
	}
	int m = accumulate(res.begin(), res.end(), 0);
	cout << m << endl;
	for (int i = 1; i <= n; i++) {
		if (res[i] == 1) {
			cout << i << endl;
		}
	}
}


Measured memory_bytes: 4844
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int a[n];
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			a[i]=s.size();
		}
		int st=0,t=0,ct=0;
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				t=t+a[j];
				if(ct==0||ct==2){
					if(t>5){
						t=0;
						ct=0;
						break;
					}
					else if(t==5){
						t=0;
						ct++;
					}
				}
				else if(ct==1||ct==3||ct==4){
					if(t>7){
						t=0;
						ct=0;
						break;
					}
					else if(t==7){
						t=0;
						ct++;
					}
				}
			}
			if(ct==5){
				st=i+1;
				break;
			}
		}
		cout<<st<<endl;
	}
    return 0;
}

Measured memory_bytes: 1204
#include<iostream>

#include<string>

using namespace std;

int main(){
  int A,B,C;

  cin>>A>>B>>C;

  if(A<=B&&B<=C){

    cout<<A<<" "<<B<<" "<<C<<endl;

  }

  else if(A<=C&&C<=B){

    cout<<A<<" "<<C<<" "<<B<<endl;

    }

  else if(B<=C&&C<=A){

    cout<<B<<" "<<C<<" "<<A<<endl;

}

  else if(B<=A&&A<=C){

    cout<<B<<" "<<A<<" "<<C<<endl;

}

  else if(C<=A&&A<=B){

    cout<<C<<" "<<A<<" "<<B<<endl;

}

  else if(C<=B&&B<=A){

    cout<<C<<" "<<B<<" "<<A<<endl;

}

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M, X, Y;
        cin >> N >> M >> X >> Y;
        vll x(N), y(M);
        rep(i, 0, N) cin >> x[i];
        rep(i, 0, M) cin >> y[i];
        ll xmx = *max_element(all(x));
        ll ymn = *min_element(all(y));
        rep(z, -100, 101) {
                if (X < z and z <= Y and xmx < z and z <= ymn) {
                        cout << "No War" << endl;
                        return 0;
                }
        }
        cout << "War" << endl;
}

Measured memory_bytes: 3608