akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second
int fun(int x,int n,int m)
{
    int ans=1;
    while(n>0)
    {
        if(1&n)
            ans=((ans%m)*(x%m))%m;
        n=n>>1;
        x=((x%m)*(x%m))%m;
    }
    return ans;
}

signed main()
{
  int n,p1=0,p2=0;
  string s;
  cin>>n>>s;
  int k=count(s.begin(),s.end(),'1');
    if(k>1)
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
            p1=(p1%(k-1)+fun(2,n-i-1,k-1)%(k-1))%(k-1);
    }
    int arr[n]={0};
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
            p2=(p2%(k+1)+fun(2,n-i-1,k+1)%(k+1))%(k+1);
    }

        for(int i=0;i<n;i++)
    {
        int p;int ans=1;
        if(s[i]=='1' && k>1)
        {
              p=(p1%(k-1)-fun(2,n-i-1,k-1)%(k-1)+(k-1))%(k-1);

              while(p>0)
              {
                  int q=0,r=p;
                  while(r>0)
                  {
                      if(1&r)
                      q++;
                      r=r>>1;
                  }
                  p=p%q;
                  ans++;
              }
              arr[i]=ans;

        }
        else if(s[i]=='0')
        {
             p=(p2%(k+1)+fun(2,n-i-1,k+1)%(k+1))%(k+1);
             while(p>0)
              {
                  int q=0,r=p;
                  while(r>0)
                  {
                      if(1&r)
                      q++;
                      r=r>>1;
                  }
                  p=p%q;
                  ans++;
              }
              arr[i]=ans;
        }

    }
    for(int i=0;i<n;i++)
        cout<<arr[i]<<endl;

}




























































































































































































































Measured memory_bytes: 5320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int p[n];
  for(int i=0;i<n;i++) cin>>p[i];
  int c=0;
  for(int i=0;i<n-1;i++){
    if(p[i]==i+1){
      swap(p[i],p[i+1]);
      c++;
    }
  }
  if(p[n-1]==n)c++;
  cout<<c<<endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    long long  N;
    long long result;
    cin >> N;
    result = 0;
    for(int i = 1; i <= N; i++){
        result = result + i * ((N/i)+1) * (N/i) / 2 ;
    }
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3628
# 190629_sat_D
# 動的計画法

import math

N, K = map(int,input().split())
devisor = 10 ** 9 + 7

def make_C_list(x):
    C_list = [[0 for i in range(x+1)] for j in range(x+1)]
    C_list[0][0] = 1
    C_list[1][0] = 1
    C_list[1][1] = 1
    for i in range(2,x+1):
        C_list[i][0] = 1
        C_list[i][i] = 1
        for j in range(1,i):
            C_list[i][j] = C_list[i-1][j] + C_list[i-1][j-1]
    return C_list

C = make_C_list(N)

for i in range(K):
    print(C[N-K+1][i+1] * C[K-1][i] % devisor)

Measured memory_bytes: 357564
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c-'0'); 
	} 
	while((uint)((c=getchar())-'0')<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

int N, M, T, sum[2005][2005], ud[2005][2005], lr[2005][2005], x, y, xx, yy, res;
char grid[2][2005];

int main()
{
	N=in(), M=in(), T=in();
	Forn(i, N)
		Forn(j, M)
		{
			grid[i&1][j]=getchar();
			while(grid[i&1][j]!='0'&&grid[i&1][j]!='1')
				grid[i&1][j]=getchar();
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(grid[i&1][j]=='1');
			lr[i][j]=lr[i-1][j]+lr[i][j-1]-lr[i-1][j-1]+(grid[i&1][j]=='1'&&grid[i&1][j-1]=='1');
			ud[i][j]=ud[i-1][j]+ud[i][j-1]-ud[i-1][j-1]+(grid[i&1][j]=='1'&&grid[!(i&1)][j]=='1');
		}
	while(T--)
	{
		x=in(), y=in(), xx=in(), yy=in();
		res=sum[xx][yy]-sum[xx][y-1]-sum[x-1][yy]+sum[x-1][y-1];
		res-=lr[xx][yy]-lr[xx][y]-lr[x-1][yy]+lr[x-1][y];
		res-=ud[xx][yy]-ud[xx][y-1]-ud[x][yy]+ud[x][y-1];
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 48896
# DP探索
# dry方式に依りnに依存しない形で書く
# dpを作る
dp = []
dp[0] = 0
for i in 1..100000 do
  dp[i] = Float::INFINITY
  power = 1
  while power <= i
    dp[i] = [dp[i],dp[i-power]+1].min
    power *= 6
  end
  power = 1
  while power <= i
    dp[i] = [dp[i],dp[i-power]+1].min
    power *= 9
  end
end
n = gets.chomp.to_i
puts dp[n]


Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

ll gcd(int a,int b){
  if(b == 0) return a;
  else return gcd(b,a%b);
}

ll lcm(int a,int b){
  return a/gcd(a,b)*b;
}

int is2(int a){
  if(a%2 == 0) return 1+is2(a/2);
  else return 0;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> A(n);
  rep(i,n) cin >> A[i];
  int check2 = is2(A[0]);
  rep(i,n){
    if(is2(A[i]) != check2){
      cout << 0 << endl;
      return 0;
    }
  }
  ll start = 1;
  rep(i,n)start = lcm(start,A[i]/2);
  ll now = start;
  int ans = 0;
  while(now<=m){
    ans ++;
    now += start*2;
  }
  cout << ans << endl;
}


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

int M[101][101];

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

  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<M[i][j];
    }
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll s; cin >> s;
  int n = (int)log10(s)+1;
  ll ans = 0;
  rep(i, 1<<(n-1)) {
    vector<int> v;
    v.push_back(-1);
    rep(j, n-1) if((i>>j)&1) v.push_back(j);
    v.push_back(n-1);
    ll tmp = 0;
    rep(j, v.size()-1) {
      tmp += s/(ll)pow(10, n-1-v[j+1])%(ll)pow(10, (v[j+1]-v[j]));
    }
    ans += tmp;
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 4004
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    s = input()
    N = int(s[-1])
    if N == 3:
        print("bon")
    elif N == 0 or N == 1 or N == 6 or N == 8:
        print("pon")
    else:
        print("hon")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10608
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#include "boost/multiprecision/cpp_int.hpp"
typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////



int main(){fastio
    
    LL x;cin>>x;
    LL y=100;
    ll ans=0;
    while(1){
        ans++;
        y=(y*101)/100;
        if(y>=x){
            cout<<ans<<endl;
            return 0;
        }
        //cout<<ans<<" "<<y<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N;
        string S;
        cin >> N >> S;
        rep(i, S.size())
        {
                S[i] = (S[i] - 'A' + N) % 26 + 'A';
        }

        cout << S << endl;

        return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string s;
	cin >> s;

	string ans = "NO";
	rep(i,s.size() + 1) {
		rep(j, s.size() - i + 1) {
			string t = s.substr(0, i);
			t += s.substr(i + j);
			if (t == "keyence") {
				ans = "YES";
			}
		}
	}
	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a, b;
    char s[10];
    scanf("%d %s %d", &a, s, &b);
    if(s[0] == '+'){
        printf("%d\n", a+b);
        return 0;
    }
    
    else{
          printf("%d\n", a-b);
        return 0;
        }
    

}

Measured memory_bytes: 1700
#include <iostream>
//#include <fstream>
using namespace std;
int ans,n,s;
 
void dfs(int sum,int cnt,int i){
	if(cnt==n&&sum==s){
        ++ans;
        return;
    } else if(cnt==n||i>=10){
        return;
    }
	dfs(sum+i,cnt+1,i+1);
    dfs(sum,cnt,i+1);
};
 
int main(){
    while(cin>>n>>s){
		if(n==0&&s==0){
			break;
		}
        ans=0;
        dfs(0,0,0);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
 using namespace std;
 
 int main()
 {
 	char a,b;
 	cin >> a >> b;
 	if(a=='H'&& b=='H') cout <<'H';
 	if(a=='H' && b=='D') cout << 'D';
 	if(a=='D' && b=='H') cout << 'D';
 	if(a=='D' && b=='D') cout << 'H';
 	
 }


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

using namespace std;

typedef long long ll;
ll n, k, a, b, c, maxim;
struct p { ll a, b, c, s; }V[1005], C[1005];
p D[] = { {1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {1, -1, -1}, {-1, 1, 1}, {-1, 1, -1}, {-1, -1, 1}, {-1, -1, -1} };

bool comp(p a, p b)
{
	return a.s > b.s;
}

void solve(p M[], p c)
{
	for (ll i = 1; i <= n; i++)
	{
		M[i].a *= c.a;
		M[i].b *= c.b;
		M[i].c *= c.c;
		M[i].s = M[i].a + M[i].b + M[i].c;
	}
	sort(M + 1, M + n + 1, comp);
	ll tot = 0;
	for (ll i = 1; i <= k; i++)
		tot += M[i].s;
	if (tot > maxim)
		maxim = tot;

}

int main()
{
	cin >> n >> k;
	for (ll i = 1; i <= n; i++)
		cin >> V[i].a >> V[i].b >> V[i].c;
	for (ll i = 1; i <= n; i++)
		C[i] = V[i];
	for (ll i = 0; i < 8; i++)
	{
		solve(V, D[i]);
		for (ll i = 1; i <= n; i++)
			V[i] = C[i];
	}
	cout << maxim;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define mod (1000000007)
void solve() 
{
    int a,b;cin>>a>>b;cout<<max({a+b,a-b,a*b})<<endl;
}

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

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    int64 sum = accumulate(a.begin(), a.end(), 0L);

    cout << (h<=sum? "Yes" : "No") << endl;
}

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

int main(int argc, char const *argv[])
{
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;++i)cin>>p[i];
    sort(p.begin(),p.end());
    int sum=0;
    for(int i=0;i<n-1;++i)sum+=p[i];
    sum+=p[n-1]/2;
    cout << sum<< endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int max = arr[0];
        int count = 1;

        for (int i = 1; i < n; i++) {
            if (max <= arr[i]) {
                count++;
                max = arr[i];
            }
        }

        System.out.println(count);

    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin>>N>>K;

  int cnt = 0;
  for(int i=1;i<=N;i+=2) cnt++;

  int ans = cnt >= K;
  cout<<(ans? "YES":"NO")<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int N;
int d[300];
long dp[2][301][601];
long fac[601],invfac[601],inv[301];
main()
{
	cin>>N;
	fac[0]=1;
	for(int i=1;i<=2*N;i++)fac[i]=fac[i-1]*i%mod;
	for(int i=0;i<=2*N;i++)invfac[i]=power(fac[i],mod-2);
	for(int i=1;i<=N;i++)inv[i]=power(i,mod-2);
	bool isroop=true;
	for(int i=0;i<N;i++)
	{
		cin>>d[i];
		if(d[i]!=2)isroop=false;
	}
	if(isroop)
	{
		cout<<fac[N-1]*inv[2]%mod<<endl;
		return 0;
	}
	int now=0;
	dp[now][0][0]=1;
	int c2=0;
	for(int i=0;i<N;i++)
	{
		if(d[i]<=2)
		{
			if(d[i]==2)c2++;
			continue;
		}
		for(int j=0;j<=N;j++)for(int k=0;k<=2*N;k++)dp[1-now][j][k]=0;
		for(int j=0;j<N;j++)for(int k=0;k<=2*N;k++)
		{
			if(dp[now][j][k]==0)continue;
			(dp[1-now][j][k]+=dp[now][j][k]*invfac[d[i]-1])%=mod;
			(dp[1-now][j+1][k+d[i]-2]+=dp[now][j][k]*invfac[d[i]-2])%=mod;
		}
		now=1-now;
	}
	for(int i=1;i<=N;i++)for(int j=1;j<=2*N;j++)(dp[now][i][j]*=inv[2])%=mod;
	for(int _=0;_<c2;_++)
	{
		for(int j=0;j<=N;j++)for(int k=0;k<=2*N;k++)dp[1-now][j][k]=0;
		for(int j=1;j<=N;j++)for(int k=1;k<=2*N;k++)
		{
			if(dp[now][j][k]==0)continue;
			(dp[1-now][j][k]+=dp[now][j][k])%=mod;
			(dp[1-now][j+1][k]+=dp[now][j][k])%=mod;
		}
		now=1-now;
	}
	long ans=0;
	for(int i=3;i<N;i++)for(int j=1;j<=2*N;j++)
	{
		(ans+=dp[now][i][j]*fac[N-1-i]%mod*fac[i-1]%mod*j%mod)%=mod;
	}
	cout<<ans<<endl;
}


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

const int N = 1e5 + 5;

int a[N] , pos[N] , b[N] , n , tot;

map<int,int>Map;

int main(void) {
	scanf("%d" , &n);
	for(int i = 1;i <= n;++ i) {
		scanf("%d" , &a[i]);
		b[i] = a[i];
	}
	sort(b + 1 , b + n + 1);
	int ans = 0;
	for(int i = 1;i <= n;++ i) Map[b[i]] = i;
	for(int i = 1;i <= n;++ i) a[i] = Map[a[i]] , pos[a[i]] = i;
	for(int i = 1;i <= n;++ i) tot += abs(a[i] - i) & 1;
	cout << tot / 2 << endl;	
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,m,pos=0;
int a[100005];

std::priority_queue<int> q;

signed main()
{
	int n,m;
	cin>>n>>m;
	for (int i=1;i*i<=m;i++)
	{
		if (m%i==0ll)
		{
			q.push(i);
			q.push(1ll*m/i);
		}
	}
	
	while (!q.empty())
	{
		pos+=1ll;
		a[pos]=q.top();
		q.pop();
	}
	
	for (int i=1ll;i<=pos;i++)
	{
		if ((1ll*m/a[i])>=n)
		{
			cout<<a[i]<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) throws IOException {
        char ans = (char)(receiveChar() + 1);
        println(ans);
        flush();
    }

    // 入出力関連
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);

    enum Delimiter {
        NONE(""), SPACE(" "), DOT("\\."), COMMA(",");

        private String regex;

        private Delimiter(String regex) {
            this.regex = regex;
        }

        public String getRegex() {
            return regex;
        }
    }

    static String receive() throws IOException {
        return br.readLine();
    }

    static int receiveInt() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    static char receiveChar() throws IOException {
        return br.readLine().charAt(0);
    }

    static char[] receiveCharArray() throws IOException {
        return br.readLine().toCharArray();
    }

    static int[] receiveIntArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).mapToInt(Integer::parseInt).toArray();
    }

    static String[] receiveStringArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).toArray(String[]::new);
    }

    static void print(Object obj) {
        pw.print(obj);
    }

    static void println(Object obj) {
        pw.println(obj);
    }

    static void flush() {
        pw.flush();
    }
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

const int N = 100005;

int X[N], Y[N];
bool used[N];
set<pii > sx, sy;
set<pii >::iterator it;
set<pii > s;

void insertX(int x, int id) {
  if(!sx.size()) return;
  it = sx.lower_bound(mp(x, id));
  if(it == sx.end()) {
    pii p = *sx.rbegin();
    s.insert(mp(abs(p.FF - x), p.SS));
    return;
  }
  s.insert(mp(abs((*it).FF - x), (*it).SS));
  if(it == sx.begin()) return;
  it--;
  s.insert(mp(abs((*it).FF - x), (*it).SS));
}

void insertY(int x, int id) {
  if(!sy.size()) return;
  it = sy.lower_bound(mp(x, id));
  if(it == sy.end()) {
    pii p = *sy.rbegin();
    s.insert(mp(abs(p.FF - x), p.SS));
    return;
  }
  s.insert(mp(abs((*it).FF - x), (*it).SS));
  if(it == sy.begin()) return;
  it--;
  s.insert(mp(abs((*it).FF - x), (*it).SS));
}

int main() {
  int n;
  S(n);
  rep(i,0,n) {
    S2(X[i],Y[i]);
    if(i) {
      sx.insert(mp(X[i], i));
      sy.insert(mp(Y[i], i));
    }
  }
  LL ans = 0;
  used[0] = true;
  insertX(X[0], 0);
  insertY(Y[0], 0);
  rep(i,1,n) {
    pii p = *s.begin();
    s.erase(p);
    int x = p.SS;
    if(used[x]) {
      i--;
      continue;
    }
    sx.erase(mp(X[x], x));
    sy.erase(mp(Y[x], x));
    used[x] = true;
    ans += p.FF;
    insertX(X[x], x);
    insertY(Y[x], x);
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int main()
{
    LL A,B,C;
    LL x,y;

    cin >> A >> B >> C >> x >> y;
    int sz = max(x,y);
    LL ans = INF;
    _rep(i,0,2*sz){
        ans = min(ans,max(0LL,(x-i/2))*A + max(0LL,(y-i/2))*B + i * C );
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a > b && b != 1) {
    cout << "Alice" << endl;
  }
  if (a == b) {
    cout << "Draw" << endl;
  }
  if (a < b && a != 1) {
    cout << "Bob" << endl;
  }
  if (a == 1 && a != b) {
    cout << "Alice" << endl;
  }
  if (b == 1 && b != a) {
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 3624
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

// code
// ------------------------------------------------
int main() {

  int n,a;

  cin >> n >> a ;

  if(( a - n) >= 0) cout << "Yes" << endl;
  else
  {
    n = n % 500;
    if((a - n) >= 0) cout  << "Yes" << endl;
    else cout << "No" << endl;
  }
  

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

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

int main(){
  int a,b;
  cin>> a >> b;
  
  vector<int> vec(3);
  vec[0] = a + b;
  vec[1] = a - b;
  vec[2] = a * b;
  
  int ans = vec[0];
  
  if(ans < vec[1]) ans = vec[1];
  if(ans < vec[2]) ans = vec[2];
  
  cout<< ans << endl;
  return 0;
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

const int Max = 100001;
int F[Max];
vector<vector<int>> B(Max);

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};

void solve() {
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind uf(N);

    for (int i = 0; i < Max; i++) F[i] = 0;

    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        F[a]++; F[b]++;
        uf.unite(a, b);
    }
    REP(i, K) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        B[a].push_back(b);
        B[b].push_back(a);
    }

    for (int i = 0; i < N; i++) {
        int a = uf.size(i);
        int f = F[i];
        int b = 0;
        for (int item : B[i]) {
            if (uf.same(i, item)) b++;
        }
        //cout << a << " " << f << " " << b << endl;
        cout << a - 1 - f - b;
        if (i != N-1) cout << " ";
        else cout << endl;
    }

}

signed main() {
    solve();
}


Measured memory_bytes: 6784
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	PRI(a + b / 2);
	return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


# refered to
# rank : http://at274.hatenablog.com/entry/2018/02/02/173000
# size : abc120 kaisetsu
class UnionFind:
    def __init__(self, n):
        # par = Parent Number or NoV
        self.par = [-1] * (n+1)
        # rank = Tree Height
        self.rank = [0] * (n+1)
    
    # Returns the number of sets to which x belongs
    def size(self, x):
        return -1*self.par[self.find(x)]
    
    def size_list(self):
        return [x*(-1) for x in self.par[1:] if x < 0]

    # Returns number if root
    def find(self, x):
        if(self.par[x] < 1):
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    # Are the parents of x and y the same?
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        # find root 
        x = self.find(x)
        y = self.find(y)

        # Already x connect to y
        if(x == y):
            return False

        # Reconnect
        if(self.size(x) < self.size(y)):
            x,y = y,x
        
        # update x size
        self.par[x] += self.par[y]
        # set parent number of y to x
        self.par[y] = x

        return True 
    
    def root_nodes(self):
        return len([i for i in self.par[1:] if i <= -1])
    
    

def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]", D: "List[int]"):
    """graph.input.linkedlist
        input: u[]:start, v[]:end
        output:g[][]
    """
    uf = UnionFind(N)

    g = [[] for i in range(N+1)]
    for i in range(M):
        g[A[i]].append(B[i])
        g[B[i]].append(A[i])
    
    g_b = [[] for i in range(N+1)]
    for i in range(K):
        g_b[C[i]].append(D[i])
        g_b[D[i]].append(C[i])
    

    for i in range(M):
        uf.union(A[i], B[i])

    # for i in range(1, N+1):
    #     print(i, uf.size(i), g[i])

    # 同じ根だったらスキップする
    # ans = [ uf.size(i)-1 - len(g[i])  for i in range(1, N+1)]
    ans = []
    for i in range(1, N+1):
        # print("after: ", i, uf.size(i)-1, len(g[i]), g_b[i], [uf.same_check(i, x) for x in g_b[i]])
        ans.append(uf.size(i)-1 - len(g[i]) - len([x for x in g_b[i] if uf.same_check(i, x) == True]))
        
    print(' '.join(map(str, ans)))
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    C = [int()] * (K)  # type: "List[int]"
    D = [int()] * (K)  # type: "List[int]"
    for i in range(K):
        C[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(N, M, K, A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 55296
#include<iostream>
#include<string>
using namespace std;
int main(){
  string w;
  string t;
  cin >> w;
  int i;
  for(i=0;i<w.size();i++) {
    if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
  }
  int o=0;
  cin >> t;
  while(t!="END_OF_TEXT"){
  
    for(i=0;i<t.size();i++) {
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) o++;
    cin >> t;
  }
  cout << o << endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; ll t; cin >> n >> t;
    VL a(n); cin >> a;
    a.push_back(LLINF);
    ll ans = 0;
    FOR(i, 0, n)ans += min(t, a[i + 1] - a[i]);
    cout << ans << "\n";
}

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

int main(){
   long int N,X,Y;
   cin>>N;
  
   for(long int i=sqrt(N);i>0;i--){
     if(N%i==0){
        X=i;
        Y=N/i;
        break;
     }
   }
   cout<<X+Y-2<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
const int inf = 0x3f3f3f3f;
const ll inff = 0x7ffffffffff;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
//head
const int N = 1000;
int n, ans = 0;
int l[N];
int main() {
	n = read();
	rep(i, 1, n) {
		l[i] = read();
	}
	rep(i, 1, n) {
		rep(j, i + 1, n) {
			rep(k, j + 1, n) {
				if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) {
					if(l[i] > l[j] && l[i] > l[k] && l[k] + l[j] > l[i]) ++ans;
					else if(l[j] > l[i] && l[j] > l[k] && l[k] + l[i] > l[j]) ++ans;
					else if(l[k] > l[j] && l[k] > l[i] && l[i] + l[j] > l[k]) ++ans;
				}
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3748
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int[] height = new int[N];
        for (int i = 0; i < height.length; i++) {
            height[i] = sc.nextInt();
        }

        int[] dp = new int[N]; // min cost to reach the i+1th stone
        dp[0] = 0;
        dp[1] = Math.abs(height[1] - height[0]);
        for (int i = 2; i < N; i++) {
            int one = Math.abs(height[i] - height[i - 1]);
            int two = Math.abs(height[i] - height[i - 2]);
            dp[i] = Math.min(dp[i - 1] + one, dp[i - 2] + two);
        }
        out.println(dp[N - 1]);
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

        double nextDouble() throws IOException { return Double.parseDouble(next()); }

        int nextInt() throws IOException { return Integer.parseInt(next()); }

        long nextLong() throws IOException { return Long.parseLong(next()); }
    }
}

Measured memory_bytes: 31876
import sys

CharToSign = {
    "A": "00000", "B": "00001", "C": "00010", "D": "00011",
    "E": "00100", "F": "00101", "G": "00110", "H": "00111",
    "I": "01000", "J": "01001", "K": "01010", "L": "01011",
    "M": "01100", "N": "01101", "O": "01110", "P": "01111",
    "Q": "10000", "R": "10001", "S": "10010", "T": "10011",
    "U": "10100", "V": "10101", "W": "10110", "X": "10111",
    "Y": "11000", "Z": "11001", " ": "11010", ".": "11011",
    ",": "11100", "-": "11101", "'": "11110", "?": "11111",
}
SignToChar = {
    "101": " ", "000000": "'", "000011": ",", "10010001": "-",
    "010001": ".", "000001": "?", "100101": "A", "10011010": "B",
    "0101": "C", "0001": "D", "110": "E", "01001": "F",
    "10011011": "G", "010000": "H", "0111": "I", "10011000": "J",
    "0110": "K", "00100": "L", "10011001": "M", "10011110": "N",
    "00101": "O", "111": "P", "10011111": "Q", "1000": "R",
    "00110": "S", "00111": "T", "10011100": "U", "10011101": "V",
    "000010": "W", "10010010": "X", "10010011": "Y", "10010000": "Z",
}

for line in sys.stdin:
    line = line[:-1]

    sign = ""
    for char in line:
        sign += CharToSign[char]

    string = ""
    part = ""

    for item in sign:
        part += item

        if part in SignToChar:
            string += SignToChar[part]
            part = ""

    print(string)



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

int main(){
  int n, m;
  int a[50], b[50];
  int num[51] = {};
  cin >> n >> m;
  for(int i = 0; i < m; ++i ){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; ++i){
    num[a[i]]++;
    num[b[i]]++;
  }
  for(int i = 1; i <= n; ++i ){
    cout << num[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int A,B;

int main(){
  cin >> A >> B;
  if(A >= 13) cout << B << endl;
  else if (A >= 6) cout << B/2 << endl;
  else cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<bool> vecbool;
typedef vector<vector<int>> vec2int;
typedef pair<int, int> P;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

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

int main()
{
    string t;
    cin >> t;
    
    rep(i, 0, t.size()){
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}


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

#define ll long long
#define N 200010
int n, a[N];
ll f[N][5];

int main()
{
    while (scanf("%d", &n) != EOF)
    {
        for (int i = 1; i <= n; ++i) scanf("%d", a + i);
        memset(f, 0x3f, sizeof f);
        for (int i = 0; i < 5; ++i) f[0][i] = 0;
        for (int i = 1; i <= n; ++i)
        {
            ll Min = (ll)1e18, cost;
            cost = a[i];
            Min = min(Min, f[i - 1][0]);
            f[i][0] = Min + cost;
            
            cost = a[i] == 0 ? 2 : (a[i] % 2);
            Min = min(Min, f[i - 1][1]);
            f[i][1] = Min + cost;

            cost = a[i] == 0 ? 1 : (a[i] % 2 == 0);
            Min = min(Min, f[i - 1][2]);
            f[i][2] = Min + cost;
            
            cost = a[i] == 0 ? 2 : (a[i] % 2);
            Min = min(Min, f[i - 1][3]);
            f[i][3] = Min + cost;

            cost = a[i];
            Min = min(Min, f[i - 1][4]);
            f[i][4] = Min + cost;
        }
        ll res = (ll)1e18;
        for (int i = 0; i < 5; ++i)
            res = min(res, f[n][i]);
        printf("%lld\n", res);
    }
    return 0;
}

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

using namespace std;

using ll= long long;

#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define PI  3.14159265358979323846264338327950L

const int maxN= 1e5+2;
vector<int> g[maxN];
bool vis[maxN];
int n,m;
int ans[maxN];
void bfs(int node){
    queue<int> q;
    vis[node]=1;
    q.push(node);
    while(!q.empty()){
        int from = q.front();
        q.pop();
        for(auto v: g[from]){
            if(!vis[v]){
                vis[v]=1;
                ans[v]=from;
                q.push(v);
            }
        }
    }
}
void solve(){
    cin>>n>>m;
    int u,v;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    bfs(1);
    bool ok= true;
    for(int i=2;i<=n;i++){
        if(!ans[i]){
            ok=false;
        }
    }
    if(ok){
        cout<<"Yes\n";
        for(int i=2;i<=n;i++){
            cout<<ans[i]<<"\n";
        }
    }else{
        cout<<"No\n";
    }
}

int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	while(_--){
        solve();
    }
	return 0;
}

/*
   check for overflows int long long
   correct size of array
*/

Measured memory_bytes: 10648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int a, b, c; cin >> a >> b >> c; cout << a + b + c << endl;
	return 0;
}


Measured memory_bytes: 3168