akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>

const int NICO = 252521;
bool graph[26][26];
int state[26];

bool dfs(int u){
    state[u] = 1;

    bool f = false;
    for(int v=0;v<26;v++){
        if(!graph[u][v]){continue;}
        
        if(state[v] == 0){
            f |= dfs(v);
        }else if(state[v] == 1){
            return true;
        }
    }
    state[u] = 2;
    return f;
}

bool hasCycle(){
    for(int i=0;i<26;i++){
        state[i] = 0;
    }

    bool f = false;
    for(int i=0;i<26;i++){
        if(!state[i]){f |= dfs(i);}
    }

    return f;
}

int main(){
    int N;
    std::cin >> N;

    for(int i=0;i<N;i++){
        int H, W;
        std::cin >> H >> W;

        std::string S[50];
        int l[50], r[50], t[50], b[50];
        std::fill(l, l+50, NICO);
        std::fill(r, r+50, -NICO);
        std::fill(t, t+50, NICO);    
        std::fill(b, b+50, -NICO);
        
        std::fill(&graph[0][0], &graph[0][0]+26*26, false);
    
        for(int i=0;i<H;i++){
            std::cin >> S[i];

            for(int j=0;j<W;j++){
                if(!std::isalpha(S[i][j])){continue;}

                int index = S[i][j] - 'A';
                l[index] = std::min(l[index], j);
                r[index] = std::max(r[index], j);
                t[index] = std::min(t[index], i);
                b[index] = std::max(b[index], i);
            }
        }

        bool f = true;
        for(int i=0;i<26;i++){
            if(l[i] == NICO){continue;}

            for(int j=t[i];j<=b[i];j++){
                for(int k=l[i];k<=r[i];k++){
                    if(S[j][k] == '.'){f = false;}
                    if(S[j][k] - 'A' != i){
                        graph[i][S[j][k] - 'A'] = true;
                    }
                }
            }
        }

        for(int i=0;i<26;i++){
            for(int j=0;j<26;j++){
                if(graph[i][j] && graph[j][i]){f = false;}
            }
        }

        // for(int i=0;i<26;i++){
        //     printf("%c:", 'A'+i);
        //     for(int j=0;j<26;j++){
        //         printf("%d ", graph[i][j]);
        //     }
        //     puts("");
        // }
        
        if(f && !hasCycle()){
            std::cout << "SAFE" << std::endl;
        }else{
            std::cout << "SUSPICIOUS" << std::endl;
        }
    }
}

Measured memory_bytes: 1212
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int i, n, m, x, max;
  vector<int> data;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    for(i=0; i<n+m; ++i){
      cin >> x;
      data.push_back(x);
    }

    sort(data.begin(), data.end());

    for(i=1, max=data[0]; i<data.size(); ++i){
      if(max < data[i] - data[i-1])
	max = data[i] - data[i-1];
    }

    cout << max << endl;
    data.clear();
  }

  return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0;i < N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
 int scoreA = 0, scoreB = 0;
  for(int k = 0; k < N;k++){
   if(k % 2 == 0){
    scoreA += A.at(k);
   }
    else{
    scoreB += A.at(k);
    }
  }
 cout << scoreA - scoreB<< endl;
}

Measured memory_bytes: 256
import numpy as np

def main():
    n = int(input())
    junbi_num = list(map(int, input().split()))
    exam_num = list(map(int, input().split()))

    min = -1

    if sum(junbi_num) < sum(exam_num):
        print(min)
        exit()

    sabun_list = np.array(junbi_num) - np.array(exam_num)

    min = np.count_nonzero(sabun_list < 0)
    
    plus_list = sabun_list[sabun_list > 0]
    plus_list = np.sort(plus_list)[::-1]

    minus = sum(sabun_list[sabun_list < 0])

    i = 0
    while(minus < 0):
        minus += plus_list[i]
        i += 1
        min += 1

    print(min)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27712
def solve(n, t_list):

    ans = [t[1] for t in t_list]
    ans.append(0)
    for i, t in enumerate(t_list):
        for j in range(i+1):
            if ans[j] < t[1]:
                ans[j] += t[0]+(t[1] - ans[j])
            else:
                if ans[j] % t[2] == 0:
                    ans[j] += t[0]
                else:
                    ans[j] += t[0] + (ans[j] // t[2] + 1)*t[2] - ans[j]

    for i in ans:
        print(i)

if __name__ == "__main__":
    n = int(input())
    t_list = [[int(j) for j in input().split()] for i in range(n-1)]
    solve(n, t_list)


Measured memory_bytes: 3188
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<i32>();
    let k = v[0];
    let x = v[1];

    let max = x + k - 1;
    let min = x - k + 1;
    print!("{}", min);
    for i in min+1..max+1 {
        print!(" {}", i);
    }
    println!("");
}


Measured memory_bytes: 4352
cards = [[False for i in range(13)]for j in range(4)]
ptn = ['S','H','C','D']
n = int(input())
for i in range(n):
    a, b = map(str,input().split())
    b = int(b)
    cards[ptn.index(a)][b-1] = True
for j in range(4):
    for k in range(13):
        if cards[j][k] == False:
            print(ptn[j],k+1)


Measured memory_bytes: 5604
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: u64);
    let ans = (1 ..= n).map(|x| { let c = n / x; x * c * (c + 1) / 2 }).sum::<u64>();
    println!("{}", ans);
}


Measured memory_bytes: 2188
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

#define INF ((int)1e9)

struct Edge {
  int to, cost;
  Edge(int t, int c) : to(t), cost(c) {}
};

typedef pair<int, int> Pii;
typedef pair<int, Pii> Piii; // cost, cnum, node

vector<Edge> G[100];
int memo[100][10];
int C, N, M, S, D;

int dijkstra(int src, int dst, int cnum) {
  
  fill(memo[0], memo[0]+N*10, INF);
  
  priority_queue<Piii> pq;
  memo[src][cnum] = 0;
  pq.push(Piii(0, Pii(-cnum, src)));
  while(!pq.empty()) {
    const Piii get = pq.top(); pq.pop();
    int cost = get.first;
    int cn = -get.second.first;
    int now = get.second.second;
    
    for(int i=0; i<G[now].size(); i++) {
      int next = G[now][i].to;
      int add_c = G[now][i].cost;
      if(memo[next][cn] > cost + add_c) {
	pq.push(Piii(cost+add_c, Pii(-cn, next)));
	memo[next][cn] = cost + add_c;
      }
      if(cn-1<0) continue;
      add_c /= 2;
      if(memo[next][cn-1] > cost + add_c) {
	pq.push(Piii(cost+add_c, Pii(-(cn-1), next)));
	memo[next][cn-1] = cost + add_c;
      }
    }
  }
  
  return *min_element(memo[dst], memo[dst]+10);
}

int main() {
  while(cin >> C >> N >> M >> S >> D && (N|M)) {
    for(int i=0; i<N; i++) {
      G[i].clear();
    }
    for(int i=0; i<M; i++) {
      int a, b, c; cin >> a >> b >> c; a--, b--;
      G[a].push_back(Edge(b, c));
      G[b].push_back(Edge(a, c));
    }
    
    S --, D --;
    cout << dijkstra(S, D, C) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int main() {
    int n; cin >> n;
    vector<string> v(n); rep(i, n) cin >> v[i];

    set<string> s;
    for (auto v2 : v) s.insert(v2);

    cout << (s.size() == 3 ? "Three" : "Four") << endl;
}


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

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin>>n;
    vector<ll> a(5);
    for(int i = 0;i < 5;++i) {
        cin>>a[i];
    }
    ll tm=(n+a[0]-1)/a[0];
    ll mi=a[0];
    for(int i = 1;i < 5;++i) {
        mi=min(mi,a[i]);
        if(a[i]>=a[i-1])++tm;
        else {
            tm=(n+mi-1)/mi;
            tm+=i;
        }
        //cerr<<"tm:"<<tm<<endl;
    }
    cout<<tm<<endl;
    return 0;
}


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

int main() {
    int n, q, c, t, x, v_size;
    cin >> n >> q;
    vector<queue<int>> v(n);
    for(int i = 0; i < q; ++i) {
        cin >> c;
        if(c == 0) {
            cin >> t >> x;
            v[t].push(x);
        } else if(c == 1) {
            cin >> t;
            if(v[t].size() != 0) {
                cout << v[t].front() << '\n';
            }
        } else {
            cin >> t;
            if(v[t].size() != 0) {
                v[t].pop();
            }
        }
    }
}



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

using namespace std;

int main(){

	int n; cin >> n;
	vector<int> arr(n);
  	for(int i = 0; i < n; ++i) cin >> arr[i];
    
  	sort(arr.begin(),arr.begin()+n);
  	double ans = arr[0];
    for(int i = 1; i < n; ++i){
    	ans = (ans+arr[i])/2;
    }
  	cout << ans << "\n";
  	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int room[4][3][10] = {};
	int b, f, r, v;
	int n, i, j, k;
	scanf("%d", &n);
	for (i=1; i<=n; i++)
	{
		scanf("%d%d%d%d", &b, &f, &r, &v);
		room[b-1][f-1][r-1]+=v;
	}
	for (i=1; i<=4; i++)
	{
		for (j=1; j<=3; j++)
		{
			for (k=1; k<=10; k++)
			{
				printf(" %d", room[i-1][j-1][k-1]);
			}
			printf("\n");
		}
		if (i==4) break;
		printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 612
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

#define M 4000005
int main(){fastio
    ll n;cin>>n;
    ll a[n];ll sum=0;
    rep(i,0,n-1){
        cin>>a[i];sum+=a[i];
    }
    
    bitset<M>u[2];
    u[0][0]=1;
    rep(i,1,n){
        ll p=i&1;
        u[p]=u[!p];
        u[p]|=u[!p]<<a[i-1];
       // cout<<u[p]<<endl;
    }
    rep(j,(sum+1)/2,sum){
        if(u[n&1][j]){
            cout<<j<<endl;return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <algorithm>
using namespace std;
inline void print(int l, int r){
	for(int i(l); i < r; ++i){
		printf("%d ", i);
	}
	printf("%d\n", r);
}
int main(){
	int len, p;
	scanf("%d%d", &len, &p);
	print(max(-1000000, p - len + 1), min(1000000, p + len - 1));
	return 0;
} 


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	x, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}

	y, err := strconv.Atoi(input())
	if err != nil {
		log.Fatalln(err)
	}

	for a := 0; a <= x; a++ {
		b := x - a

		if y == 2*a+4*b {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}


Measured memory_bytes: 1816
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	int i,j,d,l,r,n,a[3001]; ll dp[3001][3001] = {};
	cin>>n;
	for(i=1; i<=n; i++) cin>>a[i];
	for(i=1; i<=n; i++) dp[i][i] = ((n&1)?1:-1)*a[i];
	for(d=1; d<n; d++)
		for(i=1; i<=n-d; i++){
			j = i + d; int mult = (((n-(d+1))&1)?-1:1);
			if(mult == -1) dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j]);
			else dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j]);
		}

	cout<<dp[1][n];
}

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

signed main(void)
{
	int a, b, c, d;
	int imos[101];
	int cnt;

	cnt = 0;
	cin >> a >> b >> c >> d;
	for (int i = 0; i <= 100; i++) imos[i] = 0;
	for (int i = a; i <= b; i++) imos[i] += 1;
	for (int i = c; i <= d; i++) imos[i] += 1;
	for (int i = 0; i <= 100; i++)
	{
		if (imos[i] >= 2)
			cnt++;
	}
  	if (cnt > 0) cnt--;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	x := nextInt()
	y := nextInt()

	diff := 4 * x - y

	if diff < 0 {
		fmt.Println("No")
		return
	}

	if diff % 2 != 0 {
		fmt.Println("No")
		return
	}

	if diff / 2 > x {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
	return
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<queue>

int main() {
	int h, w;
	std::cin >> h >> w;
	std::vector<std::string>s(h);
	for (int i = 0; i < h; i++)std::cin >> s[i];
	std::vector<std::vector<int>>score(h, std::vector<int>(w, -1));

	std::queue<std::pair<int, int>>q;
	q.push(std::make_pair(0, 0));
	score[0][0] = 1;
	int dx[4] = { 0,0,1,-1 };
	int dy[4] = { 1,-1,0,0 };

	int white = 0;
	for (int i = 0; i < h*w; i++) {
		if (s[i / w][i%w] == '.')white++;
	}
	
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx == -1 || ny == -1 || nx == w || ny == h)continue;
			if (s[ny][nx] == '#')continue;
			if (score[ny][nx] >= 1)continue;
			q.push(std::make_pair(nx, ny));
			score[ny][nx] = score[y][x] + 1;
		}
	}
	printf("%d\n", score[h - 1][w - 1] == -1 ? -1 : white - score[h - 1][w - 1]);
}

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

int main() {
    int N,maxl=0,ind = 0,total=0;
    cin >> N;
    vector<int> length(N);

    for (int i = 0; i < N; ++i){
        cin >> length.at(i);
        maxl = max(maxl,length.at(i));
        total += length.at(i);
    }

    
    if (total - maxl > maxl){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
int n,i;
scanf("%d",&n);
for(i=1; i<=n; i++)
scanf("%d",&a[i]);
int cur = 0;
if(a[1]!=0)return printf("-1")*0;
long long ans = 0;
int cnt = 0;
for(i=2; i<=n; i++){
if(a[i] > a[i-1] + 1)return printf("-1")*0;
else if(a[i]==a[i-1]+1){
cur++;
}
else if(a[i]==a[i-1])ans+=cur;
else {
ans +=cur;
cur = a[i];
}

}
ans += cur;
printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	
	void main() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String s = sc.nextLine();
			String[] ss = s.split(" ");
			int W = Integer.parseInt(ss[0]);
			int n = ss.length - 1;
			int[] r = new int[n];
			for(int i=1;i<=n;i++) {
				r[i-1] = Integer.parseInt(ss[i]);
			}
			
			double[][] dp = new double[1<<n][n];
			double INF = 1<<28;
			for(int i=0;i<(1<<n);i++) {
				for(int j=0;j<n;j++) {
					dp[i][j] = INF;
				}
			}
			for(int i=0;i<n;i++) {
				dp[1<<i][i] = 2*r[i];
			}
			
			for(int i=0;i<(1<<n);i++) {
				for(int j=0;j<n;j++) {
					if(dp[i][j] == INF) continue;
					for(int k=0;k<n;k++) {
						if((i >> k & 1) == 1) continue;
						int nexti = i | (1 << k);
						double nextdp = dp[i][j] - r[j] + 2*Math.sqrt(r[j] * r[k]) + r[k];
						dp[nexti][k] = Math.min(dp[nexti][k], nextdp);
					}
					
				}
			}
			
			double ans = INF;
			for(int j=0;j<n;j++) {
				ans = Math.min(ans, dp[(1<<n)-1][j]);
			}
			System.out.println(ans<=W ? "OK":"NA");
		}
	}

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



}


Measured memory_bytes: 35088
import sys
import math
n = int(input())
tmp = 10**12

for i in range(int(math.sqrt(n))+1, 0, -1):
    if n % i != 0:
        continue
    else:
        if tmp > (n//i)+(i)-2:
            tmp = (n//i)+i-2
print(tmp)

Measured memory_bytes: 40044
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 1; i < n; i++){
            ans += (n-1)/i;
        }
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25920
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: usize = input();
    let a: Vec<Vec<usize>> = (0..n)
        .map(|_| (0..n - 1).map(|_| input()).collect())
        .collect();

    let mut g = vec![n; n];
    let mut cur = vec![0; n];
    for i in 0..n {
        g[i] = a[i][0] - 1;
    }

    let mut cnt = 0;
    let mut ans = 0;
    loop {
        let mut temp = vec![];
        let mut vis = vec![false; n];
        for i in 0..n {
            if vis[i] || g[i] == n {
                continue;
            }
            if g[g[i]] == i {
                vis[i] = true;
                vis[g[i]] = true;
                temp.push(i);
                temp.push(g[i]);
                cnt += 1;
            }
        }
        if temp.is_empty() {
            break;
        }
        for i in temp {
            cur[i] += 1;
            if cur[i] < n - 1 {
                g[i] = a[i][cur[i]] - 1;
            } else {
                g[i] = n;
            }
        }
        ans += 1;
    }

    if cnt != n * (n - 1) / 2 {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 12540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int[][] c = new int[10][10];
		for(int i=0;i<10;i++) {
			for(int j=0;j<10;j++) {
				c[i][j] = in.nextInt();
			}
		}
		
		for(int i=0;i<10;i++) {
			for(int j=0;j<10;j++) {
				for(int k=0;k<10;k++) {
					c[j][k] = Math.min(c[j][k], c[j][i] + c[i][k]);
				}
			}
		}
		
		int ans = 0;
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				int num = in.nextInt();
				if(num>=0) ans += c[num][1];
			}
		}
		System.out.println(ans);
		in.close();

	}

}


Measured memory_bytes: 44092
// import kotlin.comparisons.*
// import kotlin.math.*
import java.util.*

const val mod = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun repeatpow(base: Long, exp: Long): Long {
  if (exp == 0L) return 1
  if (exp % 2 == 0L) {
    val w = repeatpow(base, exp / 2)
    return w * w % mod
  } else {
    val w = repeatpow(base, exp - 1)
    return base * w % mod
  }
}

fun main(args: Array<String>) {
  val (n, a, b) = readLs()
  var fa = 1L
  for (i in 1..a) {
    fa = fa * i % mod
  }
  var fb = 1L
  for (i in a + 1..b) {
    fb = fb * i % mod
  }
  fb = fa * fb % mod
  var w1 = 1L
  val w2 = LongArray(b.toInt()) { w1 = w1 * (n - it) % mod; w1 }
  val na = w2[a.toInt() - 1]
  val nb = w2[b.toInt() - 1]

  val ans = repeatpow(2, n.toLong()) -
    (na * repeatpow(fa, mod - 2) + nb * repeatpow(fb, mod - 2)) % mod -
    1
    println(if (ans < 0) ans + mod else ans)
}


Measured memory_bytes: 42352
#include <bits/stdc++.h>                                                                              
using namespace std;                                                                                  
using ll = long long;                                                                                 
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }               
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }               
                                                                                                      
int main() {                                                                                          
  int a, b, c;                                                                                        
  cin >> a >> b >> c;                                                                                 
  if ((a == b && a != c)                                                                              
      || (a == c && a != b)                                                                           
      || (b == c && b != a)) {                                                                        
    cout << "Yes" << endl;                                                                            
  } else {                                                                                            
    cout << "No" << endl;                                                                             
  }                                                                                                   
  return 0;                                                                                           
}                                                                                                     
                                                                                                      
                                                                                                      
                                                                                                      
                                                 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 int a, b, c,e ;
 double d;
 scanf("%d", &a);
 scanf("%d", &b);
 scanf("%lf", &d);
if(a > d) {
printf("0");
return 0;
}
 d = d + 0.5;
 e = d / a;
 c = e * b;
 printf("%d", c);
 return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include<map>
#include<stack>
#define T long long


int main(){
	int n;
	std::cin >> n;
	switch(n%10){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			std::cout << "hon"<<std::endl;
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			std::cout << "pon"<<std::endl;
			break;
		case 3:
			std::cout << "bon" <<std::endl;
			break;
	}
}


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

using namespace std;
typedef long long ll;

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

  int result = 0;
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
        result += gcd(a, gcd(b, c));
      }
    }
  }
  cout << result;

  return 0;
}


Measured memory_bytes: 3620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, int(math.sqrt(m)) + 1):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = collections.defaultdict(int)
        for c in self.T:
            while n % c == 0:
                d[c] += 1
                n //= c
            if n < 2:
                break
        if n > 1:
            d[n] += 1
        return d.items()

    def sowa(self, n):
        r = 1
        for k,v in self.division(n):
            t = 1
            for i in range(1,v+1):
                t += math.pow(k, i)
            r *= t
        return r

def main():
    q = I()
    a = [LI() for _ in range(q)]
    pr = Prime(10**10)
    b = [0]
    for i in range(1,10**5+1):
        if i%2==1 and pr.is_prime(i) and pr.is_prime((i+1)//2):
            b.append(b[-1] + 1)
        else:
            b.append(b[-1])
    r = []
    for c,d in a:
        r.append(b[d]-b[c-1])

    return '\n'.join(map(str,r))

print(main())




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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string str;
    cin >> str;

    vector<ll> mod(2020, 0);
    mod[0] = 1;

    reverse(all(str));
    ll u = 0, pow10 = 1;

    ll m = 2019;

    REP(i, str.size()){
        u += (str[i] - '0') * pow10;
        u %= m;
        mod[u]++;
        pow10 *= 10;
        pow10 %= m;
    }

    ll ans = 0;

    REP(i, m){
        ans += max(0LL, mod[i]*(mod[i]-1) / 2);
    }

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


Measured memory_bytes: 3752
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main(string[] args) {
    Console.ReadLine();
    List<int> h = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToList();

    var q = new Queue<Tuple<int, int>>();
    q.Enqueue(Tuple.Create(0, h.Count));
  
    int ans = 0;

    while (q.Count > 0) {
      var e = q.Dequeue();
      if (e.Item1 == e.Item2) {
        continue;
      }

      int m = 101;
      for (int i = e.Item1; i < e.Item2; i++) {
        if (h[i] < m) {
          m = h[i];
        } 
      }
      
      ans += m;

      int next = -1;
      for (int i = e.Item1; i < e.Item2; i++) {
        if (h[i] > m) {
          h[i] -= m;
          if (next == -1) {
            next = i;
          }
        } else if (next != -1) {
          q.Enqueue(Tuple.Create(next, i));
          next = -1;
        }
      }

      if (next != -1) {
        q.Enqueue(Tuple.Create(next, e.Item2));
      }
    }

    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 13524
# 2019-11-19 19:43:48(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 

table = set()
for i in range(1, 10):
    for j in range(i, 10):
        table.add(i * j)

def main():
    n = int(sys.stdin.readline().rstrip())
    
    print('Yes' if n in table else 'No')


if __name__ == "__main__":
    main()


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

int main()
{
    int r, c, e, sumr;
    int sumc[101] = {};

    cin >> r >> c;

    for (int i = 0; i < r; i++)
    {
        sumr = 0;
        for (int j = 0; j < c; j++)
        {
            cin >> e;
            sumr += e;
            sumc[j] += e;
            cout << e << " ";
        }
        cout << sumr << "\n";
        sumc[c] += sumr;
    }
    sumr = 0;
    for (int j = 0; j < c; j++)
    {
        sumr += sumc[j];
        cout << sumc[j] << " ";
    }
    cout << sumr << "\n";
}



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

int main() {
 int N;
 cin >> N;
 int a = N/100;
 int b = (N-a*100)/10;
 int c = (N-a*100-b*10);
 if(a == 7){
   cout << "Yes" << endl;
   return 0;
 }
 if(b == 7){
   cout << "Yes" << endl;
   return 0;
 }
 if(c == 7){
   cout << "Yes" << endl;
   return 0;
 }
 else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) cout << "a < b\n";
    if (a > b) cout << "a > b\n";
    if (a == b) cout << "a == b\n";
    
	return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N;
	cin >> N;
	
	string S;
	cin >> S;
	
	int cnt_x = 0, x = 0, cnt_y = 0, y = 0;
	for_(i,0,N) {
		cnt_x += (S[i] == '(' ? -1 : 1);
		cnt_y += (S[N - i -1] == ')' ? -1 : 1);
		x = max(x, cnt_x);
		y = max(y, cnt_y);
	}
	
	cout << string(x, '(') << S << string(y, ')') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    ll h[100010];
    cin >> N >> A >> B;
    rep(i,0,N){
        cin >> h[i];
    }
    sort(h, h+N, greater<int>());

    ll l = -1, r = 1e9 + 7;
    ll h_tmp[100010];
    while(r - l > 1){
        rep(i,0,N){
            h_tmp[i] = h[i];
        }
        ll mid = (r + l)/2;
        bool is_ok = false;
        ll cnt_A = 0, dmg = A - B;
        rep(i,0,N){
            if(h_tmp[i] <= mid * B){
                h_tmp[i] = 0;
            }else{
                h_tmp[i] -= mid * B;
            }
            if(h_tmp[i] % dmg == 0){
                cnt_A += h_tmp[i] / dmg;
            }else{
                cnt_A += h_tmp[i] / dmg + 1;
            }
        }
        if(cnt_A <= mid){
            r = mid;
        }else{
            l = mid;
        }

    }
    print(r);


}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
vector<pi>adj[100009];
ll col[100009];
bool vis[100009];
ll dis[100009];
void bfs(ll node,ll n)
{
    queue<ll>q;
    vis[node]=1;
    col[node]=0;
    q.push(node);
    while(!q.empty())
    {
        ll top=q.front();
        q.pop();
        for(ll i=0;i<adj[top].size();i++)
        {
            ll chi=adj[top][i].first;
            ll cost=adj[top][i].second;
            if(vis[chi]==0)
            {
                vis[chi]=1;
                dis[chi]=dis[top]+cost;
                col[chi]=dis[chi]%2;
                q.push(chi);
//                cout<<"pushed "<<chi<<" dis "<<dis[chi]<<endl;
            }
        }
    }
}
int main()
{
    ll n;cin>>n;
    for(ll i=0;i<n-1;i++)
    {
        ll u,v,w;
        cin>>u>>v>>w;
        adj[u].pb({v,w});
        adj[v].pb({u,w});
    }
    bfs(1,n);
    cout<<col[1];
    for(ll i=2;i<=n;i++)cout<<" "<<col[i];
    cout<<endl;
}
/*
10
1 2 2
1 3 4
1 4 3
2 5 5
2 6 7
3 7 6
3 8 1
7 9 4
9 10 10
*/


Measured memory_bytes: 11392
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static String sort( String str ){
		String r = "";
		for( char i = 'a'; i <= 'z'; i++ ){
			for( int j = 0; j < str.length(); j++ ){
				if( i == str.charAt(j) ){
					r += i;
				}
			}
		}
		return r;
	}
	
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] s = new String[N];
        Map<String, Integer> myMap = new HashMap<String, Integer>();
        
        long cnt = 0;
        for( int i = 0; i < N; i++ ){
        	s[i] = sc.next();
        	s[i] = sort(s[i]);
        	if( myMap.containsKey(s[i]) ){
        		int value = myMap.get(s[i]);
        		cnt += value;
        		myMap.put(s[i],value+1 );
        	}
        	else{
        		myMap.put(s[i], 1);
        	}
        }
        
        
        System.out.println( cnt );
        
        sc.close();
    }
}

Measured memory_bytes: 74200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n, m;

void solve(){
    cin >> n >> m;
    cout << ((n*(n-1)) / 2) + ((m*(m-1)) / 2);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        int[] count = new int[3];
        for (int i = 0; i < s.length(); i++) {
            count[s.charAt(i) - 'a']++;
        }
        Arrays.sort(count);
        System.out.println(count[2] - count[0] < 2 ? "YES" : "NO");
    }
}

Measured memory_bytes: 24640
#include <stdio.h>
int main(){
char a[4];
scanf("%c%c%c%c",&a[0],&a[1],&a[2],&a[3]);
if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')printf("Yes");
else printf("No");
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n),i++)
using namespace std;
typedef long long ll;
int main() {
   int N;
   ll ans=0;
    cin>>N;
    for(int i=1;i<=N;i++){
      if(i%3!=0&&i%5!=0) ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <iomanip>

int main(int argc, char *argv[])
{
    double r;
    std::cin >> r;

    double s = M_PI * r * r;
    double l = 2 * M_PI * r;
    std::cout << std::fixed;
    std::cout << std::setprecision(9) << s << " " << l << std::endl;
    return 0;
}

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

int main(){
	char c;
	cin >> c;
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    string S, T;
    cin >> S >> T;
    int A = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) != T.at(i)){
            A = A + 1;
        }
    }
    cout << A << endl;
    return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> l(N);
    for(int i=0; i < N; i++) cin >> l[i];
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    int ans = 0;
    for(int i=0; i < K; i++) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	//??????????????????????????°
	public static void main(String[] args) {

		int debt = 100000;
		int temp = 0;
		Scanner stdin = new Scanner(System.in);
		int week = stdin.nextInt();

		for(int i = 0; i < week; i++) {

			debt *= 1.05;

			if(debt % 1000 != 0) {

				temp = ((debt / 1000) * 1000 + 1000);
				debt = temp;

			}

		}

		System.out.println(debt);

	}

}

Measured memory_bytes: 25556
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func check(a, b int) bool {
	for i := 0; i <= 32; i++ {
		x := (a >> uint(i)) % 2
		y := (b >> uint(i)) % 2
		if x == 1 && y == 1 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	cur := 0
	ans := 0
	l := 0

	for i := 0; i < N; i++ {
		f := check(cur, a[i])
		// out(f)
		if f {
			cur ^= a[i]
		} else {
			for j := 1; j <= i-l; j++ {
				ans += j
			}
			for l < i {
				cur ^= a[l]
				l++
				f := check(cur, a[i])
				if f {
					cur ^= a[i]
					break
				}
			}
			for j := 1; j <= i-l; j++ {
				ans -= j
			}
			// out("ans--", ans, l, i)
		}
	}

	// out("cnt", l)
	if l != N {
		for i := 1; i <= N-l; i++ {
			ans += i
		}
	}
	out(ans)
}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,M;
  cin>>N>>M;
  cout<<pow(2,M)*(1900*M+100*(N-M))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,k,e=0;
  cin>>n;
  map<int,int> m;
  for(int i=0;i<n;++i){cin>>k;++m[k];}
  for(auto& p:m){
    if(p.second>2){
      k=p.second-(2-p.second%2);
      n-=k;
      p.second-=k;
    }
    if(p.second==2)e++;
  }
  cout<<n-e-e%2;
}

Measured memory_bytes: 4992
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

for i in range(M - 1):
    if A[i] + 1 == A[i + 1]:
        print(0)
        exit()

MAX_N = int(1e5) + 10
memo = [0 for i in range(MAX_N + 10)]
memo[0] = 1
memo[1] = 1
memo[2] = 2
for i in range(3, MAX_N + 10):
    memo[i] = memo[i - 1] + memo[i - 2]

now = 0
ans = 1

for a in A:
    diff = a - now - 1
    ans *= memo[diff]
    ans %= int(1e9 + 7)
    now = a + 1

diff = N - now
ans *= memo[diff]
ans %= int(1e9 + 7)
print(ans)


Measured memory_bytes: 462260
package main

import (
	"fmt"
)

func main() {
	var a int
	fmt.Scan(&a)
	result := "No"

	for i := 0; i <= 100; i++ {
		for j := 0; j <= 100; j++ {
			value := 4*i + 7*j
			if value == a {
				result = "Yes"
			}
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int n,i,j,a=0,b=0;
	char s[100];
	scanf("%d %s",&n,s);
	if(n%2!=0) printf("No\n");
	else{
		b=n/2;
		for(i=0;i<b;i++){
			if(s[i]==s[i+b]) a++;
		}
		if(b==a) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1636
import numpy as np
n,m = map(int,input().split())
h_ls = list(map(int, input().split()))
isgood_ls = [1] * n

for i in range(m):
    a,b = map(int,input().split())
    if h_ls[a-1] > h_ls[b-1]:
        isgood_ls[b-1] = 0
    elif h_ls[a-1] < h_ls[b-1]:
        isgood_ls[a-1] = 0
    else:
        isgood_ls[b-1] = 0
        isgood_ls[a-1] = 0

print(sum(isgood_ls))

Measured memory_bytes: 38364
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VVI t(n,VI(2));
    REP(i,n){
        cin >> t[i][0] >> t[i][1];
    }

    VVI dp(n,VI(2));

    dp[0]=t[0];

     FOR(i,1,n){
         int tmp=max((dp[i-1][0]-1)/t[i][0],(dp[i-1][1]-1)/t[i][1])+1;
         dp[i][0] = tmp*t[i][0];
         dp[i][1] = tmp*t[i][1];
     }

    cout << dp[n-1][0]+dp[n-1][1] << ENDL;
    
    return 0;
}

Measured memory_bytes: 384