akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;
 
int main() {
  int n, l;
  cin >> n >> l;

  int lower = l;
  int upper = l + n - 1;

  int skip;
  if (lower <= 0 && upper >= 0) {
    skip = 0;
  } else if (upper < 0) {
    skip = upper;
  } else {
    skip = lower;
  }

  int sum = 0;
  rep(i, n) {
    int flavor = l + i;
    if (flavor != skip) {
      sum += flavor;
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>(stdin: &mut StdinLock) -> T {
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn parse<T: FromStr>(line: &str) -> Vec<T> {
    let split_whitespace = line.split_whitespace();
    split_whitespace
        .map(|elem| elem.parse().ok().expect("failed to parse token"))
        .collect()
}


fn euclid(a: u32, b: u32) -> u32 {
    let r = a % b;
    if r == 0 {
        return b;
    }
    euclid(b, r)
}


fn main() {
    let stdin = stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf = String::new();
    let n:usize = read(&mut stdin_lock);
    stdin_lock.read_line(&mut buf).expect("error");
    let elems:Vec<u32> = parse(&buf);
    let l:Vec<u32> = elems.iter().scan(0,|state,x|{
        *state = euclid(*state, *x);
        Some(*state)
    }).collect();
    let r:Vec<u32> = elems.iter().rev().scan(0,|state,x|{
        *state = euclid(*state, *x);
        Some(*state)
    }).collect();
    let r:Vec<u32> = r.into_iter().rev().collect();

    let mut result=vec![0;n];
    result[0]=r[1];
    for i in 1..n-1{
        result[i]=euclid(l[i-1], r[i+1]);
    }
    result[n-1]=l[n-2];
    // println!("{:?}",l);
    // println!("{:?}",r);
    // println!("{:?}",result);
    println!("{}",result.iter().max().unwrap());
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000

signed main(void)
{
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];

    int sum[n] = {a[0]};
    for( int i = 1; i < n; i++){
        sum[i] = sum[i-1] + a[i];
    }

    int diff_1 = 0, diff_2 = 0; 
    int cost_1 = 0, cost_2 = 0;
    for( int i = 0; i < n; i++){
        if( i % 2 == 0){
            if( sum[i] + diff_1 >= 0 ){
                cost_1 += sum[i] + diff_1 + 1;
                diff_1 -= sum[i] + diff_1 + 1;
            }
            if( sum[i] + diff_2 <= 0 ){
                cost_2 += - sum[i] - diff_2 + 1;
                diff_2 += - sum[i] - diff_2 + 1; 
            }
        } else {
            if( sum[i] + diff_1 <= 0 ){
                cost_1 += - sum[i] - diff_1 + 1;
                diff_1 += - sum[i] - diff_1 + 1;
            }
            if( sum[i] + diff_2 >= 0 ){
                cost_2 += sum[i] + diff_2 + 1;
                diff_2 -= sum[i] + diff_2 + 1; 
            }
        }
    }

    cout << min(cost_1, cost_2);
    return 0;
}





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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(n);
    pl4 p,q;
    p.se=1;
    q.se=1;
    q.fi=-1;
    ll k;
    cin>>p.fi;
    FOR(i,1,n-1){
        cin>>k;
        if(k==p.fi){
            p.se++;
        }else if(k==q.fi){
            q.se++;
        }else if(q.fi==-1){
            q.fi=k;
            if(abs(p.fi-q.fi)!=1){
                sal("No");
                return 0;
            }
        }else{
            sal("No");
            return 0;
        }
    }
    if (q.fi==-1){
        sal((p.fi+1==p.se | p.fi <= p.se/2)?"Yes":"No");
        return 0;
    }
    pl4 b=((p>q)?p:q);
    pl4 s=((p>q)?q:p);
    sal((s.se<=s.fi && s.se+b.se/2>=b.fi)?"Yes":"No");
}


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

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int>ans(n+1);
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    ans[a]++;
    ans[b]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << "\n";
  }

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



Measured memory_bytes: 3612
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	public static TreeMap<Integer,Integer> divMap = new TreeMap<>();
	public static List<Integer> divList = new ArrayList<>();
	public static int count;
	public static List<List<Integer>> divAllList = new ArrayList<>();
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());

		fact(N);
		search75();


		System.out.println(count);


	}

	private static void search75() {
		List<Integer> li= new ArrayList<>();
		search75plus(divMap,1);

	}

	private static void search75plus(TreeMap<Integer,Integer> map,int pSum) {
		if(map.firstEntry() == null) {
			return;
		}
		Map.Entry<Integer,Integer> me = map.firstEntry();
		map.remove(me.getKey());
		int ki=me.getValue();
		for(int k=0;k<=ki;k++) {

			int sum = (k+1)*pSum;

			if(sum <75) {
				TreeMap<Integer, Integer> map2 = new TreeMap<Integer, Integer>(map);
				search75plus(map2,sum);
			}else if(sum == 75) {
				count ++;
				break;
			}else {
				break;
			}
		}

	}


	private static void fact(int ii) {
		for(int i=2;i<=ii;i++) {
			makePrimeMap(i);
		}

	}

	private static void makePrimeMap(int num) {
		for (int i = 2;i<=num;i++) {

			if (num % i == 0) {

				if(!divMap.containsKey(i)) {
					divMap.put(i, 1);
				}else {
					int t = divMap.get(i);
					divMap.put(i, t+1);
				}

				num /= i;

				i = 1;
			}
		}

	}


}

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

int sep(int n)
{	
	int sum=0;

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

	cout << sep(n) << endl;
} 



Measured memory_bytes: 256
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
L = 1
R = N

for i in LR:
    if i[0] > L:
        L = i[0]
    
    if i[1] < R:
        R = i[1]

print(max(0, R-L+1))

Measured memory_bytes: 27340
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string s; cin >> s;
	vector<int> v(4);
	rep(i, 4) {
		v[i] = s[i] - '0';
	}

	string ans = "";
	int res = 7 - v[0];
	rep(i, 2){
		rep(j, 2){
			rep(k, 2){
				int ii = i == 0 ? -1 : 1;
				int jj = j == 0 ? -1 : 1;
				int kk = k == 0 ? -1 : 1;
				// print(ii * v[1] + jj * v[2] + kk * v[3]);
				if(res == ii * v[1] + jj * v[2] + kk * v[3]){
					cout << v[0];
					cout << (ii == -1 ? '-': '+');
					cout << v[1];
					cout << (jj == -1 ? '-': '+');
					cout << v[2];
					cout << (kk == -1 ? '-': '+');
					cout << v[3];
					cout << "=7";
					cout << endl;
					return 0;
				}
			}
		}
	}


	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

using namespace std::chrono;

int main(void)
{
    IOS
    const int A = 26;
    const int M = 1e3;
    const int TL = 1800;
    auto stime = system_clock::now();
    int D; cin >> D;
    vector<int> c(A);
    REP(i,A) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(A));
    REP(i,D) REP(j,A) cin >> s[i][j];

    vector<int> last(A,-1);
    vector<int> ans(D);
    REP(i,D) {
        int mx = 0,a = -1;
        REP(j,A) {
            int tmp = (i-last[j])*c[j] + s[i][j];
            if (mx < tmp) {
                mx = tmp;
                a = j;
            }
        }
        ans[i]=a;
        last[a] = i;
    }
    auto calc = [&](const vector<int> &a){
        vector<int> l(A,-1);
        int score = 0;
        REP(i,D) {
            score += s[i][a[i]];
            l[a[i]] = i;
            REP(j,A) {
                score -= c[j]* (i-l[j]);
            }
        }
        return score;
    };

    int maxscore = calc(ans);

    random_device seed_gen;
    mt19937 engine(seed_gen());
    while(true) {
        auto time = system_clock::now();
        int t = duration_cast<milliseconds>(time-stime).count();
        if (t >= TL) break;

        REP(i,M) {
            vector<int> a(ans);
            if (i % 5 != 0) {
                int s1 = engine() % D;
                int s2 = engine() % D;
                swap(a[s1],a[s2]);
            } else {
                a[engine() % D] = a[engine() % A];
            }
            int tmp = calc(a);
            if (maxscore < tmp) {
                swap(ans,a);
                maxscore = tmp;
            }
        }
    }

    REP(i,D) OUT(ans[i]+1)

    return 0;
}

Measured memory_bytes: 3664
N, K= map(int,input().split())
a = list(map(int,input().split()))
#a=A[:]
for _ in range(K):
  B=[0]*(N+1)
  for i in range(N):
    t = a[i]
    B[max(i-t,0)] +=1
    B[min(i+t+1,N)] -=1
  for i in range(N):
    B[i+1] += B[i]
  a=B[:N]        
  if min(a)==N:
    break
print(*a)

Measured memory_bytes: 169404
#include "iostream"
#include "string"


int main()
{
	int listA[101][101], listB[101][101];
	unsigned long int result = 0;
	int n, m, l, a;
	std::cin >> n >> m >> l;

	for (int i = 0; i < n; i++) 
		for (int j = 0; j < m; j++)
			std::cin >> listA[i][j];

	for (int j = 0; j < m; j++)
		for (int k = 0; k < l; k++)
			std::cin >> listB[j][k];
	a + 1;
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < l; k++) {
			for (int j = 0; j < m; j++) {
				result += listA[i][j] * listB[j][k];
			}
			if (k < l - 1)
				std::cout << result << " ";
			else
				std::cout << result;
			result = 0;
		}
			std::cout << std::endl;
	}

    return 0;
}

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

int a[50];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  
  double ans = a[0];
  for (int i = 1; i < n; ++i) {
    ans = (ans + a[i]) / 2;
  }
  cout << ans << endl;
}


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

int main () {
  string S;
  cin >> S;
  
  string result = "Good";
  for (int i = 1; i < S.size(); i++) {
    if(S[i] == S[i-1]) result = "Bad";
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    q = int(input())
    bc = []
    sum1 = sum(a)
    for _ in range(q):
        bc.append(list(map(int, input().split(" "))))
    d = defaultdict(lambda:0)
    for i in range(n):
        d[a[i]] += 1

    for i in range(q):
        if bc[i][0] in d:
            sum1 += (bc[i][1] - bc[i][0]) * d[bc[i][0]]
            d[bc[i][1]] += d[bc[i][0]]
            del d[bc[i][0]] 
        print(sum1)
        

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
typedef string::const_iterator state;

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

template<typename T, bool Check=false>
struct LexParser {
  typedef T expr_t;
  typedef string::const_iterator state_t;
  LexParser(){}
  expr_t eval(const string& expr){
    auto s = begin(expr);
    auto r = expression(s);
    consume(s, '=');
    return r;
  }
  void consume(state_t& s, char expected){
    if (!Check || *s == expected){
      s++;
      return;
    }
    cerr << "Expected '" << expected << "' but got '" << *s << "'" << endl;
    cerr << "Rest string is '";
    while (*s) cerr << *s;
    cerr << "'" << endl;
  }
  expr_t number(state_t& s){
    expr_t r = 0;
    while (isdigit(*s)){
      r = r * 10 + (*s - '0');
      s++;
    }
    return r;
  }
  expr_t term(state_t& s){
    expr_t r = factor(s);
    while (1){
      if (*s == '*'){
        consume(s, '*');
        r *= factor(s);
      }
      else if (*s == '/'){
        consume(s, '/');
        r /= factor(s);
      }
      else break;
    }
    return r;
  }
  expr_t factor(state_t& s){
    expr_t r;
    if (*s == '('){
      consume(s, '(');
      r = expression(s);
      consume(s, ')');
    }
    else r = number(s);
    return r;
  }
  expr_t expression(state_t& s){
    expr_t r = term(s);
    while (1){
      if (*s == '+'){
        consume(s, '+');
        r += term(s);
      }
      else if (*s == '-'){
        consume(s, '-');
        r -= term(s);
      }
      else break;
    }
    return r;
  }
};

int main()
{
  LexParser<int> parser;
  for (int n = in(); n--;){
    string expr;
    cin >> expr;
    cout << parser.eval(expr) << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

int N, M;
int H[100010];
int A[100010], B[100010];
vector<int> vec[100010];
int ans = 0;


int main() {
    cin >> N >> M;
    //Nが展望台、Mが橋の数
    REP(i, N) cin >> H[i];
    REP(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        vec[A[i]].push_back(B[i]);
        vec[B[i]].push_back(A[i]);
    }
    REP(i, N) {
        bool chk = true;
        for (auto it = vec[i].begin(); it != vec[i].end(); it++) {
            if (H[i] <= H[*it]) {
                chk = false;
                break;
            }
        }
        if (chk) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9892
program rgb_balls
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer :: n, i, j, k, cnt(3) = 0, x, y, z
  integer(8) :: ans = 1_8
  character(300000) :: s
  read(*,*) n
  read(*,*) s
  do i = 1, 3*n
    select case(s(i:i))
    case("R")
      j = 1
    case("G")
      j = 2
    case("B")
      j = 3
    end select
    x = minval(cnt)
    z = maxval(cnt)
    y = sum(cnt)-x-z
    if (cnt(j) == z) then
      cnt(j) = cnt(j)+1
    else if (cnt(j) == y) then
      ans = mod(ans*int(z-y,8),md)
      cnt(j) = cnt(j)+1
    else if (y == 0) then
      cnt(j) = cnt(j)+1
    else
      ans = mod(ans*int(y,8),md)
      do k = 1, 3
        if (k == j) cycle
        cnt(k) = cnt(k)-1
      end do
    end if
  end do
  do i = 1, n
    ans = mod(ans*int(i,8),md)
  end do
  write(*,'(i0)') ans
end program rgb_balls

Measured memory_bytes: 1468
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;

long int power(int n){
if(n==0){return 1;}
else{ return 2*power(n-1);}
}

int main() {

long int N;
cin >>N;

int keta[200];

int i=0;

while(N!=0){ //各桁の導出

if(i%2==0){
if( N%power(i+1)==0 ){ keta[i]=0;}
else { keta[i]=1; N=N-power(i);}
}

if(i%2==1){
if( N%power(i+1)==0 ){ keta[i]=0;}
else { keta[i]=1; N=N+power(i);}
}

i++;
}

int l;
l=i-1;

for(int j=l; j>=0; j=j-1){
cout <<keta[j];}

if(l==-1){cout <<0;}

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>

int main() {
  intmax_t N, M;
  scanf("%jd %jd", &N, &M);

  if (N > M)
    std::swap(N, M);

  // N <= M
  if (M > N+1)
    return !printf("0\n");

  constexpr intmax_t mod=1e9+7;
  intmax_t res=1;
  for (intmax_t i=1; i<=N; ++i)
    res = res*i % mod;

  for (intmax_t i=1; i<=M; ++i)
    res = res*i % mod;

  if (N == M)
    res = res*2 % mod;

  printf("%jd\n", res);
}


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

int main() {
   char s1[] = "JPY"; 
   int N;
   double sum = 0;
   scanf("%d", &N);
   double x;
   char u[10];
   
   for(int i = 0; i < N; i++) {
      scanf("%lf %s", &x,u);
      if(strcmp(u,s1) == 0) {
         sum = sum + x;
      } else {
         sum = sum + 380000*x;
      }
   }
   printf("%lf\n", sum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int a, b, c, x; cin >> a >> b >> c >> x;
    
    int cnt = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    string s;
    cin>>s;
    ll q=0,t=0,x=0;
    char ch;
    cin>>q;
    list<char> li;
    for(int i=0;i<s.length();i++)
        li.pb(s[i]);
    bool b=0;
    while(q-->0)
    {
        cin>>t;
        if(t==1)
            b=!b;
        else
        {
            cin>>x>>ch;
            if(b)
                x=x^3;
            if(x==1)
                li.pf(ch);
            else
                li.pb(ch);
        }
    }
    string ans;
    for(auto i=li.begin();i!=li.end();i++)
        ans.pb(*i);
    if(b)
        reverse(ans.begin(),ans.end());
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 10452
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(0,c-(a-b))<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int k, x;
    cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int a,b,x;
    
    cin >> a >> b >>x;
    
    if(a <= x ){
    
        if (a+b >= x){
        
        cout << "YES" << endl;
        
        }else{
        
        cout << "NO" << endl;
        
        }
    }else{
    
    cout << "NO" << endl;
    
    
    }

    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k,a,b,i,c(0);
cin>>k;
cin>>a>>b;
if(b<a){
swap(b,a);}
for(i=a;i<=b;i++){
if(i%k==0)
c++;}
if(c!=0)
cout<<"OK"<<endl;
else
cout<<"NG"<<endl;
return 0;
}


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

void sieve(ll n, vector<bool>& out){
    out.resize(n + 1);
    fill(out.begin(), out.end(), true);
    out.at(0) = false;
    out.at(1) = false;
    for(ll i = 2; i <= n; ++i){
        if(out.at(i) == false){ continue; }
        for(ll j = i * 2; j <= n; j += i){
            out.at(j) = false;
        }
    }
}

void solve(long long X){
    vector<bool> isprime;
    sieve(X - 1, isprime);
    set<ll> p;
    REP(i, X){
        if(isprime.at(i)){ p.insert(i); }
    }
    for(ll n = X; ; ++n){
        bool is_ok = true;
        for(auto q : p){
            if(n % q == 0){
                is_ok = false;
                break;
            }
        }
        if(is_ok){
            cout << n << endl;
            return;
        }
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 768
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a, b;
  cin >> a >> b;
  cout << (a==b ? 'H' : 'D') << endl;
  return 0;
}


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

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

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = GetInt();

            Console.WriteLine(N*N*N);
            return;
        }
    }
}


public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() => int.Parse(getArg());
    public static long GetLong() => long.Parse(getArg());
    public static double GetDouble() => double.Parse(getArg());
    public static string GetString() => getArg();
    public static char GetChar() => getArg()[0];
    public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
    public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
    public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
    public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

Measured memory_bytes: 11092
import math
from fractions import Fraction
N,K=map(int,input().split())
s=0
if N >= K:
  s=s+Fraction(N-K,N)
  d=0
  for i in range(K):
    a=math.log(K/(i+1),2)
    d=d+Fraction(1, 2)**(math.ceil(a))*Fraction(1, N)
else:
  d=0
  for i in range(N):
    a=math.log(K/(i+1),2)
    d=d+Fraction(1, 2)**(math.ceil(a))*Fraction(1, N)
print(float(s+d))
  

Measured memory_bytes: 5536
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0;
	cin>>n;
	db arr[n];
	for(auto &i:arr)
		cin>>i;
	sort(arr,arr+n);
	db r=arr[0];
	for(ll i=1;i<n;i++)
		r=(r+arr[i])/2;
	printf("%.9f\n",r);

}


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

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

  vector<double>p(n);

  for(int i=0;i<n;i++)
  {
      cin>>p[i];
  }
 
  for(int i=0;i<n;i++)
  {
      double me = p[i];
      double po = 0;
      for(int j=1;j<=me;j++)
      {
         po += j;
      }
    p[i] = po/me;
  }
  
  queue<double>q;
  double ans =0;
  double now =0;
  for(int i=0;i<n;i++)
  {
      now += p[i];
      q.push(p[i]);
     
      if(q.size()>k)
      {
         now -= q.front(); 
         q.pop();
      }
    if(q.size()==k)
    {
        ans = max(ans,now);
    }
 
  }
  

  
  cout<<setprecision(10)<<ans<<endl;
  
  return 0;

}


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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << endl;
	if (a + b > n) {
		cout << a + b - n << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll d[20010];
ll n,m;
ll a[10010],b[10010];
ll res=1e9;
int main()
{
	cin >>m>>n;
	for (int i=0;i<n;i++) cin >>a[i]>>b[i];
	d[0]=0;
	for (int i=1;i<=m+10005;i++)
	{
		d[i]=1e9;
		for (int j=0;j<n;j++)
		{
			if (a[j]>i) continue;
			d[i]=min(d[i],d[i-a[j]]+b[j]);
		}
		if (i>=m) res=min(res,d[i]);
		//cout <<d[i]<<" "<<i<<" ##\n";
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <assert.h>
#include <vector>
#include <stdio.h>
#include <iomanip>
using namespace std;

vector <int> el;

bool winner[100010];

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);

    el.resize(n);

    for (auto & i : el)
        scanf("%d", &i);

    for (int i = 0; i <= k; i++) {
        bool seen_looser = 0;
        for (auto j : el)
            if (i >= j && !winner[i - j])
                seen_looser = 1;
        winner[i] = seen_looser;
    }

    cout << (winner[k] ? "First\n" : "Second\n");

    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES

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


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

	ll num = n;
	for (ll i = 2; i <= n; i++) {
        if(num<i*i)break;
        int count=0;
        int last_count=0;
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
            count++;
            if(count>last_count){
                ans++;
                last_count=count;
                count=0;
            }
			//x.at(i)++; //割った個数を配列に足す
			num /= i;
		}
        if(i>=3)i++;
	}

    if(num!=1)ans++;
	cout << ans << endl;
	return 0;
} // end of main



//実行は、Opt + Ctl + N
//デバッグする場合は、デバッグビューでドロップダウンリストから[(lldb)Launch]を選択する
//まずビルド: Command + Shift + B
//その後、F5
//ターミナルが開くので、入力はそちらに。
//F9でブレークポイント設置
//F11でステップイン実行

// 学び
// 少数の掛け算は誤差が発生する。整数に直して行うこと。ABC169_C
// 

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n;
  string s;
  cin>>n>>s;
  int c=0,d=0;
  for(int i=0;i<n;i++)
  {
    if(s[i]=='R')
      c++;
  }
  for(int i=0;i<c;i++)
  {
    if(s[i]=='W')
      d++;
  }
  cout<<d;
  return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

inline void add(ll &x, ll y)
{
	x += y;
	x %= MOD;
}

int N, M;

ll dp[310][310][310];

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

	dp[0][1][0] = 1;

	for (int i=1;i<=M;++i) {
		for (int j=1;j<=N;++j) {
			for (int k=0;k<=N-j;++k) {
				if (dp[i-1][j][k] == 0) continue;
				add(dp[i][j][k], dp[i-1][j][k]*k);
				add(dp[i][j+k][0], dp[i-1][j][k]*j);
				add(dp[i][j][k+1], dp[i-1][j][k]*(N-j-k));
			}
		}
	}

	cout << dp[M][N][0] << endl;

	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;

    if (!is_sorted(a.begin(), a.end())) {
        prev_permutation(a.begin(), a.end());
        for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
        next_permutation(a.begin(), a.end());
    }
    for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
    next_permutation(a.begin(), a.end());
    if (!is_sorted(a.begin(), a.end())) {
        for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
    }
    prev_permutation(a.begin(), a.end());
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<double> x(N);
    std::vector<std::string> u(N);
    for (int i = 0; i < N; i++) {
        std::cin >> x[i] >> u[i];
    }

    double ans = 0;
    for (int i = 0; i < N; i++) {
        if (u[i] == "BTC") {
            ans += x[i] * 380000.0;
        } else {
            ans += x[i];
        }
    }

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


Measured memory_bytes: 256
n, m = map(int, input().split())
dict = {i:True for i in range(1, m+1)}
ans = 0

for i in range(n):
    _, *a = map(int, input().split())
    for j in range(1, m + 1):
        if j not in a:
            dict[j] = False

for i in range(1, m + 1):
    if dict[i]:
        ans += 1

print(ans)    


Measured memory_bytes: 3060
n, x, y = map(int, input().split())

COUNT = [0] * n
for i in range(1, n):
    for j in range(i + 1, n + 1):
        a = j - i; b = abs(x - i) + 1 + abs(y - j)
        d = min(a, b)
        COUNT[d] += 1

for k in range(1, n):
    print(COUNT[k])


Measured memory_bytes: 3444
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,suma = 0, sumb = 0,sumc = 0,result = 0;
string str;
int main(){
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> str;
    for(int j = 0; j <= str.length() - 2; j++){
      if(str[j] == 'A' && str[j + 1] == 'B'){
        result += 1;
      }
    }
    if(str[str.length() - 1] == 'A' && str[0] != 'B'){
        suma += 1;
      }
    if(str[0] == 'B' && str[str.length() - 1] != 'A'){
        sumb += 1;
      }
     if(str[str.length() - 1] == 'A' && str[0] == 'B'){
       sumc += 1;
     }
  }
  if(suma + sumb == 0 && sumc > 0){
    result += sumc - 1;
  }
  else if(suma + sumb > 0 && sumc == 0){
    result += min(suma,sumb);
  }
  else {
    result += min(suma,sumb) + sumc;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=1e9+7;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
 
 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;

void solve(){
    int n; cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    ll p[n+1]; p[0]=0;
    for(int i=1;i<n+1;i++){
        p[i]=p[i-1]+arr[i-1];
        if(p[i]>mod){
            p[i]%=mod;
        }
    }
    ll sum=0;
    for(int i=1;i<n;i++){
        sum+=(arr[i]*p[i]);
        if(sum>=mod){
            sum%=mod;
        }
    }
    cout<<sum%mod<<endl;
}
int main(){
    fastio();
    //write code
    int t; t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int K;
    string S;
    cin>>K>>S;
    if(S.size()>K){
        cout << S.substr(0,K) << "..." << endl;
    }else{
        cout << S<<endl;
    }





}


Measured memory_bytes: 3672
#include <iostream>
using namespace std;
int main() {
	while (true) {
		int n, m, t, p;
		cin >> n;
		cin >> m;
		cin >> t;
		cin >> p;
		if (n == 0 && m == 0 && t == 0 && p == 0) {
			return 0;
		}
		int kami[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				kami[i][j] = 1;
			}
		}
		for (int i = 0; i < t; i++) {
			int d, c;
			int kami2[n][m];
			cin >> d;
			cin >> c;
			if (d == 1) {
				if (c * 2 <= n) {
					for (int s = 0; s < c; s++) {
						for (int t = 0; t < m; t++) {
							kami2[s][t] = kami[c - s-1][t] + kami[c + s][t];
						}
					}
					for (int s = c; s < n; s++) {
						for (int t = 0; t < m; t++){
							if (c +s< n) {
								kami2[s][t] = kami[c + s][t];
							}
							else {
								kami2[s][t] = 0;
							}
						}
					}
				}
				else {
					for (int s = 0; s < n-c; s++) {
						for (int t = 0; t < m; t++) {
							kami2[s][t] = kami[c + s][t] + kami[c - s - 1][t];
						}

					}
					for (int s = n - c; s < n; s++) {
						for (int t = 0; t < m; t++) {
							if (c - s-1>=0) {
								kami2[s][t] = kami[c - s - 1][t];
							}
							else {
								kami2[s][t] = 0;
							}
						}
					}
				}
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++) {
						kami[i][j] = kami2[i][j];
						//cout << kami[i][j] << ", ";
					}
					//cout << endl;
				}
				
				//kami = kami2;
			}
			else if(d==2) {
				int kami2[n][m];
				if (c * 2 <= m) {
					for (int s = 0; s < n; s++) {
						for (int t = 0; t < c; t++) {
							kami2[s][t] = kami[s][c-t-1] + kami[s][c+t];
						}
						for (int t = c; t < m; t++) {
							if (c + t < m) {
								kami2[s][t] = kami[s][c + t];
							}
							else {
								kami2[s][t] = 0;
							}
						}
					}
				}
				else {
					for (int s = 0; s < n; s++) {
						for (int t = 0; t < m-c; t++) {
							kami2[s][t] = kami[s][c+t] + kami[s][c-1-t];
						}
						for (int t = m-c; t < m; t++) {
							if (c-t-1>=0) {
								kami2[s][t] = kami[s][c-t-1];
							}
							else {
								kami2[s][t] = 0;
							}
						}
					}
				}
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++) {
						kami[i][j] = kami2[i][j];
						//cout << kami[i][j] << ", ";
					}
					//cout << endl;
				}
				//kami = kami2;
			}
		}
		
//		int sum = 0;
		for (int i = 0; i < p; i++) {
			int x,y;
			cin >> x;
			cin >> y;
			//sum += kami[x][y];
			cout << kami[x][y]<<endl;
		}
		
	}
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()


ll func1(ll x, ll val, vector <ll> &vec){
   while(x < 1e6+1){
         vec[x] = max(vec[x], val);
         x += (x&-x);
   }
}

ll func2(ll x, vector <ll> vec){
   ll ans = 0;
   while(x > 0){
         ans = max(ans, vec[x]);
         x -= (x&-x);
   }
   return ans;
}

int c[10][10];
int arr[500][500];

int cnt[10];

int main()
{
   int h, w;
   cin >> h >> w;

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

   for(int i = 0; i < h; i++){
       for(int j = 0; j < w; j++){
           cin >> arr[i][j];
           if(arr[i][j] != -1) cnt[arr[i][j]]++;
       }
   }

   for(int k = 0; k < 10; k++){
       for(int i = 0; i < 10; i++){
           for(int j = 0; j < 10; j++){
               if(c[i][k]+c[k][j] < c[i][j]) c[i][j] = c[i][k]+c[k][j];
           }
       }
   }

   ll ans = 0;

   for(int i = 0; i < 10; i++){
       ans += 1LL*cnt[i]*c[i][1];
   }
   cout << ans;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
    
  for (int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }

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

  int sum = 1;
  
  for (int i = 1; i < N; i++) {
    if (vec.at(i - 1) != vec.at(i)) {
      sum += 1;
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

VI e[100000];
int par[100000], dep[100000], sz[100000];
int col[100000];

int dfs(int now, int past){
    sz[now] = 1;
    for (int next : e[now]){
        if (next == past) continue;
        par[next] = now;
        dep[next] = dep[now] + 1;
        sz[now] += dfs(next, now);
    }
    return sz[now];
}

int main() {
    int n;
    cin >> n;
    REP(i,n-1){
        int u, v;
        scanf("%d %d", &u, &v);
        u--;v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    dfs(0, -1);

    // REP(i,n) cout << sz[i];
    // cout << endl;

    int p = n-1;
    REP(i,(dep[n-1] - 1)/2) p = par[p];

    // cout << dep[n-1] << p << endl;

    int sn = sz[p], fe = n - sn;

    cout << (fe > sn ? "Fennec" : "Snuke") << endl;

    // cout << sn << endl;

    return 0;
}

Measured memory_bytes: 11520
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions

t = stdin.readline().rstrip().split()
n = int(t[0])
k = int(t[1])
res = []
for el in range(k):
    tt = int(stdin.readline().rstrip())
    person = [int(s) for s in stdin.readline().rstrip().split()]
    for el3 in person:
        res.append(el3)
count = 0
for el in range(1, n + 1):
    if not (el in res):
        count += 1
print(count)


Measured memory_bytes: 73032
#include<stdio.h>
#define EPS 1e-10
int main(void){
  int num;
  double w,h;
  double bmi;

  while(scanf("%d,%lf,%lf ",&num,&w,&h)!=EOF){
    bmi = w/(h*h);
    if(25.0 - bmi < EPS)printf("%d\n",num);
  }

  return 0;
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while (first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if (last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}
int main() {
    string str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    string ans;
    int n;
    cin >> n;
    char del = ' ';
    VS vs;
    vs = split(str, del);

    if (vs[n-1][1]==',')
        cout << vs[n-1][0] << endl;
    else
        cout << vs[n-1][0] << vs[n-1][1] << endl;

    return 0;
}


Measured memory_bytes: 256