akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 0

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

#define INTMAX  99999999
using namespace std;

int N, M;

vector<vector<int> > edges;
set<pair<int,int> > used;
// vector<int> usedNodes;
// priority_queue<int> usedNodes;
struct compless {
	bool operator() (pair<int,int> &a, pair<int,int> &b){
		return a.second<b.second;
	}
};

void dijkstra(int u)
{
	priority_queue<pair<int,int>, vector<pair<int,int> >, compless> q;
	// FOR(n,N) {
	// 	if(u==n) {
	// 		q.push(MP(n,0));
	// 	}
	// 	else {
	// 		q.push(MP(n,INTMAX));
	// 	}
	// }
	vector<int> costs;
	// priority_queue<pair<int,int> > q;
	q.push(MP(u,0));
	costs.resize(N, INTMAX);
	costs[u] = 0;
	while(!q.empty()) {
		pair<int,int> next = q.top();
		q.pop();
		FOR(n,N) {
			DOUT<<"cost["<<next.first<<"]=="<<next.second<<" + edges["<<next.first<<"]["<<n<<"]=="<<edges[next.first][n]<<endl;
			DOUT<<"cost["<<n<<"]=="<<costs[n]<<endl;
			if(next.second+edges[next.first][n]<costs[n]) {
				costs[n] = next.second+edges[next.first][n];
				q.push(MP(n,costs[n]));
			}
		}
	}
	// check
	FOR(s,N) {
		FOR(t,N) {
			int edgecost = edges[s][t];
			if(edgecost!=INTMAX) {
				DOUT<<"costs[from:u="<<u<<",to:s="<<s<<"]=="<<costs[s]<<endl;
				DOUT<<"costs[from:u="<<u<<",to:t="<<t<<"]=="<<costs[t]<<endl;
				DOUT<<"edgecost[s="<<s<<",t="<<t<<"]=="<<edgecost<<endl;
				if(costs[s]+edgecost==costs[t]) {
					int a = min(s,t);
					int b = max(s,t);
					DOUT<<"used.insert("<<a<<","<<b<<")"<<endl;
					used.insert(MP(a,b));
				}
			}
		}
	}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N >> M;
	edges.resize(N);

	// DOUT<<"N="<<N<<",M="<<M<<endl;
	FOR(m,M) {
		int a, b, c;
		cin >>a>>b>>c;
		a--;b--;
		// DOUT<<"a="<<a<<",b="<<b<<",c="<<c<<endl;
		if(edges[a].size()==0) {
			edges[a].resize(N,INTMAX);
			// DOUT<<"[resized]edges[a].size()="<<edges[a].size()<<endl;
		}
		if(edges[b].size()==0) {
			edges[b].resize(N,INTMAX);
		}
		// DOUT<<"a="<<a<<",b="<<b<<",c="<<c<<endl;
		// DOUT<<"edges[a].size()="<<edges[a].size()<<endl;
		edges[a][b]=c;
		// DOUT<<"edges[b].size()="<<edges[b].size()<<endl;
		edges[b][a]=c;
	}
	// Dijkstra
	FOR(n,N) {
		DOUT<<"[dijkstra] n="<<n<<endl;
		dijkstra(n);
	}

	int ans = M-used.size();
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 384
import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))
x = b[0]-b[1]+1
res = 10**15
 
for i in range(x):
    tmp = i + b[1] - 1
    if res > (a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp]))):
	    res = a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp]))
        
print(res)

Measured memory_bytes: 23084
S_pro = input()
S = list(S_pro)
loc_A = 0
loc_C = 0
flag = 0
flag_c = 0

if(S[0] == 'A'):
    flag+=1
    loc_A = 0
for i in range(len(S)):
    if(i >= 2 and i <= len(S)-2):
        if(S[i] == 'C'):
            flag_c+=1
            loc_C = i
if(flag_c==1):
    flag+=1

del S[loc_A]
del S[loc_C-1]

S_join = ''.join(S)
if(S_join.islower()):
    flag+=1
if(flag == 3):
    print('AC')
else:
    print('WA')


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

int main(){
	string s;
	cin >> s;
	int flag = 0;
	for(int i =0; i < s.size(); i++){
		if((i+1)%2 == 0){
			if(s[i] == 'R'){
				flag++;
				break;
			}
		}
		else{
			if(s[i] == 'L'){
				flag++;
				break;
			}
		}
	}
	if(flag > 0){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
} 


Measured memory_bytes: 256
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
sum_a1=[]
sum_a2=[]
ans=0
for i in range(n):
	a=sum(a1[:i+1])
	b=sum(a2[i:])
	sum_a1.append(a)
	sum_a2.append(b)
for i in range(n):
	ans=max(ans,sum_a1[i]+sum_a2[i])
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int a, b; cin >> a >> b;
  int ans = 0;
  for (int i = 1; i <= 12; ++i){
    for (int j = 1; j <= 31; ++j){
      if (i == j) ans++;
      if (i == a && j == b) {cout << ans << endl; return 0;};
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


int main(){
    double t, x;
    cin >> t >> x;
    double ans = t / x;
    cout << ans << endl;
    
}


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        scanner.close();

        int ansOfHeight = n - h + 1;
        int ansOfWidth = n - w + 1;

        System.out.println(ansOfHeight * ansOfWidth);
    }

}


Measured memory_bytes: 23124
#include <iostream>
int main(){
  int k;
  std::cin >> k;
  int r = 0;
  int tmp = 0;
  if(k % 10 == 0 or k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or k % 10 == 8)std::cout<<"-1"<<std::endl;
  else{
    while(++r){
      tmp = (tmp * 10 + 7) % k;
      if(tmp == 0){
        std::cout << r << std::endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 3588
#!/usr/bin/env python3
import sys

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def solve(N: int):
    # print(factorization(N))
    factors = factorization(N)
    r = 0
    for p,e in factors:
        if p == 1: continue
        # print(p,e)
        c = 1
        while c <= e:
            r += 1
            e -= c
            c += 1
    print(r)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9496
n, k = map(int, input().split())
if k > (n-1)*(n-2)/2:
    print('-1')
else:
    print(int(n*(n-1)/2-k))
    for i in range(n-1):
        print('1', i+2)
    a = (n-2)*(n-1)/2 - k
    if a != 0:
        b = 2
        for j in range(n-1):
            for k in range(n-j-2):
                print(2+j, 3+j+k)
                a = a-1
                if a == 0:
                    break
            if a == 0:
                break

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

const int M = 1e9+7;

int main(){
  int N,K; cin >>N >>K;

  long long int ans;

  vector<vector<long long>> v(2001,vector<long long>(2001, 0));
  for (int i=0; i<v.size();i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j <v.size();j++){
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j-1][k-1] + v[j-1][k])%M;
    }
  }

  for(int i=1;i<=K;i++){
    if(N-K+1<i) ans = 0;
    else {
      ans = (v[N-K+1][i] * v[K-1][i-1])%M;
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
int N, K;
cin >> N >> K;

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

vector<int>dp(N, 1e9+7);
dp[0] = 0;

for(int i = 1; i < N; i++){ 
    for(int j = 1; j < K + 1; j++){ 
        if(i - j < 0) break;
        dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
    }
}

cout << dp[N - 1]<< endl; 

}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int n , i;
	double x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4;
	scanf("%d" , &n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf" , &x1 , &y1 , &x2 , &y2 , &x3 , &y3 , &x4 , &y4);
		if((x2-x1) * (y4-y3) == (x4-x3) * (y2-y1)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

typedef struct {
    int x, y;
} point;

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2> &p) const {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

int main() {
    int n;
    cin >> n;
    vector<point> p(n);
    for (size_t i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }

    unordered_map<pair<int, int>, int, hash_pair> diff;
    for (size_t i = 0; i < n; i++) {
        for (size_t j = 0; j < n; j++) {
            if (i == j)
                continue;
            diff[make_pair(p[i].x - p[j].x, p[i].y - p[j].y)]++;
        }
    }

    int m = 0;
    for (auto p : diff) {
        m = max(m, p.second);
    }

    cout << n - m << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

int main() {
#ifdef zerol
    freopen("a.in", "r", stdin);
#endif
    int n, k; cin >> n >> k;
    if (k <= (n + 1) / 2) puts("YES");
    else puts("NO");
}


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

using namespace std;

string substrBack(string str, size_t pos, size_t len) {

    const size_t strLen = str.length();

    return str.substr(strLen - pos, len);
}

int main() {

    string str;

    cin >> str;

    // 文字列の最後から1番目の1文字を抽出
    string substr = substrBack(str, 1, 1);

    if (substr == "2") {

        cout << "hon";

    }

    if (substr == "4") {

        cout << "hon";

    }

    if (substr == "5") {

        cout << "hon";

    }


    if (substr == "7") {

        cout << "hon";

    }

    if (substr == "9") {

        cout << "hon";

    }

    if (substr == "0") {

        cout << "pon";

    }

    if (substr == "1") {

        cout << "pon";

    }

    if (substr == "6") {

        cout << "pon";

    }

    if (substr == "8") {

        cout << "pon";

    }

    if (substr == "3") {

        cout << "bon";

    }



    return 0;
}

Measured memory_bytes: 3100
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N, M;
        cin >> N >> M;

        cout << 1. * N / M << endl;

        return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
#define int long long
int32_t main()
{
  int i,j,k,n,m,x,l;
   cin>>n>>m>>x;
   int a[n+1][m+1];
   for(i=1;i<=n;i++)
   {
     for(j=0;j<=m;j++)
      cin>>a[i][j];
   }
   int min1=4e16,s=0;
   for(i=1;i<(1<<n);i++)
   {
     j=i;k=1;vector<int> v(m+1);s=0;
     while(j>0)
     {
       if(j%2==1)
       {
         s+=a[k][0];
         for(l=1;l<=m;l++)
          v[l]+=a[k][l];
       }
       k++;
       j=j/2;
     }
     for(l=1;l<=m;l++)
     {
       if(v[l]<x)
        break;
     }
     if(l==(m+1))
      min1=min(min1,s);
   }
   if(min1==4e16)
    cout<<"-1";
   else
    cout<<min1;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
long long n, x, a, b;
signed main() {
	cin >> n >> x;
	if (x & 1)
		a = 2, b = 1;
	else
		a = 1, b = 2;
	for (int i = 1; i < n; ++i)
		if (cin >> x, x & 1)
			a = a * 3 + b * 2;
		else
			a = a * 3 + b * 1, b = b * 2;
	cout << a << endl;
}

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

int main(void){
    char s[30],t[27]="abcdefghijklmnopqrstuvwxyz",u[27]="zyxwvutsrqponmlkjihgfedcba";
    scanf("%s",s);
    int count=0;
    bool letter[26]={};
    for (int i=0; i<strlen(t); i++){
        for (int j=0; j<strlen(s); j++){
            if (s[j]==t[i]){
                letter[i]=true;
                count++;
            }
        }
    }
    if (count!=26){
        printf("%s",s);
        for (int i=0; i<strlen(t); i++){
            if (letter[i]==false){
                printf("%c\n",t[i]);
                break;
            }
        }
    } else {
        if (strcmp(s,u)==0){
            printf("-1\n");
        } else {
            int last,prev=0;
            for (int i=0; i<strlen(s); i++){
                for (int j=0; j<strlen(t); j++){
                    if (s[strlen(s)-1-i]==t[j]){
                        last=j;
                    }
                }
                if (last<prev){
                    for (int k=0; k<strlen(s)-1-i; k++){
                        printf("%c",s[k]);
                    }
                    for (int k=last; k<strlen(t); k++){
                        if (letter[k]==false){
                            printf("%c\n",t[k]);
                            return 0;
                        }
                    }
                } else {
                    prev=last;
                    letter[last]=false;
                }
            }
        }
    }
	return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define n_max 105
#define INF 1000000


int main(){
    int n,m;
    cin >> n >>m;
    int graph[n_max][n_max];
    REP(i,n) REP(j,n) graph[i][j]=INF;
    int d[n_max][n_max];
    REP(i,n) REP(j,n) d[i][j]=INF;
    int a,b,c;
    REP(i,m){
        scanf("%d%d%d",&a,&b,&c);
        graph[a-1][b-1]=c;
        d[a-1][b-1]=c;
        graph[b-1][a-1]=c;
        d[b-1][a-1]=c;
    }


    REP(i,n){
        REP(j,n){
            REP(k,n){
                d[j][k] = min(d[j][k],d[j][i] + d[i][k]);
            }
        }
    }

    int ans=0;
    REP(i,n){
        REP(j,n){
            if(graph[i][j]!=INF){
                if(graph[i][j] != d[i][j]) ans +=1;
            }
        }
    }
    cout << ans / 2 << endl;

}

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

int main() {
	// your code goes here
	int n, k;
	cin>>n>>k;
	
	vector<int> choices(n, 0);
	vector<bool> dp(k+1, false);
	
	dp[0] = false;
	
	for(int i=0; i<n; i++) cin>>choices[i];

	for(int w=0; w<=k; w++){
		for(int choice: choices){
			if(w - choice < 0) continue;
			else{
				dp[w] = dp[w] || !dp[w-choice];
			}
		}
	}
	
	cout<<(dp[k] ? "First" : "Second");
	
	return 0;
}

Measured memory_bytes: 3604
n,q = map(int, input().split())
s = input()
count = [0]*n
for i in range(1,n):
    count[i] += count[i-1]
    if s[i-1:i+1]=="AC": count[i]+=1
for i in range(q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 7700
S = input()
tf = []
for s in S:
    if s in "ACGT":
        tf.append(True)
    else:
        tf.append(False)

ans = 0
temp = 0
for res in tf:
    if res:
        temp += 1
    else:
        temp = 0
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 61764
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans = 0;
		ans=(N/(A+B))*A;
		if (A<=(N%(A+B))){
			ans=ans+A;
		}
		else{
		ans=ans+(N%(A+B));
		}
		System.out.println(ans);
    }
}

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

int main(){
    int a,b;
    string op;
    cin>>a;
    cin>>op;
    cin>>b;
    while(true){
        if (op=="+") cout<<a+b<<endl;
        else if (op=="-") cout<<a-b<<endl;
        else if (op=="/") cout<<a/b<<endl;
        else if (op=="*") cout<<a*b<<endl;
        else if (op=="?") break;
        cin>>a;
        cin>>op;
        cin>>b;
    }
}


Measured memory_bytes: 3156
#include<stdio.h>

int main(){
	int N;
	scanf("%d", &N);
	int M;
	scanf("%d", &M);
	int n_even = (N * (N - 1)) / 2;
	int n_odd = (M * (M - 1)) / 2;
	
	if(N == 0 && M > 0)
		printf("%d", n_odd);
	else if(M == 0 && N > 0)
		printf("%d", n_even);
	else
		printf("%d", n_odd + n_even);
	return 0;
}

Measured memory_bytes: 128
n,a,b = list(map(int,input().split()))
if((b-a)%2==0):
    print(int((b-a)//2))
else:
    u = (b-a-1)//2
    if(n>(a+b-1)):
        print(u+a)
    else:
        print(u+(n-b+1))   

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

while True:
    score = list(map(int, input().split()))
    
    if score[0] == -1 and score[1] == -1 and score[2] == -1:
        break
    elif -1 in (score[0], score[1]) or (score[0] + score[1]) < 30:
        print('F')
    elif (score[0] + score[1]) >= 80:
        print('A')
    elif 65 <= (score[0] + score[1]) < 80:
        print('B')
    elif 50 <= (score[0] + score[1]) < 65 or (30 <= (score[0] + score[1]) < 50 <= score[2]):
        print('C')
    elif 30 <= (score[0] + score[1]) < 50:
        print('D')



Measured memory_bytes: 5600
val MOD = 1000000007L

fun main(args : Array<String>) {
    val n = readLine()!!.toLong()
    val ff = mutableMapOf<Long, Long>()

    for (i in 2..n) {
        val f = factors(i)
        f.entries.forEach {
            ff[it.key] = (ff[it.key] ?: 0) + it.value
        }
    }

    var ans = 1L
    ff.forEach {
        ans *= (it.value + 1)
        ans %= MOD
    }

    println(ans)
}

fun factors(value: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    val max = Math.sqrt(value.toDouble()).toLong()
    var tmp = value

    for (i in 2..max) {
        while (tmp % i == 0L) {
            tmp /= i
            factors[i] = (factors[i] ?: 0) + 1
        }
    }

    if (factors.isEmpty()) {
        factors[value] = 1
    } else {
        var f = value
        factors.entries.forEach {
            f /= Math.pow(it.key.toDouble(), it.value.toDouble()).toLong()
        }
        if (f != 1L) {
            factors[f] = 1
        }
    }

    return factors
}

Measured memory_bytes: 34120
#include<stdio.h>

int main()
{
	int r, c, a[10201] = {0}, i, j;

	scanf("%d %d", &r, &c);
	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			scanf("%d", a + i * (c + 1) + j);
			printf("%d ", a[i * (c + 1) + j]);
			a[(i + 1) * (c + 1) - 1] += a[i * (c + 1) + j];
			a[r * (c + 1) + j] += a[i * (c + 1) + j];
			a[(r + 1) * (c + 1) - 1] += a[i * (c + 1) + j];
		}
		printf("%d\n", a[(i + 1) * (c + 1) - 1]);
	}
	for (i = 0; i < c; i++)
	{
		printf("%d ", a[r * (c + 1) + i]);
	}
	printf("%d\n", a[(r + 1) * (c + 1) - 1]);
	return 0;
}


Measured memory_bytes: 2048
# coding: utf-8
# Your code here!

import collections
s = input()
counter = collections.Counter(s.split())
d = counter.most_common()

maxm = 0
maxn = 0
for i in range(len(d)):
   if d[i][1] > maxm:
      maxm = d[i][1]
   if len(d[i][0]) > maxn:
      maxn = len(d[i][0])

for i in range(len(d)):
   if d[i][1] == maxm:
      print(d[i][0], end = "")
   if len(d[i][0]) == maxn:
      print("", d[i][0])


Measured memory_bytes: 5972
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}

const long long INF = 1LL << 60;
int main() {
  ll n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n - 1; ++i) {
    cin >> a[i];
    a[i]--;
  }
  ll num[n] = {0};
  for (int i = 0; i < n - 1; ++i) {
    ++num[a[i]];
  }
  for (int i = 0; i < n; ++i) COUT(num[i]);
  return 0;
}

Measured memory_bytes: 5980
// RGB Cards
#include <iostream>
using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int total_rgb = 100*r + 10*g + b;
    if (total_rgb % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

bool pairCompare(const pair<int, int>& x, const pair<int, int>& y) {
    return x.second > y.second;
}

int main() {
  int N, M; cin >> N >> M;
  ll A[N]; rep(i,N) cin >> A[i];
  sort(A,A+N);

  vector<pair<int, int>> num(M);
  rep(i,M) {
    int B, C; cin >> B >> C;
    num[i] = make_pair(B, C);
  }
  sort(num.begin(), num.end(), pairCompare);

  int ap = 0;
  rep(i, M) {
    bool flg = true;
    int count = num[i].first;
    while (count) {
      if (A[ap] < num[i].second) {
        A[ap] = num[i].second;
        count--;
      }
      ap++;
      if (ap==N) {
        flg = false;
        break;
      }
    }
    if (!flg) break;
  }
  // rep(i,N) cout << A[i] << endl;
  ll result = 0; rep(i,N) result += A[i];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func gcd(x, y int) {
	if x == 0 || y == 0 {
		fmt.Println(0)
		return
	} else if x == 1 || y == 1 {
		fmt.Println(1)
		return
	} else if x >= y && x%y == 0 {
		fmt.Println(y)
		return
	} else if y > x && y%x == 0 {
		fmt.Println(x)
		return
	} else {
		if x > y {
			gcd(y, x%y)
		} else {
			gcd(x, y%x)
		}
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	x, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	sc.Scan()
	y, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	gcd(x, y)
}



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

using namespace std;

template <typename T>
class WeightedUnionFind {
 private:
  std::vector<int> parent;
  std::vector<T> weight;

 public:
  WeightedUnionFind(int n) : parent(n, -1), weight(n, 0) {}

  int root(int x) {
    if (parent[x] < 0) return x;
    int rx = root(parent[x]);
    weight[x] += weight[parent[x]];
    return parent[x] = rx;
  }

  bool is_same(int x, int y) { return root(x) == root(y); }

  int size(int x) { return -parent[root(x)]; }

  T distance(int x, int y) {
    root(x), root(y);
    return weight[y] - weight[x];
  }

  bool unite(int x, int y, int w) {
    int rx = root(x), ry = root(y);
    w += weight[x] - weight[y];
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) std::swap(rx, ry), w *= -1;
    weight[ry] = w;
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  WeightedUnionFind<int64_t> uf(N);
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    if (!uf.unite(l, r, d)) {
      if (uf.distance(l, r) != d) {
        cout << "No" << '\n';
        return 0;
      }
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 4500
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

int main(void){
	int i,n;
	string s;
	cin >> s;
	n = s.l_ength();
	for(i=0; i<n; i+=2){
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string s, t;
    cin >> s >> t;
    int n = min(s.size(), t.size());
    if (s.size() - t.size() == 1) {
        for (int i = 0; i < n; i++) {
            cout << s[i] << t[i];
        }
        cout << s[n];
    }
    else{
        for (int i = 0; i < n; i++) {
            cout << s[i] << t[i];
        }
    }
    cout << endl;

    return 0;
}

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

double s(int64_t x) {
    return (x != 0 ? s(x / 10) + x % 10 : 0);
}

int64_t f(int64_t n) {
    vector<pair<double, int64_t>> candidates{{ n / s(n), n }};
    for (int64_t d = 0; d <= log10(n) + 1; d++) {
        double x = pow(10, d+1) * floor(n / pow(10, d+1) + 1) - 1;
        candidates.emplace_back(x / s(x), x);
    }

    sort(begin(candidates), end(candidates));
    return candidates[0].second;
}

int main() {
    int64_t k;
    cin >> k;

    for (int64_t i = 0, n = 1; i < k; i++, n = f(n+1)) cout << n << endl;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))

count = 1
up,down = 1,1

for i in range(1,N):
  if A[i-1] > A[i]:
    up = 0
    if down == 0:
      count += 1
      up,down = 1,1
  elif A[i-1] < A[i]:
    down = 0
    if up == 0:
      count += 1
      up,down = 1,1

print(count)


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

int main() {
    string s;
  	int price;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') ++counter;
    if (s[1] == 'o') ++counter;
    if (s[2] == 'o') ++counter;
  
  	price = 700 + 100 * counter;
    
  cout << price << endl;
  
  
}

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

using namespace std;

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

	vector<int> t(n);
	for (int i = 0; i < n; i++)
	{
		cin >> t.at(i);
		sum += t.at(i);
	}

	int m;
	cin >> m;
	vector<int> p(m);
	vector<int> x(m);
	for (int i = 0; i < m; i++)
	{
		cin >> p.at(i) >> x.at(i);
		cout << sum - t.at(p.at(i) - 1) + x.at(i) << endl;
	}
}


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

void fnInput(int &a_riLoadingCnt, int &a_riTrackCnt, vector<int> &a_rviLoading)
{
  cin >> a_riLoadingCnt >> a_riTrackCnt;

  a_rviLoading.resize(a_riLoadingCnt);
  for (int i = 0; i < a_riLoadingCnt; i++)
    cin >> a_rviLoading[i];
}

int fnSimuAlloc(const vector<int> &a_cnrviLoading, int a_iTrackCnt, int a_iMinLoading)
{
  int iCurLoading;
  int iTrackCnt = 0;

  for (int i = 0; i < a_cnrviLoading.size();    )
  {
    if (a_cnrviLoading[i] > a_iMinLoading) return 0;
    if (++iTrackCnt       > a_iTrackCnt  ) return 0;

    iCurLoading = 0;
    while (i < a_cnrviLoading.size())
    {
      iCurLoading += a_cnrviLoading[i];
      if (iCurLoading > a_iMinLoading)
        break;

      i++;
    }
  }
  return 1;
}

void fnAllocation(const vector<int> &a_cnrviLoading, int a_iTrackCnt, int &a_riMinLoading)
{
  const int cniMinLoading = 0;
  const int cniMaxLoading = 1000000000;

  int iLow  = cniMinLoading;
  int iHigh = cniMaxLoading;
  a_riMinLoading = cniMaxLoading;

  while (iLow < iHigh)
  {
    int iMid = (iLow + iHigh) / 2;
    if (fnSimuAlloc(a_cnrviLoading, a_iTrackCnt, iMid))
    {
      a_riMinLoading = min(a_riMinLoading, iMid);
      iHigh = iMid;
    }
    else
      iLow = iMid + 1;
  }
}

void fnResultOut(int a_iMinLoading)
{
  cout << a_iMinLoading << endl;
}

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

  int iLoadingCnt, iTrackCnt;
  vector<int> viLoading;
  int iMinLoading = 0;

  fnInput(iLoadingCnt, iTrackCnt, viLoading);
  fnAllocation(viLoading, iTrackCnt, iMinLoading);
  fnResultOut(iMinLoading);

  return 0;
}

Measured memory_bytes: 1524
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    OUT(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible" : "Impossible");
    return 0;
}



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

AB = []
for _ in range(M):
  a, b = map(int, input().split())
  AB.append((a, b))

cities = [0] * N

for ab in AB:
  cities[ab[0] - 1] += 1
  cities[ab[1] - 1] += 1

for load in cities:
  print(load)

Measured memory_bytes: 3064
#include <stdio.h>

int main( void ) {
	int i, j, tmp, cnt, n, data[ 100 ];

	for ( ; scanf( "%d", &n ), n; printf( "%d\n", cnt ) ) {
		for ( i = 0; i < n; i++ )
			scanf( "%d", data + i );

		cnt = 0;
		for ( i = 0; i < n - 1; i++ )
			for ( j = n - 1; j > i; j-- )
				if ( data[ j - 1 ] > data[ j ] ) {
					tmp = data[ j - 1 ];
					data[ j - 1 ] = data[ j ];
					data[ j ] = tmp;

					cnt++;
				}
	}

	return 0;
}

Measured memory_bytes: 600
# 閉路検出を繰り返し, 閉路の長さを減らしていく































def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)


    def bfs(start):
        pre = [-1]*n
        d = deque([start])
        res = []

        while d:
            v = d.popleft()
            for nv in adj[v]:
                if nv == start:
                    path = []
                    while v != -1:
                        path.append(v+1)
                        v = pre[v]
                    if not res or len(res) > len(path):
                        res = path
                    break

                if pre[nv] != -1:
                    continue
                pre[nv] = v
                d.append(nv)

        return res
    
    res = [0]*(n+1)
    for i in range(n):
        temp = bfs(i)
        if temp and len(res) > len(temp):
            res = temp
    if len(res) <= n:
        print(len(res))
        print(*res, sep='\n')
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 43500
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
import itertools
import math
from operator import mul
from functools import reduce

mod = 10 ** 9 + 7

n = I()
if n < 2:
    ans = 0
elif n == 2:
    ans = 2
else:
    ans = 0
    a = pow(10, n, mod)
    b = pow(9, n, mod) * 2
    c = pow(8, n)
    ans = (a-b+c) % mod

print(ans)


Measured memory_bytes: 10500
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

A,B,DEGREE = map(int,input().split())

rad = math.radians(DEGREE)

S = A*B*math.sin(rad)/2.0
C = math.sqrt(A*A+B*B-2*A*B*math.cos(rad))
h = 2*S/A

print("%.10f %.10f %.10f"%(S,A+B+C,h))



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

typedef struct {
	int id;
	int score;
} man_t;

int compare(const void* x,const void* y) {
	man_t* a;
	man_t* b;
	a=(man_t*)x;
	b=(man_t*)y;
	if(a->score<b->score)return 1;
	if(a->score>b->score)return -1;
	if(a->id>b->id)return 1;
	if(a->id<b->id)return -1;
	return 0;
}

int main(void) {
	man_t mandata[40];
	int score[10][3];
	int mannum;
	int i,j;
	while(1) {
		scanf("%d",&mannum);
		if(mannum==0)break;
		for(i=0;i<mannum;i++) {
			scanf("%d",&mandata[i].id);
			for(j=0;j<9;j++) {
				scanf("%d",&score[j][0]);
				score[j][1]=0;
				if(score[j][0]!=10)scanf("%d",&score[j][1]);
			}
			scanf("%d",&score[9][0]);
			scanf("%d",&score[9][1]);
			score[9][2]=0;
			if(score[9][0]==10 || score[9][0]+score[9][1]==10)
				scanf("%d",&score[9][2]);
			mandata[i].score=0;
			for(j=0;j<9;j++) {
				mandata[i].score+=score[j][0]+score[j][1];
				if(score[j][0]==10) {
					mandata[i].score+=score[j+1][0];
					if(score[j+1][0]==10 && j<8)
						mandata[i].score+=score[j+2][0];
					else mandata[i].score+=score[j+1][1];
				} else if(score[j][0]+score[j][1]==10) {
					mandata[i].score+=score[j+1][0];
				}
			}
			mandata[i].score+=score[9][0]+score[9][1]+score[9][2];
		}
		qsort(mandata,mannum,sizeof(man_t),compare);
		for(i=0;i<mannum;i++) {
			printf("%d %d\n",mandata[i].id,mandata[i].score);
		}
	}
	return 0;
}

Measured memory_bytes: 0
/*

Author : AllKilled
Date   : 202001197 19:50:00 UTC+8

Website: https://atcoder.jp/contests/abc152
Contest: AtCoder Beginner Contest 152
Problem: Task A.
Result :

*/
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> PLL;

const int inf = 0x3f3f3f3f;
const int N = 18;
const LL MAXN = (1 << N) + 3;

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



int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  vector<int> B(N,0);
  for(int i=N-1;i>=0;i--){
    // decide whether ball in box_(i+1)
    int sum = 0;
    for(int j=2;j*(i+1)-1<N;j++){
      sum += B[j*(i+1)-1];
    }
    B[i] = (A[i]+sum)%2;
  }
  int balls=0;
  for(int i=0;i<N;i++){
    balls += B[i];
  }
  cout << balls << endl;
  for(int i=0;i<N;i++){
    if(B[i]>0){
      cout << i+1 << " ";
    }
  }
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < N; i++) {
            min = Math.min(min, sum(i) + sum(N - i));
        }
        System.out.println(min);
    }

    static int sum(int n) {
        int sum = 0;
        while (n > 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }
}

Measured memory_bytes: 23124
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
  int n;
  cin >> n;
  vi a(n);
  int mn = INT_MAX;
  rep(i,n) {
    cin >> a[i];
    int cnt = 0;
    while(a[i]%2==0){
      a[i] /= 2;
      cnt++;
    }
    mn = min(mn, cnt);
  }
  cout << mn  << endl;
  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

int main(){
  int k, x;
  cin >> k >> x;
  for(int i=x-k+1; i<k+x; i++) cout << i << " ";
  return 0;
}

Measured memory_bytes: 256
import heapq
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = 0
q = []
heapq.heappush(q,-A[0])
for i in range(1,N):
    tmp = heapq.heappop(q)
    tmp*=-1
    ans+=tmp
    heapq.heappush(q,-A[i])
    heapq.heappush(q,-A[i])
print(ans)


Measured memory_bytes: 31792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
 
int main(){
    int W,a,b;
    cin >> W >> a >> b;
    if((a<=b&&b<=a+W)||(a<=b+W&&b+W<=a+W)) cout << "0\n";
    else if(b+W<a) cout << a-b-W << endl;
    else if(a+W<b) cout << b-a-W << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
H=[]
T=[]
for i in range (n):
    a=list(map(str, input().split())) 
    if a[0]>a[1] :
        H.append(3)
    elif a[0]<a[1] :
        T.append(3)
    else :
        H.append(1)
        T.append(1)
        

print(sum(H), sum(T))


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

#define int long long

int r, g, b, n, ans;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			if ((n - i * r - j * g) % b == 0 && (n - i * r - j * g) / b >= 0)
				ans++;
	cout << ans;
}

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

const LL mod = 1000000007;

int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>A(N), B(M);
	rep(i, N) in >> A[i];
	rep(i, M) in >> B[i];

	std::vector<LL>fact(N*M + 1);
	fact[0] = 1;
	for (LL i = 1; i <= N * M; ++i) fact[i] = (fact[i - 1] * i) % mod;

	std::vector<std::vector<LL>>max(N, std::vector<LL>(M));
	std::map<LL, bool>kotei, must;
	rep(i, N)
	{
		rep(j, M)
		{
			max[i][j] = std::min(A[i], B[j]);
			if (A[i] == B[j]) kotei[A[i]] = true;
		}
	}

	std::vector<std::vector<LL>>res(N, std::vector<LL>(M));
	std::map<LL, LL>add;
	std::vector<LL>musts(N*M);
	rep(i, N)
	{
		rep(j, M)
		{
			if (A[i] == B[j]) res[i][j] = -1;
			else res[i][j] = max[i][j];
			++add[res[i][j]];
		}
	}
	rep(i, N)
	{
		if (kotei[A[i]]) continue;
		must[A[i]] = true;
		rep(j, M) if (B[j] > A[i]) ++musts[A[i]];
	}
	rep(j, M)
	{
		if (kotei[B[j]]) continue;
		must[B[j]] = true;
		rep(i, N) if (A[i] > B[j]) ++musts[B[j]];
	}

	LL avail = 0, ans = 1;
	for (LL i = N * M; i >= 1; --i)
	{
		avail += add[i];
		if (kotei[i]) continue;
		else if (must[i]) (ans *= musts[i]) %= mod;
		else (ans *= avail) %= mod;
		--avail;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 219008
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

int main() {
    ll m_, n_;
    cin >> m_ >> n_;

    mint m = mint(m_);
    mint ans = m.pow(n_);
    cout << ans.x << endl;

    return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>

int main(){
  int x,y,z,temp;
  
  while(scanf("%d %d",&x,&y)!=EOF){

    if(y < x){
      temp=x;
      x=y;
      y=temp;
    }
    
    while(1){
      z=x%y;
      if(z==0) break;
      x=y;
      y=z;
    }
    printf("%d\n",y);
  }
  
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n;
ll ans;
map<int,int> s;

int main()
{
    scanf("%d",&n);
    for(int i=1,x;i<=n;i++)
    {
        scanf("%d",&x);
        ans+=s[-x+i];
        s[x+i]++;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 20780
#include<bits/stdc++.h> 
using namespace std;
int mod=1e9+7;
int solve(vector<string>& graph, int R, int C){
	vector<vector<int>> ans(R,vector<int>(C,0));
	for (int i=0;i<R;i++){
		if (graph[i][0]=='#') break;
		else ans[i][0]=1;
	}
	for (int i=0;i<C;i++){
		if (graph[0][i]=='#') break;
		else ans[0][i]=1;
	}
	for (int i=1;i<R;i++){
		for (int j=1;j<C;j++){
			if (graph[i][j]!='#'){
				ans[i][j]=(ans[i-1][j]%mod+ans[i][j-1]%mod)%mod;
			}
		}
	}
	return ans[R-1][C-1];
}
signed main() {
	int R,C;
    cin>>R>>C;
    vector<string> graph(R);
    for (int i=0;i<R;i++){
    	cin>>graph[i];	
    }
	cout<< solve(graph,R,C)<<endl;
    return 0; 
}


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

long long get_operation_count(vector<long long> &a, int n,
                              bool is_start_negative) {
  long long a_sum = 0;
  long long diff_sum = 0;
  long long operation_count = 0;

  for (int i = 0; i < n; i++) {
    a_sum += a[i];
    long long sum = a_sum + diff_sum;
    int is_positive = i % 2 == 0;
    if (is_start_negative) is_positive = !is_positive;

    if (is_positive && sum <= 0) {
      long long diff_abs = abs(1 - sum);
      operation_count += diff_abs;
      diff_sum += diff_abs;
    } else if (!is_positive && 0 <= sum) {
      long long diff_abs = abs(-1 - sum);
      operation_count += diff_abs;
      diff_sum -= diff_abs;
    }
  }

  if (a_sum + diff_sum == 0) operation_count++;
  return operation_count;
}

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

  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  long long positive_count = get_operation_count(a, n, true);
  long long negative_count = get_operation_count(a, n, false);

  cout << min(negative_count, positive_count) << endl;
}


Measured memory_bytes: 4008
#include<stdio.h>

const int FALSE = 0;
const int TRUE = 1;
int main(){
    int N;
    scanf("%d", &N);

    int d[100];

    for(int i = 0; i < 100; i++){
        d[i] = -1;
    }

    for(int i = 0; i < N; i++){
        scanf("%d", &d[i]);
    }

    int cnt[110];
    for(int i = 0; i < 110; i++){
        cnt[i] = -1;
    }

    int pos = 0;
    int hit;
    for(int i = 0; i < 100; i++){
        if(i >= N){
            break;
        }
        hit = FALSE;
        for(int j = 0; j < pos; j++){
            if(d[i] == cnt[j]){
                hit = TRUE;
            }
        }
        if(!hit){
            cnt[pos++] = d[i];
        }

    }

    printf("%d\n", pos);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

vector<int> v[101010],art;
vector <pint> bridge;
int low[101010],ord[101010];

void dfs(int& count,int from,int x){
    ord[x]=count++;
    low[x]=ord[x];
    bool isart=false;
    int cnt=0;
    for(auto to:v[x]){
        if(to==from)continue;
        if(ord[to]==-1){
            cnt++;
            dfs(count,x,to);
            if(ord[x]<low[to])bridge.push_back({min(x,to),max(to,x)});
            if(from!=-1&&ord[x]<=low[to])isart=true;
            low[x]=min(low[x],low[to]);
        }
        else low[x]=min(low[x],ord[to]);
    }
    if(from==-1&&cnt>1)isart=true;
    if(isart)art.push_back(x);
}
int main(){
   int n,m;
   cin>>n>>m;
   rep(i,m){
       int x,y;
       cin>>x>>y;
       x--;y--;
       v[x].push_back(y);
       v[y].push_back(x);
   }
   int cnt=0;
   rep(i,n)ord[i]=-1;
   dfs(cnt,-1,0);
   cout<<bridge.size()<<endl;
   return 0;
}


Measured memory_bytes: 2688
using System;

namespace AtCoderSnippet
{
    class Program
    {
        static void Main(string[] args)
        {
            var L_R_d = Console.ReadLine().Split(" ");
            var L = int.Parse(L_R_d[0]);
            var R = int.Parse(L_R_d[1]);
            var d = int.Parse(L_R_d[2]);
            var cnt = 0;


            for (int i = L; i <= R; i++)
            {
                if (i % d == 0) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 27532