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

class Dice{
public:
    int face[7];
    int nowFace;

    int center;
    int top;
    int bottom;
    int left;
    int right;

    Dice(int num[]){
        for(int i = 1; i <= 6; i++){
            face[i] = num[i];
        }
        // nowFace = face[0];

        center = 1;
        top = 5;
        bottom = 2;
        left = 4;
        right = 3;
    }

    void move(char command){
        switch(command){
            case 'E':
                top = top; // 変化せず
                bottom = bottom; // 変化せず
                right = center;
                center = left;
                left = 7 - right;
                // printDebug();
                break;
            case 'N':
                left = left; // 変化せず
                right = right; // 変化せず
                top = center;
                center = bottom;
                bottom = 7 - top;
                // printDebug();
                break;
            case 'S':
                left = left; // 変化せず
                right = right; // 変化せず
                bottom = center;
                center = top;
                top = 7 - bottom;
                // printDebug();
                break;
            case 'W':
                top = top; // 変化せず
                bottom = bottom; // 変化せず
                left = center;
                center = right;
                right = 7 - left;
                // printDebug();
                break;
        }
    }

    void printDebug(){
        cout << "center: " << center << endl;
        cout << "top: " <<  top << endl;        
        cout << "bottom: " <<  bottom << endl;        
        cout << "left: " <<  left << endl;        
        cout << "right: " <<  right << endl;        
    }

    void print(){
        cout << face[center] << endl;
    }
};

int main(){
    
    int face[6];
    int num;
    for(int i = 1; i <= 6; i++){
        cin >> num;
        // cout << num << endl;
        face[i] = num;
    }

    Dice dice(face);

    char commands[100];
    cin >> commands;
    for(int i = 0; i < strlen(commands); i++){
        // cout << commands[i] << endl;
        dice.move(commands[i]);
    }

    dice.print();

    return 0;
}


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

using namespace std;

int main()
{
    int n,sum=0;
    cin>>n;
    int temp=n;
    while(n!=0){
        sum+=n%10;
        n=n/10;
    }
    if(temp%sum==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    double d;
    cin >> d;

    const double PI=3.14159265358979323846;

    cout << 2.0 * d * PI << endl;

    return 0;
}



Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, k, s;
  cin >> n >> k >> s;

  vector<ll> ans;
  for(ll i = 0; i < k; i++){
    ans.pb(s);
  }
  for(ll i = 0; i < n-k+1; i++){
    if(s == 1000000000) ans.pb(1);
    else ans.pb(1000000000);
  }

  for(ll i = 0; i < n; i++){
    cout << ans[i] << (i == n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 2292
p,q,r=map(int,input().split())

m1=p;
m1=min(m1,q)
m1=min(m1,r)
if(m1==p):
        m2=min(q,r)
elif(m1==q):
        m2=min(p,r)
else:
        m2=min(p,q)

print(m1+m2)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define N 50000+10

using namespace std;

typedef long long ll;

int main()
{
    int t,x;
    scanf("%d%d",&x,&t);
    if(x>t)
        printf("%d\n",x-t);
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
using namespace std;

const double pi = acos(-1);

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int R;
    cin >> R;

    cout.precision(10);
    cout << fixed << 2.0*pi*R << "\n";

    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;

int main() {
  int A,B;
  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 <iostream>
using namespace std;

int main() {
    string S;
    cin >> S;

    bool used[26] = { false };
    for (char ch : S) {
        used[ch - 'a'] = true;
    }

    for (char ch = 'a'; ch <= 'z'; ch++) {
        if (not used[ch - 'a']) {
            cout << S << ch << endl;
            return 0;
        }
    }

    if (S == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    string ans = string(26, 'z' + 1);
    for (int i = S.size() - 1; i >= 0; i--) {
        used[S[i] - 'a'] = false;
        string str = S.substr(0, i);

        for (char ch = 'a'; ch <= 'z'; ch++) {
            if (not used[ch - 'a'] and ch > S[i]) {
                ans = min(ans, str + ch);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
	int n, ans = 0;
	vector<int> input, sorted;

	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		input.emplace_back();
		cin >> input.back();
	}

	sorted = input;

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

	for (int i = 0; i < input.size(); ++i)
		if (input[i] != sorted[i])
			++ans;

	cout << (ans <= 2 ? "YES\n" : "NO\n");

	return 0;
}

Measured memory_bytes: 256
n = int(input())

count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    count[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, count[b][f])))
    if b != 3:
        print("####################")


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	int a;
	cin >> a;
	cout << a + pow(a, 2) + pow(a, 3);
}

Measured memory_bytes: 4132
n = int(raw_input())

d = [0]*5

for a in range(n):
  s = raw_input()
  if s[0] == "M":
    d[0] += 1
  elif s[0] == "A":
    d[1] += 1
  elif s[0] == "R":
    d[2] += 1
  elif s[0] == "C":
    d[3] += 1
  elif s[0] == "H":
    d[4] += 1

ans = 0
for a in range(0,3):
  for b in range(a+1,4):
    for c in range(b+1,5):
      ans += d[a]*d[b]*d[c]
print ans


Measured memory_bytes: 5764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string a1="abcdefghijklmnopqrstuvwxyz";
string a2[]={"ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw","ts"};
string s[1001];
int ans[38][38];
int main(){
    int n;
    int sz=12;
    cin>>n;
    cin.ignore();
    rep(i,n) getline(cin,s[i]);
    rep(i,n){
        int m=s[i].size();
        s[i]+=' ';
        rep(j,m-1){
            if(s[i][j]==' ') continue;
            bool flag1=false;
            if(j<m-2){
                rep(k,sz){
                    if(s[i][j]==a2[k][0]&&s[i][j+1]==a2[k][1]){
                        bool flag2=false;
                        flag1=true;
                        if(s[i][j+2]!=' '){
                            if(j<m-2){
                                rep(l,sz){
                                    if(s[i][j+2]==a2[l][0]&&s[i][j+3]==a2[l][1]){
                                        ++ans[k+26][l+26];flag2=true;
                                        break;
                                    }
                                }
                            }
                            if(!flag2){
                                rep(l,26){
                                    if(s[i][j+2]==a1[l]){
                                        ++ans[k+26][l];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if(flag1) break;
                }
            }
            if(flag1){++j;continue;}
            if(!flag1){
                rep(k,26){
                    if(s[i][j]==a1[k]){
                        if(s[i][j+1]!=' '){
                            bool flag2=false;
                            if(j<m-1){
                                rep(l,sz){
                                    if(s[i][j+1]==a2[l][0]&&s[i][j+2]==a2[l][1]){
                                        ++ans[k][l+26];flag2=true;flag1=true;
                                        break;
                                    }
                                }
                            }
                            if(!flag2){
                                rep(l,26){
                                    if(s[i][j+1]==a1[l]){
                                        ++ans[k][l];flag1=true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if(flag1) break;
                }
            }
        }
    }
    rep(i,38){
        int mx=0,cur=0;
        rep(j,38){
            if(mx<ans[i][j]) mx=ans[i][j],cur=j;
        }
        string fst,snd;
        if(i>=26) fst+=a2[i-26];
        else fst+=a1[i];
        if(cur>=26) snd+=a2[cur-26];
        else snd+=a1[cur];
        cout<<fst<<" "<<snd<<" "<<mx<<endl;
    }
    return 0;
}


Measured memory_bytes: 3280
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if(s.length() % 2 != 0) {
			System.out.println("No");
			return;
		}

		for(int i=0; i<s.length(); i+=2) {
			if(!s.substring(i, i+2).equals("hi")) {
				System.out.println("No");
				return;
			}
		}


		System.out.println("Yes");
	}

}


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

using namespace std;

int main(){
  int k,x; cin >> k >> x;
  int m=max(-1000000,x-k+1);
  int M=min(1000000,x+k-1);
  for(int i=m;i<M;i++){
    cout << i << " ";
  }
  cout << M << endl;
}


Measured memory_bytes: 256
using System;

namespace aizu
{
    class OnlineJudge
    {
        const int Max = 1000000;
        static void Main()
        {
            bool[] check = new bool[Max];
            int[] prime = new int[Max];
            for(int i=2; i < Max; ++i) {
                prime[i] = prime[i - 1];
                if(!check[i]) {
                    ++prime[i];
                    for(int l = 2; i * l < Max; ++l) {
                        check[l * i] = true;
                    }
                }
            }
            string num;
            while((num = Console.ReadLine()) != null) {
                Console.WriteLine(prime[int.Parse(num)]);
            }
        }
    }
}

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

int main(void) {
    int N, M;
    cin >> N >> M;
    int H[100010];
    for (int i=1; i<=N; i++) {
        cin >> H[i];
    }
    int R[100010] = {0};

    for (int j=0; j<M; j++) {
        int a, b;
        cin >> a;
        cin >> b;
        if (H[a] >= H[b]) R[b] = 1;
        if (H[a] <= H[b]) R[a] = 1;
    }

    int cnt = 0;
    for (int i=1; i<=N; i++) {
        if (R[i] == 0) cnt++;
    }

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



Measured memory_bytes: 4372
// 2014/04/18 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int b1, b2, b3;
	cin >> b1 >> b2 >> b3;

	if((b1==1 && b2==1 && b3==0) || (b1==0 && b2==0 && b3==1)){
		cout << "Open" << endl;
	}
	else{
		cout << "Close" << endl;
	}

	return 0;
}

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

using namespace std;

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

    string s;
    cin >> s;

    if (s.find("C") != string::npos && s.find('F', s.find('C') + 1) != string::npos) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 384
// UnionFind木
#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 2e5+5;
const int K = 1e5+5;
string s;
vector<int> v[N];
int n, k, l;

class UnionFind {
  int par[N]; // 親
  int rank[N]; // 木の深さ
  unsigned size_;
public:
  void init(int n) {
    for (int i=0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  unsigned size() {return size_;}
  // 木の根を求める
  int find(int x) {
    if(par[x] == x) {
     return x;
    } else {
     return par[x] = find(par[x]);
    }
  }
  // xとyの属する集合を併合
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }
  // xとyが同じ集合に属するかいなか
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int p, a, c[K], result[K];
P b[K];
map<P, int> m;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k >> l;
  UnionFind uf, train;
  uf.init(n);
  train.init(n);
  rep(i,k) {
    cin >> p >> a;
    uf.unite(p-1, a-1);
  }
  rep(i,l) {
    cin >> p >> a;
    train.unite(p-1,a-1);
  }

  rep(i,n) {
    m[P(uf.find(i), train.find(i))]++;
  }

  rep(i,n) cout << m[P(uf.find(i), train.find(i))] << " ";
  br();
}


Measured memory_bytes: 19968
#include <bits/stdc++.h>
typedef long long ll;
#define loop(n) for (ll i = 0; i < n; i++)
#define loopy(n) for (ll j = 0; j < n; j++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define oo 1e18
#define fr first
#define se second
#define in(x) scanf("%d",&x)
using namespace std;
const int N = 2e4 + 10;
const int M = 1e7 + 10;
const ll mod = 1e9 + 7;
char temp[N] ; 
string a[N] ;
int ans[(int)2e5] ; 
int main(){ 
    int a, b ; cin >> a >> b ; 
    if(a <= 5 ) 
        cout<<"0"<<endl ; 
    else if ( a >= 6 && a <= 12 )
        cout<<(b/2)<<endl ;
    else 
        cout<<b<<endl ;  


    return 0;
}
 

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import java.util.function.IntPredicate;


public class Main {
	
	int N;
	int[] A;
	long div = 1000000007;
	public void solve() {
		N = nextInt();
		A = new int[N];
		for(int i = 0; i < N; i++){
			A[nextInt()]++;
		}
		if(N % 2 == 0){
			for(int i = 0; i < N; i+=2){
				if(A[i] != 0 || A[i + 1] != 2){
					out.println(0);
					return;
				}
			}
			out.println(pow(N / 2));
		}else{
			if(A[0] != 1){
				out.println(0);
				return;
			}else{
				for(int i = 1; i < N; i+=2){
					if(A[i] != 0 || A[i + 1] != 2){
						out.println(0);
						return;
					}
				}
				out.println(pow(N / 2));
			}
		}
	}
	
	public long pow(long n){
	    long sum = 1;
	    long x = 2;
	    while (n > 0) {
	        if ((n & 1) == 1) {
	            sum *= x;
	            sum %= div;
	        }
	        x *= x;
	        x %= div;
	        n >>= 1;
	    }
	    return sum;
	}

	private static PrintWriter out;

	public static void main(String[] args) {
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}

	public static int nextInt() {
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if (str.charAt(0) == '-') {
			minus = true;
			i++;
		}
		int len = str.length();
		for (; i < len; i++) {
			char c = str.charAt(i);
			if (!('0' <= c && c <= '9'))
				throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}

	public static long nextLong() {
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if (str.charAt(0) == '-') {
			minus = true;
			i++;
		}
		int len = str.length();
		for (; i < len; i++) {
			char c = str.charAt(i);
			if (!('0' <= c && c <= '9'))
				throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	public static String next() {
		int c;
		while (!isAlNum(c = read())) {
		}
		StringBuilder build = new StringBuilder();
		build.append((char) c);
		while (isAlNum(c = read())) {
			build.append((char) c);
		}
		return build.toString();
	}

	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;

	private static int read() {
		if (bufferLength < 0)
			throw new RuntimeException();
		if (bufferIndex >= bufferLength) {
			try {
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			if (bufferLength <= 0)
				return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}

	private static boolean isAlNum(int c) {
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 21868
#include<bits/stdc++.h>
#define __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

double c=380000;

int main()
{ __;

    int n;
    string s;
    cin>>n;
    double a,ans=0.0;
    while(n--)
    {
        cin>>a>>s;
        if(s=="BTC"){
            ans+=(a*c);
        }
        else ans+=a;
    }
    cout<<ans<<endl;


    return 0;
}


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

int main() {
  
  int n, m, x;
  cin >> n >> m >> x;
  
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  
  int ans = 2000000;
  int all = 1<<n;
  
  for (int k = 0; k < all; k++) {
    int cost = 0;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
      if ((k>>i)&1) {
        cost += c[i];
        for (int j = 0; j < m; j++) {
          l[j] += a[i][j];
        }
      }
    }
    bool answer = true;
    for (int j = 0; j < m; j++) {
      if(l[j] < x ) answer = false;
    }
    if (answer) ans = min(ans, cost);
  }
  
  if (ans == 2000000) cout << -1 << endl;
  else cout << ans << endl;
  
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int N;
	string S;
	int Q;
	int k[76];
	scanf("%d",&N);
	cin >> S;
	scanf("%d",&Q);
	for(int i = 0 ; i < Q ; i++){
		scanf("%d",&k[i]);
	}
	
	for(int testcase = 0 ; testcase < Q ; testcase ++){
		int K = k[testcase];
		int r = 0;
		long long cnt_m = 0;
		long long cnt_c = 0;
		long long cnt_mc = 0;
		long long ret = 0;
		for(int loc = 0 ; loc < N ; loc ++){
			while(r < N && r < loc+K){
				if(S[r] == 'M'){
					cnt_m ++;
				}
				else if(S[r] == 'C'){
					cnt_c ++;
					cnt_mc += cnt_m;
				}
				r ++;
			}
			if(S[loc] == 'D')ret += cnt_mc;
			else if(S[loc] == 'M'){
				cnt_m --;
				cnt_mc -= cnt_c;
			}
			else if(S[loc] == 'C'){
				cnt_c --;
			}
			//cout << loc << " " << cnt_m << " " << cnt_c << " " << cnt_mc << " " << ret << endl;
		}
		cout << ret << endl;
	}
}


Measured memory_bytes: 1412
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define foi(i, a, n) for (i = (a); i < (n); ++i)
#define foii(i, a, n) for (i = (a); i <= (n); ++i)
#define fod(i, a, n) for (i = (a); i > (n); --i)
#define fodd(i, a, n) for (i = (a); i >= (n); --i)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
#define l long int
#define d double
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vll>
//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define mii map<int, int>
#define mll map<long long, long long>
#define pii pair<int, int>
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;
// ll ans = 0, c = 0;
// ll i, j;
// ll a, b;
// ll x, y;




int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif

    cin>>n>>k;
    vll height(n, 0);
    rep(i, 0, n) cin>>height[i];
    vll step;
    rep(i, 1, k+1) step.pb(i);
    vll dp(n, INT_MAX);
    dp[0] = 0;
    rep(i, 0, n) {
        rep(j, 0, sz(step)) {
            if(i - step[j] >= 0) {
                dp[i] = min(dp[i], abs(height[i] - height[i-step[j]])  + dp[i-step[j]]);
            }
        }
    }
    cout<<dp[n-1];

    return 0;
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   string s, v;
   int cnt = 0, ans = 0, a, b, n;

   cin >> n;
   n = n * n;
   cout << n << '\n';
}

Measured memory_bytes: 256
#ABC084-B
a,b = map(int,input().split())
s = input()

mae = s[:a]
usiro = s[a+1:a+b+1]
#print(mae)
#print(usiro)
if mae.isdecimal() and usiro.isdecimal() and s[a] == '-':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int n,i,Max=0,Min=10000000000;
    int a[1000]={0};
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>Max)
            Max=a[i];
        if(a[i]<Min)
            Min=a[i];
    }
    cout<<Max-Min<<endl;
    return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string S;
    cin >> S;
    bool ok = true;
    if (S[0] != 'A') ok = false;
    int count = 0;
    FOR(i, 2, S.length() - 1) {
        if (S[i] == 'C') count++;
    }
    ok &= count == 1;
    count = 0;
    REP(i, S.length()) {
        if (islower(S[i])) count++;
    }
    ok &= count == S.length() - 2;

    if (ok) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var n = input[0];
            var x = input[1];
            var arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var count = 1;
            var d = 0;
            foreach (var l in arr)
            {
                d += l;
                if (d > x)
                {
                    break;
                }

                count++;
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

int n, a[120], b[120];

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    int cont = 0, pasos = 0;
    while(cont != n){
        bool f = false;
        cont =0;
        for(int i=0; i<n; i++){
            if(b[i] != a[i] && !f){
                b[i] ++;
                f = true;
                pasos ++;
            } else if(b[i] == a[i] && f){
                f = false;
                cont ++;
            } else if(b[i] == a[i] && !f){ cont++;}
              else if(b[i] != a[i] && f){
                b[i]++;
            }
        }
    }
    printf("%d\n", pasos);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static final boolean debugMode = false;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = readInt(sc);
		int n = readInt(sc);
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = readInt(sc);

		}

		int max = 0;
		for (int i = 0; i < n - 1; i++) {
			max = Math.max(max, a[i + 1] - a[i]);
		}

		max = Math.max(max, k - a[n - 1] + a[0]);

		System.out.println(k - max);
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}

Measured memory_bytes: 61696
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	nQueries := nextInt()
	m := map[string]int{}
	for iQuery := 0; iQuery < nQueries; iQuery++ {
		queryType := nextInt()
		key := nextString()
		if queryType == 0 {
			x := nextInt()
			m[key] = x
		} else if queryType == 1 {
			v, ok := m[key]
			if ok {
				fmt.Println(v)
			} else {
				fmt.Println(0)
			}
		} else if queryType == 2 {
			delete(m, key)
		}
	}
}



Measured memory_bytes: 18900
/*********************************************
* 20.05.19 AtCoder Beginner Contest 153
* 
* 
*********************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define et "\n"

class CRun{
private:
    struct {
    }gv;
public:
    char problem_num;
    
    CRun(){
        problem_num = 'A';
    }; 
    ~CRun(){};
    void build();
    void solve_A(); void solve_B(); void solve_C(); 
    void solve_D(); void solve_E(); void solve_F();
};

void CRun::build(){
    
}

/*********************************************
A - Serval vs Monster
敵の体力H
味方の攻撃1回で体力をA減らせる
勝つための攻撃回数は？
*********************************************/
void CRun::solve_A(){
    int H; cin >> H;
    int A; cin >> A;
    
    int ans = 0;
    ans += (H % A > 0 ? H / A + 1 : H / A);
    cout << ans;
}

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

*********************************************/
void CRun::solve_B(){
    
}

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

*********************************************/
void CRun::solve_C(){
    
}

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

*********************************************/
void CRun::solve_D(){
    
}

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

*********************************************/
void CRun::solve_E(){
    
}

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

*********************************************/
void CRun::solve_F(){
    
}

int main(){
    CRun run;
    run.build();
    switch (run.problem_num) {
        case 'A' : run.solve_A();
        case 'B' : run.solve_B();
        case 'C' : run.solve_C();
        case 'D' : run.solve_E();
        case 'E' : run.solve_D();
        case 'F' : run.solve_F();
    }
}



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


int main () {
  int y, m, d;
  char c1, c2;
  cin >> y >> c1 >> m >> c2 >> d;
  cout << (m <= 4 ? "Heisei" : "TBD") << endl;
}


Measured memory_bytes: 3596
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<6000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> {
        val m = readInt; isPrime(m)
      }
    })
  }
}

Measured memory_bytes: 66856
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL n, k, ans = 0;
	cin >> n >> k;
	for (LL b = k + 1; b <= n; ++b) {
		LL c = n / b;
		ans += (b - k) * c;
		LL r = n % b;
		if (r >= k) {
			ans += k ? (r - k + 1) : r;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define pb push_back
using namespace std;

int A,B,K;
vector<int> a,b;

int rec(int p,int t,int B,vector<int> c){
  if(p==a.size()){
    int res = 0;
    int k = 1;
    for(int i=0;i<(int)c.size();i++){
      res += k*c[i];
      k *= 10;
    }
    return res;
  }

  int res = 0;

  if(a[p]-B>=b[p]){
    c.pb(a[p]-B-b[p]);
    B = 0;
  }else{
    c.pb(a[p]-B-b[p]+10);
    B = 1;
  }

  if(t<K && B==1){
    res = max(res,rec(p+1,t+1,0,c));
  }
  res = max(res,rec(p+1,t,B,c));
  return res;
}

int main(){

  cin >> A >> B >> K;

  while(A>0){
    a.pb(A%10);
    A/=10;
  }

  while(B>0){
    b.pb(B%10);
    B/=10;
  }
  while(b.size()<a.size())b.pb(0);

  vector<int> c;
  cout << rec(0,0,0,c) << endl;
}

Measured memory_bytes: 0
N, M, X = list(map(int, input().split()))

A = list(map(int, input().split()))

flg = 0
costA = 0
costB = 0

for i in range(N+2):
    if i == X:
        flg = 1
    elif i in A:
        if flg == 0:
            costA += 1
        else:
            costB += 1
            

if costA > costB:
    print(costB)
else:
    print(costA)

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

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things. 
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

#define MAXN 100001
ll tot[MAXN];

int main(){
	
	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;

    ll arr[n];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
        tot[arr[i]]++;
    }

    ll q;
    cin>>q;

    ll b,c,bcount;
    while(q--){
        cin>>b>>c;
        bcount=tot[b];
        sum-=b*bcount;
        sum+=c*bcount;
        tot[b]=0;
        tot[c]+=bcount;
        cout<<sum<<endl;
    }

}

Measured memory_bytes: 5216
x = gets.to_i
a = [100, 101, 102, 103, 104, 105]
dp = Array.new(101000, 0)
dp[0] = 1
100010.times do |i|
  a.each do |c|
    # next if i - c < 0
    dp[i + c] = 1 if dp[i] == 1
    # p i if dp[i] == true
  end
end

p dp[x]
# pp dp
# p dp[0..x]

Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int K; cin >> K;
  
  unordered_map<int,int> ss;
  int k = 7;
  k %= K;
  int s = 7;
  s %= K;
  ss[s]++;
  int ans = 1;
  
  while(true) {
    if(s%K == 0) {
      cout << ans << endl;
      return 0;
    }
    k *= 10;
    k %= K;
    s += k;
    s %= K;
    ans++;
    if(ss[s] > 0) {
      cout << -1 << endl;
      return 0;
    } else ss[s]++;
  }

}

Measured memory_bytes: 42604
MOD = 10 ** 9 + 7

def solve(N, K, A):
    A.sort()
    ans = 0
 
    for i in range(1, N):
        now = cmb(i, K - 1, MOD)
        ans += A[i] * now
 
    A.sort(reverse=True)
    for i in range(1, N):
        now = cmb(i, K - 1, MOD)
        ans += A[i] * (-now)
 
    return ans % MOD
 
 
# N = int(input())
# S = input()
N, K = map(int, input().split())
A = list(map(int, input().split()))

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


print(solve(N, K, A))


Measured memory_bytes: 20180
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

const int MAXN = 1e5 + 10;
int h[MAXN];
bitset<MAXN> mark;

int32_t main () {
  hellcat;

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < n; ++i)
		cin >> h[i];

	int ans = n;
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		if (h[u] > h[v] && !mark[v]) {
			mark[v] = true;
			ans--;
		} else if (h[v] > h[u] && !mark[u]) {
			mark[u] = true;
			ans--;
		} else if (h[v] == h[u]) {
			if (!mark[u])
				ans--;
			if (!mark[v])
				ans--;
			mark[u] = true;
			mark[v] = true;
		}
	}

	cout << ans << '\n';

	return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    REP(i, (s.length()+1)/4)
    {
        if(!(s[i]==s[s.length()/2-1-i]&&
        s[s.length()-1-i]==s[s.length()/2+1+i]&&
        s[i]==s[s.length()/2+1+i])){
            ans="No";
            break;
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    
    if(a + b >= 10)
    {
        cout << "error" << endl;
    }
    else
    {
        cout << a + b << endl;
    }
    
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main() {
	int w, a, b;
	cin >> w >> a >> b;
	int ans = min(b - a + w, a - b + w);
	if (b <= a + w && a <= b + w) {
		ans = 0;
	}
	cout << abs(ans) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<ll,pair<ll,ll>>;
#define MAX 1000000
#define MOD 998244353
#define INF 1000000000000000000

int main(){
  int N,Q;
  cin>>N>>Q;
  fenwick_tree<ll> tree(N);
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    tree.add(i,a);
  }
  for(int i=0;i<Q;i++){
    ll q,l,r;
    cin>>q>>l>>r;
    if(q==0){
      tree.add(l,r);
    }else{
      cout<<tree.sum(l,r)<<endl;
    }
  }
}


Measured memory_bytes: 8224
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[100];
int main()
{
  ll n;
  scanf("%lld", &n);
  a[0] = 2, a[1] = 1;
  for (int i = 2; i <= n; i++)
  {
    a[i] = a[i - 1] + a[i - 2];
  }
  printf("%lld\n", a[n]);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
ll dp[2][2][100];
ll mod=1e9+7;ll d;
ll mo(ll x)
{
    if(x>=0)
    return(x%d);
    else
    return(x%d+d)%d;
}
int main()
{
    flash
    string s;
    cin>>s;ll n=s.size();ll a[n];
    for(ll i=0;i<n;i++)
    {
        a[i]=s[i]-'0';
    }
cin>>d;
  dp[1][0][0] = 1;dp[1][1][0] = 1;
 
    for(ll i = n-1; i >=0 ; i--) {
        for(ll state = 0; state < 2 ; state++) {
            for(ll sum = 0; sum < d; sum++) {
                if(state) {
                    for(ll x = 0; x <= a[i] ; x++) {
                        dp[0][1][sum] += (x== a[i]) ? dp[1][1][mo(sum-x)]%mod:dp[1][0][mo(sum-x)]%mod;
                    }
                }
                else {
                    for(ll x = 0; x < 10 ; x++) {
                        dp[0][0][sum] += dp[1][0][mo(sum-x)]%mod;
                    }
                }
            }
          }
          if(i!=0)
          {
         for(ll sum=0;sum<d;sum++)
            {
                dp[1][1][sum]=dp[0][1][sum];
                dp[1][0][sum]=dp[0][0][sum];
                dp[0][1][sum]=0;
                dp[0][0][sum]=0;
            }
          }
    }
    dp[0][1][0]--;
    if(dp[0][1][0]==-1)
    dp[0][1][0]=mod-1;
    dp[0][1][0]=dp[0][1][0]%mod;
    cout<<dp[0][1][0]<<endl;
}

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

string S;

int main() {
    cin >> S;

    char T[3];
    rep(i, 3) {
        T[i] = S[i];
    }

    sort(T, T + 3);

    string target;
    rep(i, 3) {
        target += T[i];
    }
    if (target == "abc") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin>>S;
  int count = 0;
  int ans = 0;
  for(int i = 0; i<N; i++){
      if(S[i] == 'I'){
          count++;
      }
      else{
          count--;
      }
      ans = max(ans,count);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice dice = new Dice();
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		int x6 = sc.nextInt();
		String temp = sc.next();
		dice.setSurf(x1, x2, x3, x4, x5, x6);
		char order[] = temp.toCharArray();
		for (int i = 0; i < order.length; i++) {
			if (order[i] == 'N')
				dice.rollN();
			else if (order[i] == 'S')
				dice.rollS();
			else if (order[i] == 'E')
				dice.rollE();
			else if (order[i] == 'W')
				dice.rollW();
		}
		System.out.println(dice.getSurf1());
	}
}

class Dice {
	private int surf1;
	private int surf2;
	private int surf3;
	private int surf4;
	private int surf5;
	private int surf6;
	private int upper;

	public int getSurf1() {
		return surf1;
	}

	public int getSurf2() {
		return surf2;
	}

	public int getSurf3() {
		return surf3;
	}

	public int getSurf4() {
		return surf4;
	}

	public int getSurf5() {
		return surf5;
	}

	public int getSurf6() {
		return surf6;
	}

	public void setSurf(int surf1, int surf2, int surf3, int surf4, int surf5, int surf6) {
		this.surf1 = surf1;
		this.surf2 = surf2;
		this.surf3 = surf3;
		this.surf4 = surf4;
		this.surf5 = surf5;
		this.surf6 = surf6;
	}

	public void rollN() {
		this.upper = this.surf2;
		this.surf2 = this.surf6;
		this.surf6 = this.surf5;
		this.surf5 = this.surf1;
		this.surf1 = this.upper;
	}

	public void rollS() {
		this.upper = this.surf5;
		this.surf5 = this.surf6;
		this.surf6 = this.surf2;
		this.surf2 = this.surf1;
		this.surf1 = this.upper;
	}

	public void rollE() {
		this.upper = this.surf4;
		this.surf4 = this.surf6;
		this.surf6 = this.surf3;
		this.surf3 = this.surf1;
		this.surf1 = this.upper;
	}

	public void rollW() {
		this.upper = this.surf3;
		this.surf3 = this.surf6;
		this.surf6 = this.surf4;
		this.surf4 = this.surf1;
		this.surf1 = this.upper;
	}
}


Measured memory_bytes: 26404
#include <iostream>
using namespace std;
int main () {
    int n, m, x, count1 = 0, count2 = 0;
    cin >> n >> m >> x;
    int a[m];
    for (int i = 1; i <= m; i++)    {
        cin >> a[i];
    }
    for (int i = 1; i <= m; i++)    {
        for (int j = x; j <= n; j++)    {
            if (a[i] == j)  count1++;
        }
    }
    for (int i = 1; i <= m; i++)    {
        for (int j = x; j >= 0; j--)    {
            if (a[i] == j)  count2++;
        }
    }
    if (count1 > count2)    cout << count2;
    else    cout << count1;
    return 0;
}

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

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		Arrays.sort(L);
		int max = L[N-1];
		int sum = 0;
		for (int i = 0; i < N-1; i++) {
			sum += L[i];
		}
		if (sum <= max) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(void) {
    int x, y, r; // x > yとする。また、rはxをyで割った余り
    scanf("%d %d", &x, &y);
    if (y > x) {
        r = x; 
        x = y; 
        y = r;
    }
    r = y;
    while (x % y != 0) {
        r = x % y;
        x = y;
        y = r;
    }
    printf ("%d\n", r);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	pair<int, int> AB[100000];
	rep(i, N) cin >> AB[i].first >> AB[i].second;
	sort(AB, AB + N);
	priority_queue<int> que;

	int kotae = 0;
	int j = 0;
	rep1(i, M) {
		while (j < N && AB[j].first <= i) {
			que.push(AB[j++].second);
		}
		if (que.size()) {
			kotae += que.top();
			que.pop();
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1660