akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
    int i;
    char in_str[1000];
    int in_num;
    int sum;

    while (1){
        sum = 0;
        scanf("%s", in_str);
        if (in_str[0] == '0'){
            break;
        }else{
            for (i = 0; i < 1000; i++){
                if (in_str[i] == '\0'){
                    break;
                }else{
                    in_num = in_str[i] - '0';
                    sum += in_num;
                }
            }
            printf("%d\n", sum);
        }
    }

    return 0;
}

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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  string s;
  cin >> s;
  cout << s[0] << (s.size() - 2) << s[s.size() - 1] << endl;
}


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

long long int dp[1001][1001];
int h,w;
string str[1001];
long long int mod = 1000000007;
long long int func(int i,int j)
{
	if(i>=h || j>=w)return 0;
	if(i == h-1 && j == w-1)return 1;
	if(dp[i][j] != -1)return dp[i][j];
	if(str[i][j] == '#')
	{
		dp[i][j] = 0;
		return dp[i][j];
	}
	dp[i][j+1] = func(i,j+1)%mod;
	dp[i+1][j] = func(i+1,j)%mod;
	return (dp[i][j+1] + dp[i+1][j])%mod;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>str[i];
	for(int i=0;i<1001;i++)for(int j=0;j<1001;j++)dp[i][j] = -1;
	cout<<func(0,0)%mod<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <unordered_map>

using namespace std;

int main(){
    int N, a, remove_count;
    unordered_map<int, int> mp;

    cin >> N;

    for (int i = 0; i < N; i++){
        cin >> a;

        if (mp.count(a) != 0){
            mp[a] += 1;
        }
        else{
            mp[a] = 1;
        }
    }

    remove_count = 0;
    int count;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr){
        a = itr->first;
        count = itr->second;

        if (a < count){
            remove_count += count - a;
        }
        else if (a > count){
            remove_count += count;
        }
    }

    cout << remove_count << "\n";

    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  ll r;
  cin >> r;
  printf("%.7f\n", r*2*3.1415926);
  
}


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

int n, m;
string s;

vector<int> v;
bool func(int now){
  if(now == 0){
    return true;
  }
  if(now < 0){
    return false;
  }
  for(int i = m; i >= 1; i--){
    int next = now - i;
    if(s[next] == '0'){
      v.push_back(next);
      if(func(next)) return true;
      v.pop_back();
    }
  }
  return false;

}



int main(){
  cin >> n >> m;
  cin >> s;
  int now = n;
  while(now > 0){
    bool ok = false;
    for(int i = m; i >= 1; i--){
      int next = now - i;
      if(next < 0) continue;
      if(s[next] == '1') continue;
      v.push_back(next);
      now = next;
      ok = true;
      break;
    }
    if(!ok){
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(v.begin(), v.end());
  for(int i = 1; i <= v.size(); i++){
    if(i == v.size()) cout << n - v[i - 1] << " ";
    else cout << v[i] - v[i - 1] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3816
#include<iostream>
#include<cmath>
#include<cstdio>
typedef struct{
  double x,y;
}space;
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(){
  space in[21];
  char m;
  rep(i,2)cin>>in[i].x>>m>>in[i].y;
  double d,e;
  int i=1;
  double sum=0;
  while(cin>>d>>m>>e){
    double a=hypot(in[0].x-in[i].x,in[i].y-in[0].y);
    double b=hypot(d-in[i].x,in[i].y-e);
    double c=hypot(in[0].x-d,e-in[0].y);
    double z=(a+b+c)/2;
    sum+=sqrt(z*(z-a)*(z-b)*(z-c));
    in[i+1].x=d;
    in[i+1].y=e;
    i++;
    //cout<<sum<<endl;
  }
  printf("%.10f\n",sum);
}

Measured memory_bytes: 1252
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, 87)
	arr[0] = 2
	arr[1] = 1
	for i := 2; i <= N; i++ {
		arr[i] = arr[i-1] + arr[i-2]
	}
	fmt.Println(arr[N])
}


Measured memory_bytes: 512
# https://atcoder.jp/contests/abc087/tasks/abc087_b



A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

ans = 0
yen500 = [X / 500, A].min
0.upto(yen500) do |a|
  yen100 = [(X - 500 * a) / 100, B].min
  0.upto(yen100) do |b|
    ans += 1 if 500 * a + 100 * b + 50 * C >= X
  end
end

puts ans


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

int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  string t;
  rep(qi,q){
    int ty;
    cin >> ty;
    if (ty==1){
      swap(s,t);
    }
    else {
      int f;
      char c;
      cin >> f >> c;
      if (f==1){
        t+=c;
      }
      else {
        s+=c;
      }
    }
  }
  reverse(t.begin(),t.end());
  t+=s;
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 1128
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
//typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size()){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

signed main (){
    int n;
    cin>>n;
    int mi=1e16;
    rep(i,0,5){
        int x;cin>>x;
        mi=min(mi,x);
    }
    cout<<4+(n+mi-1)/mi<<endl;

}
/*
*/


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

int main() {
  string S;
  int count;
  cin >> S;
  for (int i = 0; i < S.length(); ++i) {
    if (i == 0) {
      continue;
    }
    if (S[i - 1] == '0' && S[i] == '0') {
      S[i] = '1';
      count++;
    }
    if (S[i - 1] == '1' && S[i] == '1') {
      S[i] = '0';
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int m=1e9;

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

    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int n,k,x,y;
        cin>>n>>k>>x>>y;
        if(n<=k)
        {
            cout<<n*x<<endl;
        }
        else
        {
            cout<<(k)*x+(n-k)*y<<endl;
        }
    }
    return 0;
}


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

using namespace std;

int N;
long long int a[100005], L;

int main(void) {

	cin >> N >> L;

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	long long int MAX = 0;
	int I;
	for (int i = 1; i <= N - 1; i++) {
		if (a[i] + a[i + 1] > MAX) {
			MAX = a[i] + a[i + 1]; I = i;
		}
	}

	if (MAX < L) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		for (int i = 1; i < I; i++) {
			cout << i << endl;
		}
		for (int i = N - 1; i > I; i--) {
			cout << i << endl;
		}
		cout << I << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<int> r(n + 1);
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        ++r.at(a);
        ++r.at(b);
    }
    for (int i = 1; i <= n; ++i) cout << r.at(i) << endl;
    return 0;
}


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

void push(int64_t x, vector<bool> &used)
{
  ans.push_back(x);
  used.at(x) = true;
}

int main()
{
  int64_t n, x;
  cin >> n >> x;
  int64_t m = 2 * n - 1;
  if (x == 1 || x == m)
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  vector<bool> used(m + 1, false);
  if (n == 2)
  {
    for (int i = 1; i <= 3; i++)
    {
      cout << i << endl;
    }
    return 0;
  }
  if (x == 2)
  {
    push(x + 2, used);
    push(x, used);
    push(x - 1, used);
    push(x + 1, used);
  }
  else
  {
    push(x - 1, used);
    push(x, used);
    push(x + 1, used);
    push(x - 2, used);
  }
  bool front = true;
  for (int i = 1; i <= m; i++)
  {
    if (used[i])
      continue;
    if (front)
      ans.push_front(i);
    else
      ans.push_back(i);
    front = !front;
  }
  while (ans.size())
  {
    cout << ans.front() << endl;
    ans.pop_front();
  }
}


Measured memory_bytes: 5260
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	ok := false
	if strings.Count(s, "C") >= 1 && strings.Count(s, "F") >= 1 {
		if strings.LastIndex(s, "F") > strings.LastIndex(s, "C") {
			ok = true
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 20;

int main(){
  string S;
  int x = 0, y = 0;
  cin >> S;

  rep(i, S.length()){
    if((i+1) % 2 == 1){
      if(S[i] !='R' && S[i] !='U' && S[i] !='D') x = 1; 
    }else{
      if(S[i] !='L' && S[i] !='U' && S[i] !='D') y = 1;
    }
  }

cout << ( x==0 && y==0 ?"Yes" : "No") << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
check=[list(map(int,input().split())) for i in range(M)]

for x,y in X:
    dist=[abs(x-c[0])+abs(y-c[1]) for c in check]

    MIN=min(dist)

    print(dist.index(MIN)+1)

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

using namespace std;

int main()
{
    int N,M;
    cin>>N>>M;
    vector<int> nodes,edges[10];
    for (int i=2;i<=N;i++) {
        nodes.push_back(i);
    }
    for (int i=0;i<M;i++) {
        int le, ri;
        cin>>le>>ri;
        edges[le].push_back(ri);
        edges[ri].push_back(le);
    }
    
    int ans=0, donecou, nodenum;
    do {
        nodenum=1;
        donecou=0;
        for (int oi=0;oi<nodes.size();oi++) {
            bool flag=false;
            for (int i=0;i<edges[nodenum].size();i++) {
                if (edges[nodenum][i]==nodes[oi])
                    flag=true;
            }
            if (!flag)
                break;
            nodenum=nodes[oi];
            donecou++;
        }
        if (donecou==nodes.size())
            ans++;
    } while(next_permutation(nodes.begin(), nodes.end() ));
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  char s[100];
  int flag=1;
  scanf("%d %s",&n,s);
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[i+n/2]){
      flag=0;
    }
  }
  if(flag==1&n%2==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1620
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=b[a[0]-1]
for i in range(1,n):
    s+=b[a[i]-1]
    if((a[i]-a[i-1])==1):
        s+=c[a[i-1]-1]
    #print(s)
print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

const int INF = INT_MAX;
int dp[n_max] = {};

//狭義のLIS
void N_LIS(vector<int> a){
    fill(dp, dp+n_max, INF);
    int n = a.size();
    rep(i,n){
        *lower_bound(dp, dp + n_max, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp + n_max, INF) - dp << endl;
    return ;
}
//広義のLIS
void B_LIS(vector<int> a){
    int n = a.size();
    fill(dp, dp+n_max, INF);
    rep(i,n){
        *upper_bound(dp, dp + n_max, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp + n_max, INF) - dp << endl;
    return ;

}

//狭義のLDS
void N_LDS(vector<int> a){
    // fill(dp, dp + n_max, INF);
    int n = a.size();
    vector<int> b;
    for(int i = n-1;0 <= i;i--){
        b.pb(a[i]);
    }
    N_LIS(b);
}

//広義のLDS
void B_LDS(vector<int> a){
    int n = a.size();
    vector<int> b;
    for(int i = n-1;0 <= i;i--){
        b.pb(a[i]);
    }
    B_LIS(b);
}

int main(){
    int n; cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    B_LDS(a);
    return 0;
}

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

using namespace std;

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define Sort(x) sort(x.begin(),x.end()); 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;

using namespace std;

vector<ll> v(87);
vector<bool> b(87,false);
ll ruca(int x) {
	if (b[x - 1]) return v[x-1];
	if (x == 1) {
		v[x - 1] = 2;
		return 2;

	}
	else if (x == 2) {
		return 1;
		v[x - 1] = 1;
	}
	
	if (!b[x - 1]) {
		b[x - 1] = true;
		v[x - 1] = ruca(x - 1) + ruca(x - 2);
	}
	return v[x-1];
}

int main(void) {
	int x;
	cin >> x;
	x++;
	cout << ruca(x) << endl;


	return 0;
}

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

int main()
{
    char str[3];
    cin >> str;

    if(str[0]=='S' && str[2]=='N') cout << 7 << endl;
    else if(str[0]=='M' && str[2]=='N') cout << 6 << endl;
    else if(str[2]=='E') cout << 5 << endl;
    else if(str[2]=='D') cout << 4 << endl;
    else if(str[2]=='U') cout << 3 << endl;
    else if(str[2]=='I') cout << 2 << endl;
    else if(str[2]=='T') cout << 1 << endl;

    return 0;
}


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

int main() {
    std::vector<int> v(100002);
    int n; std::cin >> n;
    for (int i = 0; i < n; i++) {
        int vv; std::cin >> vv;
        v[vv]++;
    }

    int m = 0;

    for (int i = 1; i < 100000; i++) {
        m = std::max(m, v[i-1]+v[i]+v[i+1]);
    }

    std::cout << m << std::endl;

    return 0;
}

Measured memory_bytes: 640
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n,m = m()

S = l()
T = l()

dp = [ [0 for i in range(n+1)]  for j in range(m+1)]

for i in range(n+1):
    dp[0][i] = 1
for i in range(m+1):
    dp[i][0] = 1

for i in range(n):
    for j in range(m):
        if S[i] == T[j]:
            dp[j+1][i+1] += dp[j][i]
        dp[j+1][i+1] +=dp[j+1][i] + dp[j][i+1] - dp[j][i]
        dp[j+1][i+1] %= 10**9+7
print(dp[-1][-1])



Measured memory_bytes: 74716
I = input().split()
a = []
for i in I:
    if i.isdigit():
        a.append(int(i))
    else:
        n = a.pop()
        m = a.pop()
        if i == "+":
            a.append(m+n)
        if i == "-":
            a.append(m-n)
        if i == "*":
            a.append(n * m)
print(a[0])



Measured memory_bytes: 5600
n=gets.to_i
s=[nil]
t=[nil]
n.times do |i|
  s[i+1]=[]
  t[i+1]=[]
end
n.times do |i|
  gets.to_i.times do
    x,y=gets.split.map(&:to_i)
    if y==1
      s[x] << i+1
    else
      t[x] << i+1
    end
  end
end
m=0
[1,0].repeated_permutation(n) do |b|
  c=b.count(1)
  if c<=m
    next
  end
  f=true
  n.times do |i|
    if b[i]==1
      t[i+1].each do |tt|
        if b[tt-1]==1
          f=false
          break
        end
      end
    else
      s[i+1].each do |ss|
        if b[ss-1]==1
          f=false
          break
        end
      end
    end
    if !f
      break
    end
  end
  if f
    m=b.count(1)
  end
end
puts m


Measured memory_bytes: 2300
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX/2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++)
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(110, INF));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<char, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	string s, ans;
	cin >> s;
	REP(i,s.size())
	{
		if (s[i] == '0') ans += '0';
		else if (s[i] == '1') ans += '1';
		else
		{
			int siz = ans.size();
			if (siz) ans = ans.substr(0, siz - 1);
		}
	}
	cout << ans << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;

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

   cout<<max(0LL,n-2*m);    

   return 0;
}

Measured memory_bytes: 256
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;


// 辺
struct Edge {
  int to;
  ll cost;
  Edge(int to, ll cost) : to(to), cost(cost) {}
};

// ノード
struct Node {
  int id;
  vector<Edge> edges;
  Node(int id) : id(id) {}
  void addEdge(int to, ll cost) {
    edges.push_back(Edge(to, cost));
  }
};

// グラフ
class Graph {
  private:
    int nodeN;
    vector<Node> nodes;
  public:
    Graph(int nodeN) {
      this->nodeN = nodeN;
      for(int i = 0; i < nodeN; i++) {
        nodes.push_back(Node(i));
      }
    }
    void addEdge(int from, int to, ll cost) {
      nodes[from].addEdge(to, cost);
    }
    /**
      getter
      */
    int getNodeN() {
      return this->nodeN;
    }
    vector<Node> getNodes() {
      return this->nodes;
    }
};

/**
  ベルマンフォード法
  計算量: O(|V|・|E|)
  */
vector<ll> bellmanFord(Graph graph, int s) {
  // 距離情報初期化
  int n = graph.getNodeN();
  vector<ll> d(n, -INF);
  d[s] = 0;

  // 全ての辺に対して、nodeN回更新を掛ける
  for(int i = 0; i < n; i++) {
    for(Node node : graph.getNodes()) {
      for(Edge edge : node.edges) {
        if(d[edge.to] < d[node.id] + edge.cost) {
          d[edge.to] = d[node.id] + edge.cost;

          // 負閉路検出
          if(i == n-1 && edge.to == n-1) {
            d[n-1] = -INF;
            return d;
          }
        }
      }
    }
  }
  return d;
}

int main() {
  // 入力
  int N, M;
  cin >> N >> M;
  Graph graph = Graph(N);
  for(int i = 0; i < M; i++) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--; b--;
    graph.addEdge(a, b, c);
  }

  vector<ll> d = bellmanFord(graph, 0);

  if(d[N-1] != -INF) {
    cout << d[N-1] << endl;
  } else {
    cout << "inf" << endl;
  }

  return 0;
}

Measured memory_bytes: 512
N,A,B = map(int, input().split())
count = 0

for i in range(1,N+1):
    
    m = 0
    tmp = i
    for t in range(1, len(str(i))+1):
        #print(tmp)
        
        m += tmp%10
        tmp /= 10
        tmp = int(tmp)
    
    if( A <=m and m <= B):
        count += i

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int N;	cin >> N;
	string S;	cin >> S;
	int w_s = 0;
	int b_s = 0;
	int white = 0;
	int black = 0;
	int tmp = 0;


	rep(i, N)	{
		if (S[i] == '#')	b_s++;
		else							w_s++;
	}

	int ans = w_s;

	rep(i, N)	{
		if (S[i] == '#')	black++;
		else							white++;

		tmp = black + (w_s-white);
		ans = min(tmp, ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
  int x, a, b;
	cin>>x>>a>>b;
  b -= a;
  if(b<=0) cout<<"delicious"<<endl;
  else if(b<=x) cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
	return 0;
}


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

typedef long long LL;

int main ()
{
    int n;
    scanf("%d",&n);
    LL ans=0;
    bool same = true;
    int min_b = 1234567890;
    for (int i=1;n>=i;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        same &= (a==b);
        if (a<=b) ans += a;
        else min_b = min(b,min_b),ans+=a;
    }
    if (same) puts("0");
    else printf("%lld\n",ans-min_b);
}


Measured memory_bytes: 256
#include<stdio.h>
int n,y;
int main()
{
    int i,j,k;
    scanf("%d%d",&n,&y);
    for(i=0;i<=n;i++)
    for(j=0;j<=n;j++)
    for(k=0;k<=n,i+j+k<=n;k++)
    if(i+j+k==n&&i*10000+j*5000+k*1000==y)
    {printf("%d %d %d\n",i,j,k);
    return 0;}
    printf("-1 -1 -1 \n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    int s,w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    //--------------
    return 0;
}

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

bool prime(int n){
    if(n == 2) return true;
    if(n % 2 == 0) return false;
    for(int i = 3; i * i <= n; i += 2){
        if(n % i == 0) return false;
    }
    return true;
}

int main(void){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int num = 0;
        cin >> num;
        if(prime(num)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



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

namespace ABC_C
{
    class C091
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            SortedDictionary<int, int> dicR = new SortedDictionary<int, int>();
            SortedDictionary<int, int> dicB = new SortedDictionary<int, int>();

            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                dicR.Add(int.Parse(s[0]), int.Parse(s[1]));
            }
            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                dicB.Add(int.Parse(s[0]), int.Parse(s[1]));
            }

            int counter = 0;
            foreach (var pair in dicB)
            {
                int c = pair.Key, d = pair.Value;
                var reds = dicR.Where(x => x.Key < c && x.Value < d);
                if (reds.Count() > 0)
                {
                    int mx= reds.Max(x => x.Value);
                    var red = reds.Where(x => x.Value == mx).Single().Key;
                    dicR.Remove(red);
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }
    }
}


Measured memory_bytes: 13780
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    char n[5];
    cin >> n[0] >> n[1] >> n[2];

    if(n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
n,*t=map(int,open(0).read().split());e=[[]for _ in[0]*n];q=[0];f=[0]+[-1]*~-n
for v,w,c in zip(t[::3],t[1::3],t[2::3]):e[v-1]+=(w-1,c),;e[w-1]+=(v-1,c),
while q:
 v=q.pop()
 for w,c in e[v]:
  if f[w]<0:f[w]=(c+f[v])%2;q+=w,
print(*f)

Measured memory_bytes: 115152
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

/*
    Author: Koushik Sahu
    Created: 29 August 2020 Sat 17:50:02
*/

int n, m, a, b;
vvint g;
set<ipair> seen;
bool vis[200001];

void dfs(int src, int& g_size){
    vis[src] = true;
    g_size++;
    for(int v: g[src]){
        if(!vis[v]){
            dfs(v, g_size);
        }
    }
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n>>m;
    g.resize(n);
    for(int i=0; i<m; i++){
        cin>>a>>b;
        a--, b--;
        if(seen.find({a, b})==seen.end()){
            g[a].push_back(b);
            g[b].push_back(a);
        }
        seen.insert({a, b});
        seen.insert({b, a});
    }
    fill_n(vis, n, false);
    int ans = INT_MIN;
    for(int i=0; i<n; i++){
        if(!vis[i]){
            int g_size = 0;
            dfs(i, g_size);
            ans = max(ans, g_size);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 42500
N,M = map(int,input().split())
cake_ppp = []
cake_ppm = []
cake_pmp = []
cake_pmm = []
cake_mpp = []
cake_mpm = []
cake_mmp = []
cake_mmm = []
maxes = []

for i in range(0,N):
    value = [int(x) for x in input().split()]
    cake_ppp.append(value[0] + value[1] + value[2])
    cake_ppm.append(value[0] + value[1] - value[2])
    cake_pmp.append(value[0] - value[1] + value[2])
    cake_pmm.append(value[0] - value[1] - value[2])
    cake_mpp.append(-value[0] + value[1] + value[2])
    cake_mpm.append(-value[0] + value[1] - value[2])
    cake_mmp.append(-value[0] - value[1] + value[2])
    cake_mmm.append(-value[0] - value[1] - value[2])

cake_ppp.sort()
cake_ppm.sort()
cake_pmp.sort()
cake_pmm.sort()
cake_mpp.sort()
cake_mpm.sort()
cake_mmp.sort()
cake_mmm.sort()

maxes.append(sum(cake_ppp[N-M : N]))
maxes.append(sum(cake_ppm[N-M : N]))
maxes.append(sum(cake_pmp[N-M : N]))
maxes.append(sum(cake_pmm[N-M : N]))
maxes.append(sum(cake_mpp[N-M : N]))
maxes.append(sum(cake_mpm[N-M : N]))
maxes.append(sum(cake_mmp[N-M : N]))
maxes.append(sum(cake_mmm[N-M : N]))

print(max(maxes))


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

#define all(x) (x).begin(), (x).end()
#define X real()
#define Y imag()

typedef array<int, 3> tri;
typedef long long ll;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; cout << '\n'; return O;}


void _main() {
        ll n, d; cin >> n >> d;
        ll ans = 0;
        while (n--) {
                ll x, y; cin >> x >> y;
                if (sqrt(x * x + y * y) <= d) ans++;
        }

        cout << ans;
}

int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3696
#include<stdio.h>

#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){

  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2040
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VI a(8, 0);
    int am = 0;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if(tmp >= 3200) am++;
        else if(tmp >= 2800) a[0] = 1;
        else if(tmp >= 2400) a[1] = 1;
        else if(tmp >= 2000) a[2] = 1;
        else if(tmp >= 1600) a[3] = 1;
        else if(tmp >= 1200) a[4] = 1;
        else if(tmp >= 800) a[5] = 1;
        else if(tmp >= 400) a[6] = 1;
        else a[7] = 1;
    }
    int sum = 0;
    REP(i, 8) sum += a[i];
    cout << max(1, sum) << " " << sum + am << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a[100],n,i;
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	for (i=n-1;i>= 0; i--){
		cout << a[i];
		if (i != 0) cout << " ";
		else cout << endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

bool prime(ll x){
  bool a=true;
  ll b=sqrt(x)+1;
  FOR(i,2,b){
    if(x%i==0)
      a=false;
  }
  return a;
}

int main() {
  ll x;
  cin >> x;
  while(prime(x)!=true){
    x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010
string s;
ll n,k;
ll dp[110][110][2];
ll f(ll pos,ll dig,ll ok){
	if(pos>=sz(s)) {
		if(dig==k) return 1;
		return 0;
	}
	if(dp[pos][dig][ok]!=-1) return dp[pos][dig][ok];
	ll ans = 0;
	rep(i,0,10){
		ll x = s[pos]-'0';
		bool okk = ok or (i<x);
		bool ff = okk or (i==x);
		ll dign=dig;
		if(i!=0)dign++;
		if(ff){
			ans+=f(pos+1,dign,okk);
		}
	}
	return dp[pos][dig][ok]=ans;
}
int main(){
	IOS;
	tihs;
	memset(dp,-1,sizeof(dp));
	cin>>s>>k;
	cout<<f(0,0,0);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {
	Scanner sc=new Scanner(System.in);

	public void run() {
		int a=sc.nextInt(),b=sc.nextInt();
		if(a>b){
			ln("a > b");
		}else if(a<b){
			ln("a < b");
		}else{
			ln("a == b");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
	
	public static void pr(Object o) {
		System.out.print(o);
	}
	
	public static void ln(Object o) {
		System.out.println(o);
	}
	
	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n, k;
  string s;

  cin >> n >> k;

  cin >> s;

  s[k-1] += 32;

  cout << s << 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();
		long answer = 0;
		long[][] dp = new long[n+1][4];
		dp[1] = new long[]{1, 1, 1, 1};
		dp[2] = new long[]{4, 4, 4, 4};
		dp[3] = new long[]{16, 14, 15, 16};
		if(n >= 4) {
			for(int i = 4; i <= n; i++) {
				long sum = 0;
				for(int j = 0; j < 4; j++) {
					sum += dp[i-1][j];
				}
				sum %= 1000000007;
				//A and T
				dp[i][0] = sum;
				dp[i][3] = sum;
				//C
				dp[i][1] = sum - dp[i-2][0] -dp[i-2][2] - dp[i-3][0]*3;
				//G
				dp[i][2] = sum - dp[i-2][0] + dp[i-3][2];
				sum = 0;
			}
		}
		for(int j = 0; j < 4; j++) {
			answer += dp[n][j];
		}
		answer %= 1000000007;
		System.out.println(answer);
	}

}

Measured memory_bytes: 23124
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,K = map(int,input().split())
graph = list([] for _ in range(N))
for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
def f(x,y):
    r = 1
    for i in range(y):
        r = (r*(x-i))%mod
    return r
q = graph[0]
V = {0}
ans = f(K-1,len(q))
while q:
    v = q.pop()
    if v in  V:
        continue
    V.add(v)
    q += graph[v]
    ans = (f(K-2,len(graph[v])-1)*ans)%mod
print((K*ans)%mod)

Measured memory_bytes: 71840
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <stdlib.h>
#include <unordered_map>
#define ll long long
using namespace std;
int main() {
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World";
    }
    else{
        int a,b;
        cin>>a>>b;
        cout<<a+b;
        
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long MOD = 998244353 ;
const long long INF = 1e18;
const int INT_INF   = 1e9 + 8;
int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD, long long tot = 1) {
    for(;exp > 0; exp >>= 1, base = base * base % mod) if((exp & 1) == 1) tot = tot * base % mod;
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD, long long tot = 0) {
    for(;exp > 0; exp >>= 1, base = base * 2 % mod) if((exp & 1) == 1) tot = (tot + base) % mod;
    return tot;
}
struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;
    string s; cin >> s;
    for(int i = 0; i < s.size(); ++i){
        int j = s[i] - 'A';
        j = (j + n) % 26 + 65;
        cout << (char) j;
    }
    return 0;

}


Measured memory_bytes: 256
import numpy as np

N, W = map(int, input().split())

dp = np.zeros(W+1, dtype=np.int64)

for _ in range(N):
    w, v = map(int, input().split())  # 重さw, 価値vの荷物
    np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])  # dp[:-w]はまだ重さwのもの入るナップサックの状態
    # outは戻り値を格納する配列を指定できる

print(dp[-1])


"""
今dpは一次元配列
dp[:-w]は後ろからw個より前の要素, つまり(N-w)個
dp[w:]は前からw個より後ろの要素, つまり(N-w)個
よって形状が一致する
"""

"""
dp[:-w]は今見ている"重さw, 価値v"の荷物を入れることのできる状態のナップサック
dp[:-w]+vをすることで、今見ているその荷物を入れた時の価値の総和になる.
今、"重さw, 価値v"の荷物を入れたナップサックと、dp[w:]を比較する。
それぞれの要素について大きい方が新しい要素となり、out=dp[w:]によって上書きされる。
maxmimumが返すのはnp配列。そのnp配列の形状は比較対象となっている配列の形状と一致するから、
問題なく上書きできる
"""


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

int main () {
  long long int n, a, b;
  cin >> n >> a >> b;
  if (n==1&&a==b)
    cout << 1 << endl;
  else if ((n==1&&a!=b)||(a>b))
    cout << 0 << endl;
  else 
    cout << (b-a)*(n-2) + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int d, n; cin>>d>>n;
    vector<int> t(d);
    vector<int> a(n), b(n), c(n);
    for(int i=0; i<d; i++) cin>>t[i];
    for(int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];

    vector<vector<ll>> dp(210, vector<ll>(210, -INF));

    for(int i=0; i<n; i++){
        if(a[i]<=t[0] && t[0]<=b[i]) dp[0][c[i]]=0;
    }

    for(int i=1; i<d; i++){
        for(int j=0; j<=100; j++){
            if(dp[i-1][j]<=-INF) continue;
            for(int k=0; k<n; k++){
                if(a[k]<=t[i] && t[i]<=b[k]){
                    dp[i][c[k]]=max(dp[i][c[k]], dp[i-1][j]+abs(c[k]-j));
                }
            }
        }
    }

    ll ans=0;
    for(int i=0; i<=100; i++){
        chmax(ans, dp[d-1][i]);
    }
    cout << ans << endl;
}


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



static const int N = 1000;

int lcs(string X, string Y) 
{
	int c[N + 1][N + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (int i = 0; i <= m; i++)c[i][0] = 0;
	for (int j = 1; j <= n; j++)c[0][j] = 0;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (X[i] == Y[j])
			{
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else
			{
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	return maxl;
}



int main()
{
	string s1, s2;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}

    return 0;
}


Measured memory_bytes: 7124
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    int n;
    cin >> n;
    vector< int> a(n), b(n);
    for (int &i : a) cin >> i;
    for (int &i : b) cin >> i;

    vector< int> c(n);
    for (int i = 1; i <= n; i++) c[i - 1] = i;

    int x, y, cnt = 0;

    do {
        if (a == c) x = cnt;
        if (b == c) y = cnt;
        cnt++;
    } while (next_permutation(begin(c), end(c)));
    cout << abs(x - y) << endl;
}

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

for _ in range(M):
    L, R = map(int, input().split())
    max_L = max(max_L, L)
    min_R = min(min_R, R)
print(max(min_R-max_L+1, 0))


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


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

  int ans = 0, kind = 0; ///kindはsの文字の種類

  int num = 'a'-'0' + 26;
  int check[num];
  int basyo[n]; ///i文字目までに存在する文字の種類
  rep(i, num) check[i] = 0;
  rep(i, n) basyo[i] = 0;
  rep(i, n){
    if (check[s[i]-'0'] == 0){
      kind++;
      check[s[i]-'0'] ++;
    }
    basyo[i] = kind;

  }

  rep(i, n){
    int ari = 0;
    int ch[num];
    rep(i, num) ch[i] = 0;
    string s1 = s.substr(0, i);
    string s2 = s.substr(i);
    
    rep(j, s1.length()){
      rep(k, s2.length()){
        if (s1[j] == s2[k] && ch[s1[j]-'0']== 0){
          ari ++;
          ch[s1[j]-'0']++;

        }
      }
    }
  
    if (ari > ans) ans = ari;

  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
l,r=list(map(int, input().split()))
answer=2019
for i in range(l,min(r+1,l+2020)):
    for j in range(l+1,min(r+1,l+2020)):
        if i>=j:
            continue
        _i=i%2019
        _j=j%2019
        answer=min(answer,(_i*_j)%2019)
print(answer)

Measured memory_bytes: 3188