akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
}
int main(){
  int h,k,h2,k2,K,mins;
  cin>>h>>k>>h2>>k2>>K;
  if(h2>=h)
  {
    if(k2>=k){
      mins=k2-k+60*(h2-h);
    }
    else{
      mins=k2-k+60+60*(h2-h-1);
      if(h==h2){
          mins+=1440;
      }
    }
  }
  else{
    swap(h,h2);
    swap(k,k2);
    if(k2>=k){
      mins=k2-k+60*(h2-h);
    }
    else{
      mins=k2-k+60+60*(h2-h-1);
    }
    mins=1440-mins;
  }
  mins-=K;
  cout<<mins<<"\n";
  return 0;
}

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

int main(){
    int N, H, i, right = 0, memo = 0, max = 0;

    cin >> N;
    for(i = 0; i < N; i++){
        cin >> H;
        if(H > memo)right = 0;
        else right++;
        memo = H;
        if(right > max)max = right;
    }
    cout << max << endl;
}

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

int main() {
  int N;
  cin >> N;
  int K = 0;
  for(int i=0; i<N; i++){
    int l,r;
    cin >> l >> r;
    K+=r+1-l;
  }
  cout << K << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define n_mod(a, k) ((a % k) + k) % k
#define mod(a, k) (a % k)
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define LSOne(S) (S & (-S))
#define repa(v) lpi(i, 0, sz(v)) lpi(j, 0, sz(v[i]))
#define P(x) cout << #x << " = { " << x << " }\n"
#define PB push_back
#define MP make_pair
#define M_PI 3.14159265358979323846
#define fast_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define file_IO                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<string> vs;
int dcmp(double x, double y)
{
    return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
const int MAX = 1e5 + 10;
ll memo[MAX][4];
int n;
ll arr[MAX][4];
ll dp(int i, int last)
{
    if (i == n)
    {
        return 0;
    }
    ll &ret = memo[i][last];
    if (ret != -1)
    {
        return ret;
    }
    ll path = -INF;
    lp(j, 3)
    {
        if (j != last || i == 0)
        {
            path = max(path, dp(i + 1, j) + arr[i][j]);
        }
    }
    return ret = path;
}
int main()
{
    // #ifndef ONLINE_JUDGE
    //     file_IO;
    // #else
    //     fast_IO;
    // #endif
    //file_IO;
    fast_IO;
    clr(memo, -1);
    cin >> n;
    lp(j, n)
        lp(i, 3)
    {
        cin >> arr[j][i];
    }
    cout << dp(0, 3) << '\n';
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {
    int n, a;
    cin >> n >> a;
    if (n % 500 == 0) {
        cout << "Yes" << endl;
    }
    else if (n < 500 && a < n) {
        cout << "No" << endl;
    }
    else {
        int c = n / 500;
        int d = n - c * 500;
        if (d <= a) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  vector<int> a(m);
  int sum = 0;

  for (int i = 0; i < m; ++i) {
    cin >> a[i];
    sum += a[i];
  }

  if (n >= sum) {
    cout << n - sum;
  }
  else {
    cout << -1;
  }




  return 0;
}


Measured memory_bytes: 3196
N,K = map(int,input().split())
XYC = [[int(x)%(2*K),int(y)%(2*K),int(c=="B")] for x,y,c in [input().split() for _ in [0]*N]]

score = [[[0]*(3*K+1) for _ in [0]*(3*K+1)] for _ in [0]*2]
for x,y,c in XYC:
    x+=1
    y+=1
    score[c][y][x] += 1
    if x<K: score[c][y][x+2*K] += 1
    if y<K: score[c][y+2*K][x] += 1
    if x<K and y<K: score[c][y+2*K][x+2*K] += 1

S = score
for c in range(2):
    for j in range(3*K):
        for i in range(3*K):
            S[c][i+1][j+1] += S[c][i][j+1]
    for i in range(3*K):
        for j in range(3*K):
            S[c][i+1][j+1] += S[c][i+1][j]

def get_sum(c,si,sj,i,j):
    i+=1
    j+=1
    return S[c][i][j] + S[c][si][sj] - S[c][i][sj] - S[c][si][j]

ans = 0
for i in range(K):
    for j in range(2*K):
        tmp = 0
        tmp += get_sum(0,i,j,i+K-1,j+K-1)
        tmp += get_sum(1,i+K,j,i+2*K-1,j+K-1)
        j = (j+K)%(2*K)
        tmp += get_sum(1,i,j,i+K-1,j+K-1)
        tmp += get_sum(0,i+K,j,i+2*K-1,j+K-1)
        ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 193524
#include<iostream>

int main()
{
	
	int n;
	int num;
	int min;
	int max;
	long int sum;

	std::cin >> n;


	for (int i = 0; i < n;i++){
		std::cin >> num;
		
		if (i == 0){
			min = num;
			max = num;
			sum = num;
			continue;
		}

		if (min > num){
			min = num;
		}
		else if (max < num){
			max = num;
		}
		sum += num;
	}
	std::cout << min <<' '<< max <<' '<< sum << '\n';
	return 0;
}



Measured memory_bytes: 3088
h, w = map(int, input().split())
tizu = [list(input()) for _ in range(h)]
pos = 1
for row in tizu:
    pos -= 1
    for i, index in enumerate(row):
        if i == pos:
            if index == "#":
                pos += 1
        else:
            if index == "#":
                print("Impossible")
                exit()
print("Possible")

Measured memory_bytes: 3060
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]

INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define GOOGLE 0
#define MULTIPLE_TC 0

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int a, b, c, d, i, j;
  cin >> a >> b >> c >> d;
  for(i = 0; ;i++){
    if((i & 1) == 0){
      c -= b;
    }else{
      a -= d;
    }
    if(a <= 0){
      cout << "No\n"; return;
    }
    if(c <= 0){
      cout << "Yes\n"; return;
    }
  }
}

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

  pre();

  int t = 1, T;

  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}


Measured memory_bytes: 3840
N = int(input())
S = input()

min_count = N

left = {'W':0, 'E':0}
w = S.count('W')
right = {'W':w, 'E':N-w}

for i in range(N):
    base = S[i]
    right[base] -= 1
    min_count = min(left['W']+right['E'], min_count)
    left[base] += 1
print(min_count)

Measured memory_bytes: 3828
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var (N, M) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var p = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var xy = Range(0, M).Select(i => ReadLine().Split(' ').Select(int.Parse).ToArray());

        var uf = new UnionFind(N);
        foreach (var (x, y) in xy)
            uf.Unite(x - 1, y - 1);

        var group = new Dictionary<int, (HashSet<int> n, HashSet<int> i)>();

        for (int i = 0; i < N; i++)
        {
            var g = uf.Find(i);
            if (!group.ContainsKey(g))
                group.Add(g, (new HashSet<int>(), new HashSet<int>()));

            group[g].n.Add(p[i] - 1);
            group[g].i.Add(i);
        }

        var ans = 0;

        foreach (var (n, i) in group.Select(g => g.Value))
        {
            n.IntersectWith(i);
            ans += n.Count;
        }

        WriteLine(ans);
    }
}

class UnionFind
{
    private int[] d;
    public UnionFind(int n) => d = Enumerable.Repeat(-1, n).ToArray();
    public int Find(int x) => (d[x] < 0) ? x : d[x] = Find(d[x]);
    public bool Unite(int x, int y)
    {
        (x, y) = (Find(x), Find(y));
        if (x == y)
            return false;
        if (-d[x] < -d[y])
            (x, y) = (y, x);
        (d[x], d[y]) = (d[x] + d[y], x);
        return true;
    }
    public bool Same(int x, int y) => Find(x) == Find(y);
    public int Size(int x) => -d[Find(x)];
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 73104
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String s = sc.next();
	    String[] sp  = s.split("");
	    boolean hantei = true;
	    for(int i = 1; i <= sp.length; i++) {
	        if(i % 2 == 1) {
	            if(sp[i-1].equals("R") || sp[i-1].equals("U") || sp[i-1].equals("D")) {
	                continue;
	            }else {
	                hantei = false;
	                break;
	            }
	        }else {
	            if(sp[i-1].equals("L") || sp[i-1].equals("U") || sp[i-1].equals("D")) {
	                continue;
	            }else {
	                hantei = false;
	                break;
	            }
	        }
	    }
	    if(hantei) {
	        System.out.println("Yes");
	    }else {
	        System.out.println("No");
	    }
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1<<30;

int main() {
  int N; cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; ++i) {
    cin >> P[i];
  }
  int min_n = inf;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(P[i] < min_n) {
      min_n = P[i];
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 998244353;

int n;
// int dp[100000001];
// int find(vector<int> v, int curr) {
// 	if (curr == n)
// 		return 1;
// 	if (curr > n)
// 		return 0;
// 	if (dp[curr] != -1)
// 		return dp[curr];
// 	int ans = 0;
// 	for (int j = 0; j < v.size(); j++) {
// 		if (curr + v[j] <= n) {
// 			ans = (ans + find(v, curr + v[j])) % mod;
// 		}
// 	}
// 	return dp[curr] = ans % mod;
// }

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int k, a, b;
	cin >> n >> k;
	int l[k], r[k];
	for (int i = 0; i < k; i++) {
		cin >> l[i] >> r[i];
		++r[i];
	}
	int dp[n];
	memset(dp, 0, sizeof dp);
	dp[0] = 1, dp[1] = -1;
	for (int i = 0; i < n; i++) {
		if (i != 0)
			dp[i] = (dp[i] + dp[i - 1]) % mod;
		for (int j = 0; j < k; j++) {
			if (i + l[j] < n)
				dp[i + l[j]] = (dp[i + l[j]] + dp[i] + mod) % mod;
			if (i + r[j] < n)
				dp[i + r[j]] = (dp[i + r[j]] - dp[i] + mod) % mod;
		}
	}
	cout << dp[n - 1] % mod;
	return 0;
}

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

int main(void) {
	char str[201];
	while(scanf("%s",str)){
		if(!strcmp(str, "-")) break;
		
		int m, h = 0,b ,i;
		scanf("%d", &m);
		for(i = 0; m > i; i++){
			scanf("%d", &b);
			h += b;
		}
		h %= strlen(str);
		for(i = h; strlen(str) + h > i; i++){
			printf("%c", str[i%strlen(str)]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer cur = nil -> next ;// 番兵の次の要素から辿る
  while( cur != nil && cur -> key != key) {
  	cur = cur -> next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if( t == nil ) return;
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  deleteNode( nil -> prev);
}

void delete(int key){
  /* your code */
  // 検索したノードを削除
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  
  // 番兵の直後に要素を追加
  x -> next = nil -> next;
  nil -> next -> prev= x;
  nil -> next = x;
  x -> prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, cnt=0;
    cin >> n;
    vector<int> vec(n);

    for(int i=0; i<n; i++){
        cin >> vec.at(i);
    }
    for(int i=1; i<n-1; i++){
        if((vec[i-1] < vec[i]) && (vec[i] < vec[i+1])) cnt++;
        else if((vec[i-1] > vec[i]) && (vec[i] > vec[i+1])) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
    string s;
    cin >> s;
    string s2 = s;
    int N = s2.length();
    int idx1 = 0;
    int idx2 = N-1;
    int ans = 0;
    while (idx1 < N && idx2 >= 0){
        if (s[idx1] == 'x' && s[idx2] == 'x'){
            idx1++;
            idx2--;
        }else if (s[idx1] == 'x' && s[idx2] != 'x'){
            idx1++;
            ans++;   
        }else if (s[idx1] != 'x' && s[idx2] == 'x'){
            idx2--;
            ans++;   
        }else if(s[idx1] != s[idx2]){
            cout << -1 << '\n';
            return 0;
        }else{
            idx1++;
            idx2--;
        }

        if ((idx2-idx1) < 0) break;
    }


    cout << ans << '\n';
    return 0;

}

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

int main(void){
    int h, w, k, white = 0, black = 0, ans = 0;
    cin >> h >> w >> k;
    char **c = new char*[h];
    for(int i = 0; i < h; i++){
        c[i] = new char[w];
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(c[i][j] == '#') black++;
            else white++;
        }
    }
    for(int i = 0; i < (1<<h); i++){
        for(int j = 0; j < (1<<w); j++){
            int b0 = black, w0 = white;
            for(int ii = 0; ii < h; ii++){
                for(int jj = 0; jj < w; jj++){
                    if(((i >> ii) % 2 == 1 || (j >> jj) % 2 == 1) && c[ii][jj] == '#') b0--;
                    else if((i >> ii) % 2 == 1 || (j >> jj) % 2 == 1) w0--;
                }
            }
            if(b0 == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

void call(int n){
	int i=1;
	check_num:
		int x = i;
		if(x%3==0){
			printf(" %d", i);
			goto end_check_num;
		}
		
	include3:
		if(x%10==3){
			printf(" %d", i);
			goto end_check_num;
		}
		
	x /= 10;
	if(x) goto include3;
	end_check_num:
		if(++i <= n) goto check_num;
		
	printf("\n");
}

int main(){
	int a;
	scanf("%d", &a);
	call(a);
}


Measured memory_bytes: 2740
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys

# sys.stdout.write(str(n)+"\n")
MODULO = 1000000007
# INF = 1e18+10

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

n = int(input())

a_b = [() for i in range(n)]
m_b_a = [() for i in range(n)]

# a_b_value_indices = {}
# m_b_a_value_indices = {}

a_b_value_count = {}
m_b_a_value_count = {}

a_b_value_rep = {}
m_b_a_value_rep = {}

used = [False for _ in range(n)]
zeroes = 0
is_zero = [False for _ in range(n)]

for i in range(n):
	a, b = map(int, input().split())

	if a == 0 and b == 0:
		zeroes += 1
		used[i] = True
		is_zero[i] = True
	else:
		if a == 0:
			a_b[i] = (0, 1)
			m_b_a[i] = (1, 0)
		elif b == 0:
			a_b[i] = (1, 0)
			m_b_a[i] = (0, 1)
		else:
			neg = False
			if a*b < 0:
				neg = True
			d = gcd(abs(a), abs(b))
			a = abs(a) // d
			b = abs(b) // d

			if neg:
				a_b[i] = (-a, b)
				m_b_a[i] = (b, a)
			else:
				a_b[i] = (a, b)
				m_b_a[i] = (-b, a)

		a_b_value_count[a_b[i]] = a_b_value_count.get(a_b[i], 0) + 1
		# a_b_value_indices[a_b[i]] = a_b_value_indices.get(a_b[i], []) + [i]
 
		m_b_a_value_count[m_b_a[i]] = m_b_a_value_count.get(m_b_a[i], 0) + 1
		# m_b_a_value_indices[m_b_a[i]] = m_b_a_value_indices.get(m_b_a[i], []) + [i]
		if a_b[i] not in a_b_value_rep:
			a_b_value_rep[a_b[i]] = i
		if m_b_a[i] not in m_b_a_value_rep:
			m_b_a_value_rep[m_b_a[i]] = i

ans = 1
for i in range(n):
	if not is_zero[i] and not used[a_b_value_rep[a_b[i]]]:
		# if not connected
		if a_b[i] not in m_b_a_value_count:
			ans *= pow(2, a_b_value_count[a_b[i]], MODULO)
			ans %= MODULO
			used[a_b_value_rep[a_b[i]]] = True
			# for j in a_b_value_indices[a_b[i]]:
			# 	used[j] = True
		else:
			s = a_b_value_count[a_b[i]]
			t = m_b_a_value_count[a_b[i]]
			ans *= ((1*pow(2, s, MODULO) + 1*pow(2, t, MODULO) -1) % MODULO)
			ans %= MODULO

			used[a_b_value_rep[a_b[i]]] = True
			used[m_b_a_value_rep[a_b[i]]] = True
			# for j in m_b_a_value_indices[a_b[i]]:
			# 	used[j] = True
 
			# used_a_b_keys.add(a_b_key)
			# used_a_b_keys.add(-1/a_b_key)
 
 
# -1 is for empty
print((ans-1+zeroes) % MODULO)

Measured memory_bytes: 206720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<cmath>
using namespace std;
#define fr first
#define sc second
#define MAX 201
int main(){
  int D,N,T[MAX],A[MAX],B[MAX],C[MAX],dp[MAX][MAX];
  bool can[MAX][MAX];
  cin >> D >> N;
  for(int i = 0 ; i < D ; i++ ){
    cin >> T[i];
  }
  for(int i = 0 ; i < N ; i++ ){
    cin >> A[i] >> B[i] >> C[i];
  }
  for(int i = 0 ; i < D ; i++ ){
    for(int j = 0 ; j < N ; j++ ){
      can[i][j] = ( A[j] <= T[i] && T[i] <= B[j] );
      dp[i][j] = -1;
    }
  }
  for(int i = 0 ; i < N ; i++){
    if(can[0][i]) dp[0][i] = 0;
  }
  for(int i = 0 ; i < D - 1 ; i++)
    for(int j = 0 ; j < N ; j++)
      if(dp[i][j] != -1)
        for(int k = 0 ; k < N ; k++){
          if(can[i+1][k]){
            dp[i+1][k] = max(dp[i+1][k],dp[i][j] + abs( C[j] - C[k] ));
          }
        }

  int ans = 0;
  for(int i = 0 ; i < N ; i++){
    ans = max( ans , dp[D-1][i] );
  }
  cout << ans << endl;
}

Measured memory_bytes: 1360
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main() {
  int N, c = 0; cin >> N;
  map<string, int> mp;
  for(int i = 0; i < N; i++) {
    string input; cin >> input;
    mp[input] = 1;
  }
  cout << mp.size() << endl;
  return 0;
}

Measured memory_bytes: 19116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
int main(){
	scanf("%lld",&n);
	printf("%lld",10-n/200);
}

Measured memory_bytes: 1732
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define EPS 1e-9
#define N 1000005

using namespace std;

int x, y;
bool solve(){
  for(int i=0; i<=x; ++i)
  for(int j=0; j<=x - i; ++j) {
    if(i + j == x && i * 4 + j * 2 == y) return true;
  }

  return false;
}

int main(){
  cin>>x>>y;
  if(solve()) cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';

}

Measured memory_bytes: 3124
A, B, C, D= map(int,input().split())

if A % D == 0:
  A_Attack = A // D
else:
  A_Attack = A // D + 1
  
if C % B == 0:
  T_Attack = C // B
else:
  T_Attack = C // B + 1


if A_Attack >= T_Attack:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184
#include <stdio.h>

int main(void){
	double a,b,c,d,e,f,x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
		y=(c*d-a*f)/(b*d-a*e)+0.00001;
		x=(c-b*y)/a+0.00001;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    st.insert(v[i]);
  }
  sort(v.begin(), v.end());
  // cout << v << endl;

  int count = 0;
  for (int i = 0; i < n - 1; i++)
    if (v[i + 1] == v[i]) count++;

  if (count % 2 == 0) {
    cout << st.size() << endl;
  } else {
    cout << st.size() - 1 << endl;
  }
}


Measured memory_bytes: 5376
def f(s):

    ar = list(s)
    
    result = 0

    for i in range(1, len(ar)):
        if ar[i] == ar[i - 1]:
            ar[i] = '.'
            result += 1
    
    return result


s = input()
k = int(input())

if s[0] != s[-1]:
    print(f(s) * k)
else:

    l, r = 0, len(s) - 1

    while l < len(s) and s[l] == s[0]:
        l += 1
    
    while r >= 0 and s[r] == s[-1]:
        r -= 1
    
    l, r = l - 1, r + 1

    if r == 0:
        print((len(s) * k) // 2)
    else:
        print((l + 1) // 2 + (len(s) - r) // 2 + f(s[l + 1 : r]) * k + ((l + 1 + len(s) - r) // 2) * (k - 1))


Measured memory_bytes: 39888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())

int main()
{
    int n,x; cin >> n >> x;
    vector<int> m(n); rep(i, n) cin >> m[i];
    Sort(m);
    rep(i,n) x -= m[i];
    cout << n + x/m[0] << endl;

}

/*
Ctrl+@
g++ a.cpp
./a.out
*/

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int a, b; cin >> a >> b;

	int ans = a - 2 * b;
	if (ans > 0) {
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    r1, c1, r2, c2 = map(int, readline().split())

    def calc(c):
        prev = 1
        cur = 1
        comb1 = 0
        comb2 = 0

        for i in range(1, r1 + 1):
            cur = prev * (c + i)
            cur %= MOD
            cur *= pow(i, MOD - 2, MOD)
            cur %= MOD
            comb1 += cur
            comb1 %= MOD
            prev = cur

        comb2 = comb1

        for i in range(r1 + 1, r2 + 2):
            cur = prev * (c + i)
            cur %= MOD
            cur *= pow(i, MOD - 2, MOD)
            cur %= MOD
            comb2 += cur
            comb2 %= MOD
            prev = cur

        return comb1, comb2

    comb1, comb2 = calc(c1-1)
    comb3, comb4 = calc(c2)

    ans = comb4 - comb2 - comb3 + comb1
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67164
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int h, w, k;
ll b;

ll add_score(vector<vi>& c) {
	ll ret = 0;
	rep(i, h) {
		int last = 0;
		int st = 0;
		rep(j, w) {
			if(c[i][j] == last) continue;
			if(j - st >= k) {
				ret += b * last * (j - st);
				for(int j2 = st; j2 <= j-1; j2++) c[i][j2] = 0;
			}
			last = c[i][j];
			st = j;
		}
		if(w - st >= k) {
			ret += b * last * (w - st);
			for(int j2 = st; j2 <= w-1; j2++) c[i][j2] = 0;
		}
	}
	return ret;
}

void update(vector<vi>& c) {
	rep(j, w) {
		int i2 = h-1;
		for(int i = h-1; i >= 0; i--) {
			if(c[i][j] != 0) {
				swap(c[i][j], c[i2][j]);
				i2--;
			}
		}
	}
}

ll score(int i, int j, vector<vi> c) {
	c[i][j] = 0;
	update(c);
	ll ret = 0;
	b = 1;
	while(true) {
		ll add = add_score(c);
		if(add == 0) break;
		ret += add;
		update(c);
		b *= 2;
	}
	return ret;
}

int main() {
//	cout << fixed << setprecision(15);
	cin >> h >> w >> k;
	vector<vi> c(h, vi(w));
	rep(i, h) {
		string s;
		cin >> s;
		rep(j, w) c[i][j] = s[j] - '0';
	}
	ll ans = 0;
	rep(i, h) rep(j, w) chmax(ans, score(i, j, c));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>
void read(T &x)
{
	char ch=getchar();
	int f=1;
	for (x=0;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
	if (ch=='-') f=-1,ch=getchar();
	for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
	x*=f;
}
int n,T;
int a[200010];
ll ans;
int main()
{
	read(n),read(T);
	for (int i=1;i<=n;i++)
		read(a[i]);
	a[n+1]=a[n]+T;
	for (int i=1;i<=n;i++)
		ans+=min(a[i+1]-a[i],T);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;//ここ逆？
  if ( t == nil ) return;
  deleteNode(t);
  return;
}

void deleteLast(){
  NodePointer t = nil->prev;//ここ逆？
  if( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = nil->next;
  while(1){
    if(t == nil) break;
    if(t->key == key){
      deleteNode(t);
      break;
    }
    t = t->next;
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if (strlen(com) > 6){
      if ( com[6] == 'F' ) {
	//printf("delF worked!!\n");
	deleteFirst();
	//printf("⊂二二二（ ＾ω＾）二⊃ ﾌﾞｰﾝ \n");
	//break;
      }
      else if ( com[6] == 'L' ) {
	//printf("delLworked!!\n");
	deleteLast();
	//printf("⊂二二二（ ＾ω＾）二⊃ ﾌﾟｰﾝ \n");
	//break;
      }
    }else if(strlen(com) <= 6){
      scanf("%d", &key);
      if ( com[0] == 'i' ) {
	//printf("in worked!!\n");
	insert(key);
	np++;
	size++;
      }
      else {
	//printf("del worked!!\n");
	delete(key);
	nd++; 
      }
      size--;
    }
    //printList();
  }
  
  printList();
  return 0;
}



Measured memory_bytes: 32944
from itertools import accumulate

N = int(input())
A = list([int(x) for x in input().split()])
check = list(accumulate(A))

MOD = 10**9 + 7

result = 0
for i in range(N):
    result += (A[i] * (check[N-1] - check[i]))
    result %= MOD

print(result)


Measured memory_bytes: 31252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  string S; cin >> S;
  rep(i,19){
    if(i == 5 || i == 13) cout << " ";
    else cout << S[i];
  }
  cout << endl;
  return 0;
  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int N;
   cin >> N;
   vector<int> s(N),b(N);
   int S = 0;
   for(int i = 0; i < N; i++){
       cin >> s[i];
       S += s[i];
       if(s[i]%10 != 0) b[i] = s[i];
       else b[i] = 101;
   }
   bool flag = false;
   sort(b.begin(),b.end());
   for(int i = 0; i < N; i++){
       if(b[i] != 101){
           flag = true;
           break;
       }
   }
   if(flag == false){
       cout << 0 << endl;
       return 0;
   }
   for(int i = 0; i < N; i++){
       if(S%10 != 0){
           cout << S << endl;
           return 0;
       }
       S -= b[i];
   }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c, x, i, j, k, g=0;
    int d, e, f;
    
    scanf("%d%d%d%d",&a,&b,&c,&x);
    
    for(i=0;i<=a;i++){
        d=500*i;
        if(x-d>=0){
            for(j=0;j<=b;j++){
                e=100*j;
                if(x-d-e>=0){
                    for(k=0;k<=c;k++){
                        f=50*k;
                        if(x-d-e-f==0){
                            g++;
                            break;
                        }
                    }
                }
            }
        }
    }
    printf("%d\n",g);
    return 0;
}

Measured memory_bytes: 1736
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()

if N == 0:
    print('0')
    exit()

cnt = 0
rep = N
lista = []

# -2進数　N = -9のとき
# -9を1, -2, 4, -8...で表現する → 1 + (-10) を1, -2, 4, -8...で表現する
# -10を-2, 4, -8...で表現する
# ↑　使う数に1を加えないと-9を-2, 4, -8...で表現する事になりこれは不可能
while rep != 0:
    split = (abs(rep) % 2 ** (cnt + 1)) // 2 ** cnt
    if split == 0:
        lista.append(0)
    else:
        lista.append(1)
    rep -= (split * ((-2) ** cnt))
    cnt += 1
lista.reverse()
print(''.join(map(str, lista)))

Measured memory_bytes: 60780
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int h, w;
	cin >> h >> w;

	int c;
	cin >> c;

	vector<int> ai(c);
	for (int i = 0; i < c; ++i) {
		cin >> ai[i];
	}

	vector<vector<int> > grid(h, vector<int> (w));
	int k = 0;
	int curr_color = ai[k];
	for (int i = 0; i < h; ++i) {
		if (i & 1) {
			for (int j = w - 1; j >= 0; --j) {
				grid[i][j] = k + 1;
				--ai[k];
				if (ai[k] == 0) {
					++k;
				}
			}
		} else {
			for (int j = 0; j < w; ++j) {
				grid[i][j] = k + 1;
				--ai[k];
				if (ai[k] == 0) {
					++k;
				}
			}
		}
	}

	cout << grid;

	return 0;

}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

class modint {
public:
	ll val;
	modint(ll a) {
		val = a % MOD;
	}
	modint operator+(const modint& r) {
		return modint((this->val + r.val) % MOD);
	}
	modint operator-(const modint& r) {
		return modint((this->val - r.val) % MOD + ((this->val - r.val) % MOD < 0) * MOD);
	}
	modint operator*(const modint& r) {
		return modint((((this->val % MOD) * (r.val % MOD))) % MOD);
	}
	modint operator/(const modint& r) {
		return modint(this->val * modinv<ll>(r.val, MOD) % MOD);
	}
	modint& operator+=(const modint& r) {
		*this = *this + r;
		return *this;
	}
	modint& operator-=(const modint& r) {
		*this = *this - r;
		return *this;
	}
	modint& operator*=(const modint& r) {
		*this = *this * r;
		return *this;
	}
	modint& operator/=(const modint& r) {
		*this = *this / r;
		return *this;
	}

};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> S(N), T(M);
	for (int i = 0; i < N; i++)cin >> S[i];
	for (int i = 0; i < M; i++)cin >> T[i];
	vector<vector<modint>> dp(N+1, vector<modint>(M+1, modint(0)));
	vector<vector<modint>> sum(N + 1, vector<modint>(M + 1, modint(0)));
	for (int i = 1; i < N + 1; i++)for (int j = 1; j < M + 1; j++) {
		if (S[i - 1] == T[j - 1]) {
			dp[i][j] = sum[i-1][j-1] + modint(1);
		}
		else dp[i][j] = 0;
		sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + dp[i][j];
	}
	cout << sum[N][M].val+1 << endl;
}

Measured memory_bytes: 62976
const main = (input) => {
  const mod = 10**9 + 7
  const [n, k] = input.trim().split(' ').map(Number)
  

  let ans = 0

  for (let i=k; i<=n+1; i++) {
    const s_sum = (i-1) * i / 2

    const b_f = n - i + 1

    const b_sum = (b_f + n) * i / 2

    ans += b_sum - s_sum + 1
  }

  return console.log((ans % mod + mod) % mod)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 33064
import numpy as np

n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))

# グループ内（初項）
start = 0
for i in range(n - 1):
    start += np.where(a[i + 1:] < a[i])[0].shape[0]

# グループ間（差）
coef = 0
for i in range(n):
    coef += np.where(a < a[i])[0].shape[0]

mod = 10**9 + 7

ans = (start + start + coef * (k - 1)) * k // 2 % mod

print(ans)

Measured memory_bytes: 12488
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
bool flag=true;
vector<ll>g=v;
for(ll i=1;i<n;i++)
{
    ll dif=v[i]-v[i-1];
    if(dif<=-2)
    {
        flag=false;
        break;
    }else if(dif==-1)
    {
        v[i-1]--;
    }else if(dif==0)
    {
        continue;
    }
}
for(ll i=1;i<n;i++)
{
    if(v[i]<v[i-1])
    {
        flag=false;
        break;
    }
}
bool flag1=true;
for(ll i=g.size()-2;i>=0;i--)
{
    ll dif=g[i]-g[i+1];
    if(dif>=2)
    {
        flag1=false;
        break;
    }else if(dif==1)
    {
        g[i]--;
    }
}
for(ll i=1;i<n;i++)
{
    if(g[i]<g[i-1])
    {
        flag1=false;
        break;
    }
}
if(flag1==false&&flag==false)
{
    cout<<"No";
}else
{
    cout<<"Yes";
}


return 0;
}


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

def divisor(N, div):
    if N==0 or N==1:
        return div
    n=N
    for i in range(2, int(N**0.5)+1):
        if n%i==0:
            cnt=0
            while n%i==0:
                cnt+=1
                n//=i
            try:
                div[i]+=cnt
            except:
                div[i]=cnt
    if n!=1:
        try:
            div[n]+=1
        except:
            div[n]=1
    return div

def fact(n):
    div={}
    for i in range(1, n+1):
        div=divisor(i, div)
    return div

d=fact(n)
mod=10**9+7
ans=1
for k,v in d.items():
    ans*=(v+1)
    ans%=mod
print(ans)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int K = scan.nextInt();
        boolean t = sub(K, A, B, C);
        if (t) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
    private boolean sub(int K, int A, int B, int C) {
        for (int i = 0; i < 3; i++) {
            boolean t = dfs(K, A, B, C, i, 0);
            if (t) {
                return true;
            }
        }
        return false;
    }
    private boolean dfs(int K, int A, int B, int C, int choice, int turn) {
        if (K <= turn) {
            return false;
        }
        if (choice == 0) {
            A *= 2;
        }
        if (choice == 1) {
            B *= 2;
        }
        if (choice == 2) {
            C *= 2;
        }
        if (A < B && B < C) {
            return true;
        }
        for (int i = 0; i < 3; i++) {
            boolean t = dfs(K, A, B, C, i, turn + 1);
            if (t) {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 35664
import math

N = int(input())

f = math.factorial(N)
i = 2
ans = 1
cnt = 0

while f != 1:
    if f % i == 0:
        f //= i
        cnt += 1
    else:
        ans *= (cnt + 1)
        cnt = 0
        i += 1


print(ans * (cnt + 1) % (10 ** 9 + 7))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  double w,h;

  while(scanf("%d,%lf,%lf",&n,&w,&h) != EOF){
    
    if(w/(h*h)>=25) printf("%d\n",n);
  }

  return (0);
}

Measured memory_bytes: 3140
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int n,size=1;
long long l;
int tr[100010][2];
bool vis[100100];
char s[100010];
int dep[100010];
long long sg[100010];
int cnt;
void add(int x)
{
	int nod=1;
	for (int i=1;i<=x;i++)
	{
		if (!tr[nod][s[i]-'0'])
			tr[nod][s[i]-'0']=++size,nod=size;
		else nod=tr[nod][s[i]-'0'];
	}
	vis[nod]=1;
}
void dfs(int x,int y)
{
	if (vis[x]) return;
	dep[x]=dep[y]+1;
	if (tr[x][0]) dfs(tr[x][0],x);
	if (tr[x][1]) dfs(tr[x][1],x);
	if (tr[x][0]==0||tr[x][1]==0) sg[++cnt]=l-dep[x]+1;
}
int main()
{
	scanf("%d",&n);
	scanf("%lld",&l);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		add(strlen(s+1));
	}
	dfs(1,0);
	long long ans=0;
	for (int i=1;i<=cnt;i++)
		ans^=(sg[i]&(-sg[i]));//,cout<<sg[i]<<endl;
	if (!ans) printf("Bob");
	else printf("Alice");
}

Measured memory_bytes: 5376
import math
a,b,h,m = map(int,input().split())

hl = h * 30 + 30 * (m / 60)
ml = m * 6

if ml == 0:
    c = 360 - hl
else:
    c = abs(hl - ml)

if c > 180:
    c = 360 - c

d = (a ** 2) + (b ** 2) - (2 * a * b * (math.cos(math.radians(c))))

print(math.sqrt(d))

Measured memory_bytes: 9464
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=int (a);i<int (n);i++)
#define OUT  freopen("output.txt", "w", stdout)
#define IN  freopen("input.txt", "r", stdin)
#define mem(a,b) memset((a),(b),sizeof(a))
#define NumofDigits(n) ((int)log10(n)+1)
#define NumofBits(n) ((int)log2(n)+1)
#define PI 3.14159265358979323846264
#define vii vector<pair<int,int>>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi  vector<int>
#define nl  cout<<"\n"
#define pb  push_back
#define mp  make_pair
#define ll  long long 
#define ss  second 
#define ff  first
#define endl "\n"
#define sp  " "
using namespace std;
	
int main(){
ios::sync_with_stdio(0);cin.tie(0);

ll t=1; //cin>>t; 
while(t--){
string s, t;cin>>s>>t;
int n=s.size(),m=t.size();

ll ar[n+1][m+1];
rep(i,0,n+1)ar[i][0]=0;
rep(i,0,m+1)ar[0][i]=0;

rep(i,1,n+1){
rep(j,1,m+1){
	if(s[i-1]==t[j-1]){
		ar[i][j]=1+ar[i-1][j-1];
	}
	else{
		ar[i][j]=max(ar[i-1][j],ar[i][j-1]);
	}
}
}
/*rep(i,0,n+1){rep(j,0,W+1)cout<<ar[i][j]<<sp;nl;}*/
vector<char> v;
int i=n,j=m;
while(i>0&&j>0){
	if(s[i-1]==t[j-1]){
		v.pb(s[i-1]);i--,j--;
	}
	else{
		if(ar[i-1][j]>ar[i][j-1])
		i--;
		else j--;	
	}
	
}
reverse(all(v));
for(auto c:v)cout<<c;


}


}


Measured memory_bytes: 73988
n, a, b = map(int, input().split())
s = input()

cnt_a = 0
cnt_b = 0

for i in range(n):
    if s[i] == "a":
        if cnt_a + cnt_b < a + b:
            cnt_a += 1
            print("Yes")
        else:
            print("No")
    elif s[i] == "b":
        if cnt_a + cnt_b < a + b and cnt_b < b:
            cnt_b += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016
n,m = map(int, input().split())
dp = [0]*(2**n + 1)
for i in range(m):
  a,b = map(int, input().split())
  c = list(map(int, input().split()))
  temp=0
  for i in c:
    temp += 2 ** (i-1)
  for i in range(2**n):
    if i != 0 and dp[i] == 0:
      continue
    t = i | temp
    if dp[t] == 0:
      dp[t] = dp[i] + a
    else:
      dp[t] = min(dp[i] + a, dp[t])

ans = dp[2**n - 1]
if ans == 0:
  print(-1)
else:
  print(ans)

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

const int maxn = 1e5+5;
int n, a[maxn];

int main(){
	scanf("%d", &n);
	map<int, int> cnt;
	
	for(int i = 0; i<n; i++) 
		scanf("%d", &a[i]),
		cnt[a[i]]++;
	
	int ans = 0;
	for(auto &p: cnt){
		if (p.first > p.second) ans+= p.second;
		if (p.first < p.second) ans+= p.second - p.first;
	}
	printf("%d\n", ans);
	
    return 0;
}


Measured memory_bytes: 5120