akhauriyash/Code-Regression huggingface dataset:
N=int(input())
S=input()

R_num=S.count('R')
G_num=S.count('G')
B_num=S.count('B')

ans=0
for k in range(N//2-2+1 if N&1==0 else N//2-1+1):
    flag=0
    for i in range(N-k-2):

        if i+2*(k+1)<=N-1:
            ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
    
            if "R" in ls and "G" in ls and "B" in ls:
                ans+=1


print(R_num*G_num*B_num-ans)

Measured memory_bytes: 67948
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    set<ll> st;
    rep(i, n) {
        ll a;
        cin >> a;
        st.insert(a);
    }

    if(st.size() == n) {
        out("YES");
    }
    else {
        out("NO");
    }

    re0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void)
{
	int H, W, K;
	cin >> H >> W >> K;

	vec ans(W, 0);

	mat dp(H+1, vec(W, 0));

	dp[0][0] = 1;

	rep(H, h)
	{
		rep((1<<(W-1)), bit)
		{
			bool ok = 1;
			rep(W-2, i)
			{
				if (bit >> i & 1 && bit >> (i+1) & 1)
				{
					ok = 0;
					break;
				}
			}

			if (!ok) continue;

			rep(W, i)
			{
				if (i == 0)
				{
					if (bit & 1)
					{
						dp[h+1][i] += dp[h][i+1];
						dp[h+1][i] %= MOD;
					}
					else
					{
						dp[h+1][i] += dp[h][i];
						dp[h+1][i] %= MOD;
					}
					continue;
				}
				if (i == W-1)
				{
					if (bit >> (i-1) & 1)
					{
						dp[h+1][i] += dp[h][i-1];
						dp[h+1][i] %= MOD;
					}
					else
					{
						dp[h+1][i] += dp[h][i];
						dp[h+1][i] %= MOD;
					}
					continue;
				}
				if (bit >> (i-1) & 1)
				{
					dp[h+1][i] += dp[h][i-1];
					dp[h+1][i] %= MOD;
				}
				else if (bit >> i & 1)
				{
					dp[h+1][i] += dp[h][i+1];
					dp[h+1][i] %= MOD;
				}
				else
				{
					dp[h+1][i] += dp[h][i];
					dp[h+1][i] %= MOD;
				}
			}
		}
	}

	//cout << dp[H] << endl;

	cout << dp[H][K-1] << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

const vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};

int H, W;
vector<string> S;
vector<vector<bool>> seen;

ll cntb = 0, cntw = 0;

void dfs(int y, int x) {
  seen[y][x] = true;
  if (S[y][x] == '#') {
    cntb++;
  } else {
    cntw++;
  }

  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
    if (S[ny][nx] == S[y][x]) continue;
    if (seen[ny][nx]) continue;

    dfs(ny, nx);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W;
  S.resize(H), seen.resize(H, vector<bool>(W, false));
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

  ll res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      /* if (S[i][j] == '.') continue; */
      if (seen[i][j]) continue;
      cntb = cntw = 0;
      dfs(i, j);
      res += cntb * cntw;
    }
  }

  cout << res << '\n';
  return 0;
}


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

int main(){
  char a,b;
  cin >> a >> b;
  if(a<b){
    cout << "<" << endl;
  }else if(a>b){
    cout << ">" << endl;
  }else if(a==b){
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
/* 北さん参考 */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int power (int x, int y) {
    int tmp = 1;
    REP(i, y) {
        tmp *= x;
    }
    return tmp;

}

int calcCnt(int money, int rate) {
    /* できるだけ大きい値でおろしつづける */
    int ans = 0;
    int money2 = money;
    while(1) {
        if(money2 < rate) {
            ans += money2;
            return ans;
        }
        int tmp = money2;
        int cnt = 0;
        while(1) {
            if(tmp < rate) break;
            tmp /= rate;
            cnt++;
        }
        money2 -= power(rate, cnt);
        ans++;
    }

}

int main(){
    int n;
    cin >> n;
    int ans = INF;

    /* 9円と6円で引き出せる金額を決める */
    for(int money_9 = 0; money_9 <= n; money_9++) {
        int money_6 = n - money_9;
        int cnt = 0;
        cnt += calcCnt(money_6, 6);
        cnt += calcCnt(money_9, 9);
        //if(ans > cnt) cout << money_6 << " " << money_9 << " " << cnt << endl;
        ans = min(ans, cnt);

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int len;
char a[1000];
int ans;
int main(){
	cin>>a;
	len=strlen(a);
	for(int i=0;i<len/2;i++){
		ans+=a[i]!=a[len-i-1];
	}
	cout<<ans;
	return 0;
}

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

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        decimal[] v = new decimal[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                v[i] = decimal.Parse(words[i]);
            }
        }

        Array.Sort(v);
        decimal value = v[0];
        for (int i = 1; i < n; i++)
        {
            value = (value + v[i]) / 2;
        }

        Console.WriteLine(value);
    }
}

Measured memory_bytes: 11476
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
int main(){
    fast;
    ll n;
    string s;
    cin>>n>>s;
    n=n%26;
    for(int i=0;s[i]!='\0';i++){
        s[i]=int(s[i])+n;
        if(s[i]>=91){
            s[i]=s[i]-26;
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N,T,A,X;
    cin>>N>>T>>A;
    int B=0;
    int C=1<<30;
    for(int i=1;i<=N;i++){
        cin>>X;
        int d=(T*1000-X*6)-A*1000;
        if(d<0)d=-d;
        if(C>d){
            C=d;
            B=i;
        }


    }
    cout<<B<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N, R=0, B=0;
    string s;
    cin >> N >> s;
    for(int i = 0; i<N;++i){
        if(s[i]=='R')R++;
        else B++;
    }
    if(R>B) cout << "Yes" << endl;
    else cout << "No" <<endl;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	map<llong, int> m;
	int n;
	llong in;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> in;
		m[in]++;
	}

	int cnt = 0;
	vector<llong> beki;
	for(llong i = 1; i <= 1e10; i *= 2)
		beki.pb(i);

	auto it = m.end();
	it--;
	for(;;it--){
		cerr << it->first << endl;
		llong check = *upper_bound(beki.begin(), beki.end(), it->first) - it->first;
		if(it->first == check){
			cnt += m[check]/2;
			m[check] = m[check]/2 ? 1:0;
		}else if(m.find(check) != m.end()){
			int dec = min(m[it->first], m[check]);
			cnt += dec;
			m[it->first] -= dec;
			m[check] -= dec;
		}
		if(it == m.begin()) break;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 12800
//Insert DP
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int mod = 1000000007;
	int N, X;
	cin >> N >> X;
	vector<int> s(N, 0);
	for(int i = 0; i < N; i += 1)
	{
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	vector<vector<long>> dp(N + 1, vector<long>(X + 1, 0));
	for(int x = 0; x <= X; x += 1)
	{
		dp[0][x] = x;
	}

	for(int i = 0; i < N; i += 1)
	{
		for(int x = 0; x <= X; x += 1)
		{
			dp[i + 1][x] = (dp[i][x % s[i]] + i * dp[i][x]) % mod; //insert in front of array and in mid of array
		}
	}
	cout << dp[N][X] << endl;
	return 0;
}



Measured memory_bytes: 158592
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

template<class T>bool maxs(T& a,T b){if(a < b){a = b;return true;}else return false;}
ll dp1[5010];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    
    long long n;cin >> n;
    long long g[2],s[2],b[2];
    REP(i,2)cin >> g[i] >> s[i] >> b[i];
    //A->B
    for(ll i = 0;i <= n;i++){
        if(i + g[0] <= n)maxs(dp1[i+g[0]],dp1[i] + g[1] -g[0]);
        if(i + s[0] <= n)maxs(dp1[i+s[0]],dp1[i] + s[1] -s[0]);
        if(i + b[0] <= n)maxs(dp1[i+b[0]],dp1[i] + b[1] -b[0]);
    }
    //B->A
    ll MAX = 0;
    for(ll i = 0;i <= n;i++){
//        cout << dp1[i] << '\n';
        maxs(MAX,dp1[i]);
    }
    MAX += n;
    vector<ll> dp2(MAX+1,0);
    for(ll i = 0;i <= MAX;i++){
        if(i + g[1] <= MAX)maxs(dp2[i+g[1]],dp2[i] + g[0] -g[1]);
        if(i + s[1] <= MAX)maxs(dp2[i+s[1]],dp2[i] + s[0] -s[1]);
        if(i + b[1] <= MAX)maxs(dp2[i+b[1]],dp2[i] + b[0] -b[1]);
    }
    ll ans = 0;
    for(ll i = 0;i <= MAX;i++){
        maxs(ans,dp2[i]);
    }
    cout << ans + MAX << '\n';
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  int n = s.size();
  vector<int> a(n+1,-1);
  
  int res = 0;
  string s1 = s + '<';
  rep(i,n+1){
    if(s1[i]=='<'){
      a[i] = res;
      res++;
    }else{
      a[i]=res;
      res = 0;
    }
  }
  string s2 = '>' + s;
  res = 0;
  for(int i=n;i>=0;i--){
    if(s2[i]=='>'){
      a[i] = max(a[i],res);
      res++;
    }else{
      a[i] = max(a[i],res);
      res = 0;
    }
  }
  ll ans = 0;
  rep(i,n+1){
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3844
import Data.List.Split

toInt :: String -> Int
toInt = read :: String -> Int

doABCswap :: [Int] -> [Int]
doABCswap l = last l : init l

showAnswer :: [Int] -> String
showAnswer (x:[]) = show x
showAnswer (x:xs) = show x ++ " " ++ showAnswer xs 

main = do
  s <- getLine
  putStrLn $ showAnswer . doABCswap $ map toInt (splitOn " " s)

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

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

//階乗,factで初期化
vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

//nCk 繰り返し高速
ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll n,m,k;
  cin >> n >> m >> k;
  ll ans=0;
  fact(n*m);
  for(ll i=1;i<=n-1;i++) {
    ll tans=m*m%mod*(n-i)%mod*i%mod*comb(n*m-2,k-2)%mod;
    (ans+=tans)%=mod;
  }
  for(ll i=1;i<=m-1;i++) {
    ll tans=n*n%mod*(m-i)%mod*i%mod*comb(n*m-2,k-2)%mod;
    (ans+=tans)%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 78336
n = int(input())
A = list(map(int, input().split()))
ans = 0

if n == 0 and A[0] == 1:
    print(1)
    exit()
if n == 0 and A[0] != 1:
    print(-1)
    exit()
if n != 0 and A[0] == 1:
    print(-1)
    exit()


start = 1
way = sum(A)

for i in range(1,n+1):
    start *= 2

    if start < A[i]:
        print(-1)
        exit()
    if start > way:
        start = way

    ans += start
    #print(start, start-A[i])
    start -= A[i]
    way -= A[i]
#print()
print(ans+1)


Measured memory_bytes: 20152
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int l, a, b, c, d;
    cin >> l >> a >> b >> c >> d;
    cout << l-max((a+c-1)/c, (b+d-1)/d) << "\n";
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n;
char lx[N];

int main() {
  scanf("%s", lx + 1);
  int n = strlen(lx + 1);
  for(int i = 1; i <= n; ++i)
    a[i] = (lx[i] == '1');
  if(n & 1) {
    int mid = n / 2 + 1, pd = a[mid], tmp = mid;
    for(int i = mid; i <= n; ++i)
      if(a[i] == pd) tmp = i;
      else break;
    int pos = mid;
    for(int i = mid - 1; i >= 1; --i)
      if(a[i] == pd) pos = i;
      else break;
    printf("%d\n", mid + max(0, min(tmp - mid, mid - pos)));
  } else {
    int mid = n / 2, pd = a[mid];
    if(a[mid] != a[mid + 1]) printf("%d\n", n / 2);
    else {
      int tmp = mid + 1;
      for(int i = mid + 1; i <= n; ++i)
        if(a[i] == pd) tmp = i;
        else break;
      int pos = mid;
      for(int i = mid - 1; i >= 1; --i)
        if(a[i] == pd) pos = i;
        else break;
      printf("%d\n", mid + max(0, min(tmp - mid, mid - pos + 1)));
    } 
  }
  return 0;
}

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

int main(void){
  double x1,y1,x2,y2;

  scanf("%lf",&x1);
  scanf("%lf",&y1);
  scanf("%lf",&x2);
  scanf("%lf",&y2);

  printf("%f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  
  return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ABS(a) ((a)>0 ? (a):-(a))
#define ll long long
#define SWAP(a,b) {a+=b;b=a-b;a-=b;}
ll cmb[52][52];

ll comb(ll n,ll r){
	if(r == 0 || n == r) return 1ll;
	if(r == 1) return n;
	if(cmb[n][r] != 0) return cmb[n][r];
	else return cmb[n][r] = comb(n-1,r-1) + comb(n-1,r);

//	int i;
//	ll p;
//	for(i=1;i<=r;i++) p=p*(n-i+1)/i;
//	return p;
//

}

int main(){
	ll n,a,b,v[52];
	double ave = 0;
	ll numin = 0,numall = 0,num = 0;

	scanf("%lld %lld %lld",&n,&a,&b);
	FOR(i,0,n) scanf("%lld",&v[i]);

	FOR(i,0,n-1){
		FOR(j,i+1,n)
		if(v[i] < v[j]) SWAP(v[i],v[j]);
	}

	FOR(i,0,a) ave += v[i];
	ave /= a;
	printf("%f\n",ave);

	FOR(j,0,a) if(v[j] == v[a-1]) numin ++;
	FOR(j,0,n) if(v[j] == v[a-1]) numall ++;

	memset(cmb,0,sizeof(cmb));

	if(v[0] == v[a-1]){
		FOR(k,a,fmin(b+1,numall+1)) num += comb(numall,k);
	}else{
		num = comb(numall,numin);
	}

	printf("%lld\n",num);

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010;
int n,m;
int a[N];
bool w[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline bool check(int k) {
    for(int i=1;i<=m;i++) w[i]=(a[i]>=k);
    for(int i=0;i<n;i++)
	if(w[n-i]==w[n-i-1]||w[n+i]==w[n+i+1]) return w[n-i];
    return w[1];
}
int main() {
    cin>>n,m=n+n-1;
    for(int i=1;i<=m;i++) a[i]=gi();
    int l=1,r=m;
    while(l<=r) {
	int mid=(l+r)>>1;
	if(check(mid)) l=mid+1;
	else r=mid-1;
    }
    cout<<r;
    return 0;
}

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

bool is_valid(int N, int K, vector<int> D){
  while(N > 0){
    int cur = N % 10;
    for(int j=0; j<K; j++){
      if (cur == D[j]) return false;
    }
    N /= 10;
  }
  return true;
}

int main(){
  int N, K;
  vector<int> D(11);

  cin >> N >> K;
  for(int i=0; i<K; i++) cin >> D[i];

  while (true){
    bool flag = is_valid(N, K, D);
    if(flag) break;
    N++;
  }

  cout << N << endl;
}

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

int main(){
     int N,K;
     while(cin>>N>>K,N||K){
	  int s[K];
	  for(int i=0;i<K;i++){
	       cin>>s[i];
	  }
	  int temp;
	  bool flag=true;
	  for(int j=0;j<N;j++){
	       for(int i=0;i<K;i++){
		    cin>>temp;
		    s[i]-=temp;
		    if(s[i]<0)flag=false;
	       }
	  }
	  if(flag)cout<<"Yes"<<endl;
	  else cout<<"No"<<endl;
     }
}

Measured memory_bytes: 856
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <functional>

#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; while(getline(stream,res,sp_word))
#define rem_space(x) x.erase(remove(all(x), ' '),x.end())
#define scl(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())

using namespace std;

int main(){
  int N;
  scanf("%d",&N);

  int a[N];
  rep(i,N) scanf("%d",&a[i]);

  function<void(int,int)> dsp = [&](int push_btn,int push_cnt){
    if(push_btn == 2){
      printf("%d\n",push_cnt);
      exit(0);
    }else if(push_cnt >= N){
      return;
    }
    dsp(a[push_btn - 1],push_cnt + 1);
  };

  dsp(1,0);
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 3712
import numpy as np

ret = []
use = []

def func(k, n):
    if k == 0:
        if n >= N:
            print(n)
            exit()
        return

    for i in use:
        func(k-1, n*10 + i)

N, K = list(map(int, input().split()))

num = np.array([i for i in range(10)])
f = np.array([True for i in range(10)])

D = list(map(int, input().split()))
for i in D:
    f[i] = False

use = num[f]

func(1, 0)
func(2, 0)
func(3, 0)
func(4, 0)
func(5, 0)


Measured memory_bytes: 15912
h,w=gets.split.map(&:to_i)
canv=[]
h.times{|i|canv[i]=gets}
flag=false
h.times{|y|
  w.times{|x|
    if canv[y][x]=='#' then
      if (y-1<0 or canv[y-1][x]=='.') and (y+1>=h or canv[y+1][x]=='.') and (x+1>=w or canv[y][x+1]=='.') and (x-1>=w or canv[y][x-1]=='.') then
        flag=true
      end
    end
  }
}
puts flag ?"No":"Yes"

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

const int MAX_COLOR = 200000;

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

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

  vector<FiniteField> dp(n);
  vector<vector<int>> c_indexes(MAX_COLOR + 1);

  dp[0] = 1;
  c_indexes[cs[0]].push_back(0);
  for (int i = 1; i < n; i++) {
    int c = cs[i];
    if (c_indexes[c].size() == 0) {
      c_indexes[c].push_back(i);
      dp[i] = dp[i - 1];
    } else {
      int j = c_indexes[c].back();
      if (i - j >= 2) {
        dp[i] = dp[i - 1] + dp[j];
      } else {
        dp[i] = dp[i - 1];
      }

      c_indexes[c].push_back(i);
    }
  }

  cout << dp[n - 1].Value() << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)
#define Foreach(i,arr) For(i,0,arrlen(arr))
#define Arrin(arr) Foreach(i,arr){cin>>arr[i];}
#define Arrin2(arr1,arr2) Foreach(i,arr1){cin>>arr1[i]>>arr2[i];}
#define Arrin3(arr1,arr2,arr3) Foreach(i,arr1){cin>>arr1[i]>>arr2[i]>>arr3[i];}
	
int main(){
	string S;
	cin >> S;
	int N=stoi(S);
	int N1=N/100,N2=N%100;
	
	bool YYMM=false,MMYY=false;
	if(1<=N2&&N2<=12) YYMM=true;
	if(1<=N1&&N1<=12) MMYY=true;
	
	if(YYMM&&!MMYY) cout << "YYMM";
	else if(!YYMM&&MMYY) cout << "MMYY";
	else if(YYMM&&MMYY) cout << "AMBIGUOUS";
	else cout << "NA";
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int n,s,ans=0;
class SumofIntegers{
public:
    void solve(){
        dfs(0,0,0);
        cout<<ans<<endl;
        ans=0;
    }
    void dfs(int d,int sum,int idx){
        if(d==n){
            if(sum==s)ans++;
            return;
        }
        for(int i=idx;i<10;i++)dfs(d+1,sum+i,i+1);
    }
};
int main(){
    SumofIntegers inst;
    while(cin>>n>>s){
        if(n==0&&s==0)break;
        inst.solve();
    }
}

Measured memory_bytes: 2920
S =input()
#print(S)
#文字数をカウントする。
#print(len(S))
count = 0
#文頭と文末の文字を比べる。
#同じであれば次の文字へ移行。
for i in range(len(S)//2):
  if S[i] == S[len(S) - i - 1]:
    i = i+1
    #異なる場合、1回カウント。
  else:
    i =i+1
    count = count + 1
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  int Ai;
  for (int i = 0; i < M; ++i) {
    cin >> Ai;
    ans += Ai;
  }
  ans = N - ans;
  ans = max(-1, ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define F(i,a,b) for(int i=a;i<=b;++i)
int n,a,x=0;
int main()
{
	cin>>n;
	F(i,1,n)
	{
		cin>>a;
		if((i&1)&&(a&1)) ++x;
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 3580
N = int(input())
A_list = list(map(int, input().split()))
from collections import Counter

counter = Counter(A_list)
result = 0
for (key, value) in counter.items():
    #print(key,value)
    result += int(value * (value - 1) / 2)

#print(result)
for a in A_list:
    value = counter.get(a)
    #print(value)
    answer = result - (int(value * (value - 1) / 2)) + int((value - 1) * (value - 2) / 2)
    print(answer)

Measured memory_bytes: 24748
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

MAX_DIFF = 80
h, w = getNM()

A = [getList() for i in range(h)]
B = [getList() for i in range(h)]
c = [[abs(A[i][j] - B[i][j]) for j in range(w)] for i in range(h)]

# bitset高速化
# 集合を010110...の形で持つ
sets = [[0 for j in range(w)] for i in range(h)]
# 中央0: 1 << MAX_DIFFに + c[0][0], - c[0][0]
sets[0][0] = (1 << MAX_DIFF + c[0][0]) | (1 << MAX_DIFF - c[0][0])

# 縦方向に進む
for i in range(1, h):
    # c[i][0]の+-を足したもの
    sets[i][0] |= (sets[i - 1][0] << MAX_DIFF + c[i][0]) | (sets[i - 1][0] << MAX_DIFF - c[i][0])
# 下方向に進む
for i in range(1, w):
    sets[0][i] |= (sets[0][i - 1] << MAX_DIFF + c[0][i]) | (sets[0][i - 1] << MAX_DIFF - c[0][i])
for i in range(1, h):
    for j in range(1, w):
        sets[i][j] |= (sets[i - 1][j] << MAX_DIFF + c[i][j]) | (sets[i - 1][j] << MAX_DIFF - c[i][j])
        sets[i][j] |= (sets[i][j - 1] << MAX_DIFF + c[i][j]) | (sets[i][j - 1] << MAX_DIFF - c[i][j])

# 終点の集合を見る
s = bin(sets[h - 1][w - 1] + (1 << (h + w) * MAX_DIFF))
min_diff = 1 << MAX_DIFF
for i in range(len(s)):
    if s[- 1 - i] == '1': # フラグが立っているなら判定
        min_diff = min(min_diff, abs(i - (h + w - 1) * MAX_DIFF))
print(min_diff)

Measured memory_bytes: 95020
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m, mini, tmp;
  cin >> n >> m;
  int coins[m], dp[50001];
  for(int i = 0; i < m; i++) cin >> coins[i];
  for(int i = 2; i < n + 2; i++){
    mini = n + 1;
    for(int j = 0; j < m; j++){
      if(coins[j] < i){
        tmp = dp[i - coins[j]] + 1;
        mini = min(mini, tmp);
        dp[i] = mini;
      }  
    }
  }
  cout << dp[n + 1] << endl;
}



Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int d;
int c[26],s[365][26],last[26],t[365];

int main() {
  cin >> d;
  for(int i=0;i<26;i++) {
    cin >> c[i];
  }
  for(int i=0;i<d;i++) {
    for(int j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }
  int score=0;
  for(int i=0;i<d;i++) {
    score+=s[i][t[i]];
    last[t[i]]=i+1;
    for(int j=0;j<26;j++) {
      score-=c[j]*(i+1-last[j]);
    }
  }
  int cnt=10000;
  while(cnt--) {
    int day=rand()%d;
    int v=rand()%26;
    int tscore=0;
    for(int i=0;i<26;i++) last[i]=0;
    for(int i=0;i<d;i++) {
      if(day==i) {
        tscore+=s[i][v];
        last[v]=i+1;
      }
      else {
        tscore+=s[i][t[i]];
        last[t[i]]=i+1;
      }
      for(int j=0;j<26;j++) {
        tscore-=c[j]*(i+1-last[j]);
      }
    }
    if(tscore>score) {
      score=tscore;
      t[day]=v;
    }
  }
  for(int i=0;i<d;i++) {
    cout << t[i]+1 << endl;
  }
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

int main() {
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
}


Measured memory_bytes: 256
import collections

N=int(input())
s=[input() for _ in range(N)]

perm_s=["".join(sorted(list(item))) for item in s]
#print(perm_s)
c = collections.Counter(perm_s)
vlist=list(c.values())
print(sum([int(v*(v-1)/2) for v in vlist]))

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

#define int long long int 

int32_t main()
{
   int a,b,c;
   cin>>a>>b>>c;
   int x;
   if((a+b+c)%2 && (3*max({a,b,c}))%2 || (a+b+c)%2==0 && 3*max({a,b,c})%2==0)
   x=max({a,b,c});
   else
   x=max({a,b,c})+1;
  cout<<(3*x-(a+b+c))/2<<endl;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n; cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n == 1) {
        cout << "YES\n"; return 0;
    }
    auto mod = [&](int a, int b, int m) {
        return ((a - b) % m + m) % m;
    };

    int d = mod(a[0], a[n-1], n);
    for (int i = 1; i < n; i++) {
        if (d != mod(a[i], a[i-1], n)) {
            cout << "NO\n"; return 0;
        }
    } 
    long long maxi = 0;
    for (int i = 0; i < n; i++) {
        maxi = max(maxi, a[(i+1)%n]-a[i]);
    }
    long long sub = 0;
    for (int i = 0; i < n; i++) {
        int y = a[(i+1)%n]-a[i];
        if (y < maxi) {
            long long z = (maxi - y) / n;
            sub += z * (n-i);
        }
    }
    if (a[0]-sub >= 0 && (a[0]-sub) % (n*(n+1)/2) == 0) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

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

#define PI acos(-1)
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
#define endl "\n"
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl
#define bug(n) {outl(n);return;}
#define N 100005
ll n,a[N];
multiset<ll> s;
void solve(){
    cin>>n;
    rep(i,1,n+1)cin>>a[i];
    rep(i,1,n+1){
        auto it=s.lbd(a[i]);
        if(it==s.begin())s.insert(a[i]);
        else{
            it--;
            s.erase(it);
            s.insert(a[i]);
        }
    }
    bug(sz(s));
}
void prep(){
    
}
int main(){
    io;
    ll t=1;
    // cin>>t;
    prep();
    fix(12);
    while(t--)
        solve();
    return 0;
}

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

int main(){
	int a,b,W;
	int distance;
	scanf("%d %d %d",&W,&a,&b);

	if(b > a + W){
		distance = b - a - W;
	}
	else if(a > b + W){
		distance = a - b - W;
	}
	else{
		distance = 0;
	}

	printf("%d\n",distance);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int N, M;
vector<vector<int>> adj;
vector<vector<int>> adj_rev;
vector<int> ans;
int root;

vector<int> topological_sort(const vector<vector<int>> &G) {
    int V = G.size();
    vector<int> L;        // トポロジカルソートされたリスト
    queue<int> S;         // 入力辺がないノードたち
    vector<int> Sink(V);  // 入力の個数

    for (int i = 0; i < V; i++)
        for (auto to : G[i]) Sink[to]++;

    for (int i = 0; i < V; i++)
        if (Sink[i] == 0) S.push(i);

    while (!S.empty()) {
        int from = S.front();
        L.push_back(from);
        S.pop();
        for (auto to : G[from]) {
            Sink[to]--;
            if (Sink[to] == 0) S.push(to);
        }
    }
    return L;
}

int main(){
    cin >> N >> M;
    adj.resize(N);
    adj_rev.resize(N);
    ans.resize(N, -1);

    for(int i=0; i<N-1+M; i++){
        int A, B;
        cin >> A >> B;
        A--; B--;
        adj[A].push_back(B);
        adj_rev[B].push_back(A);
    }


    vector<int> topo = topological_sort(adj);
    map<int, int> mp;
    for(int i=0; i<N; i++)
        mp[topo[i]] = i;

    queue<int> que;
    for(int i=0; i<N; i++)
        if(adj[i].empty())
            que.push(i);

    while(!que.empty()){
        int s = que.front();
        que.pop();
        int idx, last = -1;
        for(auto t : adj_rev[s]){
            if(mp[t] > last){
                last = mp[t];
                idx = t;
            }
        }
        if(last == -1) continue;
        ans[s] = idx;
        que.push(idx);
    }


    //for(auto x : topo)
    //    cerr << x << endl;

    //for(int i=0; i<N; i++)
    //    if(adj_rev[i].empty())
    //        root = i;

    //ans[root] = 0;
    //queue<int> que;
    //que.push(root);

    //while(!que.empty()){
    //    int s = que.front();
    //    que.pop();
    //    for(int t : adj[s]){
    //        ans[t] = s;
    //        que.push(t);
    //    }
    //}

    for(int i=0; i<N; i++)
        cout << ans[i] + 1 << endl;

    return 0;
}

Measured memory_bytes: 17268
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define deb(x) cout << #x << " => " << x << endl
#define MOD 1000000007

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

    int n, m;
    cin >> n >> m;
    string mat[n];
    for (int i = 0; i < n; i++) {
        cin >> mat[i];
    }

    int dp[n][m];
    memset(dp, 0, sizeof dp);
    dp[0][0] = mat[0][0] == '.';
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (mat[i][j] == '.') {
                dp[i][j] = (dp[i][j] + (i > 0 ? dp[i - 1][j] : 0)) % MOD;
                dp[i][j] = (dp[i][j] + (j > 0 ? dp[i][j - 1] : 0)) % MOD;
            }
        }
    }
    cout << dp[n - 1][m - 1] << endl;

    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}

Measured memory_bytes: 384
import sys                                                                                                                                                                                                                                                                                      
def range_union(al,ah,bl,bh):
    cl = max(al,bl)
    ch = min(ah,bh)
    if cl > ch:
        return 0
    else:
        return ch-cl +1
 
N = int(sys.stdin.readline())
T = map(int,sys.stdin.readline().strip().split())
A = map(int,sys.stdin.readline().strip().split())
 
p = 1
if N >= 2:
    Tl = T[0]
    Th = T[0]
    if A[0] > A[1]:
        Al = A[0]
        Ah = A[0]
    elif A[1] == A[0]:
        Al = 1
        Ah = A[0]
    else:
        p = 0
        print p
        exit(0)
 
    r = range_union(Tl,Th,Al,Ah)
    if not r:
        p = 0
        print p
        exit(0)
    else:
        p = (p*r) % 1000000007
        
for i in xrange(1,N-1):
    if T[i-1] < T[i]:
        Tl = T[i]
        Th = T[i]
    elif T[i-1] == T[i]:
        Tl = 1
        Th = T[i]
    else:
        p = 0
        break
        
    if A[i] > A[i+1]:
        Al = A[i]
        Ah = A[i]
    elif A[i+1] == A[i]:
        Al = 1
        Ah = A[i]
    else:
        p = 0
        break
 
    r = range_union(Tl,Th,Al,Ah)
    if not r:
        p = 0
        break
    else:
        p = (p*r) % 1000000007
 
if N >= 2:
    Al = A[-1]
    Ah = A[-1]
    if T[-1] > T[-2]:
        Tl = T[-1]
        Th = T[-1]
    elif T[-1] == T[-2]:
        Tl = 1
        Th = T[-1]
    else:
        p = 0
        print p
        exit(0)
 
    r = range_union(Tl,Th,Al,Ah)
    if not r:
        p = 0
        print p
        exit(0)
    else:
        p = (p*r) % 1000000007
 
if A[0] != T[-1]:
    print 0
    exit(0)
print p 

Measured memory_bytes: 14552
package main

import (
	"fmt"
	"math"
)

var N, X, ans int

func main() {
	fmt.Scan(&N, &X)

	L := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&L[i])
	}

	ans = 1
	var D int
	for i := 1; i <= N; i++ {
		D = D + L[i-1]
		if X < D {
			break
		}
		ans++
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e3 + 5;
ll n, t, vis[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		vector<queue<ll>> v(n + 5);
		for (ll i = 1; i <= n; ++i)
			for (ll j = 1; j < n&&cin >> t; ++j)
				v[i].emplace(t);
		ll ans = 0;
		bool go = true;
		while (go)
		{
			go = false;
			for (ll i = 1; i <= n; ++i)
				vis[i] = 0;
			for (ll i = 1; i <= n; ++i)
				if (!v[i].empty() && !vis[i])
				{
					ll tmp = v[i].front();
					if (!v[tmp].empty() && !vis[tmp] && v[tmp].front() == i)
						v[i].pop(), v[tmp].pop(), vis[tmp] = vis[i] = 1, go = true;
				}
			ans++;
			ll sum = 0;
			for (ll i = 1; i <= n; ++i)
				sum += v[i].size();
			if (!sum)
				go = false;
			if (ans > 100000)
			{
				cout << 499500 << endl;
				return 0;
			}
		}
		bool flag = true;
		for (ll i = 1; i <= n&&flag; ++i)
			if (!v[i].empty())
				flag = false;
		cout << (flag ? ans : -1) << endl;
	}
}
/*
3
2 3
1 3
1 2

4
2 3 4
1 3 4
4 1 2
3 1 2

3
2 3
3 1
1 2
*/

Measured memory_bytes: 8960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();

        int answer = b % a == 0 ? a + b : b - a;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main(){
  int N;
  cin>>N;
  int jump[N];
  for(int i=0;i<N;i++){
    cin>>jump[i];
  }
  int jum_dis=0;
  for(int i=0;i<N-1;i++){
    jum_dis=max(jum_dis,jump[i]);
    if(jum_dis<10){cout<<"no\n";return 0;}
    jum_dis -= 10;
  }

  jum_dis=0;
  for(int i=0;i<N-1;i++){
    jum_dis=max(jum_dis,jump[N-i-1]);
    if(jum_dis<10){cout<<"no\n";return 0;}
    jum_dis -= 10;
  }

  cout<<"yes\n";
}



Measured memory_bytes: 4252
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	string S;
	cin >> S;
	if (S == "ABC") {
		cout << "ARC" << endl;
	} else {
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int ans=0,num=0;
string s;

int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S') num++;
		else{
			if(num) num--;
			else ans++;
		}
	}
	cout<<ans+num<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int x,y,r=0;
  cin>>x>>y;
  if(x==y&&y==1)r+=4;
  r+=max(0,4-x)+max(0,4-y);
  cout<<(r?r:0)<<(r?"00000":"");
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
struct node{
	int p,l,r;
}tree[30];
void preorder(int u){
	if(u==NIL)return;
	printf(" %d",u);
	preorder(tree[u].l);
	preorder(tree[u].r);
}
void inorder(int u){
	if(u==NIL)return;
	inorder(tree[u].l);
	printf(" %d",u);
	inorder(tree[u].r);
}
void postorder(int u){
	if(u==NIL)return;
	postorder(tree[u].l);
	postorder(tree[u].r);
	printf(" %d",u);
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)tree[i].p = tree[i].l = tree[i].r = NIL;
	
	for(int i=0;i<n;++i){
		int pa,lc,rc;
		scanf("%d %d %d",&pa,&lc,&rc);
		tree[pa].l = lc;
		tree[pa].r = rc;
		if(lc!=NIL)tree[lc].p = pa;
		if(rc!=NIL)tree[rc].p = pa;
	}
	int root;
	for(int i=0;i<n;++i)if(tree[i].p==NIL){root=i;break;}
	
	printf("Preorder\n");
	preorder(root);
	printf("\n");
	
	printf("Inorder\n");
	inorder(root);
	printf("\n");
	
	printf("Postorder\n");
	postorder(root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

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

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main(void) {
  int K;
  char str[] = "ACL";
  char ans[20] = "";
  scanf("%d", &K);

  for(int i = 0; i < K; i++) {
    strcat(ans, str);
  }

  printf("%s\n", ans);

  return 0;
}

Measured memory_bytes: 1620