akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <utility>
#include <bitset>

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

using namespace std;

int main () {
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0) {
            if (n / i >= 1 && n / i <= 9) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			int most = 0;
			double d = Double.MAX_VALUE;
			for (int i = 0; i < n; i++)
			{
				int m = sc.nextInt();
				double h = sc.nextInt() / 100.0, w = sc.nextInt();
				if (d > Math.abs(w / (h * h) - 22.0))
				{
					d = Math.abs(w / (h * h) - 22.0);
					most = m;
				}
			}
			System.out.println(most);
		}
	}
}

Measured memory_bytes: 12000
import sys
N = int(input())
A = [int(a) for a in input().split()]

for a in A:
    if(a==0):
        print(0)
        sys.exit()

ans = 1
for a in A:
    ans *= a
    if(ans > 1000000000000000000) :
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 21636
#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_V 202
#define MAX_E 1000
using namespace std;
struct edge {
	int to, cap, rev;
	edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
};

int V, E;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void AddEdge(int from, int to, int cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

void BFS(int s) {
	fill(level, level + V, -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (size_t i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int DFS(int v, int t, int f) {
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			int d = DFS(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int Dinic(int s, int t) {
	int flow = 0;
	while (true) {
		BFS(s);
		if (level[t] < 0) return flow;
		fill(iter, iter + V, 0);
		int f;
		while ((f = DFS(s, t, INF)) > 0) {
			flow += f;
		}
	}
}

int main()
{
	int X, Y;
	cin >> X >> Y >> E;
	V = X + Y + 2;
	for (int i = 0; i < X; i++) {
		AddEdge(X + Y, i, 1);
	}
	for (int i = 0; i < Y; i++) {
		AddEdge(X + i, X + Y + 1, 1);
	}
	for (int i = 0, x, y; i < E; i++) {
		cin >> x >> y;
		AddEdge(x, X + y, 1);
	}
	cout << Dinic(X + Y, X + Y + 1) << endl;
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
        int N, M, X;
        cin >> N >> M >> X;

        vector<int> C(N);
        vector<vector<int>> A(N, vector<int>(M));
        REP(i, N) {
                cin >> C[i];
                REP(j, M) cin >> A[i][j];
        }


        vector<int> U(M);
        REP(i, N) {
                REP(j, M) {
                        U[j] += A[i][j];
                }
        }

        bool check = true;
        REP(i, M) {
                if (U[i] < X) check = false;
        }
        if (!check) {
                cout << "-1" << endl;
                return 0;
        }


        int min_price = numeric_limits<int>::max();
        REP(i, (1 << N)) {
                U = vector<int>(M);
                int price = 0;

                REP(j, N) {
                        int mask = 1 << j;
                        if ((i & mask) > 0) {
                                price += C[j];
                                REP(k, M) U[k] += A[j][k];
                        }
                }

                check = true;
                REP(j, M) {
                        if (U[j] < X) check = false;
                }
                if (check) {
                        min_price = min(min_price, price);
                }
        }

        cout << min_price << endl;
        return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(){
    int a, b, i, dif, sum;

    scanf("%d%d", &a, &b);
    dif = b-a;
    sum = 0;

    for(i = 1; i <= 999; i++)
    {
        sum += i;
        if(i >= dif){
            printf("%d\n", sum-b);
            break;
        }
    }

    return 0;
}

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

const ll mod = 1000000007;

ll power(ll x, ll y) {
    if(y == 1) {
        return x;
    }
    
    ll ans;
    if(y % 2 == 1) {
        ll r = power(x,(y-1)/2);
        ans = r * r % mod;
        ans = ans * x % mod;
    }
    else {
        ll r = power(x,y/2);
        ans = r * r % mod;
    }
    
    return ans;
}

ll conb(ll x, ll y) {
    ll c, p;
    c = p = 1;
    
    while(y >= 1) {
        c *= x;
        p *= y;
        c %= mod;
        p %= mod;
        x--;
        y--;
    }
    //cout << c << " " << p << endl;
    
    return c * power(p,mod-2) % mod;
}

int main() {
    ll s;
    cin >> s;
    
    if(s < 3) {
        cout << 0 << endl;
        return 0;
    }
    
    ll c = s / 3;
    ll ans = 1;
    for(ll i = 1; i < c; i++) {
        ll p = s - 3*(i+1) + i;
        //cout << p << " " << i << endl;
        if(p <= i)
            ans++;
        else
            ans += conb(p,i);
        ans %= mod;
    }
    
    cout << ans << endl;
    //cout << power(2,mod) << endl;
    
    
    return 0;
}




Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    ll h, w;
    cin>>h>>w;
    ll ans=0;
    if(w==1||h==1) {
        ans=1;
    }
    else{
        rep(i, h){
            if(i%2==0){
                ans+=(w+1)/2;
            }
            else ans+=w/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s,t = LS()
    a,b = LI()
    u = S()
    d = defaultdict(lambda : 0)
    d[0] = a
    d[1] = b
    if s == u:
        d[0] -= 1
    else:
        d[1] -= 1
    print(d[0],d[1])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <string> 
#include <sstream>  
#include <vector> 
#include <time.h>
#include <algorithm>
using namespace std;

int main(){
    int price[4] = {6000,4000,3000,2000};
    int a,b;
    for(int i = 1;i <= 4;i++){cin >> a >> b;cout << b * price[a-1] << endl;}
} 

Measured memory_bytes: 1164
using System;
using System.Linq;
class Program{
static void Main(string[] args){
  var N = int.Parse(Console.ReadLine());
  var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
  a.Sort();
  a.Reverse();
  int ans=0;
  for(int i=0;i<N/2;i++){
    ans+=a[i*2];
    ans-=a[i*2+1];
  }
  if(N%2==1){
  ans+=a[N-1];
  }
  Console.WriteLine(ans);
}
}

Measured memory_bytes: 13396
import heapq

N = int(input())
d = [0] * N
INF = float('inf')
        
G = [[] for i in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
    
def dijkstra(s):
    for i in range(N):
        d[i] = INF
    d[s] = 0
    h = []
    heapq.heappush(h, [0, s])
    
    while h != []:
        p = heapq.heappop(h)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(G[v])):
            e = G[v][i]
            if d[e] > d[v] + 1:
                d[e] = d[v] + 1
                heapq.heappush(h, [d[e], e])

dijkstra(0)
d2 = d.copy()
F = d2

dijkstra(N - 1)
S = d

Fennec = 0
for i in range(N):
    if F[i] <= S[i]:
        Fennec += 1
        
print('Fennec' if Fennec > N - Fennec else 'Snuke')

Measured memory_bytes: 29100
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

#define N_MAX (200000)

typedef struct {
  size_t X; /* モンのX座標 */
  size_t H; /* モンのHP */
} Monster;

static size_t N;                        /* モンの総数 */
static size_t D;                        /* 爆弾のレンジ */
static size_t A;                        /* 爆弾のダメージ */
static Monster M[N_MAX];                /* モン達 */
static size_t  L[N_MAX];                /* 巻き添え開始位置(詳細は後述) */
static unsigned long long Y[N_MAX + 1]; /* 累計ダメージ量 */

int cmp(const void* lhs, const void* rhs) {
  return ((const Monster*)lhs)->X - ((const Monster*)rhs)->X;
}

int main(void) {
  size_t i, j, c;
  static unsigned long long y, result = 0;
  /* 入力チェックは全て省略 */
  scanf(" %u %u %u", &N, &D, &A);
  for (i = 0; i < N; ++i) {
    scanf(" %u %u", &M[i].X, &M[i].H);
  }
  /* モンを左から順に並べ替えておく */
  qsort(M, N, sizeof(Monster), cmp);

  /* i番目のモンが巻き添えを受け始める位置を計算し、L[i]に格納する */
  /* ※O(N)で計算可能だから性能上がるんじゃないか、という主張 */
  j = 0;
  for (i = 0; i < N; ++i) {
    while ((j < i) && (M[j].X + 2 * D < M[i].X))
      ++j;
    L[i] = j;
  }

  /* 左のモンから順にムッコロス */
  /* ※最左のモンにCeiling(モンのHP/爆弾のダメージ)回 */
  /*   当てるのは必要経費なので */
  for (i = 0; i < N; ++i) {
    /* 以前にモンを倒したときの巻き添えダメージ量を計算 */
    y = Y[i] - Y[L[i]];
    /* 巻き添えで倒し切れていない場合のみ、残りHPを削る */
    if (y < M[i].H) {
      /* たぶんCeiling(モンの残りHP/爆弾のダメージ)になっているはず */
      c = (M[i].H - (size_t)y + A - 1) / A;
      /* 以降の巻き添え計算用に、累計ダメージ量を控えておく*/
      Y[i + 1] = Y[i] + c * (unsigned long long)A;
      /* 爆弾の総使用回数を計上 */
      result += c;
    }
    else {
      Y[i + 1] = Y[i];
    }
  }
  printf("%llu\n", result);
  return 0;
}


Measured memory_bytes: 7548
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <fstream>
#include <cmath>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}

}


int main(){
  int n;cin>>n;
  vector<int> y(n),m(n),d(n);
  for(int i=0;i<n;i++)cin>>y[i]>>m[i]>>d[i];
  int year,month,day;
  int ans=0;
  int m_memo[11][3];for(int i=0;i<10;i++){m_memo[i][0]=20;m_memo[i][1]=m_memo[i][2]=20-(i%2);}
  m_memo[10][0]=200;m_memo[10][1]=m_memo[10][2]=195;
  for(int i=0;i<n;i++){
    ans=0;ans-=d[i]+1;
    for(int j=0;j<m[i]-1;j++)ans-=m_memo[j][y[i]%3];
    for(; y[i]<1000;y[i]++)ans+=m_memo[10][y[i]%3];
    cout<<ans+2<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
N, M = list(map(int,input().split()))
a = []
for i in range(N):
    a.append(list(input().split()))
b = 0
c = 0
d = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(N):
    for j in range(M):
        if a[i][j] == 'snuke':
            b = i+1
            c = j

print(d[c]+str(b))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int group(int x)
{
    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) return 1;
    else if(x == 4 || x == 6 ||x == 9 ||x == 11) return 0;
    else if(x == 2) return 2;
    else return -1;
}

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

    if(group(x) == group(y)) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print(max(0, a - 2 * b))
    return

#B
def B():
    n = II()
    d = LI()
    ans = 0
    for i in range(n):
        for k in range(i+1, n):
            ans += d[i] * d[k]
    print(ans)
    return

#C
def C():
    n = II()
    s = S()
    i = 0
    ans = 1
    for i in range(1, n):
        if s[i - 1] == s[i]:
            continue
        ans += 1
    print(ans)
    return

#D
def D():
    n = II()
    l = LI()
    l.sort()
    ans = 0
    for i in range(n - 1, 0, -1):
        for k in range(i - 1, -1, -1):
            ab = l[i] - l[k]
            c = max(0, k - bisect_right(l, ab))
            ans += c
    print(ans)
    return

#E
def E():
    n, m, l = LI()
    dist = [[inf] * n for i in range(n)]

    for _ in range(m):
        a, b, c = LI_()
        c += 1
        if c > l:
            continue
        dist[a][b] = c
        dist[b][a] = c

    supply = [[n] * n for i in range(n)]
    for k in range(n):
        distk = dist[k]
        for i in range(n):
            if i == k:
                continue
            disti = dist[i]
            distik = dist[i][k]
            for j in range(i + 1, n):
                if distik + distk[j] < disti[j]:
                    disti[j] = distik + distk[j]
                    dist[j][i] = disti[j]

    lis = [[] for i in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            if dist[i][j] <= l:
                supply[i][j] = 0
                supply[j][i] = 0
                lis[i].append(j)
                lis[j].append(i)

    for i in range(n):
        q = []
        for k in lis[i]:
            heappush(q, (0, k))
        supplyi = supply[i]

        while q:
            time, p = heappop(q)
            for k in lis[p]:
                if supplyi[k] > time + 1:
                    supplyi[k] = time + 1
                    heappush(q, (time + 1, k))

    q = II()
    for _ in range(q):
        s, t = LI_()
        if dist[s][t] == inf:
            print(-1)
            continue
        else:
            print(supply[s][t])
    return


#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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


int main(){
	string input;
	cin >> input;
	if(input.size() < 4){
		cout << "No" << endl;
		return 0;
	}
	
	if(input[0] == 'Y' && input[1] == 'A' && input[2] == 'K' && input[3] == 'I'){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

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

using namespace std;

#define ll long long
#define endl "\n"

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

    int d,t,s;
    cin >> d >> t >> s;
    int ans = s*t;
    if(ans>=d) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n,p;
string s;
int tpow,suff;
int cnt[10010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>p>>s;
	if(p==2||p==5){
		long long res=0LL;
		for(int i=0;i<n;i++){
			if((s[i]-'0')%p==0)
				res+=(long long)(i+1);
		}
		cout<<res<<endl;
		return 0;
	}
	tpow=1;
	suff=0;
	cnt[0]=1;
	long long res=0LL;
	for(int i=n-1;i>=0;i--){
		suff=(suff+(s[i]-'0')*tpow)%p;
		tpow=(tpow*10)%p; 
		res+=(long long)(cnt[suff]);
		cnt[suff]++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 720
def resolve():
    '''
    code here
    '''
    import heapq
    N = int(input())
    input_list = [-1 * int(item) for item in input().split()]

    heapq.heapify(input_list)

    input_list = [-1 * item for item in input_list]
    print('', *input_list)


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 63644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAX=2100,MOD=1000000007;

ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  int n,k; cin>>n>>k;
  int red=n-k+1,blue=k-1;
  COMinit();
  for(int i=0;i<k;i++){
    cout<<COM(red,i+1)*COM(blue,i)%MOD<<endl;
  }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i])
  }
  mod := a[0]
  for _, v := range a {
    mod = gcd(mod, v)
  }
  fmt.Println(mod)
}

func gcd(a, b int) int {
  var mod int
  for a%b > 0 {
    mod = a % b
    a = b
    b = mod
  }
  return b
}


Measured memory_bytes: 5504
f :: (Int, Int) -> String
f (a,b) = show(a) ++ "x" ++ show(b) ++ "=" ++ show(a*b)

main = do
    let i = [ (x,y) | x<-[1..9], y<-[1..9] ]
        j = map f i
    mapM_ putStrLn j

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

int main(void){
    int k,t;
    cin >> k >> t;
    int a[t];
    for(int i = 0;i < t;i++)cin >> a[i];
    sort(a,a+t,greater<int>());
    if((k-a[0]+1) - a[0] >= 0)cout << 0;
    else cout << a[0] - (k-a[0]+1);
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            var ans = 48 - GetInt();

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {

        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

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

vector<int> g[MAX];
vector<int> color(MAX,0);

bool dfs(int v, int c){
    color[v] = c;
    rep(i,g[v].size()){
        if(color[g[v][i]] == c) return false;
        if(color[g[v][i]] == 0 && !dfs(g[v][i],-c)) return false; 
    }
    return true;
}

int main(){
    ll n, m;
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if(dfs(0,1)){
        ll b = 0;
        rep(i,n) if(color[i] == 1) b++;
        cout << b*(n-b) - m << endl;
    } else {
        cout << n*(n-1)/2 - m << endl;
    }
    return 0;
} 

Measured memory_bytes: 6528
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define db double
#define LL long long
#define inf 0x3f3f3f3f
#define N 200005
using namespace std;
int gi()
{
    int res=0,s=1; char ch;
    for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=res*10+ch-48;
    return res*s;
}

int n,a[N]; LL ans=0;

int main()
{
    n=gi();
    for(int i=1;i<=n;++i) a[i]=gi();
    if(a[1]) {printf("-1"); return 0;}
    for(int i=2;i<=n;++i) if(a[i]>a[i-1]+1) {printf("-1"); return 0;}
    for(int i=2;i<=n;++i) {
	if(a[i]==a[i-1]+1) ans++;
	else ans+=a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=__max(ans,a*d);
    ans=__max(ans,b*c);
    ans=__max(ans,b*d);
    cout << ans << "\n";
}


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

int main()
{
	string ans;
	string abcd;
	int n[4];

	cin >> abcd;

	for( int i = 0; i < 4; i++ ) {
		n[i] = abcd[i] & 0x0f;
	}

	int i, j , k;

	for( i = 0; i < 2; i++ ) {
		for( j = 0; j < 2; j++ ) {
			for( k = 0; k < 2; k++ ) {
				int s = n[0];
				if(  i == 0 ) {
					s += n[1];
				}
				else {
					s -= n[1];
				}
				if(  j == 0 ) {
					s += n[2];
				}
				else {
					s -= n[2];
				}
				if(  k == 0 ) {
					s += n[3];
				}
				else {
					s -= n[3];
				}
				if( s == 7 ) {
					goto exit_loop;
				}
			}
		}
	}
exit_loop:
	string sign[2] = { "+", "-" };
	ans = abcd[0] + sign[i] + abcd[1] + sign[j] + abcd[2] + sign[k] + abcd[3] + "=7";

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    int n=s.size();
    ll ans=0;
    rep(i,0,1<<(n-1)){
        ll u=i;
        ll sum=0;
        ll now=s[0]-'0';
        rep(j,1,n){
            if(u%2){
                sum+=now;
                now=s[j]-'0';
            }
            else{
                now*=10;
                now+=s[j]-'0';
            }
            u/=2;
        }
        sum+=now;
        ans+=sum;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main() {
    cin.sync_with_stdio(false);
	int n;
	cin >> n;
	vi A(n);
	rep(i,0,n) cin >> A[i];
	vi P(n);
	int start = n/2;
	rep(i,0,n) {
		P[start = start+(i%2==1?i*-1:i)] = A[i];
	}
	if(n%2 == 1) reverse(P.begin(), P.end());
	iter(it,P) cout << *it << " "; 
	cout << endl;
    return 0;
}


Measured memory_bytes: 3712
n = int(input())
a = [int(input()) for i in range(n)]
count = 0
i = 0
ans = False
while count < n:
    count += 1
    if a[i] == 2:
        ans = True
        break
    else:
        i = a[i] - 1
if ans == True:
    print(count)
else:
    print("-1")

Measured memory_bytes: 7084
import math

n = int(input())
a, b = [0] * n, [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
ans = 0
for i in range(n):
    if (a[n - 1 - i] + ans) % b[n - 1 - i] != 0:
        ans += b[n - 1 - i] - (a[n - 1 - i] + ans) % b[n - 1 - i]
    #print(ans)
print(ans)


Measured memory_bytes: 10868
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

void run() {
    string s, t; cin >> s >> t;
    int n = s.length(), m = t.length();
    if (m == n + 1 && t.substr(0, n) == s) {
        cout << "Yes" << '\n';
    } else cout << "No" << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]

    return (n, a)


def solve(n, a):
    
    m = int(10 ** 18)
    a.sort()
    result = 1
    for i in range(n):
        result = result * a[i]
        if result > m:
            result = -1
            break

    return result    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 84888
H, W, m = map(int, input().split())
hs = [0] * (H+1)
ws = [0] * (W+1)
from collections import defaultdict
d = defaultdict(bool)
N = 10**6
for i in range(m):
    hi,wi = map(int, input().split())
    hi -= 1
    wi -= 1
    hs[hi] += 1
    ws[wi] += 1
    d[hi*10**6+wi] = True

hmx = max(hs)
hset = set()
for i,h in enumerate(hs):
    if h == hmx:
        hset.add(i)
wmx = max(ws)
wset = set()
for j, w in enumerate(ws):
    if w == wmx:
        wset.add(j)

flg = False
ans = 0
cnt = 0
for i in hset:
    for j in wset:
        ans = max(ans, hmx+wmx-d[i*N+j]) 
        if cnt >= m:
            flg = True
            break
        cnt += 1
    if flg:break

print(ans)

Measured memory_bytes: 176468
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
void dfs(void);
void visit(int);
 
int G[N][N],n,d[N],f[N],color[N],time;
 
int main(){
   int i,j,k,u,v;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      G[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u=u-1;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v=v-1;
      G[u][v] = 1;
    }
  }
  dfs();
  return 0;
}
  void dfs(){
    int u;
    for(u = 0; u < n; u++) color[u] = WHITE;
    time = 0;
    for(u =0 ; u < n; u++){
      if(color[u] == WHITE) visit(u);
    }
    for( u = 0; u < n; u++){
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
  }
  void visit(int u){
    int i;
    color[u] = GRAY; 
    d[u] = ++time;
    for(i = 0; i < n; i++){
      if(G[u][i] == 0) continue;
      if(color[i] == WHITE){
    visit(i);
      }
    }
    color[u] = BLACK;
    f[u] = ++time;
  }

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

mod = 10**9+7


ans = pow(2,n,mod)

ans -= 1
if ans < 0:
	ans += mod
# print("Ans now:", ans)

c1 = 0
cnt = n
num = 1
den = 1
for i in range(1,a+1):
	num = num * cnt;
	cnt -= 1
	den = den * i
	den %= mod
	num %= mod
# print(den,num)

c1 = num * pow(den,mod-2,mod)
c1 %= mod
# print(c1)

c2 = 0
cnt = n
num = 1
den = 1
for i in range(1,b+1):
	num = num * cnt
	cnt -= 1
	den = den * i
	den %= mod
	num %= mod
# print(den,num)
c2 = num * pow(den, mod-2, mod)
c2 %= mod

ans -= c1
if ans < 0 : ans += mod
ans -= c2
if ans < 0 : ans += mod

print(ans)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    bool flag = true;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                flag = false;
            }
        }
    }
    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;


int main() {
    ll H; cin>>H;
    ll mult = 1;
    ll ans = 0;
    while (H > 1) {
        ans += mult;
        mult <<= 1;
        H >>= 1;
    }
    ans += mult;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) x.begin(),x.end()
using namespace std;


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

    float n;
    cin >> n;
    cout << (int)pow(n, 3.0) << endl;
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var dict = new Dictionary<int, int>();

            for (var i = 0; i < N; i++)
            {
                if (dict.ContainsKey(a[i]))
                    dict[a[i]]++;
                else
                    dict[a[i]] = 1;
            }

            var one = new KeyValuePair<int, int>(0, 0);
            var two = new KeyValuePair<int, int>(0, 0);
            var three = new KeyValuePair<int, int>(0, 0);
            int count = 0, max = 1;
            foreach (var d in dict.OrderBy(z => z.Key))
            {
                if (count == 0)
                    one = d;
                else if (count == 1)
                    two = d;

                if (N == 1) break;
                if (dict.Count == 2 && count == 1)
                {
                    if (one.Key + 1 == two.Key || one.Key + 2 == two.Key)
                        max = one.Value + two.Value;
                    break;
                }

                max = Math.Max(max, d.Value);
                if (count >= 2)
                {
                    three = d;
                    if (one.Key + 1 == two.Key)
                        max = Math.Max(max, one.Value + two.Value);
                    if (one.Key + 1 == two.Key && two.Key + 1 == three.Key)
                        max = Math.Max(max, one.Value + two.Value + three.Value);
                    if (one.Key + 2 == two.Key)
                        max = Math.Max(max, one.Value + two.Value);

                    one = two;
                    two = three;
                }
                count++;
            }

            Console.WriteLine(max);
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<string> ss(N);
  for (int i = 0; i < N; i++) {
    cin >> ss.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<string> ts(M);
  for (int i = 0; i < M; i++) {
    cin >> ts.at(i);
  }
  
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      if (ts.at(i) == ss.at(j)) {
        ss.at(j) = "";
        break;
      }
    }
  }

  int max = 0;
  for (int i = 0; i < N; i++) {
    if (ss.at(i) == "") continue;
    
    int c = 1;
    for (int j = i + 1; j < N; j++) {
      if (ss.at(i) != "" && ss.at(i) == ss.at(j)) {
        c++;
        ss.at(j) = "";
      }
    }
    if (c > max) max = c;
  }
  
  cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int, int> pii;


int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n;
	cin >> n;
	map<int,int> bucket;
	for (int i = 0; i < n; ++i) {
	  int x; cin >> x;
	  bucket[x]++;
	}
	
	int distintos = 0;
	int etzor = 0;
	for (auto it : bucket) {
	  etzor ^= it.first;
	  distintos++;
	}
	if (distintos == 1) {
	  cout << (bucket[0] == n ? "Yes" : "No") << "\n";
	} else if (n % 3) {
	  cout << "No\n";
	} else if (distintos == 2) {
		cout << (bucket[0] == n/3 ? "Yes" : "No") << "\n";
	} else if (distintos == 3) {
	  bool flag = (etzor == 0);
	  for (auto it : bucket) {
	  	if (it.second != n/3) flag = false;
	  }
	  cout << (flag ? "Yes" : "No") << "\n";
	} else {
	  cout << "No\n";
	}
  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

template<typename T>
struct BIT{
  int n;
  vector<T> d;
  BIT(int n = 0):n(n),d(n+1){}
  void add(int i,T x=1){
    for(i++;i<=n;i += i&-i){
      d[i] += x;
    }
  }
  T sum(int i){
    T x = 0;
    for(i++;i>0;i -= i&-i){
      x += d[i];
    }
    return x;
  }
};

int main(){
  int h,w,d;cin >> h >> w >> d;
  map<int,int> mp;
  rep(i,h)rep(j,w){
    int a; cin >> a;--a;
    mp[a] = w*i+j;
  }
  vector<BIT<int>> tree(d,BIT<int>(h*w/d+1));
  for(int i = 0;i < h*w;i++){
    if(i/d == 0) tree[i%d].add(0,0);
    else {
      int cost = abs(mp[i]/w - mp[i-d]/w) + abs(mp[i]%w - mp[i-d]%w);
      //printf("%d %d %d %d\n",i,cost,mp[i],mp[i-d]);
      tree[i%d].add(i/d,cost);
    }
  }

  int q;cin >> q;
  rep(i,q){
    int l,r;cin >> l >>r;
    --l;--r;
    cout << tree[l%d].sum(r/d) - tree[l%d].sum(l/d) << endl;
  }

  //for(auto v:tree[0].d) cout << v << endl;

  //cout << ans << endl;
}

Measured memory_bytes: 12820
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<int> C;
#define X real()
#define Y imag()
//typedef unordered_set<ll> usll;
//typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll> > vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
//typedef unordered_multiset<int> umsi;
//typedef unordered_set<int> usi;
typedef pair<int,int> pi;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<double,double> > vpd;
typedef pair<double,double> pd;
typedef priority_queue<int> pqi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ind_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mo 1000000007
#define inf 1000000000000000001
#define ninf -1000000000000000001
#define ima INT_MAX
#define imi INT_MIN
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
const ld pii=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

void dfs(int cur,stack<int> &s,vi ch[],bool vis[])
{
	if(!vis[cur])
	{
		vis[cur]=true;
		for(int i=0;i<ch[cur].size();i++)
		{
	
			dfs(ch[cur][i],s,ch,vis);
		}
	}
	s.push(cur);
}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
int n,m;
cin>>n>>m;
char a[n][m];
for(int i=0;i<n;i++)
{
	for(int j=0;j<m;j++)
	cin>>a[i][j];
}

ll dp[n][m];
dp[0][0]=1;
for(int i=1;i<n;i++)
{dp[i][0]=0;
	if(a[i][0]=='#')
	dp[i][0]=0;
	else
	dp[i][0]+=dp[i-1][0];
}
for(int i=1;i<m;i++)
{dp[0][i]=0;
	if(a[0][i]=='#')
	dp[0][i]=0;
	else
	dp[0][i]+=dp[0][i-1];
}

for(int i=1;i<n;i++)
{
	for(int j=1;j<m;j++)
	{dp[i][j]=0;
	if(a[i][j]=='#')
	dp[i][j]=0;
	else
	dp[i][j]=madd(dp[i-1][j],dp[i][j-1]);
	}
}



cout<<dp[n-1][m-1];


}return 0;}








Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>

using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	const int begin[5][3] = {1868, 9, 8, 1912, 7, 30, 1926, 12, 25, 1989, 1, 8, 9999, 12, 31};
	int y,m,d;
	while(cin >> y >> m >> d) {
		int i=0;
		while(begin[i][0] < y) i++;
		if(begin[i][0] == y && (begin[i][1] < m || begin[i][1] == m && begin[i][2] <= d)) i++;
		if(i!=0) y -= begin[i-1][0] - 1;
		switch(i) {
		case 0: cout << "pre-meiji" << endl; break;
		case 1: cout << "meiji"; break;
		case 2: cout << "taisho"; break;
		case 3: cout << "showa"; break;
		case 4: cout << "heisei"; break;
		}
		if(i!=0) cout << " " << y << " " << m << " " << d << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
int main(){
  int numOfHotel;
  int maxHeight{};
  int objHeight;
  int can_see{};
  std::cin>>numOfHotel;
  for (int idx{};idx<numOfHotel;++idx){
    std::cin>>objHeight;
    if (maxHeight<=objHeight){
      ++can_see;
      maxHeight=objHeight;
    }
  }
  std::cout<<can_see;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int A,B,M;
  cin >>A>>B>>M;
  int nedan_a[A];
  rep(i,A){
    cin>>nedan_a[i];
  }
  int nedan_b[B];
  rep(i,B){
    cin>>nedan_b[i];
  }
  int bangouA[M];
  int bangouB[M];
  int nedan_c[M];
  rep(i,M){
    cin>>bangouA[i]>>bangouB[i]>>nedan_c[i];
  }
  int yasune=0;
  int a_min=2147483647;
  int b_min=2147483647;
  rep(i,A){
    a_min=min(a_min,nedan_a[i]);
  }
  rep(i,B){
    b_min=min(b_min,nedan_b[i]);
  }
  yasune=a_min+b_min;
  int x,y,sum;
  rep(i,M){
    x=bangouA[i]-1;
    y=bangouB[i]-1;
    sum=nedan_a[x]+nedan_b[y]-nedan_c[i];
    yasune=min(yasune,sum);
  }
  cout<<yasune<<endl;
  return 0;
}     

Measured memory_bytes: 2176
def main():
    import sys

    input = sys.stdin.readline

    inf = 10 ** 8 + 10

    n, m = map(int, input().split())

    size = (1 << n)

    dp = [inf] * size
    dp[0] = 0

    for _ in range(m):
        price, _ = map(int, input().split())
        key = sum(1 << ind for ind in (int(x) - 1 for x in input().split()))
        for mask in range(size):
            dp[mask | key] = min(dp[mask | key], dp[mask] + price)

    ans = dp[size - 1]
    print(ans if ans != inf else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42844
//In His Name
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >e;
vector<int>adj[100100];
int n,m,minlvl[100100],lvl[100100];
bool mark[100100];
void dfs(int x,int par){
	mark[x]=true;
	minlvl[x]=lvl[x];
	for(int i=0;i<adj[x].size();i++){
		int v=adj[x][i];
		if(!mark[v]){
			lvl[v]=lvl[x]+1;
			dfs(v,x);
			minlvl[x]=min(minlvl[x],minlvl[v]);
		}
		else if(v!=par) minlvl[x]=min(minlvl[x],minlvl[v]);
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(x>y) swap(x,y);
		adj[x].push_back(y);
		adj[y].push_back(x);
		e.push_back(make_pair(x,y));
	}
	for(int i=0;i<n;i++)
		if(!mark[i]) dfs(i,i);
	sort(e.begin(),e.end());
	for(int i=0;i<m;i++){
		int x=e[i].first,y=e[i].second;
		if(lvl[x]<lvl[y]) swap(x,y);
		if(minlvl[x]>lvl[y]) cout<<e[i].first<<" "<<e[i].second<<endl;
	}
	return -0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll func(ll n)
{
	auto temp = (n + 1) / 2 % 2;
	if (n % 2 == 0)
	{
		temp ^= n;
	}

	return temp;
}

int main()
{
	ll A, B;
	cin >> A >> B;

	cout << (func(A - 1) ^ func(B)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	cin >> n;
	int A[1001];
	rep(i, n){
		cin >> A[i];
		if(i > 0)cout << " ";
		cout << A[i];
	}
	FIN("");
	for(int i = 1; i < n; i++){
		int j = i - 1;
		int memo = A[i];
		while(A[j] > memo && j >= 0){
			A[j+1] = A[j];
			j--; 
		}
		A[j+1] = memo;
		rep(k, n){
			if(k > 0)cout << " ";
			cout << A[k];
		}
		FIN("");
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1176
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    r=INT()
    g=INT()
    print(2*g-r)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
MOD=1000000007
n,k=map(int,input().split())

total=0
i=k
while i<=n+1:
	total+=(n - i + 1 + n) * i / 2 - (0 + i - 1) * i / 2 + 1;
	total %= MOD
	i+=1

print(int(total))

Measured memory_bytes: 9192
<>=~$";$L=$';
for(<>){
	$t=0;
	for(/./g){
		$t=$$_[$t]||=++$k
	}
}
sub f{
	for($0[$_],$1[$_]){
		if($_){
			--$L;&f;++$L
		}else{
			$z^=$L&-$L
		}
	}
}
f;
print$z?Alice:Bob


Measured memory_bytes: 83920
import java.util.*;
class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   long ans = 0;
   for(int i=1; i<=N; i++){
     if(i%3==0 || i%5==0){
       continue;
     }
     ans += i;
   }
   System.out.print(ans);
 }
}


Measured memory_bytes: 35608
import java.util.*;

public class Main {
    private static final long MODVAL = 1000000007L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int count[] = new int[N+1];
        long total = 0L;
        for(int i=0; i<N; i++) {
            A[i] = sc.nextInt();
            total += count[A[i]];
            count[A[i]]++;
        }
        for(int i=0; i<N; i++) {
            System.out.println(total - (count[A[i]]-1));
        }
     }
}


Measured memory_bytes: 93184