akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> l(n,0);
    REP(i,n)cin >> l[i];

    sort(all(l));

    ll ans = 0;
    for(int j = 0;j < n;j++){
        for(int i = j + 1;i < n;i++){
            // cout << "a b " << l[i] << " " << l[j] << endl; 
            int t = l[j] + l[i];
            int s = l[i] - l[j];
            // cout << "t s " << t << " " << s << endl; 
            int tt = lower_bound(all(l),t) - l.begin();
            int ss = upper_bound(all(l),s) - l.begin();
            // cout << "tt ss " << tt << " " << ss << endl; 
            if(tt - (i+1) <= 0)continue;
            ans += tt - (i+1);
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

const int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int N = Cin();
    vector<int> As(N);
    for (int i = 1; i <= N; ++i)
    {
        As[i - 1] = Cin() - i;
    }
    sort(As.begin(), As.end());
    int median;
    if (N % 2 == 0)
    {
        median = (As[N / 2 - 1] + As[N / 2]) / 2;
    }
    else
    {
        median = As[N / 2];
    }
    LLONG ans = 0;
    for (const int &Ai : As) { ans += abs(Ai - median); }
    cout << ans << endl;
}


Measured memory_bytes: 1024
F = {}

def fib(n):
  global F
  if n < 0:
    print("error")
    exit()
  if n < 2:
    F[n] = 1
    return F[n]
#  F[n] = fib(n-1) + fib(n-2)
  F[n] = F[n-1] + F[n-2]
  return F[n]

n = int(input())
#print(fib(n))
#n = int(input())
#print(fib(n))
#fib(44)
for i in range(n+1):
  result = fib(i)
print(result)
#  print(F[i])

Measured memory_bytes: 7668
import java.util.ArrayList;
import java.util.Scanner;

class Score {
	private int id;
	private int pt;

	Score(int id, int pt){
		this.id = id;
		this.pt = pt;
	}

	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getPt() {
		return pt;
	}
	public void setPt(int pt) {
		this.pt = pt;
	}
}

public class Main {

	public static void main(String[] args) {
		ArrayList<Score> s = new ArrayList<Score>();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

			for (int i = 0; i < n; i++) {
				s.add( new Score(sc.nextInt(), sc.nextInt()) );
			}

		s.sort((a,b)-> a.getId() - b.getId() );
		s.sort((a,b)-> b.getPt() - a.getPt() );
		System.out.printf("%d %d\n", s.get(0).getId(), s.get(0).getPt());


		sc.close();

	}

}



Measured memory_bytes: 32356
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#define rep(i, N) for(int (i)=0;(i)<(N);(i)++)
using namespace std;

int main(){
    int K, flag=0;
    unsigned long ans=0;
    char tmp;
    string N;
    string n = "npos";
    cin >> N >> K;
    string D;
    rep(i, K) {
        cin >> tmp;
        D.push_back(tmp);
    }
    
    for(unsigned long i=atol(N.c_str()); i<100000;i++){
        if(atol(N.c_str())<=i){
            ans = i;
            flag = 1;
            rep(j, to_string(i).size()){
                if(D.find(to_string(i)[j])!= std::string::npos) {
                    flag=0;
                }
            }
        }
        if(flag==1) break;
    }
    cout<<ans<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<int>abc(3,0); char s;
	while(cin>>s)++abc.at(s-'a');
	sort(abc.begin(),abc.end());
	cout<<(abc.back()-abc.front()<=1?"YES"s:"NO"s)<<"\n"s;
}


Measured memory_bytes: 3652
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	vector<ll>stu(n);

	rep(i, n)cin >> stu[i];
	ll tmp = 0,sum=0;
	for (int i = 1; i < n; i++) {
		if (stu[i] < stu[i - 1]) {
			tmp = stu[i-1] - stu[i];
			stu[i] += tmp;
			sum += tmp;
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 4788
n, m = map(int, input().split())
connect_l = [list(map(int, input().split()))[1:] for _ in range(m)]
p_l = list(map(int, input().split()))

ans = 0
for i in range(1 << n):
    cond = []
    flag = True
    for j in range(n):
        if (i >> j) & 1 == 1:
            cond.append(1)
        else:
            cond.append(0)
    for j in range(len(connect_l)):
        num_on = 0
        for s in connect_l[j]:
            num_on += cond[s-1]
        if not num_on % 2 == p_l[j]:
            flag = False
    if flag:
        ans += 1
print(ans)
            

        







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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n;
    cin>>n;
    n/=200;
    cout<<10-n<<endl;
    
    return 0;
}

Measured memory_bytes: 3592
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1])
 
c_l=[]
for b,c in l:
  c_l+=[c]*b
  if len(c_l)>=n:
    break
 
for i in range(min(n,len(c_l))):
  a[i]=max(a[i],c_l[i])
 
print(sum(a))

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

int a, s, t;

int main() {
	rep(i,4) scanf("%d",&a), s += a;
	rep(i,4) scanf("%d",&a), t += a;
	printf("%d\n",max(s,t));
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],c[maxn];
string s; 
signed main()
{
	ios::sync_with_stdio(0);
	cin >> s;
	int l = s.size();
	rep(i,0,2)
		cout << s[i];
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int n=0,m=0,city[51]={0},t1=0,t2=0;
  scanf("%d %d",&n,&m);
  for (size_t i = 0; i < m; i++) {
    scanf("%d %d",&t1,&t2);
    city[t1]++;city[t2]++;
  }
  for (size_t i = 1; i <= n; i++) {
    printf("%d\n",city[i]);
  }
  return 0;
}

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

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

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[] s = br.readLine().toCharArray();
		br.close();

		int ans = 0;
		int w = 0;
		int r = n - 1;
		while (w < r) {
			while (w < n && s[w] == 'R') {
				w++;
			}
			while (r >= 0 && s[r] == 'W') {
				r--;
			}
			if (w < r) {
				ans++;
				w++;
				r--;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 36452
#include<stdio.h>
#include<string.h>

int main()
{
    int a;
    int b;
    char tmp[16];
    
    while(scanf("%d %d", &a, &b) != EOF){
        sprintf(tmp, "%d", a+b);
        printf("%d\n", strlen(tmp));
    }
    
    return 0;
}

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

const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(int argc, char const *argv[])
{
	int h,w;
	cin>>h>>w;
	char s[h][w];
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin>>s[i][j];
		}
	}
	int f=1;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (s[i][j]=='#')
			{
				int g=0;
				for (int k = 0; k < 4; ++k)
				{
					int nx=i+dx[k],ny=j+dy[k];
					if (0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='#')
					{
						g=1;
					}
				}
				if (g==0)
				{
					f=0;
				}
			}
		}
	}
	if (f)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import static java.lang.Math.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double c = toRadians(sc.nextDouble());
		double S = b * a * sin(c) / 2;
		double L = a + b + sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(c));
		double h = b * sin(c);
		System.out.printf("%f %f %f\n",S, L, h);
	}
}



Measured memory_bytes: 28296
#include <iostream>

using namespace std;

int main(void)
{
    string s;

    cin >> s;

    int count[20] = {0};
    int j = 0;

    for (int i = 0 ; i < s.length(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            count[j]++;
        }
        else {
            j++;
        }

    }

    int max = 0;
    for (int i = 0; i < 20; i++) {
        if (max < count[i]) {
            max = count[i];
        }
    }

    cout << max << endl;


    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NXY = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NXY[0]; var X = NXY[1]; var Y = NXY[2];
            var distance = new int[N + 1, N + 1];
            var distanceCount = new int[N];
            for (int i = 1; i < N; i++)
            {
                for (int j = i + 1; j < N + 1; j++)
                {
                    distance[i, j] = Math.Min(j - i, Math.Min(Math.Abs(i - X) + Math.Abs(j - Y) + 1, Math.Abs(j - X) + Math.Abs(i - Y) + 1));
                    distanceCount[distance[i, j]]++;
                }
            }
            for (int i = 1; i < N; i++) Console.WriteLine(distanceCount[i]);
        }
    }
}


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

using namespace std;
const int N = 100005, INF = 1e9;
int n, k;
int h[N], sol[N];

int main() {
	cin >> n >> k;
	for(int i = 1; i <= n; i ++) {
		cin >> h[i];
	}
	for(int i = 1; i <= n; i ++) {
		sol[i] = INF;
	}
	sol[1] = 0;
	for(int i = 2; i <= k + 1; i ++) {
		sol[i] = abs(h[1] - h[i]);
	}
	for(int i = k + 2; i <= n; i ++) {
		for(int j = 1; j <= k; j ++) {
			sol[i] = min(sol[i], (sol[i - j] + abs(h[i - j] - h[i])));
		}
	}
	cout << sol[n];
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int[] lookW = new int[n];
        int[] lookE = new int[n];
        if(s.charAt(0)=='E') {
            lookE[0] = 1;
        } else {
            lookW[0] = 1;
        }
        for (int i = 1; i < n; i++) {
            if (s.charAt(i) == 'E') {
                lookE[i] = lookE[i - 1] + 1;
                lookW[i] = lookW[i - 1];
            } else {
                lookE[i] = lookE[i - 1];
                lookW[i] = lookW[i - 1] + 1;
            }
        }
        long ans = Long.MAX_VALUE;
        ans = Math.min(ans, lookE[n-1]-lookE[0]);
        for(int i = 1; i < n; i++) {
            ans = Math.min(ans, lookW[i-1]+lookE[n-1]-lookE[i]);
        }
        System.out.println(ans);
    }
}

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

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

int arr[n];
long long ans=0;
int maxi=0;

for(int i=0;i<n;i++)
{
cin>>arr[i];
}

maxi = arr[0];
for(int i=1;i<n;i++)
{
if(maxi <= arr[i])
maxi = arr[i];
else
ans += (maxi - arr[i]);
}

cout<<ans;

return 0;
}

Measured memory_bytes: 4400
def ruijo(n, l, mod):
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

def cmb(n, r, mod):
    if r == 1:
        return n
    elif n == r:
        return 1
    else:
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return ruijo(n, n-r+1, mod) * g2[r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

mod = 10**9+7 #出力の制限
    
n,a,b = map(int, input().split())
ans = power(2,n,mod) - 1 - cmb(n, a, mod) - cmb(n ,b ,mod)
if ans < 0:
    ans += mod
if ans < 0:
    ans += mod
print(ans)

Measured memory_bytes: 127688
#include <stdio.h>
#define repeat(i, n) for(int i = 0; i < n; i++)
#define maxN 100


int
main(int argc, char *argv[])
{
  int n, a[maxN], min = 1000, max = 0;
  scanf("%d", &n);
  repeat(i, n){
    scanf("%d", &a[i]);
    min = (a[i] < min ? a[i] : min);
    max = (a[i] > max ? a[i] : max);
  }
  printf("%d\n", max - min);

  return 0;
}

Measured memory_bytes: 128
N = int(input())
a = [list(map(int,input().split())) for i in range(2)]
b = []
for i in range(0,N):
    s = 0
    v = 0
    for j in range(0,i+1):
        s += a[0][j]
    for j in range(i,N):
        v += a[1][j]
    b.append(s+v)
print(max(b))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;

ll n,ans[N];
vector <pair<ll,ll>> v;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	FOR(i,0,n){
		ll w;
		cin>>w;
		v.pb(make_pair(w,i));
	}
	SORT(v);
	ll b=v[n/2-1].first;
	ll a=v[n/2].first;
	FOR(i,0,n/2){
		ans[v[i].second]=a;
	}
	FOR(i,n/2,n){
		ans[v[i].second]=b;
	}
	FOR(i,0,n){
		pri(ans[i]);
	}
	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());

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

    reverse(t.begin(), t.end());

    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;

ll gcd(ll a, ll b){
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll a, b, i;
    cin >> a >> b;
    if (a < b) swap(a, b);
    
    ll c = gcd(a, b);
    ll ans = 1;
    for (i=2;i*i<=c;i++){
        if (c%i == 0) {
            while (c%i == 0) c/=i;
            ans++;
        }
    }
    if (c > 1){
        ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
x,y,z = 0,0,0
ans = 1
mod = 10**9+7
for i in range(N):
    c = [x,y,z].count(A[i])
    if c == 0:
        print(0)
        exit(0)
    ans = ans*c % mod
    if x == A[i]:
        x += 1
    elif y == A[i]:
        y += 1
    else:
        z += 1
    l = list(sorted([x,y,z]))
    x,y,z = l[0],l[1],l[2]

print(ans)

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int n;cin>>n;
    int ans=0;

    if(n%10==0){
        cout<<10<<endl;
    }
    else {
        while(n>0){
            ans+=n%10;
            n/=10;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a + b == 15){
				System.out.println("+");
			}
			else if(a * b == 15){
				System.out.println("*");
			}
			else{
				System.out.println("x");
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 23636
import datetime
a=input()
year=a[0:4]
month=a[5:7]
day=a[8:10]

comp1 = datetime.datetime(int(year), int(month), int(day))
comp2 = datetime.datetime(2019 , 4 , 30)   

if comp1 > comp2:
    print('TBD')
else :
    print('Heisei')

Measured memory_bytes: 3312
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static final int MOD = 998244353;

	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}

	static int sub(int a, int b) {
		int res = a - b;
		return res < 0 ? res + MOD : res;
	}

	static void solve() throws Exception {
		String s = scanString();
		int k = scanInt();
		int n = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '0') {
				++n;
			}
		}
		int gs[] = new int[n + 1];
		for (int i = 0, j = 0; i < s.length(); i++) {
			if (s.charAt(i) == '0') {
				gs[j + 1] = gs[j];
				++j;
			} else {
				++gs[j];
			}
		}
		int m = gs[n];
		if (k > m) {
			k = m;
		}
		int dyn1[][][] = new int[n + 1][m + 1][k + 1];
		int dyn2[][][] = new int[n + 1][m + 1][k + 1];
		if (k > 0 && gs[0] < m) {
			dyn1[0][gs[0] + 1][1] = 1;
		}
		dyn2[0][gs[0]][0] = 1;
		for (int i = 0; i <= n; i++) {
			for (int j = m; j > gs[i]; j--) {
				for (int j2 = 0; j2 <= k; j2++) {
					dyn2[i][j - 1][j2] = add(dyn2[i][j - 1][j2], dyn2[i][j][j2]);
				}
			}
			for (int j = 0; j < m; j++) {
				for (int j2 = 0; j2 < k; j2++) {
					dyn1[i][j + 1][j2 + 1] = add(dyn1[i][j + 1][j2 + 1], dyn1[i][j][j2]);
				}
			}
			if (i < n) {
				for (int j = gs[i]; j <= m; j++) {
					int nj = j + gs[i + 1] - gs[i];
					for (int j2 = 0; j2 <= k; j2++) {
						int v = add(dyn1[i][j][j2], dyn2[i][j][j2]);
						if (j2 < k && nj < m) {
							dyn1[i + 1][nj + 1][j2 + 1] = add(dyn1[i + 1][nj + 1][j2 + 1], v);
						}
						dyn2[i + 1][min(nj, m)][j2] = add(dyn2[i + 1][min(nj, m)][j2], v);
						if (j > 0) {
							dyn2[i + 1][j - 1][j2] = sub(dyn2[i + 1][j - 1][j2], v);
						}
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i <= k; i++) {
			ans = add(ans, add(dyn1[n][m][i], dyn2[n][m][i]));
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 67428
#include <iostream>

using namespace std;

int main(void) {
  int sashikomi_num, tap_num, i;
  int A, B;
  cin >> A >> B;
  
  sashikomi_num = 1;
  tap_num = 0;
  while(B > sashikomi_num) {
    tap_num++;
    sashikomi_num--;
    sashikomi_num += A;
  }
  cout << tap_num << endl;
  return 0;
}

Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	string s;
	cin>>s;
	ll n=s.length();
	ll cura=0,co=0;
	for(ll i=0;i<n;i++)
	{
		if(i+1<n&&s[i]=='B'&&s[i+1]=='C')
		{
			co+=cura;
			i++;
			continue;
		}
		if(s[i]=='A')
		{
			cura++;
		}
		else
		{
			cura=0;
		}
	}
	cout<<co<<endl;
	return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  ll L, R;
  cin >> L >> R;
  R = min(R, L + 4038);
  int ans = 2018;
  for (ll i = L; i <= R; i++) { //ワンチャンここllにしてなかったからWA吐かれてた可能性…(アホ)
    for (ll j = i + 1; j <= R; j++) {
      int x = (i * j) % 2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main() {
  string s;
  while (cin >> s) {
    long long result = 0;
    for (int i = 0; i < (int)(1 << (s.length() - 1)); ++i) {
      string t = "";
      t += s[0];
      for (int j = 1; j < s.length(); ++j) {
	if (i & 1 << (j-1)) {
	  t += " ";
	}
	t += s[j];
      }
      istringstream sin(t);
      long long sum = 0, x;
      while (sin >> x) sum += x;
      result += sum;
    }

    cout << result << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a != b && b != c && a != c) {
            System.out.println("No");
        } else if (a == b && b == c) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 22868
#include<stdio.h>

int main (){
  int a, b;
  int ans = 0;
  scanf("%d %d", &a, &b);
  
  ans = a*b;
  
  if(ans%2==0){
    printf("Even\n");
  }else{
    printf("Odd\n");
  }
  
  return 0;
}


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

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

    static class AGettingDifference {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int max = 0;
            int n = in.nextInt();
            int targ = in.nextInt();
            int[] a = new int[n];
            int gcd = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                max = Math.max(max, a[i]);
                gcd = (int) MathUtil.gcd(gcd, a[i]);
            }

            for (int i = 0; i < n; i++) {
                if (a[i] >= targ && (a[i] - targ) % gcd == 0) {
                    out.println("POSSIBLE");
                    return;
                }
            }
            out.println("IMPOSSIBLE");
        }

    }

    static class MathUtil {
        public static long gcd(long a, long b) {
            if (b == 0) return a;
            return a % b == 0 ? b : gcd(b, a % b);
        }

    }
}



Measured memory_bytes: 48336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main(int argc, char **argv)
{
	ld L; cin >> L;

	ld each = L / 3;
	std::cout << fixed << setprecision(10) << pow(each, 3.0) << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200009];
main(){
    int n, k;
    cin>> n >>k;
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    int ans  = 0;
    for(int i = 1;i <= k; i++)
        ans += a[i];
    cout<<ans<<endl;
}


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    vector<int> dp(n, n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i == 0){
            dp[i] = a[i];
        }else{
            dp[i] = min(dp[i-1], a[i]);
        }
    }
    for(int i = 0; i < n; i++){
        if(a[i] <= dp[i]){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE << '\n';
    SetConsoleTextAttribute(hConsole, 7);
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1> {}(p.first);
        auto h2 = hash<T2> {}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "NO";
    exit(0);
}
const int NMAX = 2 * 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int n;
int v[NMAX], sol;

int main()
{
    FASTIO;
    cin >> n;
    for1(i, n) cin >> v[i];
    for1(i, n - 1)
    {
      //  cerr << i << ' ' << v[i] << endl;
        if(v[i] == i) {swap(v[i], v[i + 1]); sol++;}
    }
    if(v[n] == n) sol++;
    cout << sol;
    return 0;
}


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

const int mod = 1e9 + 7;

long long bp(long long a, int n) {
	if(n == 0) return 1;
	if(n & 1) return a * bp(a % mod, n - 1) % mod;
	return bp(a * a % mod, n / 2) % mod;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	long long ans = bp(10, n) - 2 * bp(9, n) + bp(8, n);
	ans %= mod;
	ans += mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3684
#include <iostream>

using namespace std;

class PriorityQueue
{
    int max_nelem, end;
    int* array;
public:
    PriorityQueue(int n) : max_nelem(n), end(0){
        array = new int[max_nelem];
    }

    void insert(int key)
    {
        int index = end;
        array[end++] = key;
        while(index > 0)
        {
            int parent = (index - 1) / 2;
            if(array[index] > array[parent])
            {
                swap(array[index], array[parent]);
                index = parent;
            }
            else break;
        }
    }

    void maxheapfy(int index)
    {
        int l = 2*index + 1, r = 2*index + 2;
        int largest = index;
        if(l < end && array[l] > array[largest])
        {
            largest = l;
        }
        if(r < end && array[r] > array[largest])
        {
            largest = r;
        }
        if(largest != index)
        {
            swap(array[largest], array[index]);
            maxheapfy(largest);
        }
    }

    int extract()
    {
        //if(end <= 0) raiseError;
        int rvalue = array[0];
        swap(array[0], array[--end]);
        maxheapfy(0);
        return rvalue;
    }
};


int main()
{
    PriorityQueue Q(2000000);
    char com[10];
    int v;
    while(1)
    {
        cin >> com;
        if(com[0] == 'i')
        {
            cin >> v;
            Q.insert(v);
        }
        else
        {
            if(com[1] == 'x')
            {
                v = Q.extract();
                cout << v << endl;
            }
            else break;
        }        
    }
}



Measured memory_bytes: 7012
/*
ID: little_10
LANG: C++
TASK: frac1
*/
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <map>

using namespace std;

#define gc() getchar()
#define digit(x) ('0' <= x && x <= '9')

int read()
{
	int x=0, f=1;char c=gc();
	while(!digit(c)){if(c == '-') f=-1;c=gc();}
	while(digit(c))x=(x<<3)+(x<<1)+x-'0', c=gc();
	return x*f;
}

const int N = 160;

int a, b;

int main()
{
	scanf("%d %d", &a, &b);
	if(a>=1 && a<=9 && b>=1 && b<=9)
		printf("%d\n",a*b);
	else
		printf("-1\n");
	return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	// "github.com/davecgh/go-spew/spew"
	// "github.com/k0kubun/pp"
)

var sc = bufio.NewScanner(os.Stdin)

func ScanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A := ScanInt()
	B := ScanInt()
	C := ScanInt()
	D := ScanInt()
	E := ScanInt()
	F := ScanInt()

	wPattern := map[int]int{}
	for a := 0; a <= F; a += 100 * A {
		for b := 0; b <= F; b += 100 * B {
			total := a + b
			if total > F {
				break
			}
			wPattern[total] = 0
		}
	}

	// not exists set
	sPattern := make(map[int]int)
	for c := 0; c <= F; c += C {
		for d := 0; d <= F; d += D {
			total := c + d
			if total > F {
				break
			}
			sPattern[total] = 0
		}
	}

	// 1 2 1 2 1 100 のとき
	// => 100 0 と水が0でなく存在するようにする
	var ansW, ansS int
	ansW = 100 * A
	for w := range wPattern {
		for s := range sPattern {
			if w == 0 || (w+s) > F {
				continue
			}
			if s*100 > E*w {
				continue
			}

			if s*(ansW+ansS) >= ansS*(w+s) {
				ansW, ansS = w, s
			}
		}
	}

	fmt.Println(ansW+ansS, ansS)

	// print to stderr for debug
	/*
			debug := false
			if debug {
				fmt.Fprintf(os.Stderr, "%#v\n", wPattern)
				spew.Fdump(os.Stderr, wPattern)
				pp.Fprintln(os.Stderr, sPattern)
		    }
	*/
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-


if __name__ == '__main__':

    n, k = [int(s) for s in input().split(" ")]
    W = [int(input()) for _ in range(n)]

    def check(P):
        i = 0
        for j in range(k):
            s = 0
            while (s + W[i]) <= P:
                s += W[i]
                i += 1
                if i==n:
                    return n

        return i

    left = 0
    right = 100000 * 10000

    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid

    print(right)  



Measured memory_bytes: 9564
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> cnt(100001, 0);
  REP(i, n) {
    int d; cin >> d;
    ++cnt[d];
  }
  int ans = 0, tmp = n;
  FOR(i, 1, 100001) {
    if (tmp == n / 2) ++ans;
    tmp -= cnt[i];
  }
  cout << ans << '\n';
  return 0;
}


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

//https://atcoder.jp/contests/agc003/tasks/agc003_c

int n, ans;
pair<int, int> arr[100000];

int main() {
	cin >> n;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		arr[i] = make_pair(a, i);
	}
	sort(arr, arr + n);
	for (int i = 0; i < n; i += 2)
		if (arr[i].second & 1)
			ans++;
	cout << ans << endl;
}


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


int main()
{
	int n,t,a;
	cin >> n >> t >> a;
	int best;
	cin >> best;
	int num = 1;
	for (int i = 1; i < n; i++){
		int h;
		cin >> h;
		if ((a - (t-h * 0.006))*(a -(t- h * 0.006)) < (a -(t- best * 0.006))*(a - (t-best * 0.006))) {
			best = h;
			num = i + 1;
		}
	}
	cout << num << endl;
	
	return 0;

}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n[3];

  REP(i, 3) {
    cin >> n[i];
  }

  sort(n, n + 3);

  int ct = 0;
  if (n[0] % 2 == n[1] % 2 && n[1] % 2 == n[2] % 2) {
    ct = (n[2] * 2 - n[1] - n[0]) / 2;
  } else if (n[1] % 2 == n[0] % 2) {
    ct = ((n[2] - 1) * 2 - (n[1] + n[0])) / 2 + 1;
  } else {
    ct = ((n[2] + 1) * 2 - (n[1] + 1 + n[0])) / 2 + 1;
  }

  cout << ct << endl;
}

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

int main(){
    int a,b,n,m;
    cin >> n >> m;
    vector<int> road(n+1);
    for(int i=0;i<m;i++){
        cin >> a >> b;
        road.at(a)++;
        road.at(b)++;
    }
    for(int i=1;i<n+1;i++)
        cout << road.at(i) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int qty = sc.nextInt();
		int[] mnt = new int[qty];
		for(int i=0; i<qty; i++) {
			mnt[i] = sc.nextInt();
		}
		
		int max =mnt[0];
		int cnt = 1;
		
		for(int i=1; i<qty; i++) {
			if(max <= mnt[i]) {
				max = mnt[i];
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        int[] a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int[] b = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int[] c = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

        int n = int.Parse(Console.ReadLine());
        int x;

        for (int i = 0; i < n; i++)
        {
            x = int.Parse(Console.ReadLine());
            for (int j = 0; j < 3; j++)
            {
                if (a[j] == x)
                {
                    a[j] = -1;
                }
            }
            for (int j = 0; j < 3; j++)
            {
                if (b[j] == x)
                {
                    b[j] = -1;
                }
            }
            for (int j = 0; j < 3; j++)
            {
                if (c[j] == x)
                {
                    c[j] = -1;
                }
            }
        }

        bool flag = false;

        for (int i = 0; i < 3; i++)
        {
            if (a[i] == -1 && a[i] == b[i] && b[i] == c[i])
            {
                flag = true;
            }
        }

        if (a[0] == -1 && a[0] == a[1] && a[1] == a[2])
        {
            flag = true;
        } else if (b[0] == -1 && b[0] == b[1] && b[1] == b[2])
        {
            flag = true;
        } else if (c[0] == -1 && c[0] == c[1] && c[1] == c[2])
        {
            flag = true;
        } else if (a[0] == -1 && a[0] == b[1] && b[1] == c[2])
        {
            flag = true;
        } else if (a[2] == -1 && a[2] == b[1] && b[1] == c[0])
        {
            flag = true;
        }

        if (flag)
        {
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
n = int(input())
a = [-1] + list(map(int, input().split()))
b = [-1] + list(map(int, input().split()))
c = [-1] + list(map(int, input().split()))

ans = 0
for i in range(1, n+1):
    ans += b[a[i]]
    if a[i] - a[i-1] == 1:
        ans += c[a[i-1]]

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[12];
int t;
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    for(int i=0;i<3;i++)
    {
        cin>>t;
        a[t]++;
    }
    if(a[5]==2&&a[7]==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const int NMAX = 99999;

int main() {

  int n;

  while(cin>>n && n!=0) {
    //cout<<n<<endl;
    int x[NMAX] = {0};
    int y[NMAX] = {0};

    for(int i=1; i<n; i++) {
      int where, tmp, dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
      cin>>where;
      cin>>tmp;
      x[i] = x[where]+dx[tmp];
      y[i] = y[where]+dy[tmp];
    }

    int xMax = 0, xMin = n*n, yMax = 0, yMin = n*n;
    for(int i=0; i<n; i++) {
      xMax = max(xMax, x[i]);
      xMin = min(xMin, x[i]);
      yMax = max(yMax, y[i]);
      yMin = min(yMin, y[i]);
    }
    cout<<xMax-xMin+1<<" "<<yMax-yMin+1<<endl;
  }

}

Measured memory_bytes: 1948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		C[keta] = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(C[i]);
	putchar('\n');
}

int main() {
	int N;
	N = getint();
	int A[200001] = {};

	int mae = 0;
	int kotae = 1;
	int mod = 1e9 + 7;
	rep(i, N) {
		int C;
		C = getint();
		if (mae != C) kotae = (kotae + *(A + C)) % mod;
		*(A + C) = kotae;
		mae = C;
	}

	putint(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1152
#include <cmath>
#include <iostream>
#include <vector>
#include <boost/range/algorithm/find.hpp>

using namespace std;

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

    vector<int> p_arr(n);
    for (auto& p : p_arr) {
        cin >> p;
    }

    int approx = x;
    auto is_decided = false;
    for (auto i = 0; ; ++i) {
        if (boost::find(p_arr, x + i) == end(p_arr)) {
            approx = x + i;
            is_decided = true;
        }
        if (boost::find(p_arr, x - i) == end(p_arr)) {
            approx = x - i;
            is_decided = true;
        }
        if (is_decided) {
            break;
        }
    }

    cout << approx << endl;

    return 0;
}


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

long long gcd(long long m,long long n){
    long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

long long lcm(long long  m, long long  n)
{
	return m * n / gcd(m,n); 
}

//no1
int main(int argc, const char * argv[]) {
    long long a,b,c,d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    long sum = 0;

    long long first = a / c;
    if(a % c != 0) first++;
    long long end =   b / c;
    sum = end - first;
    //最小公倍数
    long long bai = lcm(c,d);
    sum -= b / bai - a / bai ;

    sum += b / d - a / d;
    long long all = b - a;
   
    cout << all - sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int gcd(int a, int b){
  if(a<b){
    int temp=a;
    a=b;
    b=temp;
  }
  int temp=a%b;
  while(temp!=0){
    a=b;
    b=temp;
    temp=a%b;
  }
  return b;
}


int main(){
  char buf[1024];
  int A, B, K;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d %d", &A, &B, &K);

  int n=gcd(A,B);

  int count=0;
  int support;
  SREP(i, 1, n){
    if(n%i==0){
      count++;
    }
    if(count==K){
      support=i;
      break;
    }
  }

  int ans=n/support;
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
def main():
    S = input()
    a = ["1" if i % 2 == 0 else "0" for i in range(len(S))]
    b = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
    if comparison(S, a) <= comparison(S, b):
        print(comparison(S, a))
    else:
        print(comparison(S, b))


def comparison(S, n):
    count = 0
    for i in range(len(S)):
        if not n[i] == S[i]:
            count += 1
    return count


if __name__ == "__main__":
    main()


Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define  pb push_back
#define sort1(v) sort(v.begin(),v.end())
#include <sstream>
//cout<<fixed<<setprecision(n)<<number - for n digits after decimal
long long int max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}
void print(vector<int>arr)
{
    for(int i=0;i<(int)arr.size();i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void upd(int a[],int l,int r,int num)
{
    for(int i=l;i<=r;i++)
        a[i]+=num;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max(a*c,b*d);
  	ll ans2=max(b*c,a*d);
  	ans=max(ans,ans2);
    cout<<ans;
}








Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

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

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

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    int n;
    cin >> n;
    vector<vector<P>> vec(n, vector<P>());
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            P p;
            cin >> p.first >> p.second;
            --p.first;
            vec[i].push_back(p);
        }
    }

    int max_ans = 0;
    rep(i, 1 << n) {
        int ans = 0;
        rep(j, n) {
            if (i & 1 << j) {
                ++ans;
            }
        }
        bool has_ans = true;
        rep(j, n) {
            if (!(i & (1 << j))) {
                continue;
            }
            for(P k : vec[j]) {
                if (k.second && !(i & 1 << k.first)) {
                    has_ans = false;
                }
                if (!k.second && (i & 1 << k.first)) {
                    has_ans = false;
                }
            }
        }
        if (!has_ans) {
            continue;
        }
        max_ans = max(max_ans, ans);
    }
    cout << max_ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
int main() {
ll n,m;
cin>>n>>m;
ll f=0;
ll counter=0;
ll a[m]={};
ll b[m]={};
ll c[n+1]={};
for(ll i=0; i<=n; i++){
c[i]=1;}
set <ll> q;
q.insert(1);
for(ll i=0; i<m; i++){
cin>>a[i]>>b[i];}
for(ll i=0; i<m; i++){
if(q.count(a[i])&&c[a[i]]>=2){
q.insert(a[i]);
q.insert(b[i]);
c[a[i]]--;
c[b[i]]++;}
else if(q.count(a[i])&&c[a[i]]==1){
q.erase(a[i]);
q.insert(b[i]);
c[a[i]]--;
c[b[i]]++;}
else {
c[a[i]]--;
c[b[i]]++;}}
cout<<q.size()<<endl;}

Measured memory_bytes: 7296
import random
D = int(input())
C = input().split()
C = [int(c) for c in C]
S = []
for i in range(D):
  s = input().split()
  s = [int(j) for j in s]
  S.append(s)
#T = [1,17,13,14,13]
T = [1] * D
def value():
  M = 0
  last = [0] * 26
  for d in range(1,D+1):
    N = 0
    t = T[d-1]
    last[t-1] = d
    #print(last)
    for j in range(26):
      N = N + C[j]*(d-last[j])
    M = M + S[d-1][t-1] - N
  return(M)
Vmax = value()
#print(Vmax)
Q = []
for i in range(100):
  Q.append([random.randint(1,D), random.randint(1,26)])
for i in range(100):
  Tprev = T
  T[Q[i][0]-1] = Q[i][1]
  V = value()
  if V > Vmax:
    Vmax = V
  else:
    T = Tprev
  #print(Vmax)
#print(T)
for t in T:
  print(t)

Measured memory_bytes: 9916