akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int N,x,y,i,s;
  scanf("%d",&N);
  s=0;
  for(i=0;i<N;i++){
    scanf("%d %d",&x,&y);
    s+=y-x+1;
  }
  printf("%d",s);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    double l;
    cin >> l;
    double res = l * l * l / 27;
    cout << fixed << setprecision(8) << res << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> ab(n);
  for (int i = 0; i < n; i++)
    cin >> ab[i].first >> ab[i].second;
  sort(ab.begin(), ab.end(), [](const pair<ll, ll> &l, const pair<ll, ll> &r) {
    return l.first < r.first;
  });
  ll ans = 0;
  int id = 0;
  while (m > 0) {
    ans += min(m, ab[id].second) * ab[id].first;
    m -= min(m, ab[id].second);
    id++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

#define INF (1 << 26)
#define MAX_V 10000

struct edge{
	int to;
	int cost;
};

typedef pair<int, int> P; // first??????????????¢???second??????????????????

vector<edge> G[MAX_V];
int d[MAX_V];

// ?????????O(|E|log|V|)

void shortest_path(int s, int V){ // V???????????°
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // ????????????????°???????????????´??°
	}
}

int main(){
	
	int c, n, m, s, g;
	
	while(true){
		cin >> c >> n >> m >> s >> g;
		if(c == 0 && n == 0 && m == 0 && s == 0 && g == 0){
			break;
		}
		int V = n * (c + 1);
		for(int i = 0; i <= V; i++){
			G[i].erase(G[i].begin(), G[i].end());
		}
		for(int i = 0; i < m; i++){
			int a, b, f;
			cin >> a >> b >> f;
			
			int cost = f;
			
			for(int j = 0; j <= c; j++){
				
				int index1 = (a - 1) * (c + 1) + j;
				int index2 = (b - 1) * (c + 1) + j;
				
				edge e1, e2;
				e1.to = index2;
				e2.to = index1;
				e1.cost = cost;
				e2.cost = cost;
				G[index1].push_back(e1);
				G[index2].push_back(e2);
			}
			
			for(int j = 0; j < c; j++){
				
				int index1 = (a - 1) * (c + 1) + j;
				int index2 = (b - 1) * (c + 1) + j + 1;
				
				edge e1;
				e1.to = index2;
				e1.cost = cost / 2;
				G[index1].push_back(e1);
			}
			
			for(int j = 0; j < c; j++){
				
				int index1 = (a - 1) * (c + 1) + j + 1;
				int index2 = (b - 1) * (c + 1) + j;
				
				edge e1;
				e1.to = index1;
				e1.cost = cost / 2;
				G[index2].push_back(e1);
			}
			
		}
		s = (s - 1) * (c + 1);
		g--;
		
		shortest_path(s, V);
		
		int min = INF;
		
		for(int i = 0; i <= c; i++){
			if(d[g * (c + 1) + i] < min){
				min = d[g * (c + 1) + i];
			}
		}
		
		cout << min << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
ll n;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		ll cnt = 0;
		for (int i = 1; i <= n; ++i)
			if (to_string(i).size() & 1)
				cnt++;
		cout << cnt << endl;
	}
}
/*
11
136
100000
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[1001000];
int main(){
    int n,m,w;
    cin>>n>>m;
    w=pow(10,ceil(log10(m+1)))*n+m;
    int g=sqrt(w);
    if (g*g==w)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int S[100005];
int main(){
  int N;
  cin>>N;
  FOR(i,0,N){
    int A;
    cin>>A;
    S[A-1]++;
    S[A]++;
    S[A+1]++;
  }
  sort(S,S+100005,greater<int>());
  cout<<S[0]<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>

#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)

inline void read( int &x ){
    x = 0 ; int f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

inline void readl( ll &x ){
    x = 0 ; ll f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

using namespace std ;

#define N 100010

int a[ N ] , n , m ; 
int cnt1[ N ] , cnt2[ N ] ;
int p1 , p2 , mx1 , mx2 , P1 , P2 , M1 , M2 ; 

int main() {
	scanf( "%d" , &n ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		scanf( "%d" , &a[ i ] ) ; 
		if( i & 1 ) cnt1[ a[ i ] ] ++ ;
		else cnt2[ a[ i ] ] ++ ;
	}
	for( int i = 1 ; i <= int( 1e5 ) ; i ++ ) {
		if( cnt1[ i ] > mx1 ) {
			swap( p1 , p2 ) ;
			swap( mx1 , mx2 ) ;
			mx1 = cnt1[ i ] ;
			p1 = i ;
		}else if( cnt1[ i ] > mx2 ) {
			mx2 = cnt1[ i ] ;
			p2 = i ;
		}
		if( cnt2[ i ] > M1 ) {
			swap( P1 , P2 ) ;
			swap( M1 , M2 ) ;
			M1 = cnt2[ i ] ;
			P1 = i ;
		}else if( cnt2[ i ] > M2 ) {
			M2 = cnt2[ i ] ;
			P2 = i ;
		} 
	}
//	printf( "%d %d %d %d\n" , mx1 , mx2 , M1 , M2 ) ;
//	printf( "%d %d %d %d\n" , p1 , p2 , P1 , P2 ) ;
	if( p1 != P1 ) {
		printf( "%d\n" , n - M1 - mx1 ) ;
	}else {
		printf( "%d\n" , n - max( M1 + mx2 , M2 + mx1 ) ) ;
	}
	return 0 ;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	double a, b, v, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;

	if (v <= w) {
		cout << "NO\n";
		return 0;
	}
	double dis = abs(a - b);
	double vec = v - w;
	double time = dis / vec;
	if (time <= t) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
	
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
const int inf=2e9+7;
long long n,m;
long long w[101],v[101];
long long dp[101][100001];

int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	fill(dp[0],dp[0]+100001,inf);
	dp[0][0]=0;
	for (int i=0;i<n;i++){
		for (int j=0;j<=100000;j++){
			if (j<v[i]){
				dp[i+1][j]=dp[i][j];
			}else {
				dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
			}
		}
	}
	int res=0;
	for (int i=0;i<=100000;i++){
		if (dp[n][i]<=m){
			res=i;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;

    int seila = b/a;

    if (seila >= c) {
        cout << c << endl;
    }
    else {
        cout << seila << endl;
    }


    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    string n;
    cin >> n;
    int cnt = 0;
    char prev = ' ';
    int maxCnt = 0;
    rep (i, n.size()) {
        if (prev == n[i]) {
            cnt++;
        }
        else {
            maxCnt = max(maxCnt, cnt);
            cnt = 1;
            prev = n[i];
        }
    }
    maxCnt = max(maxCnt, cnt);
    yorn (maxCnt >= 3);
    return 0;
}

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    public class StringData
    {
        public string str;
        public int count;

    }

    class Program
    {
        static void Main(string[] args)
        {
            string maxLengthString = "";
            string maxCountString = "";
            List<StringData> list = new List<StringData>();
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] array = input.Split(' ');
                foreach (string s in array)
                {
                    int flag = 0;
                    foreach (StringData sd in list)
                    {
                        if (s == sd.str)
                        {
                            sd.count++;
                            flag = 1;
                            break;
                        }

                    }

                    if (s.Length > maxLengthString.Length)
                    {
                        maxLengthString = s;
                    }

                    if (flag == 0)
                    {
                        StringData tmpSd = new StringData();
                        tmpSd.str = s;
                        tmpSd.count = 1;
                        list.Add(tmpSd);
                    }

                }

            }

            int maxCount = 0;
            foreach (StringData sd in list)
            {
                if (sd.count > maxCount)
                {
                    maxCountString = sd.str;
                    maxCount = sd.count;
                }
            }

            Console.WriteLine("{0} {1}", maxCountString, maxLengthString);


        }

        
    }
}

Measured memory_bytes: 5452
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(n: usize, k: usize, x: usize, y: usize);
    if n > k {
        println!("{}", k * x + (n - k) * y);
    } else {
        println!("{}", n * x);
    }
}


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

int main() {

  double a, b, t;
  cin >> a >> b >> t;

  int ans = 0;
  int i = 2;
  int time = a;
  while(time<t+0.5) {
    ans += b;
    time = i*a;
    i++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
long long int p[100000];
//long long int x[1000000000]={0};

int main()
{
    long long int n,i,a[100000],ans,q;
   // cin>>n;
   map<ll,ll>x;
   scanf("%lld",&n);
    ans=0;q=0;
    for(i=0;i<n;i++)
    {
       // cin>>a[i];
       scanf("%lld",&a[i]);
        x[a[i]]++;
        if(x[a[i]]==2)
        {
            p[q++]=a[i];
        }

    }
    sort(p,p+q);
   if(q>=2)
     {
         if(x[p[q-1]]>=4)
            ans=p[q-1]*p[q-1];
         else
            ans=p[q-1]*p[q-2];
     }
   else if(q==1&&x[p[0]]>=4)
     ans=p[0]*p[0];
   else
    ans=0;

   // cout<<ans<<endl;
   printf("%lld\n",ans);
}


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

int main(){
    ll n,m;
    scanf("%lld", &n);
    scanf("%lld", &m);
    
    int Ai[m];
    rep(i,m){
        scanf("%d", &Ai[i]);
        n = n - Ai[i];
        if (n < 0){
            n = -1;
            break;
        }
    }
    printf("%lld",n);
}

Measured memory_bytes: 3832
N = int(input())

a = map(int, input().split())

li_even = []

for i in a:
    if i % 2 == 0:
        li_even.append(i)
    else:
        pass
count = 0
for num in li_even:
    while num % 2 == 0:
        num /= 2
        count += 1

print(count)


Measured memory_bytes: 4144
$N = gets.chomp.to_i

$X = gets.chomp.split(' ').map(&:to_i)

half = $N / 2

sorted = $X.sort

medium = [sorted[half - 1], sorted[half]]

$N.times do |i|
  if medium[0] < $X[i]
    puts medium[0]
  else
    puts medium[1]
  end
end

Measured memory_bytes: 25672
n = gets.to_i
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)
destroy_num_all = 0

n.times do |i|
  # 1つ目の街で討伐
  destroy_num = [a[i], b[i]].min
  b[i] -= destroy_num
  # a[i] -= destroy_num
  destroy_num_all += destroy_num

  # 2つ目の街で討伐
  destroy_num = [a[i + 1], b[i]].min
  # b[i] -= destroy_num
  a[i + 1] -= destroy_num
  destroy_num_all += destroy_num
end

puts destroy_num_all


Measured memory_bytes: 19612
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int box[1000005];
int main()
{
	for(int i=0;i<=999999;i++)
		box[i]=1;
	box[1]=box[0]=0;
	int n;
    int rooted=sqrt(999999);
    for(int i=2;i<=rooted;i++)
        if(box[i])
            for(int j=2;j*i<=999999;j++)
                box[j*i]=0;
	while (cin >> n)
	{
		int s=0;
		for (int i=1;i<=n;i++)
			s+=box[i];
		cout << s << endl;
	}
}

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

struct seg {
  vector<int> v;
  seg(int n):v(n*2,2147483647){}
  void update(int i,int x){
    for(i+=v.size()/2,v[i]=x;i/= 2;)v[i]=min(v[i*2],v[i*2+1]);
  }
  int find(int l,int r){
    int x=2147483647;
    for(l+=v.size()/2,r+=v.size()/2;l!= r;l/=2,r/=2){
      if(l%2)x=min(x,v[l++]);
      if(r%2)x=min(x,v[--r]);
    }
    return x;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  seg s(n);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c)
      cout << s.find(x, y + 1) << endl;
    else
      s.update(x, y);
  }
}


Measured memory_bytes: 3560
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto a = readln.chomp.to!BigInt;
  auto b = readln.chomp.to!BigInt;
  if (a > b) {
    writeln("GREATER");
  } else if (b > a) {
    writeln("LESS");
  } else {
    writeln("EQUAL");
  }
}


Measured memory_bytes: 256
N= int(input())
l = list(map(int, input().split()))

ans = 0
while True:
    end_flg = True
    for i, item in enumerate(l):
        if item % 2 ==0:
            l[i] = item // 2
            end_flg = False
            ans += 1
    if end_flg:
        break
print(ans)

Measured memory_bytes: 4148
use proconio::input;
// use num::*;

fn main() {
    input! {
      n: i128,
      k: usize,
      mut p: [usize; n]
    };
    p.sort();
    let mut index: usize = 0;
    let mut ans = 0;
    while index < k {
        ans += p[index];
        index = index + 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2200
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt();
        int Q = scanner.nextInt();
        scanner.nextLine();

        WeightedUnionFindTree uft = new WeightedUnionFindTree(N);
        for (int i = 0; i < Q; i++) {
            int[] q = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            if (q[0] == 0) {
                uft.merge(q[1], q[2], q[3]);
            } else {
                int ans = uft.diff(q[1], q[2]);
                if (ans == Integer.MAX_VALUE) {
                    System.out.println('?');
                } else {
                    System.out.println(ans);
                }
            }
        }
    }

}

class WeightedUnionFindTree {
    int size;
    int[] par;
    int[] rank;
    int[] weight;

    public WeightedUnionFindTree(int size) {
        this.size = size;
        par = new int[size];
        for (int i = 0; i < size; i++) {
            par[i] = i;
        }
        rank = new int[size];
        Arrays.fill(rank, 1);
        weight= new int[size];
    }

    private int root(int x) {
        if (x == par[x]) {
            return x;
        }
        int root = root(par[x]);
        // cSum
        weight[x] += weight[par[x]];
        par[x] = root;
        return root;
    }

    private int calcWeight(int x) {
        root(x);
        return weight[x];
    }

    public int diff(int x, int y) {
        if (!same(x, y)) {
            return Integer.MAX_VALUE;
        }
        return calcWeight(y) - calcWeight(x);
    }

    public boolean same(int x, int y) {
        return root(x) == root(y);
    }

    public void merge(int x, int y) {
        merge(x, y, 1);
    }

    // merge as weight(y) = weight(x) + w
    public void merge(int x, int y, int w) {
        w += calcWeight(x);
        w -= calcWeight(y);

        int xr = root(x);
        int yr = root(y);

        if (xr == yr) {
            return;
        }

        if (rank[xr] < rank[yr]) {
            par[xr] = yr;
            weight[xr] = -w;
        } else {
            par[yr] = xr;
            weight[yr] = w;
            if (rank[xr] == rank[yr]) {
                rank[xr]++;
            }
        }
    }

}



Measured memory_bytes: 213372
import math
import collections
import sys

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

k=I()
s1=k*(k+1)//2
s2=0
for i in range(1,k):
    for j in range(i+1,k+1):
        s2+=gcd(i,j)
s2=6*s2
#print(s1,s2)
s3=0
for i in range(1,k-1):
    for j in range(i+1,k):
        for l in range(j+1,k+1):
            s3+=6*gcd(gcd(i,j),l)
#print(s3)
ans=s1+s2+s3
print(ans)

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



int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<long long> dp(N, 0);

    int a;
    for (int i = 0; i < M; i++) {
        std::cin >> a;
        dp[a] = -1;
    }

    for (int i = N-1; i >= 0; i--) {
        if (dp[i] == -1) continue;
        if (i + 1 < N && dp[i+1] != -1) {
            dp[i] = (dp[i] + (dp[i+1] % 1000000007))  % 1000000007;
        }
        else if (i+1==N) {
            dp[i] = (dp[i] + 1) % 1000000007;
        }

        if (i + 2 < N && dp[i+2] != -1) {
            dp[i] = (dp[i] + (dp[i+2] % 1000000007))  % 1000000007;
        }
        else if (i+2==N) {
            dp[i] = (dp[i] + 1) % 1000000007;
        }  
    }

    long long ans = dp[0] % 1000000007;

    std::cout << dp[0] << std::endl;

    return 0;
}

Measured memory_bytes: 1024
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const num = Number(input[0]);
const hour = Math.floor(num / (60 * 60));
const minute = Math.floor(num / 60) % 60;
const second = num % 60
console.log(hour + ':' + minute + ':' + second);

Measured memory_bytes: 15676
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n;cin>>n;
	string ans = "No";
	rep(i,1,9)rep(j,1,9)if(i*j==n)ans="Yes";
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
using namespace std;

#define n 100

int main (void)
{
	char ei[100], data[200], temp[100];

	scanf("%s", data);
	scanf("%s", ei);

	strcpy(temp, data);
	strcat (data, temp);


	if (strstr(data, ei) != NULL)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 968
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int k = sc.nextInt();
			if (k % 2 == 0) {
				System.out.println((int) Math.pow((k / 2), 2));
			} else {
				System.out.println((k / 2) * (k / 2 + 1));
			}
		}
	}
}


Measured memory_bytes: 35736
N = int(input())
S = input()
S2 = []

alfa = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

for i in range(len(S)):
    num = alfa.index(S[i])
    num += N
    if num >= 26:
        num -= 26
    S2.append(alfa[num])

for i in range(len(S2)):
    print(S2[i], end="")
print("")

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define UINF -1

using namespace std;

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

const int max_n = 2000002;

int a[max_n];
int heap_size;

void maxHeapify (int i )
{
	int l = 2*i + 1;
	int r = 2*i + 2;
	int largest;

	if (l < heap_size && a[l] > a[i] )
		largest = l;
	else
		largest = i;
	if (r < heap_size && a[r] > a[largest] )
		largest = r;

	if (largest != i ){
		swap (a[i], a[largest] );
		maxHeapify (largest );
	} // end if				
}

int heapExtractMax (void )
{
	if (heap_size < 1 ){
		return -1;
	} // end if

	int max = a[0];
	a[0] = a[heap_size-1];
	heap_size--;
	maxHeapify (0  );

	return max;
}

void heapIncreaseKey (int i, int key )
{
	if (key < a[i] ){
		cerr << "新しいキーは現在のキーより小さい" << endl;
	} // end if
	
	a[i] = key;
	while (i > 0 && a[(i-1)/2] < a[i] ){
		swap (a[i], a[(i-1)/2] );
		i = (i-1)/2;
	} // end while
}

void maxHeapInsert (int key )
{
	heap_size++;
	a[heap_size-1] = UINF;
	heapIncreaseKey (heap_size-1, key );
}

int main()
{
	memset (a, 0, sizeof (a ) );
	heap_size = 0;

	ios_base::sync_with_stdio(0);
	string com = "";
	while (true ){
		cin >> com;
		if (com == "end" ) break;
		else
		if (com == "insert" ){
			int key; cin >> key;
			maxHeapInsert(key );
		}else
		if (com == "extract" ){
			int maxv = heapExtractMax();
			cout << maxv << endl;
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 9048
#include<stdio.h>

int main(){
	
	int l,m,n,i,z;
	
	while(1){
		scanf("%d",&l);
		if(l==0){
			break;
		}
		
		for(i=1;i<=12;i++){
			scanf("%d %d",&m,&n);
			
			if(l>0 && l-(m-n)<=0){
				z=i;
			}
			
			l-=(m-n);
		}
		
		if(l<=0){
			printf("%d\n",z);
		}
		else if(l>0){
			printf("NA\n");
		}
	}
return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	char c; cin >> c;
	char lo[] = { 'a','i', 'u', 'e', 'o' };
	bool elf = false;
	rep(i, 5) if (c == lo[i]) elf = true;
	puts(elf ? "vowel" : "consonant");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int cla,yen;
	for(int i=0;i<4;i++){
	cin>>cla>>yen;
	if(cla==1){
	cout<<6000*yen<<endl;
	}else if(cla==2){
	cout<<4000*yen<<endl;
	}else if(cla==3){
	cout<<3000*yen<<endl;
	}else if(cla==4){
	cout<<2000*yen<<endl;
	}
	}
	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long n, std::vector<long long> d) {
    sort(all(d));
    // int n;
    // cin >> n;
    // int d[n];
    // rep(i, n) { cin >> d[i]; }
    // check
    // rep(i, n) {
    //     if (i > 0) cout << " ";
    //     cout << d[i];
    // }
    // cout << endl;

    // cout << d.size() << endl;
    int abc = d[d.size() / 2 - 1];
    int arc = d[d.size() / 2];
    // cout << d[d.size() / 2 - 1] << endl;
    // cout << d[d.size() / 2] << endl;
    // cout << arc << " " << abc << endl;
    if (arc == abc) {
        cout << 0 << endl;
    } else {
        cout << arc - abc << endl;
    }
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> d(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &d[i]);
    }
    func(N, std::move(d));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=5010, LOG=15;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];
bitset<MAXN> dp[LOG];

void divide(int tl, int tr, int h){
	if (tr-tl==1){
		for (int i=max(0, k-A[tl]); i<k; i++) if (dp[h][i]) return ;
		ans++;
		return ;
	}
	int mid=(tl+tr)>>1;
	dp[h+1]=dp[h];
	for (int i=tl; i<mid; i++) dp[h+1]|=dp[h+1]<<A[i];
	divide(mid, tr, h+1);
	
	dp[h+1]=dp[h];
	for (int i=mid; i<tr; i++) dp[h+1]|=dp[h+1]<<A[i];
	divide(tl, mid, h+1);
	return ;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k;
	for (int i=1; i<=n; i++) cin>>A[i], A[i]=min(k+1, A[i]);
	dp[0].set(0);
	divide(1, n+1, 0);
	cout<<ans<<"\n";
	
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d;
    cin >> s;

    bool f = true;

    FOR(i, b, d-1){
        if(s[i] == '#' && s[i+1] == '#'){
            f = false;
            break;
        }
    }

    FOR(i, a, c-1){
        if(s[i] == '#' && s[i+1] == '#'){
            f = false;
            break;
        }
    }

    if(c > d){
        FOR(i, b-1, d){
            if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                f = true;
                break;
            }else{
                f = false;
            }
        }
    }


    cout << (f ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 592
/*
NAME:
 ___   _      _   ___  
/ __| /_\    /_\ |   \ 
\__ \/ _ \  / _ \| |) |
|___/_/ \_\/_/ \_\___/ 

lang: 
  ___   _      _   
 / __)_| |_  _| |_ 
( (__(_   _)(_   _)
 \___) |_|    |_|  

*/
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
 
using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef long l;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<l> vl;
typedef vector<ll> vll;

const int INF = 1 << 29;
const int MOD = 1e9 + 7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
 
void solve(){
	int n,d,cnt=0;
	cin>>n>>d;
	for(int i=0;i<n;i++){
		double x,y;
		cin>>x>>y;
		double root=sqrt((x*x)+(y*y));
	//	cout<<root<<endl;
		if(root<=d) cnt++;
	}
	cout<<cnt;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();

	return 0;
}

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

using namespace std;

struct edge{
	int u;	//?????????
	int v;	//??°??????
	int cost;	//??????
	//???????????????????????§?????§?°???¢????????????
	bool operator<(const edge& another) const {
			return cost < another.cost;
	}
};

const int MAX_N = 100;
const int MAX_M = 10000;

edge es[MAX_M];
int par[MAX_N];
int rank[MAX_N];

void initial(int n){		//?????????
	for(int i=0;i<n;i++){
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x){		//??¨??????????±???????
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x,int y){	//x???????????¨??¨y???????????¨?????????
	x = find(x);	//x???????????¨??????????????????x??¨??????
	y = find(y);	//y???????????¨??????????????????y??¨??????
	if(x == y) return;
	if(rank[x] < rank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

bool same(int x,int y){	//x,y???????????¨???????????§?????????
	return find(x) == find(y);
}

bool comp(const edge& e1,const edge& e2){
	return e1.cost < e2.cost;
}

int kruskal(int n,int m){
	initial(n);
	int res = 0;
	for(int i=0;i<m;i++){
		edge e = es[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			res += e.cost;
		}
	}
	return res;
}

int main(){
	int n,m=0,k,l,x;
	cin >> n;	//????????°?????\???
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin >> x;
			if(x != -1){
				edge e;
				e.u = i; e.v = j; e.cost = x;
				es[m] = e;
				m++;
			}
		}
	}
	sort(es,es+m);
	cout << kruskal(n,m) << "\n";
}

Measured memory_bytes: 3104
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int a[110];
int main() {
	int n, x;
	scanf("%d%d", &n, &x);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= x) {
			x -= a[i];
			cnt++;
		}
	}
	if (cnt == n && x != 0)
		cnt--;
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int x; cin >> x;

  int ans = 0, t = 0;
  for(int i = 0; i < INF; i++){
    if(i != 0 && t % 360 == 0) break;
    ans++;
    t += x;
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	int c[10][10];
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> c[i][j];
	for (int k = 0; k < 10; k++)
		for (int i = 0; i < 10; i++)
			for (int j = 0; j < 10; j++)
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	int ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			if (a == -1) continue;
			ans += c[a][1];
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll M,N;
    
    cin >> N>>M;
    
    double sum=0;
    
     vector<ll> vec(N);
    for (ll i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    
    for (ll i = 0; i < N; i++) {
        sum+=vec.at(i);
    }
    
   
    
    if(vec.at(M-1)<sum/(4*M)){
    cout << "No" << endl;
    }
    else cout <<"Yes";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

const long long INF = 1LL << 60;

int min(int a, int b){
    if(a<b) return a;
    else return b;
}
int main(void){
    int n, h[100001], dp[100001]={INF};
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", &h[i]);
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d", dp[n-1]);
    return 0;
}

Measured memory_bytes: 2516
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
    long long int N, A, B;
 
    cin >> N >> A >> B;
 
    long long int y = N / (A + B) * A;
    long long int a = N % (A + B);
    long long int b;
  
    if(A>=a)	b = a;
    else b = A;
  
    cout << (y+b);
 
    return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())

p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

if p == q:
    print(0)
else:
    count = 1
    for per in itertools.permutations(range(1,n+1)):
        if per == p:
            a = count
        elif per == q:
            b = count
        count += 1

    print(abs(a-b))


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n,k;
	std::cin >> n >> k;
	std::vector<ll> x(n);
	for (size_t i = 0; i < n; i++) {
		std::cin >> x[i];
	}

	ll ans = INT_MAX / 3;

	for (size_t i = 0; i <= n-k; i++) {
		if (x[i] < 0) {
			if (x[i+k-1] < 0) {
				ans = min(ans, abs(x[i]));
			}
			else {
				// 左行って右
				ans = min(ans, abs(x[i]) + x[i+k-1] - x[i]);
				// 右行って左
				ans = min(ans, x[i+k-1] + x[i+k-1] - x[i]);
			}
		}
		else {
			ans = min(ans, x[i+k-1]);
		}
	}

	std::cout << ans << '\n';

	return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

bool solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  // りんごマートはある日の朝に開店し，その時にはジュースの在庫がA本ありました。
  // すぬけ君は毎日昼にりんごマートでジュースをB本買います。
  // りんごマートでは毎日夜にジュースの在庫を確認し，
  // C本以下だった場合，次の日の朝までにD本在庫を追加します。

  // はじめから無い
  if (a < b)
    return false;

  // 充填数のほうが消費数よりも少ない
  if (b > d)
    return false;

  if (c >= b)
    return true;

  a %= b;
  ll step = gcd(b, d);

  a += ((b - a - 1) / step) * step;
  if (a > c)
    return false;

  return true;
}

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

  ll t;
  cin >> t;
  rep(i, t) {
    bool b = solve();
    cout << ((b) ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

ll ans = 0;
ll n;
vector<vector<pair<ll, ll> > > v;

void solve(ll i, ll bit)
{
    if (i != n)
    {
        solve(i + 1, bit);
        solve(i + 1, bit | (1LL << i));
    }
    else
    {
        // cout << "bit : " << bit << endl;
        // ll temp_ans = 0;
        // 矛盾が出たらreturn
        // 矛盾する人をカウント？
        for (ll k = 0; k < n; k++)
        {
            ll mask = 0;
            if ((bit >> k) & 1)
            {
                mask = 1;
            }
            // cout << mask << endl; // maskはあってる

            if (!v[k].empty())
            {
                for (ll m = 0; m < v[k].size(); m++)
                {
                    ll px = v[k][m].first - 1;
                    ll py = v[k][m].second;
                    //  & mask; // mask=0なら反転では？
                    if (mask == 0)
                    {
                        py = py ^ 1LL;
                    }

                    if (mask == 1)
                        if (py != ((bit >> px) & 1))
                        {
                            return;
                        }
                }
            }
        }
        ll temp_ans = 0;
        for (ll b = 0; b < n; b++)
        {
            if (bit & (1 << b))
            {
                temp_ans++;
            }
        }
        // cout << temp_ans << endl;

        ans = max(ans, temp_ans);
    }
}

int main(int argc, char const *argv[])
{
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        vector<pair<ll, ll> > t;
        for (ll k = 0; k < a[i]; k++)
        {
            ll x, y;
            cin >> x >> y;
            t.push_back(make_pair(x, y));
        }
        v.push_back(t);
    }

    solve(0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n = int(input())
    a = [(int(v), i) for i, v in enumerate(input().split())]
    a.sort(reverse=True)
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = a[0][0] * (n - 1 - a[0][1])
    dp[0][1] = a[0][0] * a[0][1]
    for i, v in enumerate(a[1:]):
        dp[i+1][0] = dp[i][0] + v[0] * abs(n - 1 - (i + 1) - v[1])
        dp[i+1][i+2] = dp[i][i+1] + v[0] * abs(v[1] - (i + 1))
        for j in range(1, i + 2):
            dp[i+1][j] = max(
                dp[i][j] + v[0] * abs(n - 1 - (i + 1) + j - v[1]),
                dp[i][j-1] + v[0] * abs(v[1] - (j - 1)))
    ans = -float('inf')
    for i in dp[n-1]:
        ans = max(ans, i)
    print(ans)


main()

Measured memory_bytes: 136200
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

ll dis(ll a,ll b,ll c,ll d) {
  vl arr{a,b,c,d};
  sort(rng(arr));
  if(arr[0]==0) return LINF;
  return arr[3]-arr[0];
}
  
int main() {
  int N;
  cin >> N;
  vl sum(N+1,0);
  rep(i,N) {
    int x;
    cin >> x;
    sum[i+1] = sum[i]+x;
  }
  ll ans = LINF;
  srep(m,1,N-2) {
    ll l = sum[m+1];
    ll r = sum[N]-sum[m+1];
    ll p1 = *lower_bound(rng(sum),(l+1)/2);
    ll p2 = *(lower_bound(rng(sum),(l+1)/2)-1);
    ll q1 = l-p1;
    ll q2 = l-p2;
    ll r1 = *lower_bound(rng(sum),l+(r+1)/2)-l;
    ll r2 = *(lower_bound(rng(sum),l+(r+1)/2)-1)-l;
    ll s1 = r-r1;
    ll s2 = r-r2;
    chmin(ans,dis(p1,q1,r1,s1));
    chmin(ans,dis(p1,q1,r2,s2));
    chmin(ans,dis(p2,q2,r1,s1));
    chmin(ans,dis(p2,q2,r2,s2));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
   int n,k;
   cin>>n>>k;
   int cnt=0;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       if(x>=k)cnt++;
   }
   cout<<cnt;

}


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

x = len(str(n))

ans = 0

if x%2 == 0:
    for i in range(1,x+1,2):
        ans += 10**i*(9/10)
else:
    for i in range(1,x,2):
        ans += 10**i*(9/10)
    ans += n-10**(x-1)+1
    
print(int(ans))

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l[200005], r[200005];
    l[0] = 0;
    for(int i = 1; i <= n; i++){
        l[i] = l[i - 1];
        if(s[i - 1] == 'W') l[i]++;
    }
    r[n] = 0;
    for(int i = n - 1; i >= 0; i--){
        r[i] = r[i + 1];
        if(s[i] == 'R') r[i]++;
    }
    int ans = 1000000;
    for(int i = 0; i <= n; i++){
        ans = min(ans, max(l[i], r[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 5312
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll solve(ll A, ll B) {
	ll N = A * B;
	if (A > B) swap(A, B);
	ll T = sqrt(N);
	while (T * T <= N) T++;
	while (T * T >= N) T--;
	ll sol = 0;
	if (T * (T + 1) < N) {
		// Split at T T+1
		sol = 2 * T;
	}
	else {
		// Split at T T
		sol = 2 * (T - 1) + 1;
	}
	if (T >= A) sol--;
	return sol;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int Q;
    cin >> Q;
    for (int i = 0;i < Q;i++) {
    	ll A, B;
    	cin >> A >> B;
    	cout << solve(A, B) << endl;
    }
    return 0;
}

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

int main(void){
    string pali;
    cin>>pali;
    int hl=pali.size()/2;
    
    int hug=0;
    for(int i=0;i<hl;i++){
        if(pali[i]!=pali[pali.size()-i-1])hug++;
    }
    cout<<hug<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;

int main()
{
	in>>N;
	
	LL aa=sqrt(N);
	out<<aa*aa<<std::endl;
	return 0;
}


Measured memory_bytes: 256