akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  rep(i,(tx-sx)){
    cout << 'R';
  }
  rep(i,(ty-sy)){
    cout << 'U';
  }
  rep(i,(tx-sx)){
    cout << 'L';
  }
  rep(i,(ty-sy)){
    cout << 'D';
  }
  cout << 'D';
  rep(i,(tx-sx)+1){
    cout << 'R';
  }
  rep(i,(ty-sy)+1){
    cout << 'U';
  }
  cout << 'L';
  cout << 'U';
  rep(i,(tx-sx)+1){
    cout << 'L';
  }
  rep(i,(ty-sy)+1){
    cout << 'D';
  }
  cout << 'R';
  cout << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    string s;
    while(cin>>s)
    {
        stack<int>st;
        for(int i=0;i<s.size();i++)
        {
            if(st.empty())st.push(s[i]);
            else
            {
                if(st.top()!=s[i])st.pop();
                else st.push(s[i]);
            }
        }
        pf("%d\n",s.size()-st.size());
    }   
    return 0;
}
 









 




























Measured memory_bytes: 768
import collections

n = int(input())
a = list(map(int, input().split(' ')))


def color(rate):
    if 1 <= rate <= 399:
        return 'gray'
    elif 400 <= rate <= 799:
        return 'brown'
    elif 800 <= rate <= 1199:
        return 'green'
    elif 1200 <= rate <= 1599:
        return 'water'
    elif 1600 <= rate <= 1999:
        return 'blue'
    elif 2000 <= rate <= 2399:
        return 'yellow'
    elif 2400 <= rate <= 2799:
        return 'orange'
    elif 2800 <= rate <= 3199:
        return 'red'
    elif 3200 <= rate:
        return 'multi'


MAX_COLORS = 8

l = [color(rate) for rate in a]
c = collections.Counter(l)


k_not_multi = len([k for k in c.keys() if k != 'multi'])
multis = c['multi']

_max = multis + k_not_multi

if k_not_multi == 0:
    _min = 1
else:
    _min = k_not_multi
    # print(k_not_multi)
    #
    # _max = min(k_not_multi + c['multi'], MAX_COLORS)
    #
    # if k_not_multi == 0:
    #     _min = 1
    # else:
    #     _min = k_not_multi
# else:
#     _max = _min = len([k for k in c.keys()])

print(_min, _max)


Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;

	rep(i,ty-sy)cout<<'U';
	rep(i,tx-sx)cout<<'R';
	rep(i,ty-sy)cout<<'D';
	rep(i,tx-sx)cout<<'L';
	
	cout<<'L';
	rep(i,ty-sy+1)cout<<'U';
	rep(i,tx-sx+1)cout<<'R';
	cout<<'D';
	cout<<'R';
	rep(i,ty-sy+1)cout<<'D';
	rep(i,tx-sx+1)cout<<'L';
	cout<<'U';
	cout<<endl;


	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, r, s, mn=1e9, a[9], d[205][205];
int main() {
	int i, j, k, u, v, w;
	cin>>n>>m>>r;
	for(i=0; i<r; i++) cin>>a[i];
	for(i=1; i<=n; i++) for(j=1; j<=n; j++) d[i][j] = i==j ? 0:1e8;
	while(m--) {
		cin>>u>>v>>w;
		d[u][v] = d[v][u] = w;
	}
	for(k=1; k<=n; k++) for(i=1; i<=n; i++) for(j=1; j<=n; j++)
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	sort(a, a+r);
	do {
		s = 0;
		for(i=0; i<r-1; i++) s += d[a[i]][a[i+1]];
		mn = min(mn, s);
	} while(next_permutation(a, a+r));
	cout<<mn;
	return 0;
}

Measured memory_bytes: 384
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
stack=10**18
for i in range(n):
  if stack>abs(a-(t-0.006*h[i])):
    stack=abs(a-(t-0.006*h[i]))
    ans=i+1
print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().split())
A = list(input().split())
num = 0
tokuhyo = 0

for i in range(N):
    tokuhyo += int(A[i])

for i in range(N):
    if int(A[i]) >= (tokuhyo/(4 * M)):
        num += 1
if num >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<typename T> string to_string(const T& v) {
  string str;
  for (const auto& i : const_cast<T&>(v)) str += ' ' + to_string(i);
  return str.substr(min(1, int(str.size())));
}

template<> string to_string<string>(const string& v) {return v;}

#ifdef __MINGW32__

template<> string to_string<int>(const int& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<int64_t>(const int64_t& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned int>(const unsigned int& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned int64_t>(const unsigned int64_t& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<float>(const float& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<double>(const double& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<long double>(const long double& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

#endif

int main() {
  int n, a, b, r = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; ++i) {
    string s = to_string(i);
    int k = 0;
    for (char c : s) k += c - '0';
    if (a <= k && k <= b) r += i;
  }
  cout << r << endl;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  // 最小公倍数-1を割っていくので、余りは自身-1
  cout << accumulate(a.begin(), a.end(), 0) - N << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std; using P=pair<int,int>; using ll=long long;
struct tp {int x,y,i; bool operator<(const tp tt) const {if (x==tt.x) return y<tt.y; else return x<tt.x;}};

int main() {
  int n; cin>>n;
  if (n==1) cout<<"Hello World"<<endl;
  else {
    int a,b; cin>>a>>b;
    cout<<a+b<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cerr << #x << " = " << x << "\n";
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

bool ip(string s){
	for(int i = 0; i < (int)s.size(); i++){
		if(s[i] != s[s.size() - i - 1])return false;
	}
	return true;
}

int main(){
	FIO
	
	string s;cin >> s;
	if(ip(s) && ip(s.substr(0, (s.size() - 1) / 2)) && ip(s.substr((s.size() + 3) / 2 - 1)))puts("Yes");
	else puts("No");
	return 0;
}


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

using namespace std;

int main () {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int sum = 0, tmp = i;
        while (1) {
            sum += tmp % 10;
            tmp /= 10;
            if (tmp == 0)
                break;
        }
        if (sum >= a && sum <= b)
            ans += i;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

typedef long long LL;
typedef pair<int,int>PII;

int n,m;

int x,b;

int a[4],cnt[4];

int main(void) {
	cin >> n >> m;
	if(n == 1 && m == 0) {
		cout << 0 << endl;
		return 0;
	}
	bool vis = true;
	while(m --) {
		cin >> x >> b;
		if(vis == false) continue;
		if(n > 1 && x == 1 && b == 0) {
			vis = false;
		} else if(cnt[x] && a[x] != b) {
			vis = false;
		} else {
			a[x] = b;
			cnt[x] = 1;
		}
	}
	if(vis == false) {
		cout << -1 << endl;
	} else {
		for(int i = 1; i <= n; i ++) {
			if(a[1] == 0 && cnt[1] == 0) a[1] = 1;
			cout << a[i] ;
		}
		cout << endl;
	}
	return 0;
}

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Array.Sort(x);

            Console.WriteLine(x[0] + " " + x[1] + " " + x[2]);
        }
    }
}



Measured memory_bytes: 18404
a, b, c = list(map(int, input().split()))
if a == b == c and a % 2 == 0:
    print(-1)
    exit()
count = 0
while True:
    if sum([a % 2, b % 2, c % 2]) > 0:
        print(count)
        exit()
    else:
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
        count += 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double tmp = 0.0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        tmp += (double)1/a;
    }
    double ans = (double)1/tmp;
    cout<<fixed;
    cout<<setprecision(15)<<ans<<endl;
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

vector<int> g[N];

int dfs(int u, int par)
{
    int cnt = 0;
    for (int v : g[u])
        if (v != par)
            if (dfs(v, u) == 1)
                cnt++;
    if (cnt >= 2 || cnt == 0 && par == -1)
    {
        cout << "First\n";
        exit(0);
    }
    if (cnt == 0)
        return 1;
    else
        return 0;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    rep(i, 0, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0, -1);
    cout << "Second\n";
    return 0;
}


Measured memory_bytes: 5888
from collections import defaultdict
from sys import exit

H, W = map(int, input().split())
char_counter = defaultdict(int)

for _ in range(H):
    for s in input():
        char_counter[s] += 1

if H % 2 == 0 and W % 2 == 0:
    for k, v in char_counter.items():
        if v % 4 != 0:
            print("No")
            exit()
    print("Yes")
elif H % 2 == 0 and W % 2 == 1:
    holder = defaultdict(int)
    counter = 0
    for k, v in char_counter.items():
        if v % 4 != 0:
            for _ in range(v % 4):
                holder[k] += 1
                counter += 1
    if counter <= H:
        for kk, vv in holder.items():
            if vv % 2 != 0:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")
elif H % 2 == 1 and W % 2 == 0:
    holder = defaultdict(int)
    counter = 0
    for k, v in char_counter.items():
        if v % 4 != 0:
            for _ in range(v % 4):
                holder[k] += 1
                counter += 1
    if counter <= W:
        for kk, vv in holder.items():
            if vv % 2 != 0:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")
elif H % 2 == 1 and W % 2 == 1:
    holder = defaultdict(int)
    counter = 0
    for k, v in char_counter.items():
        if v % 4 != 0:
            for _ in range(v % 4):
                holder[k] += 1
                counter += 1
    if counter <= W + H - 1:
        no_odd = False
        for kk, vv in holder.items():
            if vv % 2 != 0:
                if no_odd:
                    print("No")
                    exit()
                else:
                    no_odd = True
        print("Yes")
    else:
        print("No")


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

const int N = 100 + 10;
int l[N];

int main() {
  	int n;
    cin >> n;
    for (int i = 0; i < 2 * n; i++)
    	cin >> l[i];
    sort(l, l + 2 * n, greater<int>());
    int ans = 0;
    for (int i = 1; i < 2 * n; i += 2)
    	ans += l[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef HIRO
#include "../stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

int main() {
#ifdef HIRO
  printf("xxx\n");
  ifstream cin("input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif

  string a, b;
  cin >> a >> b;
  cout << b << a << endl;
  return 0;
}



Measured memory_bytes: 256
H, W = map(int,input().split())
MAP = []
INF = 10 ** 8
for _ in range(H):
    MAP.append(input())
 
dp = [[0 for i in range(W)] for i in range(H)]
 
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            if MAP[i][j] == "#":
                dp[i][j] = 1
        elif i == 0:
            flag = 0
            if MAP[i][j] == "#" and MAP[i][j-1] == ".":
                flag = 1
            dp[i][j] = flag + dp[i][j-1]
        elif j == 0:
            flag = 0
            if MAP[i][j] == "#" and MAP[i-1][j] == ".":
                flag = 1
            dp[i][j] = flag + dp[i-1][j]
        else:
            flag1 = 0
            flag2 = 0
            if MAP[i][j] == "#" and MAP[i][j-1] == ".":
                flag1 = 1
            if MAP[i][j] == "#" and MAP[i-1][j] == ".":
                flag2 = 1
            dp[i][j] = min(dp[i][j-1]+flag1,dp[i-1][j]+flag2)
        
 
print(dp[H-1][W-1])

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

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<int64_t> bit(n + 1);
  for (int i = 0; i < n; i++) {
    int k = i + 1;
    while (k <= n) {
      bit.at(k) += a.at(i);
      k += k & -k;
    }
  }
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 0) {
      int p, x;
      cin >> p >> x;
      int k = p + 1;
      while (k <= n) {
        bit.at(k) += x;
        k += k & -k;
      }
    } else {
      int64_t s = 0;
      int l, r;
      cin >> l >> r;
      int k = r;
      while (k) {
        s += bit.at(k);
        k -= k & -k;
      }
      k = l;
      while (k) {
        s -= bit.at(k);
        k -= k & -k;
      }
      cout << s << endl;
    }
  }
}


Measured memory_bytes: 10172
#include <stdio.h>
#include <math.h>

typedef struct Point{
  double x, y;
} Point;

void koch(int n, Point p1, Point p2){
  if (n == 0) {return;}

  Point s, t, u;
  double an = M_PI * 60.0 / 180.0;

// p1, p2 から s, t, u を計算

  s.x = (2.0*p1.x + 1.0*p2.x) / 3.0;
  s.y = (2.0*p1.y + 1.0*p2.y) / 3.0;
  t.x = (1.0*p1.x + 2.0*p2.x) / 3.0;
  t.y = (1.0*p1.y + 2.0*p2.y) / 3.0;
  u.x = (t.x - s.x)*cos(an) - (t.y - s.y)*sin(an) + s.x;
  u.y = (t.x - s.x)*sin(an) + (t.y - s.y)*cos(an) + s.y;

  koch(n - 1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, p2);
}



int main(){
  Point p1, p2;
  int n;
  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);

  return 0;
}



Measured memory_bytes: 2040
package main

import (
	"fmt"
)

func main() {

	var s string
	fmt.Scan(&s)

	for i := 1; i < len(s); i++ {
		if s[i-1] == s[i] {
			fmt.Println("Bad")
			return
		}
	}

	fmt.Println("Good")
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val N = readInputLine().toLong()
    
    var maxPoint = 0L
    
    for (i in LongRange(1L, N)) {
        if (i * (i + 1L) / 2L >= N) {
            maxPoint = i
            break
        }
    }
    
    var nowPoint = 0L
    
    for (i in LongRange(1L, maxPoint).reversed()) {
        if (nowPoint + i <= N) {
            println(i)
            nowPoint += i
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

#define N 100000
#define M 100000
#define Q 1000000007

typedef long long int ll;

ll add_mod(ll x, ll y, ll q){
	ll ret;

	ret = x + y;
	if(ret >= q) ret -= q;
	if(ret < 0) ret += q;

	return ret;
}

ll mul_mod(ll x, ll y, ll q){
	ll ret;

	if(x < 0) x+=q;
	if(y < 0) y+=q;
	ret = x * y;
	if(ret > 0) ret%=q;

	return ret;
}

ll x[N], y[M];

int main(void){
	int n, m;
	int i;
	ll ret, tmpx=0, tmpy=0;

	scanf("%d %d", &n, &m);
	for(i=0; i<n; i++) scanf("%lld", &x[i]);
	for(i=0; i<m; i++) scanf("%lld", &y[i]);
	
	for(i=0; i<n; i++)
		tmpx = add_mod(tmpx, mul_mod(add_mod(2*i, 1-n, Q), x[i], Q), Q);
	for(i=0; i<m; i++)
		tmpy = add_mod(tmpy, mul_mod(add_mod(2*i, 1-m, Q), y[i], Q), Q);
	ret = mul_mod(tmpx, tmpy, Q);
	
	printf("%lld\n", ret);

	return 0;
}

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

using namespace std;


void solve() {
    int n, _;
    cin >> n >> _;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    map<int, int> cnt;
    int mi = 1e9+19;
    for (int x: a) {
        if (x > mi) cnt[x-mi]++;
        mi = min(mi, x);
    }
    int res = cnt.rbegin()->second;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main() {
    int n, k, r, s, p;
    string t;
    vector<string> g(100000);
    cin >> n >> k >> r >> s >> p >> t;
    rep(i, n) g[i % k] += t[i];
    int ans = 0;
    rep(i, k) {
        int m = g[i].size();
        vector<vector<int>> dp(m, vector<int>(3, 0));
        if (g[i][0] == 'r') dp[0][2] = p;
        if (g[i][0] == 's') dp[0][0] = r;
        if (g[i][0] == 'p') dp[0][1] = s;

        for (int j=1;j<m;++j) {
            dp[j][2] = max(dp[j-1][0], dp[j-1][1]);
            dp[j][0] = max(dp[j-1][1], dp[j-1][2]);
            dp[j][1] = max(dp[j-1][2], dp[j-1][0]);

            if (g[i][j] == 'r') dp[j][2] += p;
            if (g[i][j] == 's') dp[j][0] += r;
            if (g[i][j] == 'p') dp[j][1] += s;
        }
        int h = max(dp[m-1][0], dp[m-1][1]);
        h = max(h, dp[m-1][2]); 
        ans += h;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i = 1; i < n; i++)
const int md = 1e9+7;
const int mx = 100005;
int n, k, comp[mx], r = 1;
long long dp[mx];
int main(){
	scanf("%d%d", &n, &k);
	for(; r*r <= n; r++) comp[r] = n/r - n/(r+1);
	fill(comp+r,comp+r+n/r, 1);
	r += n/r;
	reverse(comp+1, comp+r);
	for(int i = 0; i < k; i++){
		int temp[mx] = {};
		rep1(j,r) temp[j] = ((i ? dp[r-j] : 1) * comp[j]) % md;
		rep1(j,r) dp[j] = (dp[j-1] + temp[j]) % md;
	}
	printf("%lld\n", dp[r-1]);
}

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

using namespace std;

int dh[4] = {-1, 1, 0, 0}, dw[4] = {0, 0, -1, 1};

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++)
    cin >> S[i];
  long long ans = 0;
  int type = 0;
  vector<long long> cnt;
  vector<vector<long long>> t(H, vector<long long>(W, -1));
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      if (S[i][j] == '#')
      {
        if (t[i][j] != -1)
        {
          ans += cnt[t[i][j]];
          continue;
        }
        int tmp = 0;
        queue<pair<int, int>> que;
        que.push({i, j});
        t[i][j] = type;
        while (que.size())
        {
          pair<int, int> p = que.front();
          que.pop();
          for (int k = 0; k < 4; k++)
            if (-1 < p.first + dh[k] && p.first + dh[k] < H && -1 < p.second + dw[k] && p.second + dw[k] < W && S[p.first][p.second] != S[p.first + dh[k]][p.second + dw[k]] && t[p.first + dh[k]][p.second + dw[k]] == -1)
            {
              if (S[p.first + dh[k]][p.second + dw[k]] == '.')
                tmp++;
              que.push({p.first + dh[k], p.second + dw[k]});
              t[p.first + dh[k]][p.second + dw[k]] = type;
            }
        }
        ans += tmp;
        cnt.push_back(tmp);
        type++;
      }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	

	void solve(){
		
		
		
		ini(x);
		out(8-(x-400)/200);

		
		


			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string str;
    int i,l;
    cin>>str;
	if(str[2]==str[3] && str[4]==str[5])
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
    
}


Measured memory_bytes: 256
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
y = [num for num in range(1, n+1)]
permutation_n = list(itertools.permutations(y, n))
a=b=0
count=1
for permu in permutation_n:
  if permu == p:
    a = count
  if permu == q:
    b = count
  if a > 0 and b > 0 :
    break
  count+=1
print(abs(a-b))

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  if((A - B) % 2 == 0){
    cout << "Alice" << endl;
  }else{
    cout << "Borys" << endl;
  }
}


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

void func142c() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<int> kitajun(n);
  for (int i = 0; i < n; i++) kitajun[a[i]-1] = i+1;
  for (int i = 0; i < n; i++) cout << kitajun[i] <<"\n";
}

int main() {
  func142c();
  return 0;
}

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

using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      	    cout<<"#x "<<x<<"\n";
#define trace(x,y)  	    cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          	    cout<<"\n";


bool SBF(const pair <int,int>& a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair <int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const long double PI  = 3.1415926535;
const long long   mod = 1e9+ 7; 
const int 	  mxN = 1000;
const long long   inf = 1e18;


ll n;
vector <int> primes;
bool seive[1001];


void genPrime(){
     memset(seive,1,sizeof(seive));
     int i = 2;
     while(i*i <= 1000){
	     int k = i*i;
	     while(k <= 1000)
	     {
	       	     seive[k] = false;
		     k += i;
	     }
	     i++;
     }
     for(int i= 2;i<=1000;i++){
	     if(seive[i])primes.pb(i);
     }
}


void solve(){
	cin >> n;
        int fac[1001];
	memset(fac,0,sizeof(fac));

        for(int i=2;i<=n;i++){
		int j=0;
		int num = i;
		while(j < primes.size() && num!=1){
                        int cnt =0;
			while(num%primes[j] == 0){
				cnt++;
				num/=primes[j];
			}
			fac[primes[j]]+=cnt;
		        j++;
		}
		if(num != 1)fac[i]++;
	}
	

        ll ans = 1;
        for(int i = 2 ;i <= n; i++){
	       	(ans*=(fac[i]+1))%=mod;
	}
	cout<<ans<<"\n";
}



int main(){
	genPrime();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a,b,c;
    
    scanf("%d %d",&a,&b);
    
    while(a != b){
        if(a > b){
            c = a - b;
            a = b;
            b = c;
        }else{
            c = b - a;
            b = a;
            a = c;
        }
    }
    
    printf("%d\n",a);

    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;


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

    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    
    vector<string> R;
    int val = N;

    while(val != 1){
        if(val % 2 != 0){
            R.push_back(to_string(1));
            val = (val-1)/(-2);
        }else{
            R.push_back(to_string(0));
            val /= -2;
        }
    }

    R.push_back(to_string(1));

    for(int i=R.size()-1; i>=0; --i) cout << R[i];

    cout << '\n';

    return 0;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

def gets_f_list()
  gets.chomp.split(" ").map(&:to_f)
end

a, b, x = gets_f_list

area = x / a
ha = 2 * area / b

if a >= ha
  theta = Math.atan(b/ha)
  ans = theta / Math::PI * 180
else
  area = a * b - area
  hb = 2 * area / a
  theta = Math.atan(hb/a)
  ans = theta / Math::PI * 180
end

puts sprintf("%10.9f", ans)


Measured memory_bytes: 2172
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define in read()
#define re register
#define fur(i,a,b) for(re int i=a;i<=b;++i)
#define fdr(i,a,b) for(re int i=a;i>=b;--i)
#define cl(a,b) memset(a,b,sizeof(a))
#define jinitaimei signed
#define int long long
inline int read()
{
	int x=0;
	char ch=getchar();
	for(;!isalnum(ch);ch=getchar());
	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
}
const int xx=2e5+101;
struct person
{
	int x,y;
}m[xx];
inline bool cmp(person a,person b)
{
	return a.x<b.x;
}
jinitaimei main()
{
	int n=in,xmax=0,xmin=2e18,ymax=0,ymin=2e18;
	fur(i,1,n)
	{
		m[i].x=in,m[i].y=in;
		if(m[i].x>m[i].y) swap(m[i].x,m[i].y);
		xmax=max(xmax,m[i].x);
		xmin=min(xmin,m[i].x);
		ymax=max(ymax,m[i].y);
		ymin=min(ymin,m[i].y);
	}
	int ans=(xmax-xmin)*(ymax-ymin);
	sort(m+1,m+n+1,cmp);
	ymin=xmin;
	int maxl=m[1].y,minl=m[1].y,ans2=2e18;
	fur(i,2,n-1)
	{
		maxl=max(maxl,m[i].y);
		minl=min(minl,m[i].y);
		ans2=min(ans2,max(maxl,m[n].x)-min(minl,m[i+1].x));
	}
	if(n>2) ans2*=(ymax-ymin);
	ans=min(ans,ans2);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, Q = map(int, readline().split())

data = [0]*(N+1)
def add(k, x):
    while k <= N:
        data[k] += x
        k += k & -k

def get(k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s


ans = []
for q in range(Q):
    t, *cmd = map(int, readline().split())
    if t:
        ans.append(str(get(cmd[0])))
    else:
        s, t, x = cmd
        add(s, x)
        if t < N:
            add(t+1, -x)
write("\n".join(ans))
write("\n")


Measured memory_bytes: 13948
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(void){
    
    string s;
    cin >> s;
    
    int ans = 0;
    int f = 0;
    for(int i = 0; i < s.length(); i++){
        
        int af = true;
        int c = s[f];
        for(int j = f+1; j < s.length(); j++){
            if(c != s[j]){
                af = false;
                f = j;
                break;
            }
        }
        if(af)break;
        ans++;
        
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;


ll gcd(ll x, ll y){
    if (y==0) return x;
    else return gcd(y, x%y);
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

struct Sieve {
  int n;
  vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }

    // 調和級数によりO(AlogA)で求まる。
    Sieve sieve(1e6);

    vector<ll> pfs(10000005, 0);
    bool isOK = true;
    rep(i,N){
        auto P = sieve.factor(A[i]);

        for(auto p : P){
            if (pfs[p.first] > 0){
                isOK = false;
            }
            pfs[p.first] = p.second;
        }
    }

    if (isOK){
        cout << "pairwise coprime" << endl;
    }
    else{
        ll entire_gcd = A[0];
        for(int i = 1; i < N; i++){
            entire_gcd = gcd(entire_gcd, A[i]);
        }

        if (entire_gcd == 1){
            cout << "setwise coprime" << endl;
        }
        else{
            cout << "not coprime" << endl;
        }
    }
}


Measured memory_bytes: 93512
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353,maxn=1e7;
int n,injc[maxn+5],jc[maxn+5],pw[maxn+5],ans;
int binpow(int a,int t)
{
	int res=1,p=a;
	for (int i=t;i;i>>=1)
	{
		if (i&1) res=1ll*res*p%mod;
		p=1ll*p*p%mod;
	}
	return res;
}
int C(int n,int k)
{
	return (1ll*jc[n]*injc[k]%mod)*injc[n-k]%mod;
}
void Init()
{
	jc[0]=1;
	for (int i=1;i<=maxn;i++) jc[i]=1ll*jc[i-1]*i%mod;
	injc[maxn]=binpow(jc[maxn],mod-2);
	for (int i=maxn-1;i>=0;i--) injc[i]=1ll*injc[i+1]*(i+1)%mod;
	pw[0]=1;
	for (int i=1;i<=maxn;i++) pw[i]=pw[i-1]*2%mod;
}
int main()
{
	scanf("%d",&n);
	Init();
	for (int i=n/2+1;i<=n;i++)
	{
		ans=(1ll*C(n,i)*pw[n-i+1]+ans)%mod;
	}
	ans=(binpow(3,n)-ans)%mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

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

X=[]
S=sum(A)
x1=S
for i in range(N//2):
  x1-=2*A[2*i+1]
  
X.append(x1)

for i in range(1,N):
  X.append(2*A[i-1]-X[i-1])
print(" ".join(map(str,X)))

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


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

int main() {
  int N;
  int current;
  int last = 0;
  ll steps = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> current;
    if (last > current) {
      steps += last - current;
    } else {
      last = current;
    }
  }
  cout << steps << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	cin>>x;
	ll ans = 100;
	ll years = 0;
	while(ans<x)
	{
			years++;
			ll y = ans/100;
			ans += y;
	}
	cout<<years<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin>>s;
    int ans = 0;
    int ma = INT_MIN;
    for(int i=0;i<s.size();i++) {
        if(s[i] == 'R') {
            ans++;
        }
        else {
            ma = max(ma, ans);
            ans = 0;
        }
    }
     ma = max(ma, ans);

    cout<<ma<<endl;
}


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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

bool t[10];

bool chk(li n) {
	stringstream ss;
	ss << n;
	string s = ss.str();
	rep(i, sz(s)) {
		if (t[s[i] - '0'])return false;
	}
	return true;
}

int main() {
	rep(i, 10)t[i] = false;
	li n, k;
	cin >> n >> k;
	rep(i, k) {
		li x;
		cin >> x;
		t[x] = true;
	}

	while (true) {
		if (chk(n)) {
			cout << n << endl;
			return 0;
		}
		n++;
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int n;
int q;
int i,j,count=0;

scanf("%d",&n);
int S[n];
for(i=0;i<n;i++){
  scanf("%d",&S[i]);
}
scanf("%d",&q);
int T[q];
for(i=0;i<q;i++){
  scanf("%d",&T[i]);
}
for(i=0;i<q;i++){
  for(j=0;j<n;j++){
    if(S[j]==T[i]){
      count++;
      break;
    }
  }
}
printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2104
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn gcd(a: usize, b: usize) -> usize {
    if b > a {
        gcd(b, a)
    } else if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn modpow(x: usize, y: usize) -> usize {
    let mut result = 1;
    let mut a = x;
    let mut b = y;
    while b > 0 {
        if b % 2 == 1 {
            result = result * a % M;
        }
        a = a * a % M;
        b /= 2;
    }
    result
}

fn main() {
    input! {
        n: usize,
        ab: [(isize, isize); n],
    }
    let mut factors: HashMap<(usize, usize, bool), usize> = HashMap::new();
    let mut zero_zero = 0usize;
    for i in 0..n {
        let (ai, bi) = ab[i];
        if ai == 0 && bi == 0 {
            zero_zero += 1;
        } else if ai == 0 {
            *factors.entry((0, 1, true)).or_insert(0) += 1;
        } else if bi == 0 {
            *factors.entry((1, 0, false)).or_insert(0) += 1;
        } else if (ai > 0 && bi > 0) || (ai < 0 && bi < 0) {
            let ai = ai.abs() as usize;
            let bi = bi.abs() as usize;
            let c = gcd(ai, bi);
            *factors.entry((ai / c, bi / c, true)).or_insert(0) += 1;
        } else {
            let ai = ai.abs() as usize;
            let bi = bi.abs() as usize;
            let c = gcd(ai, bi);
            *factors.entry((ai / c, bi / c, false)).or_insert(0) += 1;
        }
    }
    // eprintln!("{:?}", factors);
    let mut result = 1;
    for (&key, &c1) in factors.iter() {
        let (ai, bi, positive) = key;
        if let Some(&c2) = factors.get(&(bi, ai, !positive)) {
            if positive {
                let x = modpow(2, c1);
                let y = modpow(2, c2);
                let z = (x + y + M - 1) % M;
                result = (result * z) % M;
            }
        } else {
            result = result * modpow(2, c1) % M;
        }
    }
    result = (result + zero_zero) % M;
    result = (result + M - 1) % M;
    println!("{}", result);
}


Measured memory_bytes: 25464
#include <stdio.h>

int main(void){
  int i,j,n,m,cn;
  char c,s[5]={'S','H','C','D','\0'};
  static int card[4][13];
  scanf("%d\n",&n);

  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&m);
    for(j=0;j<4;j++)
      if(s[j]==c)
        card[j][m-1]=1;
  }
  
  for(i=0;i<4;i++)
    for(j=0;j<13;j++)
      if(card[i][j]==0)
        printf("%c %d\n",s[i],j+1);

  return 0;
}
    



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int A, B;
	cin >> A >> B;
	if (A<10&&B<10) {
		ce(A*B)
	}
	else {
		ce(-1)
	}
    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    ans += (s[0] == '1' ? 1 : 0);
    ans += (s[1] == '1' ? 1 : 0);
    ans += (s[2] == '1' ? 1 : 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
a = np.array(list(map(int,input().split())))

b = a[0]
c = a[1:].sum()
ans = abs(b - c)

for i in range(1, n-1):
  temp = a[i]
  b += temp
  c -= temp

  if ans > abs(b-c):
    ans = abs(b-c)
else:
  print(ans)

Measured memory_bytes: 33080
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vll A(N), B(N), C(N-1);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N-1) cin >> C[i];


    //本文
    ll ans = 0;
    for(int i=0;i<N;i++){
      ll current = A[i]-1;
      ans += B[current];
      if(i>0){
      if(A[i-1]==current) ans += C[current-1];
    }
    }

    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[3][100005],c;
ll dp[2][100005],ans;
int main()
{

    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    for(int i=0;i<3*n;i++)
        cin>>a[i/n][i%n];
    sort(a[0],a[0]+n);
    sort(a[1],a[1]+n);
    sort(a[2],a[2]+n);
    while(a[0][c]<a[1][0]&&c<n){
        c++,dp[0][0]++;
    }
    for(int i=1;i<n;i++){
        dp[0][i]=dp[0][i-1];
        while(a[0][c]<a[1][i]&&c<n){
            c++,dp[0][i]++;
        }
    }
    c=0;
    while(a[1][c]<a[2][0]&&c<n){
        dp[1][0]+=dp[0][c];
        c++;
    }
    ans=dp[1][0];
    for(int i=1;i<n;i++){
        dp[1][i]=dp[1][i-1];
        while(a[1][c]<a[2][i]&&c<n){
            dp[1][i]+=dp[0][c];
            c++;
        }
        ans+=dp[1][i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2944