akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(void) {
	int A, B, C, sum, ans;
	cin >> A >> B >> C;
	int i = 0;	int x = 100;	int y = 0;
	while (x >= 0) {
		sum = A + A*i;
		ans = sum % B;
		if (ans == C) {
			cout << "YES" << endl;
			y += 1;
			break;
		}
		i++;
		x--;
	}
	if (y == 0) {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = {}
    total = 0
    for i, a in enumerate(A):
        b = B.get(a, 0)
        if b == 0:
            B[a] = 1
        else:
            B[a] += 1

    for i in B:
        if B[i] == 0:
            continue
        if B[i] == i:
            continue
        elif B[i] > i:
            total += B[i] - i
        else:
            total += B[i]
    print(total)
main()


Measured memory_bytes: 18168
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N,K; cin >>N >>K;
  cout <<N-K+1 <<endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MAX_V 100000
#define MAX_LOG_V 30

vector<int> G[MAX_V];
class LCA{
    int root;
    vector<vector<int>> parent;
    vector<int> depth;

public:
    /**
     *
     * @param V: 頂点数
     */
    LCA(int V){
        root = 0;
        init(V);
    }

    LCA(int root, int V): root(root){
        init(V);
    }

    void dfs(int v, int p, int d){
        parent[0][v] = p;
        depth[v] = d;
        for(auto u: G[v]){
            if(u != p){
                dfs(u, v, d+1);
            }
        }
    }

    void init(int V){
        parent = vector<vector<int>>(MAX_LOG_V, vector<int>(MAX_V, 0));
        depth = vector<int>(MAX_V, 0);

        dfs(root, -1, 0);
        for(int k = 0; k + 1 < MAX_LOG_V; k++){
            for(int v = 0; v < V; v++){
                if(parent[k][v] < 0) parent[k+1][v] = -1;
                else parent[k+1][v] = parent[k][parent[k][v]];
            }
        }
    }

    /**
     *
     * @param u
     * @param v
     * @return 頂点uと頂点vのLCA
     */
    int lca(int u, int v){
        if(depth[u] > depth[v]){
            swap(u, v);
        }

        for(int k = 0; k < MAX_LOG_V; k++) {
            if ((depth[v] - depth[u]) >> k & 1) {
                v = parent[k][v];
            }
        }
        if(u == v){
            return u;
        }
        for(int k = MAX_LOG_V-1; k >= 0; k--){
            if(parent[k][u] != parent[k][v]){
                u = parent[k][u];
                v = parent[k][v];
            }
        }

        return parent[0][u];
    }

};


int main(){
    int n;  cin >> n;
    for(int i = 0; i < n; i++){
        int k;  cin >> k;
        for(int j = 0; j < k; j++){
            int c;  cin >> c;
            G[i].push_back(c);
            G[c].push_back(i);
        }
    }

    LCA lca(n);
    int q;  cin >> q;
    for(int i = 0; i < q; i++){
        int u, v;   cin >> u >> v;
        cout << lca.lca(u, v) << endl;
    }


    return 0;
}



Measured memory_bytes: 23332
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int A,B;
    cin >>A>>B;
    int ans = 0;
    if(B == 1) cout << 0 << endl;
    else{
    for(int i = 1;i < 987654321;i++){
        if(((i - 1) * (A - 1) + A) >= B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int K; cin >> K;
    string S; cin >> S;

    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
from itertools import product
n, m = map(int, input().split())

a = [tuple(map(int, input().split())) for _ in range(n)]

b = []

for p in product([-1, 1], repeat=3):
    temp = sorted([p[0]*x+p[1]*y+p[2]*z for x, y, z in a], reverse=True)
    b.append(sum(temp[:m]))

print(max(b))


Measured memory_bytes: 3316
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

f [] [] = "None"
f [] (c:_) = [c]
f (c1:s1) (c2:s2) = if c1 /= c2 then [c2] else f s1 s2

main = do
  s <- map B.head . B.group . B.sort <$> B.getLine
  putStrLn $ f s "abcdefghijklmnopqrstuvwxyz"


Measured memory_bytes: 764
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M;
	cin >> N >> M;
	int dp0[2010][2010] = { 0 };
	int dp1[2010][2010] = { 0 };
	VI S(N+1), T(M+1);
	REP(i, N) {
		cin >> S[i];
	}
	REP(j, M) {
		cin >> T[j];
	}
	
	dp0[0][0] = 1;
	REP(i, N + 1) {
		REP(j, M + 1) {
			dp0[i + 1][j] += dp0[i][j];
			dp1[i][j] += dp0[i][j];
			dp1[i][j + 1] += dp1[i][j];

			dp0[i + 1][j] %= mod;
			dp1[i][j] %= mod;
			dp1[i][j + 1] %= mod;


			if (S[i] == T[j]) {
				dp0[i + 1][j + 1] += dp1[i][j];

				dp0[i + 1][j + 1] %= mod;
			}
		}
	}
	int ans = dp1[N][M];

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



Measured memory_bytes: 63488
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define P 1000000007
using namespace std;

int powmp(long long x,long long n){
	const long long p = 1000000007;
	if(n==0) return 1;
	long long y = x%p;
	if(n==1) return y;
	long long tmp = (powmp(y,n/2))%p;
	if(n%2==0) return (tmp*tmp)%p;
	else return (powmp(y,n-1)*y)%p;
}

int main(int argc, char const *argv[])
{
	long long n,a,b,c,d;
	cin >> n>>a>>b>>c>>d;
	long long dis = abs(a-b);
	bool ok = false;
	REP(i,n){
		if((dis<=i*d-(n-1-i)*c)&&(i*c-(n-1-i)*d<=dis)) ok = true;
	}
	if(ok) cout << "YES";
	else cout << "NO";
	cout << "\n";
	return 0;
}	

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

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<int> K(N);
	UnionFind tree(M);
	vector<vector<int>> L(N);
	set<int> st;
	rep(i,N){
		cin >> K[i];
		rep(j,K[i]){
			int a;
			cin >> a;
			a--;
			L[i].push_back(a);
			st.insert(a);
		}
	}
	rep(i,N){
		rep(j,K[i]-1){
			tree.unite(L[i][j],L[i][j+1]);
		}
	}
	
	int root = tree.root(*st.begin());
	for(auto x:st){
		if(!tree.same(root,x)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 6528
import sys
input = sys.stdin.readline
import math

n = int(input())

AS = list(map(int,input().split()))
AS.sort(reverse = True)

if n == 2:
    print(AS[0])
else:
    m = math.ceil(n / 2)
    ans = 0
    for i in range(m):
        if i == 0:
            ans += AS[0]
        elif i < m-1:
            ans += AS[i]*2
        else:
            if n % 2 == 0:
                ans += AS[i]*2
            else:
                ans += AS[i]
    print(ans)

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

using namespace std;

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

void solve()
{
	int n, m;
	cin >> n >> m;
	if (n >= m)
	{
		cout << 0 << "\n";
		return;
	}
	vector<int> a(m);
	priority_queue<int> pq;

	for(auto&& i : a)
	{
		cin >> i;
	}
	sort(begin(a), end(a));
	for(int i = 1; i < m; i++)
	{
		pq.push(a[i] - a[i - 1]);
	}
	long long ans = a[m - 1] - a[0];
	for(int i = 1; i < n; i++)
	{
		ans -= pq.top();
		pq.pop();
	}
	cout << ans << "\n";
}

int main()
{
	solve();
}


Measured memory_bytes: 1276
program prob1
    implicit none
    integer::A, B, i, atax, btax, ataxmax, btaxmax
    read(*,*) A, B

    btax = B*10
    btaxmax = B*10+9
    if(mod(A,2) == 1)then
        atax = A*100/8 + 1
        ataxmax = atax + 11
    else
        atax = A*100/8
        ataxmax = atax + 12
    end if

    if(btax <= atax) then
        if(btaxmax >= atax)then
            write(*,*) atax
        else
            write(*,*) -1
        end if
    else
        if(ataxmax >= btax) then
            write(*,*) btax
        else
            write(*,*) -1
        end if
    end if

    stop
end program prob1

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }

        int count = 0;

        for (int k: a) {
            if (k * 4 * M < sum) continue;
            else count++;
        }
        if (count >= M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35892
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;



ll mpow(ll x, ll n, ll mod){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

vector<ll> fact;

void calcFact(ll n, ll mod) {
    fact.assign(n+1, 1);
    repi(i, n+1) {
        fact[i] = fact[i-1] * i % mod;
    }
}

ll combination(ll n, ll a, ll mod) {
    if (n < a) {
        return 0;
    }

    ll X = fact[n];
    ll Y = fact[a];
    ll Z = fact[n-a];
    ll iY = mpow(Y, mod - 2, mod);
    ll iZ = mpow(Z, mod - 2, mod);

    ll res = X * iY % mod;
    res = res * iZ % mod;

    return res;
}


void Main()
{
    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    ll mod = 7LL + 1e9;
    calcFact(H + W, mod);
    
    ll res = 0;
    for (ll i = 0; B + i <= W - 1; i++) {
        ll x = B + i;
        ll y = H - 1 - A;

        ll c1 = combination(x + y, x, mod);
        ll c2 = combination((H-1) - (y+1) + (W-1) - x, (W-1) - x, mod);
        res += c1 * c2 % mod;
        res %= mod;
    }

    put(res);
}
signed main(){ Main();return 0;}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B;
    cin >> A >> B;
    if ((A * B) % 2 == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	int k;
	cin >> a >> b >> k;
	if(k*2 >= b-a+1)
	{
		for(int i=a;i <= b;i++)
			cout << i << endl;
		return 0;
	}	
	for(int i=0;i<k;i++)
		cout << a+i << endl;
	for(int i=k;i>0;i--)
		cout << b-i+1 << endl;
	return 0;
} 

Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = parseInt(xs[0]);
   let K = parseInt(xs[1]);
   let ans = 1;
   for(let i=0; i<N; i++){
    ans = Math.min(ans*2,ans+K);
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 29588
// Prime Numbers
#include <stdio.h>

int primeNumber(int);

int main(){
  int n, i, A[10000], count=0;
    
  scanf("%d", &n);
  for(i=0; i < n; i++){
    scanf("%d", &A[i]);
    if(primeNumber(A[i]) == 1)count++; // 素数の数をカウント
  }
  printf("%d\n", count);
  
  return 0;
}

int primeNumber(int x){
  int i;
  if(x == 2)return 1;
  if(x % 2 == 0)return 0;
  
  // sqrt(x)まで調べて割り切れる数が見つからないときは素数と判定できる
  for(i=3; i*i <= x; i+=2){
    if(x % i == 0)return 0;
  }
  return 1;
}


Measured memory_bytes: 2068
fn solve() {
    let n = read();
    let mut res = 0;
    let mut tmp;
    for i in 1..n {
        tmp = n / i;
        if n % i == 0 {
            tmp -= 1;
        }
        res += tmp;
    }
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    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")
}

// =========


Measured memory_bytes: 2240
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll A, B, C, D;
    cin>>A>>B>>C>>D;
    ll taka, ao;
    taka=(A-1)/D+1;
    ao=(C-1)/B+1;
    if(taka>=ao) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3592
/*
長方形の面積と周の長さ
*/

#include<stdio.h>
int main(void){
  int a;/*縦の長さ*/
  int b;/*横の長さ*/
  int area;/*面積*/
  int perimeter;/*周の長さ*/

  scanf("%d %d",&a,&b);
  area = a*b;
  perimeter = 2*a+2*b;
  printf("%d %d\n",area,perimeter);
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,M;
  cin>>N>>M;
  vector<vector<int>>d(N,vector<int>(N,INT_MAX/3));
  for(int i=0;i<N;i++)d[i][i]=0;
  struct E{
    int from,to,cost;
  };
  vector<E>e(M);
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    d[a][b]=c;
    d[b][a]=c;
    e[i]={a,b,c};
  }
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  int ans=0;
  for(int i=0;i<M;i++){
    if(d[e[i].from][e[i].to]!=e[i].cost)ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int crossnum[]{1,10,1,100,10,1,100,10,1};
int u,d;
void addnum(int place,int add){
	if(place<6){
		u+=add;
	}else{
		d+=add;
	}
}
void input(vector<int> &line,vector<int> &used){
	line.resize(9);
	used.resize(10,false);
	u=d=0;
	for(int i=0;i<9;++i){
		cin>>line[i];
		if(line[i]>0){
			used[line[i]]=true;
			addnum(i,line[i]*crossnum[i]);
		}
	}
}

int func(int place,vector<int> &line,vector<int> &used){
	if(place==9){
		return u==d?1:0;
	}
	int res=0;
	if(line[place]>0){
		return func(place+1,line,used);
	}
	for(int i=1;i<used.size();++i){
		if(used[i]){
			continue;
		}
		addnum(place,i*crossnum[place]);
		used[i]=true;
		res+=func(place+1,line,used);
		used[i]=false;
		addnum(place,-i*crossnum[place]);
	}
	return res;
}
int main(){
	vector<int> line;
	vector<int> used;
	input(line,used);
	cout<<func(0,line,used)<<endl;
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

signed main(){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    printf("%d\n",min(n*a,b));
    return 0; 
}

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

using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  int C = 1;
  if(A < B) swap(A, B);
  if(A == 2 && B == 1) C = 3;
  if(A == 3 && B == 2) C = 1;
  if(A == 3 && B == 1) C = 2;
  
  cout << C << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+9,mod=998244353;
int n,m,k,ans,fact[N],inv[N];
int qp(int a,int b=mod-2){
    return (b==0?1:(b%2?qp(a*a%mod,b/2)*a%mod:qp(a*a%mod,b/2)));
}
int C(int a,int b){return fact[a]*inv[b]%mod*inv[a-b]%mod;}
signed main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=0;i<=n;i++) fact[i]=(i==0?1:fact[i-1]*i%mod);
	for(int i=n;i>=0;i--) inv[i]=(i==n?qp(fact[n]):inv[i+1]*(i+1)%mod);
	for(int j=0;j<=k;j++){
		ans=(ans+m*C(n-1,j)%mod*qp(m-1,n-j-1))%mod;
	}
	printf("%lld",ans);
	return 0;
} 

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

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

typedef struct node * NodePointer;

NodePointer nil;
int size = 0;
int np = 0, nd = 0;

NodePointer listSearch(int);
void init();
void printList();
void deleteNode(NodePointer);
void delete(int);
void insert(int);
void deleteFirst();
void deleteLast();

int main(){
  int n, i;
  int key;
  char com[20];

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

NodePointer listSearch(int key){
  NodePointer t = nil->next;
  while(1){
    if(t == nil) return NULL;
    if(t->key == key){
      return t;
    }
    t = t->next; 
  }
}

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

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

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

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

void deleteLast(){
  deleteNode(nil->prev);
  /* NodePointer t = nil->next;
  while(1){
    if ( t == nil ) return;
    if(t->next == nil){
      deleteNode(t);
      return;
    }
    t = t->next;
  }
  */
}

void delete(int key){
  NodePointer t = listSearch(key);
  if(t == NULL) return;
  deleteNode(t);
}

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

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

int main(){
  string s;
  cin>>s;
  bool ok=false;
  for (int i = 0; i < s.size(); i++)
  {
    /* code */
    for (int j = i+1; j < s.size(); j++)
    {
      /* code */
      if (s[i]==s[j])
      {
        /* code */
        ok=true;
        break;
      }
      
    }
    
  }
  if (ok)
  {
    /* code */
    cout<<"no"<<endl;

  }
  else
  {
    cout<<"yes"<<endl;
  }
  
  
  
  }

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include <cstring>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define MAX 101
#define MAX_V 15
#define mset(a,x) memset(a,x,sizeof(a))
int a[100001];
int d[100001];
int main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	int c = 0, m = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1]) {
			d[a[i]]++;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (d[i]) {
			for (int j = i + 2; j <= 100000; j++) {
				while (d[j]) {
					d[i]--;
					d[j]--;
					c+=2;
				}
			}
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (d[i]) {
			c += d[i] % 2 ? d[i] + 1 : d[i];
		}
	}
	cout << n - c << endl;
	return 0;
}

Measured memory_bytes: 1024
//https://atcoder.jp/contests/dp/tasks/dp_a
#include<bits/stdc++.h>
#define endl "\n"
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
typedef long long int ll;
const int INF = 1e9;

using namespace std;

void solve()
{
    ll i, j, n, k;
    cin>>n;

    vector<ll> arr(n);

    for(auto &ele: arr) cin>>ele;

    vector<ll> dp(n);
    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);

    for(i=2; i<n; ++i)
    {
        dp[i] = min( dp[i-1] + abs(arr[i]-arr[i-1]), dp[i-2] + abs(arr[i]-arr[i-2]));
    }

    cout<<dp[n-1]<<endl;
}
 
int main()
{
    FASTIO
    solve();
    return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int n = Input.ScanInt();
          string s = Input.ScanStr();
          
          int num=0;
          int max = 0;
          for(int i=0;i<n;i++){
            if(s[i]=='I') num++; else num--;
            max = Math.Max(max,num);
          }
            
          Console.WriteLine(max);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
while True:
	inp = raw_input()
	if inp == "0": break
	m,n = map(int, inp.split())
	ans = 0
	for i in range(m,n+1):
		while i > 1:
			if i%2 == 0:
				i /= 2
			elif i%3 == 0:
				i /= 3
			elif i%5 == 0:
				i /= 5
			else:
				break
		else:
			ans += 1
	print ans

Measured memory_bytes: 35924
#include<iostream>

using namespace std;

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=100;i>=1;i--){
    if(a%i==0 && b%i==0)k--;
    if(k==0){
      cout<<i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int n,m;
string s[20];
int swaped[20];
int used[20];
int ans = 0;
bool check()
{
	memset(used,0,sizeof used);
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(used[i]||used[j]||i==j) continue;
			int cur=1;
			for(int k=0;k<n;k++){
				if(s[swaped[k]][i]!=s[k][j]){
					cur=0;
					break;
				}
			}
			if(cur){
				used[i]=used[j]=1;
			}
		}
	}
	int cnt=0,to=0;
	for(int i=0;i<m;i++){
		if(!used[i]){
			cnt++;to=i;
		}
	}
	if(cnt>=2||(m%2==0&&cnt)){
		return false;
	}
	if(!cnt) return true;
	for(int i=0;i<n;i++){
		if(s[swaped[i]][to]!=s[i][to]){
			return false;
		}
	}
	return true;
}


void dfs(int now,bool ji)
{
	if(now==(n+1)/2){
		if(check()){
			ans=1;
		}
		return;
	}
	for(int i=now;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(swaped[i]==-1&&swaped[j]==-1){
				swaped[i]=j;
				swaped[j]=i;
				dfs(now+1,ji);
				swaped[i]=-1;
				swaped[j]=-1;
			}
		}
		if(ji&&swaped[i]==-1){
			swaped[i]=i;
			dfs(now+1,false);
			swaped[i]=-1;
		}
	}

}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		cin>>s[i];
		swaped[i]=-1;
	}
	if(n&1){
		dfs(0,true);
	}else{
		dfs(0,false);
	}
	if(ans) printf("YES\n");
	else printf("NO\n");
}



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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans = "";
            for (var i = 0; i < 3; i++) ans += Console.ReadLine()[i];

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
def jd(m,a,b,c)
  return [true,m[a]] if m[a]==m[b] and m[b]==m[c] and m[a]!="s"
  return [false,0]
end
while gets
  m=$_.chomp.split("")
  l=jd(m,0,1,2)<<jd(m,3,4,5)<<jd(m,6,7,8)<<jd(m,0,3,6)<<jd(m,1,4,7)<<jd(m,2,5,8)<<jd(m,0,4,8)<<jd(m,2,4,6)
  q=l.flatten!.index(true)
  puts q.nil? ? "d" : l[q+1]
end

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

using namespace std;

int main() {
  int h, w;
  char a[102][103];
  cin >> h >> w;
  for (int i = 0; i < h + 2; i++) {
    a[i][0] = '#';
    a[i][w+1] = '#';
  }
  for (int i = 0; i < w + 2; i++) {
    a[0][i] = '#';
    a[h+1][i] = '#';
  }
  for (int i = 1; i < h + 1; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < h + 2; i++) {
    for (int j = 0; j < w + 2; j++) {
      cout << a[i][j];
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = [a[i] - b[i] for i in range(n)]
    c.sort()
    ans = 0
    x = 0
    for v in c:
        if v < 0:
            ans += 1
            x -= v
    y = 0
    for v in reversed(c):
        if y >= x:
            break
        if v > 0:
            ans += 1
            y += v
    if y >= x:
        print(ans)
    else:
        print("-1")

if __name__ == "__main__":
    main()

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

res = 0
for i in range(N):
    d = min(A[i], B[i])
    A[i] -= d
    B[i] -= d
    res += d
    d = min(A[i+1], B[i])
    A[i+1] -= d
    res += d

print(res)

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

int main(){
	string a,b;
  	cin >> a >> b;
  	if(a.size() > b.size()) {
      	cout << "GREATER" << endl;
      	return 0;
    } else if(a.size() < b.size()) {
      	cout << "LESS" << endl;
     	return 0;
    }
    for(int i = 0; i < a.size(); i++) {
     	if(a[i] > b[i]) { 
      		cout << "GREATER" << endl;
      		return 0;
    	} else if(a[i] < b[i]) {
      		cout << "LESS" << endl;
     		return 0;
    	}   
    }
    cout << "EQUAL" << endl;	
}

Measured memory_bytes: 256
import itertools
import bisect
N=int(input())
S=input()
l=[[] for i in range(10)]
for i in range(N):
    l[int(S[i])].append(i)
cnt=0
for x in itertools.product(list(range(10)),repeat=3):
    if(not l[x[0]] or not l[x[1]] or not l[x[2]]):
        continue
    zero=l[x[0]][0]
    t=bisect.bisect_left(l[x[1]],zero+1)
    if(t>=len(l[x[1]])):
        continue
    one=l[x[1]][t]
    m=bisect.bisect_left(l[x[2]],one+1)
    if(m>=len(l[x[2]])):
        continue
    cnt+=1
print(cnt)

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

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

       cin >> n;
       Cout(n/3);
return 0;
}


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

ll N,Ma,Mb;
struct drug {
     ll a;
     ll b;
     ll c;
};
drug drugs[40];
ll dp[40][401][401];

int main() {
    std::cin >> N>>Ma>>Mb;
    for (int i = 0; i < N; i++) {
        std::cin >> drugs[i].a>>drugs[i].b>>drugs[i].c;
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 400; j++) {
            for (int k = 0; k <= 400; k++) {
                if(i==0 && j==0 && k==0){
                    dp[i][j][k]=0;
                }else{
                    dp[i][j][k]=40000;
                }
            }
        }
    }
    dp[0][drugs[0].a][drugs[0].b]=drugs[0].c;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= 400; j++) {
            for (int k = 0; k <= 400; k++) {
                // if(j-drugs[i].a>=0 && k-drugs[i].b>=0){
                //     dp[i][j+][k] = min({dp[i-1][j-drugs[i].a][k-drugs[i].b]+drugs[i].c, dp[i-1][j][k],dp[i][j][k]});
                // }
                
                if(dp[i-1][j][k] == 40000)continue;
                if(j+drugs[i].a<=400 && k+drugs[i].b<=400){
                    dp[i][j+drugs[i].a][k+drugs[i].b] = min({dp[i-1][j][k]+drugs[i].c, dp[i-1][j+drugs[i].a][k+drugs[i].b],dp[i][j+drugs[i].a][k+drugs[i].b]});
                }
                dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k]);
            }
        }
    }
    ll   ans=40000;
    for (int j = 1; j <= 400/(max(Ma,Mb)); j++) {
        ans = min(ans,dp[N-1][Ma*j][Mb*j]);
    }
    
    if(ans==40000){
        std::cout << -1 << std::endl;
    }else{
        std::cout << ans << std::endl;
    }
}


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

int main() {

  int N,K,x,n=0;
  cin >> N >> K;
  for(int i=0;N>i;i++){
    cin >> x;
    if(x*2<K) n+=x*2;
    else n+=(K-x)*2;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        s = sum((X[i][d] - X[j][d])**2 for d in range(d))
        if any(k**2 == s for k in range(1000)):
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pp pair<int,int> 
#define v(T) vector<T>
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
 
int main() {
  string s;
  cin>>s;
  if(s=="Sunny") cout << "Cloudy" << endl;
  if(s=="Cloudy") cout << "Rainy" << endl;
  if(s=="Rainy") cout << "Sunny" << endl;
}  

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

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    string ans = "";

    for(int i = 0; i < s.size(); i++) {
        if(s.at(i) == 'B') {
            if(ans.size() == 1) {
                ans = "";
            } else if(ans.size() > 1) {
                ans.erase(ans.end() - 1);
            }
        } else {
            ans += s.at(i);
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] <<endl;
}

Measured memory_bytes: 256
//AGC035B
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

V path[NUM];
ll dep[NUM];
ll cnt[NUM];
ll done[NUM];

int main(){

    ll N, M;
    cin >> N >> M;
    if(M % 2){
        cout << -1 << endl;
        return 0;
    }
    rep(i, M){
        ll a, b;
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    queue<ll>Q;
    Q.push(1);
    dep[1] = 1;
    while(!Q.empty()){
        ll idx = Q.front();
        Q.pop();
        for(auto to : path[idx]){
            if(dep[to] > 0)continue;
            Q.push(to);
            dep[to] = dep[idx] + 1;
        }
    }
    vector<P>ans;
    vector<P>v;
    rep1(i, N)v.push_back(P(dep[i], i));
    sort(v.begin(), v.end(), greater<P>());
    for(auto p : v){
        ll idx = p.second;
        for(auto to : path[idx])if(done[to] == 0){
            if(cnt[idx] % 2){
                cnt[idx]++;
                ans.push_back(P(idx, to));
            }
            else{
                ans.push_back(P(to, idx));
                cnt[to]++;
            }
        }
        done[idx] = 1;
    }
    
    for(auto p : ans)cout << p.first << " " << p.second << endl;

    return 0;
}

Measured memory_bytes: 13296
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

n = np.sum(A < 0)
b = np.abs(A)
s = np.sum(b)

if n % 2:
    print(s - 2 * np.min(b))
else:
    print(s)


Measured memory_bytes: 23272
N = int(input())
mod = 10**9+7
dp = [[[[0 for i in range(4)] for j in range(4)] for k in range(4)] for l in range(N+2)]
banc = [(i,0,2) for i in range(4)] + [(0,2,i) for i in range(4)] + [(i,2,0) for i in range(4)] + [(0,i,2) for i in range(4)]
bang = [(i,0,1) for i in range(4)]
if N == 3:
    print(61)

else:

    for i in range(4):
        for j in range(4):
            for k in range(4):
                if (i,j,k) in ((0,2,1),(0,1,2),(2,0,1)):
                    continue
                dp[3][i][j][k] += 1
    
    for n in range(4,N+2):
        for i in range(4):
            for j in range(4):
                for k in range(4):
                    for l in range(4):
                        if (i,j,k) in ((0,2,1),(0,1,2),(2,0,1)):
                            continue
                        if (l,i,j) in ((0,2,1),(0,1,2),(2,0,1)):
                            continue
                        if (l,i,j) in banc:
                            if k==1:
                                continue
                            dp[n][i][j][k] += dp[n-1][l][i][j]
                            dp[n][i][j][k] %= mod
                        elif (l,i,j) in bang:
                            if k==2:
                                continue
                            dp[n][i][j][k] += dp[n-1][l][i][j]
                            dp[n][i][j][k] %= mod
                        else:
                            dp[n][i][j][k] += dp[n-1][l][i][j]
                            dp[n][i][j][k] %= mod
    ans = 0
    for i in range(4):
        for j in range(4):
            for k in range(4):
                ans += dp[N][i][j][k]
                ans %= mod
    print(ans)



Measured memory_bytes: 3440
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mdl=1000000007;
vector<VVI> wys;
in n;
in fw(in rtg, in ful, in sem){
  in& tp=wys[rtg][ful][sem];
  if(tp!=-1)
    return tp;
  if(rtg==0){
    if(ful==n)
      return tp=1;
    return tp=0;
  }
  tp=0;
  if(ful+sem!=n)
    tp+=fw(rtg-1,ful,sem+1)*(n-ful-sem)%mdl;
  if(sem!=0)
    tp+=fw(rtg-1,ful,sem)*sem%mdl;
  tp+=fw(rtg-1,ful+sem,0)*ful%mdl;
  tp%=mdl;
  return tp;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in m;
  cin>>n>>m;
  wys.resize(m+1,VVI(n+1,VI(n+1,-1)));
  cout<<fw(m,1,0)<<endl;
  return 0;
}


Measured memory_bytes: 216832
R, G, B, N = map(int, input().split())
# R, G, B, N = 1, 2, 3, 4
# R, G, B, N = 13, 1, 4, 3000


def count_r_ball_patterns(R, N_a):
    return 1 if N_a % R == 0 else 0


def count_rg_ball_patterns(R, G, B, N_b):
    max_g = N_b // G
    result = 0
    for g in range(max_g + 1):
        result = result + count_r_ball_patterns(R, N_b - G * g)
    return result


def count_rgb_ball_patterns(R, G, B, N):
    # count (r, g, b) satisties R * r + G * g + B * b = N
    R, G, B = sorted([R, G, B])
    max_b = N // B
    result = 0
    for b in range(max_b + 1):
        result = result + count_rg_ball_patterns(R, G, B, N - B * b)
    return result


if __name__ == "__main__":
    print(count_rgb_ball_patterns(R, G, B, N))


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;
const int E = numeric_limits<int>::min();

int main(void)
{
    int X;
    cin >> X;

    int deg = 0, count = 0;
    while (deg != 360){
        if (deg > 360){
            deg -= 360;
        }
        deg += X;
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n,m; cin >> n >> m;
    int sum =1;
    if(n<=1)sum=0;
    int cnt=2;
    for(int j=2; cnt<n; j++){//偶数
        sum+=j;
        cnt++;
    }
    cnt=2;
   // cout << sum << endl;
    bool c =false;
     for(int j=2; cnt<m; j++){//偶数
     if(c==false){
         sum++;
         c=true;
     }
        sum+=j;
        cnt++;
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 256
n, l = map(int, input().split())
minabs = 10000
midx = -1
for i in range(1, n + 1):
    if abs(l + i - 1) < minabs:
        midx = i
        minabs = abs(l + i - 1)
ans = 0
for i in range(1, n + 1):
    if i != midx:
        ans += l + i - 1
print(ans)

Measured memory_bytes: 3064
#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 FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int x1,y1,x2,y2;
   cin>>x1>>y1>>x2>>y2;

   int dx,dy;
   dx = x2 - x1;
   dy = y2 - y1;
   int x = x2;
   int y = y2;
   rep(i,2){
      swap(dx,dy);
      dx = -dx;
      x += dx;
      y += dy;
      cout << x << " " << y << " ";
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
#define int  unsigned long long
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e5 + 11;

int power(int a, int b){
 int res = 1;
 while (b){
  if (b & 1) res = res * a;
  a = a * a;
  b >>= 1;	 
 }	
 return res;
}

map<int, int> primef(int n){
  map<int, int> m;
  for (int i = 2; i * i <= n; i++){
	while (n % i == 0){
	  n /= i;
	  m[i]++;	
    }  
  }
  if (n != 1) m[n]++;
  return m;
}

void solve(){
  int n, p;
  cin >> n >> p;
  map<int, int> m = primef(p);
  int ret = 1;
  for (auto it : m){
	while (it.second >= n){
	  ret *= it.first;
	  it.second -= n;	
	}  
  }
  cout << ret << endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;
 
ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a / g * b;   // Be careful not to overflow
}

int main(int argc, char* argv[])
{
    int a,b;
    scanf("%d%d", &a, &b);

    printf("%lld\n", lcm(a,b));

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int N, M;
int main()
{
    cin >> N >> M;
    vector<bool> p(M, false);
    vector<int> cnt(N, 0);
    int ans = 0, pena = 0;
    int prob;
    string s;
    rep(i, 0, M)
    {
        cin >> prob >> s;
        if (p[prob - 1] == false && s == "AC")
        {
            p[prob - 1] = true;
            ans++;
            pena += cnt[prob - 1];
            cnt[prob - 1] = 0;
        }
        else if (p[prob - 1] == false)
        {
            cnt[prob - 1]++;
        }
    }

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


Measured memory_bytes: 3692
#include<stdio.h>
#define MAX_N 100000
#define MAX_Q 50000
int binarySearch(int [],int ,int );
int main(){
  
  int n,s[MAX_N],q,t[MAX_Q],c=0;
  int i;
  
  // input 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);

  // Search
  for(i=0;i<q;i++){
    c += binarySearch(s,t[i],n);
  }
  printf("%d\n",c);
  
  
  return 0;
}

int binarySearch(int *s,int key,int n) {
  
  int i=0,left=0,right=n,mid;
  
  while(left < right){
    mid = (left + right)/2;
    if(s[mid] == key) {
      return 1;
    } else if( key < s[mid]) {
      right = mid; 
    }else {
      left = mid + 1;
    }

  }
  return 0;
}

Measured memory_bytes: 1188
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]

import collections
sum_temp = sum(A)
c = collections.Counter(A)
for q in range(Q):
  B = BC[q][0]
  C = BC[q][1]
  sum_temp += c[B]*(C-B)
  c[B],c[C] = 0,c[B]+c[C]
  print(sum_temp)


Measured memory_bytes: 40288