akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;

int n, m, ans;
string vs[13];
int c[10], ca[10];
bool notZero[10];


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n, n){
        map<char, int> mp;
        m = 0; ans = 0;
        memset(c, 0, sizeof(c));
        memset(ca, 0, sizeof(ca));
        memset(notZero, 0, sizeof(notZero));
        rep(i, 0, n){
            cin >> vs[i];
            rep(j, 0, vs[i].size()){
                if(!mp.count(vs[i][j])){
                    mp[vs[i][j]] = m++;
                }
            }
            if(vs[i].size() != 1){
                notZero[mp[vs[i][0]]] = true;
            }
        }
        rep(i, 0, n){
            int tmp = 1;
            for(int j = vs[i].size() - 1; j >= 0; j--){
                if(i != n - 1) c[mp[vs[i][j]]] += tmp;
                else ca[mp[vs[i][j]]] += tmp;
                tmp *= 10;
            }
        }
        vector<int> p(10);
        rep(i, 0, 10) p[i] = i;
        do{
            bool f = true;
            int sum = 0, suma = 0;
            rep(i, 0, m){
                if(p[i] == 0 && notZero[i]){
                    f = false; break;
                }
                sum += p[i] * c[i];
                suma += p[i] * ca[i];
            }
            if(sum != suma) f = false;
            if(f) ans++;
        }while(next_permutation(p.begin(), p.end()));
        int l = 10 - m;
        int div = 1;
        rep(i, 1, l + 1) div *= i;
        cout << ans / div << endl;    
    }
}


Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=15;
const int a[N]={0,1,2,4,7,12,20,29,38,52,73};
int n,p[N];
long long g[N][N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
			p[j]=j;
		long long M=0;
		do
		{
			long long s=0;
			for(int j=1;j<i;j++)
				s+=g[p[j]][p[j+1]];
			M=max(M,s);
		}
		while(next_permutation(p+1,p+i+1));
		for(int j=1;j<i;j++)
			g[i][j]=g[j][i]=(M+1)*a[j];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			printf("%lld ",g[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main()
{
    string s, t;
    int cnt = 0;
    cin >> s >> t;
    for (size_t i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
            cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3856
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(aa: Vec<i64>) -> i64 {
    use std::cmp::max;

    let n = aa.len();

    let mut last = aa[n-1];

    for mut i in 1..n {
        i = n-i-1;
        if aa[i] + 1 < last {
            return -1
        }

        if last == 0 {
            last = aa[i];
            continue
        }

        last = max(last - 1, aa[i]);
    }

    let mut cnt = 0;
    for mut i in 1..(n+1) {
        i = n-i;
        if i < n - 1 && aa[i]+1 == aa[i+1] {
            continue
        }

        if aa[i] > i as i64 {
            return -1
        }

        cnt += aa[i];
    }

    cnt as i64
}

fn main() {
    let n = parse_line!(usize);
    let mut aa = Vec::new();

    for i in 0..n {
        aa.push(parse_line!(i64));
    }

    println!("{}", solve(aa));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![0,1,1,2]), 3);
    assert_eq!(solve(vec![1,2,1]), -1);
    assert_eq!(solve(vec![0,1,1,0,1,2,2,1,2]), 8);
}


Measured memory_bytes: 6396
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000


//void CoutingSort(int [], int n);

int main(){
     int *A, *B;
    int  n,i, j;
    int C[VMAX+1];
    scanf("%d", &n);
    
    A = malloc(sizeof(int)*n+1);
    B = malloc(sizeof(int)*n+1);
    
    /* your code */
    
    for ( i = 0; i <= VMAX; i++ ) C[i] = 0;
    
    for(i=0; i<n; i++){
        scanf("%d", &A[i+1]);
         C[A[i+1]]++;
    }
    
    for(i=1;i<=VMAX; i++){
        C[i] = C[i] + C[i-1];
    }
    
    for(j=n; j>0; j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    

    
  //  CoutingSort(A, n);
    
    for( i=1; i<=n; i++){
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 17524
n,m=map(int,input().split())
lis=[]
for i in range(0,m):
  p,q=map(int,input().split())
  lis.append([q,p,i])#iで出力の順番を管理
lis.sort()
ken=[1]*n
res=[]
for i in range(0,m):
  attack=lis[i]
  kenken=attack[1]
  ken_count=ken[kenken-1]
  moji=""
  moji+="0"*(6-len(str(kenken)))+str(kenken)+"0"*(6-len(str(ken_count)))+str(ken_count)
  ken[kenken-1]+=1
  res.append([attack[2],moji])
  
res.sort()
for i in range(0,m):
  print(res[i][1])





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

using namespace std;

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

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define mem(x,n) memset(x,n,sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main()
{
	faster;
	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cout << "ACL";
	}
	
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

    ll res = 1;
    ll count = 1;
    rep(i, n){
        if(count*count>n) break;
        else{
            res = max(count*count, res);
        }
        count++;
    }
    out(res);
}

Measured memory_bytes: 3604
n = int(input())
L = []
while n > 0:
    m = n // 26
    l = n % 26
    if l == 0:
        L.append(26)
        n = m-1
    else:
        L.append(l)
        n = m


def num2alpha(c): return chr(c+64)


for i in range(len(L)):
    t = L[-i - 1]
    print(num2alpha(t).lower(), end='')


Measured memory_bytes: 9188
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back
#define f	first
#define s	second

using namespace std;

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

int main(){
	int n, odd = 0, even = 0, x;
	scanf("%d", &n);
	repn(i, n){
		scanf("%d", &x);
		if(x % 2 == 0) even++;
		else odd++;
	}
	while(odd > 1 || even > 1){
		if(odd > 1){
			odd -= 2;
			even += 1;
		}
		else if(even > 1){
			even -= 1;
		}
	}
	if(odd + even == 1) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
   
class Main{
    public static void main(String[] args) throws Exception{
         
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        double x = Double.parseDouble(br.readLine());
        double y = 100000;
        long    z = 0;
        for (long i=0; i<x; i++) {
            y = y + (y * 0.05);
            y = y /1000;
            y = Math.ceil(y);
            y = y * 1000;
            z = (long)y;
        }
        System.out.println(z);
    }
}

Measured memory_bytes: 24372
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 1000000007;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

ll n, d;

int main(){
    cin >> n >> d;
    ll ans;
    if(d == 1){
        ans = n*(n-1)/2;
    } else if(d == 2){
        ans = n*(n-1)/2-1;
    } else{
        ans = d+2*(n-d-1)+(n-d-1)*(n-d)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1160
#include<stdio.h>

char grid[8][8];
int vecx[7][3] = { { 0, 1, 1 }, { 0, 0, 0 }, { 1, 2, 3 }, { 0, -1, -1 }, { 1, 1, 2 }, { 0, 1, 1 },{ 1, -1, 0 } };
int vecy[7][3] = { { 1, 0, 1 }, { 1, 2, 3 }, { 0, 0, 0 }, { 1, 1, 2 }, { 0, 1, 1 }, { 1, 1, 2 }, { 0, 1, 1 } };

int main()
{
	while( 1 ){
	
		for( int i = 0; i < 8; i++ )if( scanf( "%s", grid[i] ) == EOF ) goto end;
	
		for( int i = 0; i < 8; i++ ){
		 	for( int j = 0; j < 8; j++ ){
				if( grid[i][j] == '1' ){
					for( int k = 0; k < 7; k++ ){
						if( grid[i+vecy[k][0]][j+vecx[k][0]] == '1' 
						 && grid[i+vecy[k][1]][j+vecx[k][1]] == '1' 
						 && grid[i+vecy[k][2]][j+vecx[k][2]] == '1' )
							printf( "%c\n", 'A' + k );	
					}
				}
			}
		}
	}

end:

 	return 0;
}

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

int main()
{
	int n,m;
	cin >> n >> m;

	vector<int> s(m),p(m);
	for (int i=0;i<m;++i)
	{
		int ss=0;
		int num;
		cin >> num;
		for (int j=0;j<num;++j)
		{
			int s;
			cin >> s;
			ss|=(1<<(s-1));
		}
		s[i]=ss;
	}
	for (int i=0;i<m;++i)
	{
		cin >> p[i];
	}
	for (int i=0;i<m;++i)
	{
		//fprintf(stderr,"%d %d %d\n",i,s[i],p[i]);
	}

	int maximum=1<<n;
	int count=0;
	for (int i=0;i<maximum;++i)
	{
		int j;
		for (j=0;j<m;++j)
		{
			if (__builtin_popcount(i&s[j])%2!=p[j])
			{
				break;
			}
		}
		if (j==m)
		{
			++count;
		}
	}
	cout << count << endl;
}






Measured memory_bytes: 256
def main():
    N = int(input())
    ans = ''
    for a in range(N):
        t, x, y = map(int, input().split())
        if ans != 'No':
            if t-(x+y) == 0:
                ans = 'Yes'
            elif t-(x+y) > 0:
                if (t%2==0 and (x+y)%2==0) or (t%2==1 and (x+y)%2==1):
                    ans = 'Yes'
                else:
                    ans = 'No'
            else:
                ans = 'No'
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x, y;
	cin>>x>>y;
	cout<<(abs(x-y)>1 ? "Alice" : "Brown")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    A--;B--;C--;D--;
    string S;
    cin >> S;
    for (int i = min(A,B) + 1; i < max(C,D); ++i) {
        if(S[i] == '#'){
            if(S[i-1] == '#'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if(A < B && C < D){
        cout << "Yes" << endl;
        return 0;
    }
    if(A > B && C > D){
        cout << "Yes" << endl;
        return 0;
    }
    for (int j = max(B,1ll); j <= D; ++j) {
        if(S[j] == '.' && S[j-1] == '.' && S[j+1] == '.'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;



int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll x=n%(a+b);
  ll y=n/(a+b);

  ll ans=y*a+min(x,a);
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define SIZE 200005
#define INF 100000000000000000LL

using namespace std;

int main(){
    int D;cin>>D;
    if(D==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }else if(D==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(D==24){
        cout<<"Christmas Eve"<<endl;
    }else if(D==25){
        cout<<"Christmas"<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

	for(int n, k, m; cin >> n >> k >> m, n;) {
		vector<int> clock;
		clock.reserve(n);
		for(int i = 0; i < n; ++i)
			clock.push_back(i + 1);

		int idx = m - 1;
		while(clock.size() > 1) {
			clock.erase(clock.begin() + idx);
			idx = (idx + k - 1) % clock.size();
		}

		cout << clock[0] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    auto a = vector<vector<int>>(h,vector<int>(w,0));

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {   
            char c;
            cin >> c;
            if(c =='.') a[i][j] = 1;            
        }   
    }
    
    auto row = vector<int>(h,0);
    auto col = vector<int>(w,0);
    for (int i = 0; i < h; i++)
    {
        row[i] =   accumulate(a[i].begin(),a[i].end(),1,[](int sum,int num){
            return sum*num;
        });
    }

    for (int j = 0; j < w; j++)
    {
        int ans = 1;
        for (int i = 0; i < h; i++)
        {
            ans *=a[i][j];
        }
        col[j]=ans;
    }

    for (int i = 0; i < h; i++)
    {
        if(row[i]==1) continue;
        for (int j = 0; j < w; j++)
        {
            if(col[j]==1) continue;
            cout << (a[i][j]==1 ? '.':'#');
        }
        cout << endl;
        /* code */
    }
    

}

Measured memory_bytes: 256
H, W = map(int, input().split())
while 1:
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if j == W - 1:
                print("#")
            elif j == 0 or i == 0 or i == H -1:
                print("#", end = "")
            else:
                print(".", end = "")
    print()
    H, W = map(int, input().split())

Measured memory_bytes: 9064
while True:
    N, M = map(int, input().split())
    if N == 0 and M == 0:
        break
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(N):
            if i == j:
                pass
            elif M >= A[i] + A[j]:
                ans = max(A[i] + A[j], ans)
    if ans == 0:
        print("NONE")
    else:
        print(ans)



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main () {
cin >> a >> b;
if (a==b) {
	cout << "Draw" << endl;
} else if (a==1) {
	cout << "Alice" << endl;
} else if (b==1) {
	cout << "Bob" << endl;
} else if (a>b) {
	cout << "Alice" << endl;
} else {
	cout << "Bob" << endl;
}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	if(A == 1) A += 13;
	if(B == 1) B += 13;

	if(A < B) cout << "Bob" << endl;
	else if(A > B) cout << "Alice" << endl;
	else cout << "Draw" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text.RegularExpressions;

namespace Atcoder2
{
    class Program
    {

        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);
            int times = int.Parse(Console.ReadLine());

            for (int i = 0; i < times; i++)
            {
                if (A >= B)
                {
                    B = B * 2;
                }
                else if (B >= C)
                {
                    C = C * 2;
                }
            }

            if(A < B && B < C)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 27464
function Main(input) {
  var counter = 0;
  var inputNumbers = input.split(/\n/)[1].split(/\s/);

  while (inputNumbers.every((num) => num % 2 === 0)) {
    inputNumbers = inputNumbers.map((num) => num / 2);
    counter++;
  }

  console.log(counter);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MOD = 1000*1000*1000+7;
int n;
string s;
int dp[3001][3001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>s;
    dp[0][1] = 1;
    for(int i=1; i<n;i++) {
        if(s[i-1]=='>') {
            int x = dp[i-1][i];
            for(int last=i; last>=1; last--) {
                dp[i][last] = x;
                x=(x+dp[i-1][last-1])%MOD;
            }
        }else {
            int x = dp[i-1][1];
            for(int last = 2; last<=i+1; last++) {
                dp[i][last] = x;
                x=(x+dp[i-1][last])%MOD;
            }
        }
    }
    int ans=0;
    for(int i=1; i<=n;i++) {
        ans=(ans+dp[n-1][i])%MOD;
    }
    cout<<ans;
}


Measured memory_bytes: 34176
A,B,C,D = list(map(int,list(input())))
def plus(x):
    if x == 0:
        return '+'
    else:
        return '-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+(1-2*i)*B+(1-2*j)*C+(1-2*k)*D
            if ans == 7:
                print(str(A)+plus(i)+str(B)+plus(j)+str(C)+plus(k)+str(D)+'=7')
                break
        else:
            continue
        break
    else:
        continue
    break

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

int main(){
string S,T;
  cin >>S>>T;
  int len = S.length();
  int ans=0;
  for(int i=0;i<len;i++){
    if(S.at(i)!=T.at(i))
      ans++;
  }
  cout <<ans;
 

return 0;
}

Measured memory_bytes: 3836
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS --(ByteString, getLine, readInt, words)

import Data.Array.Unboxed --(UArray)
import Data.Array.IO --(IOUArray, newListArray, newArray, writeArray, readArray)

import Data.Char --(toLower, toUpper, isUpper, ord)


-- example: putStrLn show 123 ++ "and" ~~ 456 ++ "or" ~~ 789
(~~) :: Show a => String -> a -> String
a ~~ b = a ++ show b

bslen = BS.length -- o(1)
bshd = BS.head -- o(1)
bstl = BS.tail -- o(1)
bslst = BS.last -- o(1)
bsini = BS.init -- o(1)
charToInt n = ord n - ord '0'
readi n = read n :: Int

bsToInt :: BS.ByteString -> Int
bsToInt = fst . fromJust . BS.readInt
getInt = bsToInt <$> BS.getLine

bsToInts :: BS.ByteString -> [Int]
bsToInts = map bsToInt . BS.words 
getInts = bsToInts <$> BS.getLine

getLines :: Int -> IO [BS.ByteString]
getLines n = replicateM n BS.getLine

getLinesToInts :: Int -> IO [Int]
getLinesToInts n = replicateM n $ bsToInt <$> BS.getLine

mapPutStrLn :: [String] -> IO()
mapPutStrLn = mapM_ putStrLn



newints :: Int -> Int -> Int -> IO(IOUArray Int Int)
newints start n = newArray (start, n)

rd :: IOUArray Int Int -> Int -> IO Int
rd = readArray

wt :: IOUArray Int Int -> Int -> Int -> IO()
wt = writeArray

--example: effect  (newArray (1, 3) 0)  3 (+100)   ->   array [(1,0), (2,0), (3,100)]
effect :: IOUArray Int Int -> Int -> (Int -> Int) -> IO()
effect ary i operator = (operator <$> readArray ary i) >>= writeArray ary i



countIJ :: BS.ByteString -> IOUArray Int Int -> IO Int -> Int -> Int -> IO Int
countIJ s cnts acc ti d  
    |bslen s == 0 = acc
    |otherwise     = countIJ s' cnts acc' ti' d'
    where
    s'   = bsini s
    ti'  = ( num * d + ti ) `mod` 2019
    num  = charToInt (bslst s)
    d'   = (d*10) `mod` 2019
    acc' = do
        res <-  (+)  <$>  acc  <*>  rd cnts ti'
        effect cnts ti' (+1)
        return res


main :: IO ()
main = do
    s <- BS.getLine
    let n = bslen s
    let acc = 0
    cnts <- newints 0 2018  0
    wt cnts 0 1
    acc' <- countIJ s cnts (return acc) 0 1
    print acc'



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

int main(){
    int n,i,ans=0;
    cin >> n;
    vector<int> a(n);
    for(i=0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(i=0;i<n;i++){
        if(i%2==0)ans += a.at(i);
        else ans -= a.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<double> headProb(n);
	for(int i = 0; i < n; i++)
		cin >> headProb[i];
	double dp[n+1][n+1];
	for(int i = 0; i <= n; i++)
		dp[0][i] = 0;
	dp[1][0] = 1 - headProb[0];
	for( int i = 2; i<= n; i++)
	{
		dp[i][0] = dp[i-1][0]*(1-headProb[i-1]);
	}
	// cout<<"ini"<<endl;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= i; j++)
		{
			if(i==1 && j==1)
			{
				dp[i][j] = headProb[i-1];
				continue;
			}
			dp[i][j] = headProb[i-1]*dp[i-1][j-1] + (1-headProb[i-1])*dp[i-1][j];
			// cout << dp[i][j] << " ";
		}
		// cout << endl;
	}
	double ans = 0;
	// cout << n << endl; 
	for(int i = n; i > n/2; i--){
		// cout << i << " " << dp[n][i] << endl;
		ans += dp[n][i];
	}
	cout.precision(10);
	cout <<  ans << endl;
	return 0;
}

Measured memory_bytes: 70528
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long y = sc.nextLong();
    long count = 0;
    if(x==0){
      if(y>=0){
        System.out.println(Math.abs(y));
        return;
      }else{
        System.out.println(Math.abs(y)+1);
        return;
      }
    }
    if(y==0){
      if(x<=0){
        System.out.println(Math.abs(x));
        return;
      }else{
        System.out.println(Math.abs(x)+1);
        return;
      }
    }
    if(x*y>0){
      if(y-x>0){
        System.out.println(y-x);
      }else{
        System.out.println(x-y+2);
      }
    }else{
      if(x<0){//x ga hu
        if(Math.abs(x)<=Math.abs(y)){
          System.out.println(Math.abs(y)-Math.abs(x)+1);
        }else{
          System.out.println(Math.abs(x)-Math.abs(y)+1);
        }
      }else{//y ga hu
        if (Math.abs(x)>=Math.abs(y)) {
          System.out.println(Math.abs(x)-Math.abs(y)+1);
        }else{
          System.out.println(Math.abs(y)-Math.abs(x)+1);
        }
      }
    }

  }
}


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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int h, w, n, c, v;
		
		while(!(string = reader.readLine()).equals("0 0")){
			h = Integer.parseInt(string.split(" ")[0]);
			w = Integer.parseInt(string.split(" ")[1]);
			
			int[][] array = new int[h + 1][w + 1];
			boolean[][] imp = new boolean[h + 1][w + 1];
			
			n = Integer.parseInt(reader.readLine());
			for(int i = 0; i < n; i++){
				string = reader.readLine();
				c = Integer.parseInt(string.split(" ")[0]);
				v = Integer.parseInt(string.split(" ")[1]);
				imp[c][v] = true;
			}
			
			array[1][1] = 1;
			for(int i = 1; i <= h; i++){
				for(int j = 1; j <= w; j++){
					if(!imp[i][j]){
						array[i][j] = i == 1 && j == 1 ? 1 : array[i][j - 1] + array[i - 1][j];
					}else{
						array[i][j] = 0;
					}
				}
			}
			System.out.println(array[h][w]);
		}
		reader.close();
	}
}

Measured memory_bytes: 24244
import queue

n,m = map(int, input().split())
a = list(map(int, input().split()))

q = queue.PriorityQueue()

for i in range(n):
    q.put(-a[i])

for i in range(m):
    x = q.get()
    x = -((-x) // 2)
    q.put(x)

ans = 0

for i in range(n):
    x = q.get()
    ans -= x

print(ans)

Measured memory_bytes: 76008
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

/*各位の和　
int sum = 0;
for(int i = 0; i <= 5; i++){
   sum += n%10;
   n /= 10;  
}
*/

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll a,b,k;
  cin>>a>>b>>k;
  if(b-a+1<=k*2){
    rep(i,b-a+1)print(a+i);
  }
  else
  {
    rep(i,k)print(a+i)
    rep(i,k)print(b-k+i+1)
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
  vector<int> vi;
  int N, M;
  cin >> N >> M;
  int tmp;
  int sum = 0;
  for (int i= 0; i < N; i++) {
    cin >> tmp;
    sum += tmp;
    vi.push_back(tmp);
  }
  sort(vi.begin(), vi.end(), greater<int>());
  int lim = sum / (4 * M);

  if (vi[M-1] * 4 * M < sum) cout << "No" << "\n";
  else cout << "Yes" << "\n";
  return 0;
}


Measured memory_bytes: 384
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
		
			String s = sc.next();
			int q = sc.nextInt();
			
			List<String> sList = new LinkedList<>();
			List<String> revList = new LinkedList<>();
			boolean isRev = false;
			sList.add(s);
			revList.add(new StringBuilder(s).reverse().toString());
			
			for(int i = 0 ; i < q ; i++ ) {
				int op = sc.nextInt();
				
				if ( op == 1 ) {
					isRev = !isRev;
				}
				else {
					int f = sc.nextInt();
					String c = sc.next();
					
					if ( isRev) {
						if ( f == 1 ) {
							//add rev head
							sList.add(c);
							revList.add(0,c);
						}
						else {
							sList.add(0,c);
							revList.add(c);
						}
					}
					else {
						if ( f == 1 ) {
							//add head
							sList.add(0, c);
							revList.add(c);
						}
						else {
							sList.add(c);
							revList.add(0,c);
						}
					}
					
				}
			}
		
			StringBuilder sb = new StringBuilder();					

			if (isRev) {
				for(String ss : revList) {
					sb.append(ss);
				}
			}
			else {
				for(String ss : sList) {
					sb.append(ss);
				}
			}

			System.out.println(sb.toString());
			
		}
	}
}

Measured memory_bytes: 176892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

string s;
int x,y;
vector<int>vx,vy;
int dp[4010][16010];

void make(int z,int n){
    for(int i=0;i<=16010;++i){
        if(i==z)dp[0][i]=1;
        else dp[0][i]=0;
    }
    for(int i=1;i<=n;++i){
        for(int j=0;j<=16010;++j)dp[i][j]=-1;
    }
}


int cal(int n,int z, int i){
    if(z>16000||z<0)return 0;
    if(n==0)return dp[0][z];
    if(dp[n][z]!=-1)return dp[n][z];
    if(i==0)return dp[n][z]=max(cal(n-1,z+vx[n-1],0),cal(n-1,z-vx[n-1],0));
    else return dp[n][z]=max(cal(n-1,z+vy[n-1],1),cal(n-1,z-vy[n-1],1));
}


int main(){
    cin>>s;
    cin>>x>>y;

    int p=0,cnt=0;
    for(int i=0;i<s.length();++i){
        if(s[i]=='T'){
            if(p==0)vx.push_back(cnt);
            else vy.push_back(cnt);
            cnt=0;
            p++;
            p%=2;
        }
        else{
            cnt++;
        }
    }
    if(p==0)vx.push_back(cnt);
    else vy.push_back(cnt);

    make(vx[0]+8000,vx.size()-1);
    reverse(vx.begin(),vx.end());
    vx.pop_back();
    reverse(vx.begin(),vx.end());
    int a=cal(vx.size(),x+8000,0);
    //cout<<a<<endl;
    

    make(8000,vy.size());
    int b=cal(vy.size(),y+8000,1);


    if(a==1&&b==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 250368
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,k;
  long aa,bb,cc;
  long ab,bc,ca,sum=0,cnt=0;
  cin >> n >> k;

  long kmulti=0,k2multi=0;
  long startk=0;
  if(k % 2 == 0){
	kmulti = n/k;
	startk = k/2;
	
	k2multi = 1 + (n-startk)/k;
	k2multi = (n+k/2)/k;
	//cout << "kmulti:" << kmulti << "k2multi:" <<  k2multi << endl;
	sum = k2multi*k2multi*k2multi + kmulti*kmulti*kmulti;
  }
  else{
	kmulti = n/k;
	sum = kmulti * kmulti * kmulti;
  }

  //cout << ab ;
//  for(aa=1;aa<=n;aa++){
//	for(bb=1;bb<=n;bb++){
//	  for(cc=1;cc<=n;cc++){
//		ab =  aa+bb;
//		bc =  bb+cc;
//		ca =  cc+aa;
//
//		if(ab % k == 0 && bc % k == 0 && ca % k == 0){
//		  //cout << "aa:" << aa << "bb:" << bb << "cc:" << cc ;
//		  //cout << "ab:" << ab << "bc:" << bc << "ca:" << ca << endl;
//		  sum ++;
//		}
//		cnt++;
//	  }
//	}
//
//  }
  
  cout << sum << endl;
  //cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[10000];
int main()
{
    cin>>s;
    for (int i=0;i<=strlen(s);i++)
    if (s[i]=='7' && s[i-1]=='1' && s[i-2]=='0' && s[i-3]=='2')
    s[i]='8';
    cout<<s;
    return 0;
}

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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0); 
	int n ;
	cin>>n ;
	int arr[n] , arr2[n] , arr3[n] ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i] ;
		arr[i]-- ;
	}
	for(int i =0  ; i < n ; ++i)
		cin>>arr2[i] ;
	for(int i = 0 ; i < n-1 ; ++i)
		cin>>arr3[i] ;
	int ans = arr2[arr[0]] ;
	for(int i = 1 ; i < n ; ++i)
	{
		ans += arr2[arr[i]] ;
		if(arr[i] == arr[i-1] + 1)
			ans += arr3[arr[i-1]] ;
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 256
var
	A,B,C,T,U:int64;
	cnt:Longint;
begin
	read(A,B,C);
	if(A=B)and(B=C)then writeln(A mod 2-1)else begin
		cnt:=0;
		while A mod 2+B mod 2+C mod 2=0 do begin
			T:=A;
			A:=(B+C)div 2;
			U:=B;
			B:=(T+C)div 2;
			C:=(T+U)div 2;
			inc(cnt);
		end;
		writeln(cnt);
	end;
end.


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <list>

using namespace std;

int main()
{
	int n, m;
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		int t[100], h[100], sum_t=0, sum_h=0;
		int i;
		for(i = 0; i < n; i++){
			cin >> t[i];
			sum_t += t[i];
		}
		for(i = 0; i < m; i++){
			cin >> h[i];
			sum_h += h[i];
		}
		int a=-1, b=-1, j;
		for(i = 0; i < n; i++){
			for(j = 0; j < m; j++){
				if((sum_t-t[i]+h[j]) == (sum_h+t[i]-h[j])){
					a = t[i];
					b = h[j];
					i = 200;
					break;
				} 
			}
		}
		if(a == -1 && b == -1) cout << -1 << endl;
		else cout << a << " " << b << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;
bool isPrime[1010];

signed main()
{
    int N; cin>>N;
    for(int i=2;i<=N;i++) isPrime[i]=true;
    for(int i=2;i<=N;i++) if(isPrime[i]){
        for(int j=i*2;j<=N;j+=i) isPrime[j]=false;
    }

    int ans=1;
    for(int i=2;i<=N;i++){
        if(isPrime[i]){
            int cnt=0;
            for(int j=i;j<=N;j*=i) cnt+=N/j;
            ans=ans*(cnt+1)%mod;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
int s[5], c[5];

bool check(int x) {
	vector<int> xs;
	
	if (x == 0) {
		xs.push_back(0);
	}
	else {
		while (x > 0) {
			xs.push_back(x % 10);
			x /= 10;
		}
	}
	
	if (xs.size() != n) return false;
	
	int i;
	rep(i, m) {
		if (xs[n - s[i]] != c[i]) return false;
	}
	return true;
}

int main() {
	int i;
	
	cin >> n >> m;
	rep(i, m) { cin >> s[i] >> c[i]; }
	
	rep(i, 1000) {
		if (check(i)) { cout << i << endl; return 0; }
	}
	
	cout << -1 << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        string t;
        cin >> t;
        bool out = false;
        for (int start = 0; start < t.size(); ++start) {
            for (int step = 1; start + step * (s.size() - 1) < t.size(); ++step) {
                bool flag = true;
                for (int j = 0; j < s.size(); ++j) {
                    if (s[j] != t[start + j * step]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    ++ans;
                    out = true;
                    break;
                }
            }
            if (out) break;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3204
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long H, long long W, vector<string> S) {
  // int M[H][W]{};

  REP(y, H) {
    REP(x, W) {
      if (S[y][x] == '.') {
        int c = 0;
        REP(ny, H) {
          REP(nx, W) if (sqrt(POW(y - ny) + POW(x - nx)) < 2) {
            c += S[ny][nx] == '#';
          }
        }

        cout << c;

      } else {
        cout << "#";
      }
    }
    cout << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long W;
  long long H;
  cin >> H;
  vector<string> S(H - 1 + 1);
  cin >> W;
  for (int i = 0; i <= H - 1; i++) {
    cin >> S[i];
  }
  solve(H, W, S);
  return 0;
}


Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
xl=list(map(int,input().split()))
yl=list(map(int,input().split()))
zl=[i for i in range(x+1,y)]
flag=False
for i in zl:
    if i>max(xl) and min(yl)>=i:
        flag=True

if flag:
    print("No War")
else:
    print("War")
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}

int main() {

	ll N, ans;
	vector<ll> A, csum, xsum;

	cin >> N;
	ans = N;
	A.push_back(0);
	csum.push_back(0);
	xsum.push_back(0);
	for (ll i = 1; i <= N; i++) {

		ll tmp;
		cin >> tmp;
		A.push_back(tmp);
		csum.push_back(csum[i - 1] + tmp);
		xsum.push_back(xsum[i - 1] ^ tmp);

	}

	/*for (ll i = 2; i <= N; i++) {

		for (ll j = i; j <= N; j++) {

			if ((csum[j] - csum[j - i]) == (xsum[j] ^ xsum[j - i])) {

				//cout << i << " " << j << " " << csum[j] - csum[j - i] << " " << (xsum[j] ^ xsum[j - i]) << endl;
				ans++;

			}

		}

	}*/

	ll r = 2;
	for (ll i = 1; i < N; i++) {

		for (ll j = r; j <= N; j++) {

			if ((csum[j] - csum[i - 1]) != (xsum[j] ^ xsum[i - 1])) {

				ans += j - i - 1;
				//cout <<1<<" "<< i << " " <<j<<" "<< j - i - 1 << endl;
				r = j;
				break;

			}
			if (j == N) {

				ans += j - i;
				r = j;
				//cout << 2 << " " <<i<<" "<<j<<" "<< j - i << endl;

			}

		}

	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
    int n, m, q;
    cin >> n >> m >> q;
    vi a(q), b(q), c(q), d(q);

    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    
    vi A(n);
    
    vi x(n+m-1, 1);
    rep(i, m-1) x[i] = 0;

    ll mx = 0;
    
    do{
        int cnt = 1;
        int j = 0;
        ll tot = 0;
        rep(i, n+m-1) {
            if(x[i]){
                A[j] = cnt;
                j++;
            } 
            else{
                cnt++;
            }
        }
        rep(i,q){
            if(A[b[i]] - A[a[i]] == c[i]) tot += d[i];
        }
        mx = max(mx, tot);
    }while(next_permutation(all(x)));

    cout << mx << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3632
import fractions

def lcm(x,y):
     return x * y // fractions.gcd(x,y)

a,b,c,d = map(int,input().split())

countB = b - (b // c) - (b // d) + (b // lcm(c,d))
countA = a - 1 - ((a - 1) // c) - ((a - 1) // d) + ((a - 1) // lcm(c,d))

print(countB - countA)


Measured memory_bytes: 5088
N=int(input())
A=[0,0,0,0]
for i in range(4):
  A[3-i]=N%10
  N=int(N/10)

#3ビットの全探索
for bit in range(2**3+1):
  a=A[0]
  for i in range(3):
    if (bit>>i)&1:
      a-=A[i+1]
    else:
      a+=A[i+1]
  
  if a==7:
    text=str(A[0])
    for i in range(3):
      if (bit>>i)&1:
        text+="-"
      else:
        text+="+"
      text+=str(A[i+1])
    print(text+"=7")
    break

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

int ask(string a,string b) {
	cout<<a<<endl;
	cout<<b<<endl;
	string s;
	cin>>s;
	if(s=="end") exit(0);
	return s=="T";
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>N;
	
	string a="";
	string b="";
	while(1) {
		FOR(i,4) {
			a+=".#"[i/2];
			b+=".#"[i%2];
			if(ask(a,b)) break;
			a.pop_back();
			b.pop_back();
		}
		if(i==4) break;
	}
	while(1) {
		FOR(i,4) {
			a=".#"[i/2] + a;
			b=".#"[i%2] + b;
			if(ask(a,b)) break;
			a.erase(a.begin());
			b.erase(b.begin());
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
vector<LL> fact;
vector<LL> inver(1000001);


LL combination(int n,int r){
    if(n==0&&r==0) return 1;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}

LL fpow(LL a, LL n){
    int x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

int main(){
    int N;
    cin >> N;
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=1000000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[1000000]=fpow(fact[1000000],mod-2);
    for(int i=999999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
    LL ans=0;
    for(int k=1;k<N;k++){
        if(k-1<N-1-k) continue;
        ans+=k*(combination(k-1,N-1-k)%mod*fact[k]%mod*fact[N-1-k]%mod)%mod;
        if(k-2<N-k) continue;
        ans=(ans+mod-(combination(k-2,N-k)%mod*fact[k-1]%mod*fact[N-k]%mod)*k%mod)%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17900
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		C solver = new C();
		solver.solve(1, in, out);
		out.close();
	}

	static class C {
		public void solve(int testNumber, Scanner in, PrintWriter out) {
			int a = in.nextInt(), b = in.nextInt();

			int result = -1;
			for (int x = 0; ((int) (x * 0.08)) <= a; x++) {
				if (((int) (x * 0.08) == a) && ((int) (x * 0.1) == b)) {
					result = x;
					break;
				}
			}
			out.println(result);
		}

	}
}



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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int n;
    cin>>n;
    vector<ll> L(n);
    rep(i,n) cin>>L[i];
    ll ans=0;
    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            if(L[i]==L[j]) continue;
            for(int k=j+1;k<n;k++) {
                if(L[i]==L[k] || L[j]==L[k])continue;
                if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[k]+L[j]>L[i]) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644