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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

ll po(ll x, ll y) {
    ll ans = 1;
    while(y > 0) {
        if(y % 2) (ans *= x) %= MOD;
        (x *= x) %= MOD;
        y >>= 1;
    }
    return ans;
}

ll comb(ll n, ll r) {
    ll x = 1, y = 1;
    rep(i, r) (x *= n - i) %= MOD;
    rep(i, r) (y *= i + 1) %= MOD;
    y = po(y, MOD - 2);
    return x * y % MOD;
}

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = po(2, n) - 1;
    ans = ((ans - comb(n, a)) % MOD - comb(n, b)) % MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;
const bool debug = 0;
//---------------------------------//

int V, E;
vector<int> g[112345];
vector<int> depth, low;
set<pii> bridge;

int dfs(int u, int p, int d) {
	depth[u] = d;
	low[u] = d;
	
	for (int v : g[u]) {
		if (v == p) continue;
		
		if (depth[v] == -1) {
			chmin(low[u], dfs(v, u, d + 1));
			if (depth[v] == low[v]) bridge.insert(pii(min(u, v), max(u, v)));
		}
		else chmin(low[u], low[v]);
	}
	
	return low[u];
}


int main() {
	cin >> V >> E;
	REP(i, E) {
		int s, t;
		scanf("%d %d", &s, &t);
		g[s].push_back(t);
		g[t].push_back(s);
	}
	
	depth.resize(V, -1);
	low.resize(V, -1);
	
	dfs(0, -1, 0);
	
	for (pii now : bridge) printf("%d %d\n", now.first, now.second);
	
	return 0;
}

Measured memory_bytes: 7720
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    d = list(map(int, input().rstrip('\n').split()))
    for i in range(n, 10 ** 10):
        t = list(str(i))
        b = True
        for j in range(len(t)):
            if int(t[j]) in d:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40428
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int prc=0;
    char s[4];
    
    scanf("%s", s);
    
    rep(i, 3){
        if (s[i]=='o') {
            prc++;
        }
    }
    
    printf("%d", 700+100*prc);
    
    return 0;
}



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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	
	while (1) {
		bool check = false;
		int n;
		int now = 1;
		int count = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		vector<string> w(n + 1);
		vector<int>dp(n + 1);
		FOR(i, 1, n) {
			cin >> w[i];
			dp[i] = w[i].size();
		}
		FOR(i, 1, n) {
			bool flag = true;
			now = 1;
			count = 0;
			FOR(t, i, n) {
				count += dp[t];
				switch (now) {
				case 1:
					if (count > 5) {
						flag = false;
					}
					else if (count == 5) {
						now++;
						count = 0;
					}
					break;
				case 2:
					if (count > 7) {
						flag = false;
					}
					else if (count == 7) {
						now++;
						count = 0;
					}
					break;
				case 3:
					if (count > 5) {
						flag = false;
					}
					else if (count == 5) {
						now++;
						count = 0;
					}
					break;
				case 4:
					if (count > 7) {
						flag = false;
					}
					else if (count == 7) {
						now++;
						count = 0;
					}
					break;
				case 5:
					if (count > 7) {
						flag = false;
					}
					else if (count == 7) {
						now++;
						count = 0;
					}
					break;
				}
				if (flag == false) {
					break;
				}
				if (now == 6) {
					cout << i << endl;
					check = true;
					break;
				}
			}
			if (check == true) {
				break;
			}
		}
	}
}


Measured memory_bytes: 3204
#include<stdio.h>

int main() {
	int n, q;
	int i, j=0;
	int cnt = 0;
	int S[10000];
	int T[10000];

	//数値の読み込み
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &T[i]);
	}

	for (i = 0; i < q; i++) {
		S[n] = T[i];
		j = 0;
		while (S[j] != T[i]) {
			j++;
		}
		if (j < n && S[j] == T[i]) {
			cnt++;
		}
	}
	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
 
//________________________________________________________________________________________________________
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in freopen("input.txt","r",stdin)
#define out freopen("output.txt","w",stdout);
#define ll long long 
//________________________________________________________________________________________________________
ll lcm(ll a,ll b) {if(a==0 || b==0){return 0;}else{return (a*b)/__gcd(a,b);}} //


//--------------------------------------------------------------------------------------------------------
int main()
{
// #ifndef ONLINE_JUDGE
// 	in;
//    //out;
// #endif
// 	//fastread;
	string s;
	cin>>s;
	if(s=="SUN")
		cout<<"7"<<endl;
	if(s=="MON")
		cout<<"6"<<endl;
	if(s=="TUE")
		cout<<"5"<<endl;
	if(s=="WED")
		cout<<"4"<<endl;
	if(s=="THU")
		cout<<"3"<<endl;
	if(s=="FRI")
		cout<<"2"<<endl;
	if(s=="SAT")
		cout<<"1"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		
		int N=sc.nextInt();
		int gameN=N*(N-1)/2;
		int winScore[]=new int[N];
		
		for(int i=0; i<gameN; i++)
		{
			int teamNoA = sc.nextInt()-1;
			int teamNoB = sc.nextInt()-1;
			int gamePointA = sc.nextInt();
			int gamePointB = sc.nextInt();
			
			if(gamePointA > gamePointB)
			{
				winScore[teamNoA] += 3;
			}
			else if(gamePointA < gamePointB)
			{
				winScore[teamNoB] += 3;
			}
			else
			{
				winScore[teamNoA] += 1;
				winScore[teamNoB] += 1;
			}
		}
		
		int[] rank=new int[N];
		for(int i=0; i<N; i++)
			rank[i] = 1;
		
		for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
			if(winScore[i] < winScore[j])rank[i]++;
		
		for(int i=0; i<N; i++)
			System.out.println(rank[i]);
	}
}

Measured memory_bytes: 42248
N, K = map(int,input().split())

count = 0

sunuke = list(range(1,N+1))

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        try:
            sunuke.remove(a)
        except ValueError:
            continue
print(len(sunuke))

Measured memory_bytes: 9088
a,b,k = map(int,input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 != 0:
            a -= 1
        b += a//2
        a = a//2
    else:
        if b%2 != 0:
            b -= 1
        a += b//2
        b = b//2
print(a,b)

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int H,W,K,A,B,C,D;
  cin>>H>>W>>K>>A>>B>>C>>D;
  A--;
  B--;
  C--;
  D--;
  vector<string> g(H);
  for(int i = 0; i < H; i++) cin>>g[i];
  vector<vector<int>> d(H,vector<int>(W,-1));
  queue<tuple<int,int,int>> bfs;
  bfs.push(make_tuple(A,B,-1));
  d[A][B]=0;
  while(!bfs.empty()&&d[C][D]==-1){
    tuple<int,int,int> p = bfs.front();
    bfs.pop();
    if(get<2>(p)!=1){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p)+i;
      int ny = get<1>(p);
      if(nx>=H) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,0));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
    if(get<2>(p)!=0){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p)-i;
      int ny = get<1>(p);
      if(nx<0) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,1));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
    if(get<2>(p)!=3){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p);
      int ny = get<1>(p)+i;
      if(ny>=W) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,2));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
    if(get<2>(p)!=2){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p);
      int ny = get<1>(p)-i;
      if(ny<0) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,3));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
  }
  cout<<d[C][D]<<endl;
}


Measured memory_bytes: 12112
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
int A[1010];

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];

    bool approved = true;
    for (int i = 0; i < N; i++) {
        int n = A[i];
        if (n % 2 == 0) {
            if (n % 3 == 0 || n % 5 == 0) {
                continue;
            } else {
                approved = false;
                break;
            }
        }
    }
    if (approved) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}



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

using namespace std;
int main(void){
	
	int K;
	cin >> K;
	
	vector<long long> A(K);
	for(long long i=0;i<K;++i){ cin >> A[i]; }

	if( A[K-1]!=2 ){
		cout << -1 << endl;
		return 0;
	}
	
	long long min = A[K-1];
	long long max = A[K-1]*2-1;
	for(long long i=K-2;i>=0;--i){
		long long min_nx = A[i] + ((min-1)/A[i])*A[i];
		if(min_nx > max){
			cout << -1 << endl;
			return 0;
		}
		long long max_nx = A[i]-1 + (max/A[i])*A[i];

		min = min_nx;
		max = max_nx;
	}

	cout << min << " "<< max << endl;

	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC123B
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            var e = int.Parse(Console.ReadLine());

            var times = new[] { a, b, c, d, e };

            var totalTime = 0;
            foreach (var time in times)
            {
                totalTime += time;
                if (time % 10 != 0)
                {
                    totalTime += 10 - time % 10;
                }
            }

            if (times.Select(x => x % 10).Any(x => x != 0))
            {
                var min = times.Select(x => x % 10).Where(x => x != 0).Min();
                totalTime -= 10 - min;
            }

            Console.WriteLine(totalTime);
        }
    }
}


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

int main()
{
    _LL n, k;
    cin >> n >> k;
    _LL kt = k;
    _LL ans = 1;
    while( kt <= n ) kt *= k, ans++;
    cout << ans;
}

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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 20;

int k[N];

vector<ii> v[N];

bool valid(int m) {
    int mask = m;

    int i = 0;

    while (m > 0) {
        if (m&1) {
            // Person is honest
            for (auto& p : v[i]) {
                if (((mask & (1<<p.first)) ? 1 : 0) != p.second)
                    return false;
            }
        }

        m >>= 1;
        i++;
    }

    return true;
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;
    fo1(i, n) {
        int a; cin >> a;
        v[i].resize(a);
        fo1(j, a) {
            int x, y;
            cin >> x >> y;

            v[i][j] = { x-1, y };
        }
    }

    int ans = 0;
    for (int m = 0; m < (1<<n); m++) {
        if (valid(m)) {
            ans = max(ans, __builtin_popcount(m));
        }
    }

    cout << ans << endl;


    return 0;
%>

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()
using namespace std;


const int maxn=1e6+7;
vector<int>vec[maxn];

int s,t;

bool vis[maxn];

ll d[maxn];

struct cmp {
    bool operator ()(int a,int b) {
        return d[a]>d[b];
    }
};


void bfs(){
    memset(d,-1,sizeof(d));
    memset(vis,0,sizeof(vis));
    priority_queue<ll,vector<int>,cmp>q;
    q.push(s),d[s]=0;
    while(!q.empty()){
        int now=q.top();
        q.pop();
        if(vis[now]) continue;
        vis[now]=1;
        for(int x:vec[now]){
            if(!vis[x]) {
                if(d[x]<d[now]+1)
                d[x]=d[now]+1,q.push(x);
            }
        }
    }
    if(d[t]>=0) cout<<d[t]/3<<endl;
    else cout<<-1<<endl;
}

int main (){
    int n,m;scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        int x,y;scanf("%d %d",&x,&y);
        vec[x].push_back(y+n);
        vec[x+n].push_back(y+2*n);
        vec[x+2*n].push_back(y);
    }
    cin>>s>>t;
    bfs();
    return 0;
}


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

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
typedef long long LL;

const int maxn = 1500010;

int main()
{
    int x; char s[100];
    scanf("%d %s", &x, s);
    if ( x < 3200 ) puts("red");
    else printf("%s", s);
    return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	string s;
	cin >> s;

	map<char,int> alphabet;
	rep(i,s.size()){
		char c = s[i];
		alphabet[c] = 1;
	}
	int n = alphabet.size();
	if(n==26){
		if(s=="zyxwvutsrqponmlkjihgfedcba"){
			cout << -1 << endl;
			return 0 ;
		}else{
			string sbef = s;
			next_permutation(s.begin(),s.end());
			rep(i,26){
				if(s[i]==sbef[i]){
					cout<<s[i];
				}else{
					cout<<s[i]<<endl;
					return 0;
				}
			}
		}

	}
	else{//多分完成
		rep(i,26){
			char c = 'a'+i;
			if(! alphabet.count(c)){
				cout << s + c << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ma=0,ans=0;
    REP(i,n){
        int a,b;
        cin>>a>>b;
        if(ma<a){
            ma = a;
            ans = a+b;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(){
    float x1,x2,x3,x4,y1,y2,y3,y4;
    float a1=0.0,a2=0.0;
    int n,i;
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
            a1=(y2-y1)/(x2-x1);
            a2=(y4-y3)/(x4-x3);
         
            if( a1==a2 )printf("YES\n");
            else printf("NO\n");
    }
return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

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

    int N; cin >> N;
    map<string,int>m;
    rep(i,N){
        string s; cin >> s;
        m[s]++;
    }
    int pos=0;
    for(auto a:m){
        chmax(pos,a.se);
    }
    vc<string> v;
    for(auto a:m){
        if(a.se==pos){
            v.eb(a.fi);
        }
    }
    sort(all(v));
    rep(i,SZ(v)){
        cout << v[i] << "\n";
    }
}

Measured memory_bytes: 25584
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int check(const string& s) {
  int k = 0;
  rep(i, s.size()) {
    if (s[i] == '(') {
      k++;
    } else if (s[i] == ')') {
      k--;
    }

    if (k < 0) {
      return -1;
    }
  }
  return k;
}

int main() {
  std::ios::sync_with_stdio(false);
  int n;
  string s;
  while(cin >> n) {
    cin >> s;

    while(1) {
      int k = check(s);
      if (k == 0) break;
      if (0 < k) s = s + ")";
      if (k < 0) s = "(" + s;
    }
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
ll A[100000],B[100000], C[100000];
tuple<ll,ll,ll> T[100000],S[100000];
bool used[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    ll s=0;
    rep(i,0,N){
        cin>>A[i]>>B[i];
        C[i]=B[i]+A[i];
        s+=A[i];
    }
    ll res=0;
    sort(C,C+N);
    reverse(C,C+N);
    int i=1;
    while(i<N){
        res+=C[i];
        i+=2;
    }
    cout <<s-res<<"\n";
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int n, s, cnt;

void dfs(int i, int sum, int depth) {
    if (depth == n && sum == s) {
        cnt++;
        return;
    }

    if (i == 10 || depth == n || sum > s) return;

    dfs(i+1, sum, depth);
    dfs(i+1, sum + i, depth + 1);
}

int main() {
    while (cin >> n >> s) {
        if (n == 0 && s == 0) break;
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut a: [usize; n],
    }
    let mut valid_flag = true;
    a.sort();
    if a[0] == 0 {
        for i in 1..n {
            if a[i] != (i + 1) / 2 * 2 {
                valid_flag = false
            }
        }
    } else {
        for i in 0..n {
            if a[i] != (i / 2) * 2 + 1 {
                valid_flag = false
            }
        }
    }

    let mut cnt = 1;
    for _ in 0.. (n / 2) {
        cnt *= 2;
        cnt %= 1_000_000_007;
    }

    println!("{}", if valid_flag {cnt} else {0});
}


Measured memory_bytes: 4352
from bisect import bisect_right
n,m = map(int,input().split())
all_li = []
ma = {}
for _ in range(m):
    p,y = map(int,input().split())
    all_li.append((p,y))
    if p in ma:
        ma[p].append(y)
    else:
        ma[p] = [y]
#print(all_li)
#[[1, 32], [2, 63], [1, 12]]
#print(ma)
# {1: [32, 12], 2: [63]}
sorted_li = [[] for _ in range(n)]
for k,v in ma.items():
    sorted_li[k-1] = list(sorted(v))
#print(ma)
for a in all_li:
    #print(a[1],sorted_li[a[0]-1])
    count = bisect_right(sorted_li[a[0]-1],a[1],)
    #count = sorted_li[a[0]-1].index(a[1]) + 1
    print(str(a[0]).zfill(6)+str(count).zfill(6))


Measured memory_bytes: 86872
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	long L, R;
    cin >> L >> R;

    int ans = Max;
    int S[2019];
    for(int i=0;i<2019;i++) S[i] = 0;

    int k = 0;
    while(k < min(R-L+1, long(4040))){
      S[(k+L)%2019]++;
      k++;
    }

    for(int i=0;i<2019-1;i++){
      if(S[i]>0){
        for(int j=i+1;j<2019;j++){
          if(S[j]) ans = min(ans, (i*j)%2019);
        }
      }
    }

    for(int i=0;i<2019;i++){
      if(S[i]>=2) ans = min(ans, (i*i)%2019);
    }

    cout << ans <<endl;

    
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 100010;
int n, k, a[maxn], dp[maxn];
int main()
{
    read(n), read(k);
    rep(i, 1, n) read(a[i]);
    memset(dp, 0x3f, sizeof(dp));
    dp[1] = 0;
    rep(i, 1, n) rep(j, 1, k) dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
    printf("%d\n", dp[n]);
    return 0;
}

Measured memory_bytes: 1024
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var output = 0;
  var L = 0;
  var R = 0;
  var xor = list[0];
  while(L < N || R < N){
    //Rを「xor == +」が成り立つ間、進めてみる。
    //outputはLRの距離だけ増える
    //もし成り立たないところが出てきたら
    //LRの距離の累積和をoutputに足す
    //Lを進める。以下、繰り返し
    //myerr("now : " + xor);
    //myerr({L,R});
    if(xor + list[R + 1] == (xor ^ list[R + 1])){
      //myerr("ok");
      //myerr(R - L + 1);
      output += R - L + 1;
      R++;
      xor += list[R];
    }else{
      //myerr("ng");
      //output += 1//(R - L - 1) * (R - L - 2) / 2;
      xor -= list[L];
      L++;
      if(R < L){
        R = L;
        xor = list[R];
      }
    }
    //myerr("next : " + xor);
    //myerr({L,R});
  }
  myout(output + N);
}


Measured memory_bytes: 45912
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	cout << N / 3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read(){int k;scanf("%d",&k);return k;}
const int maxx = 40001;
struct A{int v,id;}a[maxx];
int V[maxx];
int n,k,Q;
int x1,f[maxx];
int q[maxx],ans=1000000000;
int tail=0;
int flag[maxx];
int aa[maxx];
int top=0;
void slove(){
	tail=0;top=0;
	for(int i=1;i<=n;i++){
		if(V[i]<x1)f[i]=1;
		if(f[i]==0){aa[++top]=V[i];}
		if(f[i]==1||i==n){if(top<k){top=0;continue;}
			sort(aa+1,aa+top+1);
			for(int i=1;i<=top-k+1;i++){
				q[++tail]=aa[i];
			}top=0;
		}
	}
	if(tail<Q)return ;
	sort(q+1,q+tail+1);
	ans=min(ans,q[Q]-x1);
	return ;
}
int main(){
	n=read();k=read();Q=read();
	for(int i=1;i<=n;i++)V[i]=read();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)f[j]=0;
		x1=V[i];
		slove();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.String;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int[] counter = new int[128];
        while (sc.hasNext()) {
            String str = sc.nextLine().toLowerCase();
            for (int i = 0; i < str.length(); i++) {
                counter[str.charAt(i)]++;
            }
        }
        for (char i = 'a'; i <= 'z'; i++) {
            System.out.println(i + " : " + counter[i]);
        }
    }
}
//答え(sc.nextline.toLowerCase();のような関数が連続するところの理解はできるが実装する発想が難しい。。。
//先生のを移して意を理解してべんきょうとするスライドわけわかめすぎ)


Measured memory_bytes: 26288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll c = gcd(a, b);
    ll ans = 1;
    
    for(ll i = 2; i <= 1e6; i++)
    {
        if(c % i == 0)
        {
            ans++;
            while(c % i == 0)
            {
                c /= i;
            }
        }
    }
    if(c != 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort();b.sort();c.sort()

bc_cum = [0]*n
bc_num = [0]*n

def bs(ls, x, n):
  l = -1; r = n-1
  while l+1<r:
    m = (l+r)//2
    if ls[m]<=x: l = m
    else: r = m
  if ls[r]>x:return r
  else: return n
  
for i in range(n-1, -1, -1):
  c_idx = bs(c, b[i], n)
  #print(b[i], c_idx)
  bc_num[i] = n-c_idx
  if i==n-1:
    bc_cum[i] = bc_num[i]
  else:
    bc_cum[i] = bc_num[i] + bc_cum[i+1]

ans = 0
for i in range(n):
  b_idx = bs(b, a[i], n)
  if b_idx<n:
    ans += bc_cum[b_idx]

print(ans)

Measured memory_bytes: 24340
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#define MAXN 200000
using namespace std;

typedef long long int lli;

lli N, A[MAXN], check[MAXN], ans;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    for(int j = 0; j < N; ++j)
        cin >> A[j];
    for(int j = 0; j < N; ++j){
        int idx = j + A[j];
        if(idx < N)
            check[idx]++;
    }
    for(int j = 0; j < N; ++j){
        int idx = j - A[j];
        if(idx >= 0)
            ans += check[idx];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6696
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    string a, b;
    cin >> a >> b;
    vector<string> s(N*2);
    int k = 0;
    for(int i = 0; i < N; i++){
        s[k++] = a[i];
        s[k++] = b[i];
    }
    rep(i, N*2){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

stack<int> sta;

int main(void)
{
  int a;
  while(scanf("%d", &a)!=EOF){
    if(a)
      sta.push(a);
    else{
      cout<<sta.top()<<endl;
      sta.pop();
    }
  }
  return 0;

}

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

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<vector<char>> field(h, vector<char>(w));
    for (auto &a : field) for (auto &b : a) cin >> b;

    int ans = 0;
    for (int r = 0; r < (1 << h); ++r) {
        for (int c = 0; c < (1 << w); ++c) {
            int wall = 0;
            for (int i = 0; i < h; ++i) {
                if (r & (1 << i)) continue;
                for (int j = 0; j < w; ++j) {
                    if (c & (1 << j)) continue;
                    wall += field[i][j] == '#';
                }
            }
            ans += wall == k;
        }
    }

    cout << ans << endl;
}



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


int main(){
	int n,k;
	cin>>n>>k;
	int ans=0;
	int x;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(x>=k) ans++; 
	} 
	cout<<ans<<endl;
	
	
	return 0;

} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,char> P;
int partition(P* A,int p,int r){
  int x=A[r].first;
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j].first<=x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
void quicksort(P* A,int p,int r){
  if(p<r){
    int q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}
signed main(){
  int n;
  cin>>n;
  P A[n];
  for(int i=0;i<n;i++) cin>>A[i].second>>A[i].first;
  map<int,string> m1,m2;
  for(int i=0;i<n;i++) m1[A[i].first]+=A[i].second;
  quicksort(A,0,n-1);
  for(int i=0;i<n;i++) m2[A[i].first]+=A[i].second;
  bool flag=1;
  for(int i=0;i<n;i++) flag&=m1[A[i].first]==m2[A[i].first];
  if(flag) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
  for(int i=0;i<n;i++){
    cout<<A[i].second<<" "<<A[i].first<<endl;
  }
  return 0;
}

Measured memory_bytes: 10140
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, stdin, BufRead};
use std::str::FromStr;

fn read_one<T>() -> T
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let stdin = stdin();
    let mut handle = stdin.lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();

    buf.trim().parse::<T>().unwrap()
}

macro_rules! read_tuple {
        ( $( $t:ty ), * ) => {
            {
                let stdin = stdin();
                let mut handle = stdin.lock();
                let mut buf = String::new();
                handle.read_line(&mut buf).unwrap();
                let mut v = buf.trim().split_whitespace()
                    .collect::<VecDeque<&str>>();
                (
                    $({
                        v.pop_front().unwrap().parse::<$t>().unwrap()
                    },)*
                )
            }
        }
    }

fn read_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let stdin = stdin();
    let mut handle = stdin.lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();

    buf.trim()
        .split_whitespace()
        .map(|s| s.parse::<T>().unwrap())
        .collect::<Vec<T>>()
}

fn find_tar(a: char, b: char) -> char {
    if a == 'R' && b == 'G'{
        'B'
    } else if a == 'R' && b == 'B'{
        'G'
    } else if a == 'G' && b == 'B' {
        'R'
    } else {
        find_tar(b, a)
    }
}

fn main() -> io::Result<()> {
    let n = read_one::<usize>();
    let s: Vec<char> = read_one::<String>().chars().collect();
    let mut sum = 0;
    let mut count_r: Vec<usize> = (0..n).map(|_| 0).collect();
    let mut count_g: Vec<usize> = (0..n).map(|_| 0).collect();
    let mut count_b: Vec<usize> = (0..n).map(|_| 0).collect();
    for i in (0..n as usize).rev() {
        count_r[i] = if i == n - 1 { 0 } else { count_r[i + 1]  };
        count_g[i] = if i == n - 1 { 0 } else { count_g[i + 1]  };
        count_b[i] = if i == n - 1 { 0 } else { count_b[i + 1]  };
        if s[i] == 'R' { count_r[i] += 1;}
        if s[i] == 'G' { count_g[i] += 1;}
        if s[i] == 'B' { count_b[i] += 1;}
    }
    for i in 0..(n-2) as usize {
        for j in (i + 1)..(n-1) as usize {
            if s[i] == s[j] {
                continue;
            }
            let tar = find_tar(s[i], s[j]);
            let danger = j + j - i;
            if tar == 'R' {
                sum += count_r[j + 1];
                if danger < n && s[danger] == 'R' {
                    sum -= 1;
                }
            } else if tar == 'G' {
                sum += count_g[j + 1];
                if danger < n && s[danger] == 'G' {
                    sum -= 1;
                }
            } else {
                sum += count_b[j + 1];
                if danger < n && s[danger] == 'B' {
                    sum -= 1;
                }
            }
        }
    }
    println!("{}", sum);
    return Ok(());
}


Measured memory_bytes: 2188
n,k = map(int,input().split())
ans = 0

for i in range(k,n+2):
    tmpans = 0
    s1 = (0+i-1)*i//2
    s2 = (n-i+1 + n)*i//2
    tmpans = s2-s1+1
    ans = (ans+tmpans)%(10**9+7)
print(max(1,ans%(10**9+7)))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;



int main(){
    double l;cin>>l;
    cout<<fixed;
    double hen=l/3.0;
    cout<<hen*hen*hen<<endl;
    
}







Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] Di;


        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Di = new long[N];
            for (int i = 0; i < Di.length; i++) {
                Di[i] = sc.nextLong();

            }
        }

        long result = 0;
        for (int i = 0; i < Di.length; i++) {
            for (int j = i+1; j < Di.length; j++) {
                result += Di[i] * Di[j];

            }
        }

        System.out.println(result);
    }

}


Measured memory_bytes: 23124
#include<stdio.h>
int main(void){
  int k, x;
  
  scanf("%d %d", &k, &x);
  int a, b;
  a = x - (k - 1);
  b = x + (k - 1);
  
   for(int i = a; i <= b; i++){
     printf("%d ", i);
   }
  return 0;
}


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

using namespace std;
#define BUF (1000)
#define ll long long 

ll x,y;

int main(void){
	cin >> x >> y;
	int ans = 0;
	while(x<=y){
		ans++;
		x*=2;
	}

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


Measured memory_bytes: 256
use std::io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, BufRead, Write};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut io = IO::new(std_in.lock(), std_out.lock());
    let n = io.r::<usize>();
    let a = io.rv::<usize>();

    let mut cnt = vec![0; n+1];
    for x in a {
        cnt[x] += 1;
    }
    io.wv(&cnt[1..=n]);
}


struct IO<'a> {
    br: BufReader<StdinLock<'a>>,
    bw: BufWriter<StdoutLock<'a>>,
}

#[allow(dead_code)]
impl IO<'_> {
    fn new<'a>(il: StdinLock<'a>, ol: StdoutLock<'a>) -> IO<'a> {
        IO {br: BufReader::new(il), bw: BufWriter::new(ol) }
    }

    fn r<T: std::str::FromStr>(&mut self) -> T {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().parse().ok().unwrap()
    }

    fn rb(&mut self) -> Vec<u8> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().as_bytes().to_vec()
    }

    fn rv<T: std::str::FromStr>(&mut self) -> Vec<T> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
    }

    fn rvb(&mut self) -> Vec<Vec<u8>> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().split_whitespace().map(|e| e.as_bytes().to_vec()).collect()
    }

    fn w<T: std::fmt::Display>(&mut self, x: T) {
        let _ = writeln!(self.bw, "{}", x);
    }

    fn wb(&mut self, s: &[u8]) {
        let _ = writeln!(self.bw, "{}", unsafe{std::str::from_utf8_unchecked(s)});
    }

    fn wv<T: std::fmt::Display>(&mut self, v: &[T]) {
        let _ = write!(self.bw, "{}", v[0].to_string());
        for x in v[1..].iter() {
            let _ = write!(self.bw, " {}", x.to_string());
        }
        let _ = writeln!(self.bw);
    }

    fn wvb(&mut self, v: &[Vec<u8>]) {
        let _ = write!(self.bw, "{}", unsafe{std::str::from_utf8_unchecked(&v[0])});
        for x in v[1..].iter() {
            let _ = write!(self.bw, " {}", unsafe{std::str::from_utf8_unchecked(x)});
        }
        let _ = writeln!(self.bw);
    }
}


Measured memory_bytes: 4984
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int get_num(int x, int mini, int maxi, vector<int> &len){
	return (upper_bound(len.begin()+x, len.end(), maxi) - len.begin()) - (lower_bound(len.begin()+x, len.end(), mini) - len.begin());
}

int main(){
	int n;
	ll ans = 0;
	cin >> n;
	vector<int> len(n);
	for (int i = 0; i < n; i++){
		cin >> len[i];
	}
	sort(len.begin(), len.end());
	for (int i = 0; i < n-2; i++){
		for (int j = i+1; j < n-1; j++){
			int lenshort = len[i], lenlong = len[j];
			ans += get_num(j+1, lenlong, lenshort + lenlong - 1, len);
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
S = input()

Sk = [S[0]]
cur = ""
for s in S[1:]:
  if Sk[-1] == cur + s:
    cur += s
  else:
    Sk.append(cur + s)
    cur = ""

if Sk[-1] == cur:
  Sk[-1] += cur
elif cur != "":
  Sk.append(cur)

print(len(Sk))

Measured memory_bytes: 8264