akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

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

typedef unsigned long long u8;

u8 A[100000];
int bits[40] = { 0 };
bool flags[40];

int main()
{
	int N;
	u8 K;
	u8 sum = 0;
	u8 tmp, tmp2 = 1;
	int stop = 0;
	bool skip = false;

	cin >> N >> K;

	tmp = K;
	while (tmp > 0) {
		stop++;
		tmp >>= 1;
	}

	rep(i, N) {
		cin >> A[i];
		sum += A[i];
		tmp = A[i];
		for (int j = 0; j < stop; j++) {
			if (tmp & 1) bits[j]++;
			tmp >>= 1;
		}
	}

	tmp = K;
	rep(i, stop) {
		if (tmp & 1) flags[i] = true;
		else flags[i] = false;
		tmp >>= 1;
	}

	/*
	cout << "bits  : ";
	for (int i = stop - 1; i >= 0; i--) cout << bits[i] << " ";
	cout << endl;

	cout << "flags : ";
	for (int i = stop - 1; i >= 0; i--) cout << flags[i] << " ";
	cout << endl;

	cout << "skip  : ";
	*/

	tmp2 = 1;
	rep(i, stop) tmp2 <<= 1;

	for (int i = stop - 1; i >= 0; i--) {
		tmp2 >>= 1;

		if (bits[i] <= N / 2) {

			if ((skip)
				&& (!flags[i])) {
			}
			else {
				tmp = (u8)N - (bits[i] * (u8)2);
				sum += tmp2 * tmp;
			}
			if (i < stop - 1) continue;

			if (bits[i] < N / 2) skip = true;
			else if (N % 2) skip = true;
		}
		else if (flags[i]) skip = false;

		//cout << skip << " ";
	}

	cout << sum << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,k;
ld ans = 0;

int main(){
  cin >> n >> k;
  for(ll i = 1;i <= n;i++){
    ll cnt = 1;
    ll x = i;
    while(x < k){
      x *= 2;
      cnt *= 2;
    }
    ans += 1/(ld)cnt/n;
  }
  cout << setprecision(17);

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n;
    cin >> n;
    vint num(1e5 + 5, 0);
    int ma = 0;
    rep(i, n){
        int tmp;
        cin >> tmp;
        num[tmp]++;
        ma = max(ma, tmp);
    }

    //連続する3項の和を取り最大値を取る
    int ans = 0;
    for(int i = 0; i <= ma; i++){
        int tmp = 0;
        tmp = accumulate(num.begin() + i, num.begin() + i + 3, 0);
        ans = max(ans, tmp);
        // cout << tmp << endl;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll a,b,c; cin>>a>>b>>c;
    a-=b;
    if(a>=c) cout<<"0\n";
    else cout<<c-a<<"\n";
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    set<ll> arr;

    for (int i = 0; i < 3; i++)
    {
        ll p;
        cin >> p;
        arr.insert(p);
    }

    if (arr.size() == 2)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

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

int main()
{
    int m, d;
    cin >> m >> d;
    long long ans = 0;
    for (auto month = 1; month <= m; month++)
    {
        for (auto day = 22; day <= d; day++)
        {
            int tmp = day;
            int d1 = tmp % 10;
            tmp /= 10;
            int d2 = tmp % 10;

            if (d1 >= 2 && d2 >= 2 && d1 * d2 == month)
            {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
          .  .
          |\_|\
          | a_a\
          | | "]
      ____| '-\___
     /.----.___.-'\
    //        _    \
   //   .-. (~v~) /|
  |'|  /\:  .--  / \
 // |-/  \_/____/\/~|
|/  \ |  []_|_|_] \ |
| \  | \ |___   _\ ]_}
| |  '-' /   '.'  |
| |     /    /|:  |
| |     |   / |:  /\
| |     /  /  |  /  \
| |    |  /  /  |    \
\ |    |/\/  |/|/\    \
 \|\ |\|  |  | / /\/\__\
  \ \| | /   | |__
       / |   |____)
       |_/
*/

#include <bits/stdc++.h>

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;



int main()
{
    FLASH
    string s,t;
    cin >> s >> t;
    for(int i = 0;i < s.size();i++)
    {
      if(s[i] != t[i])
      {
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";  
    return 0;
}



Measured memory_bytes: 3640
S = list(str(input()))
N = len(S)
revS = S[::-1]

num1 = int((N-1)/2)
num2 = int((N+3)/2)

strN = S[1:num1]
endN = S[num2:N]

if S == revS and strN == endN:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, m;
const int MAXN = 55;
int a[MAXN], b[MAXN];
bool graph[MAXN][MAXN];
bool vis[MAXN];

void dfs(int v) {
  if (vis[v]) return;
  vis[v] = true;
  rep(i,n) {
    if (graph[v][i]) dfs(i);
  }
  return;
}

int main () {
  cin >> n >> m;
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;
  rep(i,m) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    rep(j,n) vis[j] = false;
    dfs(0);
    bool bridge = false;
    rep(j,n) {
      if (!vis[j]) {
        bridge = true;
        break;
      }
    }
    if (bridge) ans++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}
template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int A, B, C,K, re = 0;
    bool t = false;
    cin >> A >> B >> C >> K;

    if (A >= B) {
        rep(i, K){
            B *= 2;
            if (A < B){
                re = i + 1;
                break;
            }
}
    }
    if (K - re != 0) {
        rep(k, K - re) {
            C *= 2;
            if (B < C) {
                t = true;
                break;
            }
        }
    }
    if (t) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    
    return 0;
}

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    int c, n = 0, t = 0;
    while((c = fgetc(stdin)) != EOF){
        pr(c);
        if(isdigit(c)){
            n = n * 10 + (c - '0');
        } else {
            t += n; n = 0;
        }
    }
    t += n;

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int d,t,s;
	string  ans="No";
	cin >>d>>t>>s;
	if (t*s>=d)ans="Yes";
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3592
N,K = map(int,input().split())

sunuke = [0]*(N+1)
for i in range(K):
  okashi_category = input()
  #print (okashi_category)
  if okashi_category ==1:
    sunuke[input()]=1
  else:
    sunukelist = list(map(int,input().split()))
    for j in range(len(sunukelist)):
      #print(sunukelist[j])
      sunuke[sunukelist[j]]=1

print (N-sum(sunuke))

Measured memory_bytes: 9192
import collections
n = int(input())
a = list(map(int,input().split()))
maxVal = max(a)
minVal = min(a)
a = collections.Counter(a)
ans = 0
for i in range(max(0, minVal-1), maxVal+1):
  temp = a[i - 1] + a[i] + a[i + 1]
  ans = max(ans, temp)
print(ans)

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

int main()
{
	string s; cin >> s;
	vector<int> c(s.size()); for (int i = 0; i < s.size(); i++) c[i] = (int)(s.at(i) - '0');
	
	int ans = 2147483647;
	for (int i = 0; i <= s.size() - 3; i++) {

		int tmp = 100 * c[i] + 10 * c[i + 1] + c[i + 2];
		ans = min(ans, abs(753 - tmp));
	
	}

	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;


vector<int> A[15];
int p[15];
int m, n;
bool check(int x){
    for(int i = 1; i <= m; i++)
    {
        int cnt = 0;
        for(int j = 0; j < A[i].size(); j++){
            int k = A[i][j]-1;
            if((x>>k) & 1)
                cnt++;
        }
        if(cnt % 2 != p[i])
            return false;
    }
    return true;
}
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int x;
            cin >> x;
            A[i].push_back(x);
        }
    }
    for(int i = 1; i <= m; i++){
        cin >> p[i];
        p[i] %= 2;
    }
    int ans = 0;
    for(int i = 0; i < (1<<n); i++){
        if(check(i))
            ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = str(input())
result = ['AC','WA','TLE','RE']
resultnum = [0,0,0,0]
for i in range(N):
    if S[i] == result[0]:
        resultnum[0] += 1
    if S[i] == result[1]:
        resultnum[1] += 1
    if S[i] == result[2]:
        resultnum[2] += 1
    if S[i] == result[3]:
        resultnum[3] += 1
for i in range(4):
    print(str(result[i]) + ' x ' + str(resultnum[i]))

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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int count=1;
    int min=p[0];
    for(int i=1;i<n;i++){
        if(min>p[i]){
            count++;
            min=p[i];
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

int main() {
    unsigned long x;
    std:: cin >> x;

    for (int i = -150; i <= 150; ++i) {
        for (int j = -150; j <= 150; ++j) {
            unsigned long pow1 = std::pow(i, 5);
            unsigned long pow2 = std::pow(j, 5);
            if (pow1 - pow2 == x || pow2 - pow1 == x ) {
                std::cout << std::max(i, j) << " " << std::min(i, j);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4036
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

x, k, d = map(int, input().split())

x = abs(x)

if x - (k * d) >= 0:
    print(x - (k * d))
    sys.exit(0)
else:
    remain = k - (x // d)
    p_min = x % d
    n_min = abs(p_min -d)
    if remain % 2 == 0:
        print(p_min)
    else:
        print(n_min)


Measured memory_bytes: 61820
N = int(input())
a = list(map(int,input().split()))

if N == 2:
    print(2*abs(a[1]-0))
    print(2*abs(a[0]-0))
else:
    lto = [0]*(N+1)
    lflo = [0]*(N+1)
    lto[0] = abs(a[0]-0)
    for i in range(1,N):lto[i] = abs(a[i] - a[i-1]) + lto[i-1]

    lflo[N] = abs(a[N-1]-0)
    for j in range(N-1,0,-1):lflo[j] = abs(a[j]-a[j-1]) + lflo[j+1]
    for i in range(N):
        t = f = con = 0
        if i==0:
            t = abs(a[1]-0)
            f = lflo[i+2]
        elif i == N-1:
            t = lto[i-1]
            f = abs(a[N-2] - 0)
        else:
            t = lto[i-1]
            f = lflo[i+2]
            con = abs(a[i+1]-a[i-1])
        print(t+con+f)

Measured memory_bytes: 16004
#include<stdio.h>
int main(void){
  int k,l,m,n=0,h[101];
  char a[201][101];
  while(1){
    n = 0;
    for(k=1;k<=200;k++){
      for(l=0;l<=100;l++){
        a[k][l]=0;
      }
    }
    scanf("\n");
    for(k=1;k<=200;k++) {
      scanf("%c",&a[k][0]);
      if(a[k][0]=='\n') break;
      n++;
    }
    if(a[1][0]=='-') break;
    scanf("%d",&m);
    for(k=1;k<=m;k++){
    scanf("%d",&h[k]);
    }
    for(l=1;l<=m;l++){
      for(k=1;k<=h[l];k++){
        if(1<=k<=h[l]){
          a[n-k+1][l] = a[h[l]-k+1][l-1];
        }
      }
      for(k=1;k<=n-h[l];k++){
        if(h[l]<k<=n){
          a[k][l] = a[h[l]+k][l-1];
        }
      }
    }
    for(k=1;k<=n;k++){
      printf("%c",a[k][m]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2060
/*Learning is endless*/
#include <bits/stdc++.h>
#define endl "\n";
#define pii pair<int,int>;
using namespace std;
typedef long long ll;
const ll BIG=1000000007;
const double PI=3.141592653589793238;
ll binpow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a)%m;}
    b>>=1;a=(a*a)%m;
    }
    return res;
}
template <typename T,typename Q>
T max(T a,Q b)
{
    if(a<b)
        return b;
    return a;
}
template <typename T,typename Q>
T min(T a,Q b)
{
    if(a>b)
        return b;
    return a;
}
long gcd(long a,long b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void solve()
{
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s')
    {
        cout<<s<<"es";
    }
    else
    {
        cout<<s<<"s";
    }
}
int main() {
    int t;
    t=1;
    while(t--)
        solve();
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h=0,j,i,k;
	char z[101][101];
	scanf("%d %d %d",&a,&s,&d);
	for(i=0;i<a;i++) scanf("%s",z[i]);
	for(i=0;i<a;i++){
		for(j=0;j<s;j++){
			if(z[i][j]=='.'){
				f=0;
				g=0;
				for(k=0;k<d;k++){
					if(i+d-1>=a) f=1;
					if(z[i+k][j]=='#') f=1;
					if(j+d-1>=s) g=1;
					if(z[i][j+k]=='#') g=1;
				}
				if(f==0) h++;
				if(g==0) h++;
			}
		}
	}
	printf("%d\n",h);
	return 0;
}

Measured memory_bytes: 2768
#include <iostream>
#include <string>
#include <stack>
#include<cstdlib>
using namespace std;

int main (){
    int n,m;
    stack<int> operand;
    string g;

    while(cin >> g){
                if ("+" == g) {
                    n = operand.top();
                    operand.pop();
                    m = operand.top();
                    operand.pop();
                    operand.push(n + m);
                }
                else if ("-" == g) {
                    n = operand.top();
                    operand.pop();
                    m = operand.top();
                    operand.pop();
                    operand.push(m - n);
                }
                else if ("*" == g) {
                    n = operand.top();
                    operand.pop();
                    m = operand.top();
                    operand.pop();
                    n = n * m;
                    operand.push(n);
                }
                else {
                    operand.push(atoi(g.c_str()));
                }
    }
    cout << operand.top() << endl;
    return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define maxn 1000005
int T,n;
P a[maxn];
char s[maxn];
bool cmp(P x,P y)
{
    if(min(x.second,y.first)!=min(x.first,y.second))
        return min(x.second,y.first)>min(x.first,y.second);
    return x.second>y.second;
}
int main()
{

    scanf("%d",&n);
    int ans=0,m=0,totlen=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        int len=strlen(s),L=0,R=0;totlen+=len;
        for(int j=0;j<len;j++)
        {
            if(s[j]=='(')L++;
            else
            {
                if(L)ans+=2,L--;
                else R++;
            }
        }
        if(L+R)a[m++]=P(R,L);
    }
    if(m)sort(a,a+m,cmp);
    for(int i=0;i<m-1;i++)
    {
        ans+=2*min(a[i].second,a[i+1].first);
        a[i+1].second+=a[i].second-min(a[i].second,a[i+1].first);
    }
    if (ans==totlen) puts("Yes");else puts("No");
    return 0;
}

Measured memory_bytes: 9404
class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i + 1] = self.factorial[i] * (i + 1) % mod
        self.inv[n] = pow(self.factorial[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def fact(self, m):
        return self.factorial[m]

    def invfact(self, m):
        return self.inv[m]


MOD = 10**9 + 7

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

D = [X[i + 1] - X[i] for i in range(N - 1)]

F = Factorial(N + 1, MOD)

res = 0
f = 0

for i in range(N - 1):
    f = (i + 1) * f + F.fact(i)
    f %= MOD
    res += D[i] * f * F.invfact(i + 1) * F.fact(N - 1)
    res %= MOD

print(res)

Measured memory_bytes: 65176
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int n, k,x,y,ans;
	std::cin >> n >> k >> x >> y;
	ans = (n >= k) ? (x*k+y*(n-k)) : (x*n);
	std::cout << ans << std::endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  string s,t; cin >>s >>t;
  rep(i,n){
    printf("%c%c",s.at(i),t.at(i));
  }
}

/// confirm df==0 ///


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

using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m, x;
    cin >> n >> m >> x;
    vector <vector <int> > data(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int a;
            cin >> a;
            data[i].push_back(a);
        }
    }
    int ans = 1e9;
    for (int mask = 0; mask < (1 << n); ++mask) {
        vector <int> cur(m, 0);
        int tmp = 0;
        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) {
                tmp += data[i][0];
                for (int j = 1; j <= m; ++j) {
                    cur[j - 1] += data[i][j];
                }
            }
        }
        int cur_h = 0;
        for (auto i : cur) {
            if (i >= x) ++cur_h;
        }
        if (cur_h == m) ans = min(tmp, ans);
    }
    if (ans == 1e9) cout << -1;
    else cout << ans;
    return 0;
}



Measured memory_bytes: 3664
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

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

            int a = 0;
            {
                List<Integer> list = new ArrayList<>();
                for (int i = 1; i <= N; i++) {
                    list.add(i);
                }

                for (int i = 0; i < N - 1; i++) {
                    int index = list.indexOf(P[i]);
                    a += index * factorial(N - 1 - i);
                    list.remove(index);
                }
            }

            int b = 0;
            {
                List<Integer> list = new ArrayList<>();
                for (int i = 1; i <= N; i++) {
                    list.add(i);
                }

                for (int i = 0; i < N - 1; i++) {
                    int index = list.indexOf(Q[i]);
                    b += index * factorial(N - 1 - i);
                    list.remove(index);
                }
            }

            System.out.println(Math.abs(a - b));
        }
    }

    public static long factorial(long N) {
        if (N == 1) {
            return 1;
        }
        return N * factorial(N - 1);
    }

}


Measured memory_bytes: 23252
from itertools import product

N = int(input())
MOD = 10 ** 9 + 7

dpm = {
    ''.join(k):1
    for k in product('ACGT', repeat = 3)
}

for k in ('AGC', 'ACG', 'GAC'):
    dpm[k] = 0

def ok4(last4):
    for i in range(4):
        t  = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

i = 3
ans = 61

while i < N:
    ndpm = {k:0 for k in dpm}
    for k in dpm:
        for c in 'AGCT':
            ns = k + c
            if ok4(ns):
                ndpm[ns[-3:]] += dpm[k]
    dpm = ndpm
    i += 1                

print(sum(dpm.values()) % MOD)

Measured memory_bytes: 3064
n, m, c = map(int, input().split())
blist = [int(i) for i in input().split()]
codes = [input().split() for i in range(n)]
codes = [[int(j) for j in i] for i in codes]
sum_1 = 0
ans = 0
for code in codes:
    for num in range(m):
        sum_1 += code[num]*blist[num]
    sum_1 += c
    if sum_1 >0:
        ans += 1
        sum_1 = 0
    else:
        sum_1 = 0

print(ans)

Measured memory_bytes: 38256
N = int(input())
def summ(X):
  a = X//10000000
  b = (X - a*10000000)//1000000
  c = (X - a*10000000 - b*1000000)//100000
  d = (X - a*10000000 - b*1000000 - c*100000)//10000
  e = (X - a*10000000 - b*1000000 - c*100000 - d*10000)//1000
  f = (X - a*10000000 - b*1000000 - c*100000 - d*10000 - e*1000)//100
  g = (X - a*10000000 - b*1000000 - c*100000 - d*10000 - e*1000 - f*100)//10
  h = X - a*10000000 - b*1000000 - c*100000 - d*10000 - e*1000 - f*100 - g*10
  return a+b+c+d+e+f+g+h
if N % summ(N) == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
from copy import deepcopy

S = input()
T = input()

answer = ''
for i in range(len(S)-len(T)+1):
    found = True
    if any([S[i+j] != '?' and S[i+j] != T[j] for j in range(len(T))]):
        continue
    tmp = deepcopy(S).replace('?', 'a')
    tmp = tmp[:i] + T + tmp[i+len(T):]
    if answer == '' or tmp < answer:
        answer = tmp

if answer == '':
    print('UNRESTORABLE')
else:
    print(answer)

Measured memory_bytes: 3444
N = int(input())
L = []
for i in range(N):
  L.append(list(input().split()))
Y = 0
B = 0
for i in range(N):
  if L[i][1] =='JPY':
    Y +=float(L[i][0])
  else:
    B +=float(L[i][0])
print(Y+B*380000)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
main()
{
    long long int a,b,c,d;double e,f;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    e=a*1./d;
    f=c*1./b;
    if(e>f)
    printf("Yes");
    else{
      if(ceil(e)==ceil(f))
      printf("Yes");
  
    else 
    
    printf("No");
 }
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#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() {
    ll r, d, x;
    cin >> r >> d >> x;
    ll ans = x;
    rep(i,10) {
        ans = r*ans-d;
        cout << ans << endl;
    }
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

char s[maxn];

void solve() {
    cin >> s + 1;
    if (s[3] == s[4] && s[5] == s[6]) cout << "Yes\n";
    else cout << "No\n";
}

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


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    // if (B > A * C) {
    //     cout << C << endl;
    // } else {
    //     cout << B / A << endl;
    // }

    cout << min(B / A, C) << endl;
    
    return 0;
}

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

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

    if((s[0] == s[1]) && (s[1] == s[2])) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
    return 0;
}


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

int main()
{
    char c[20];
    scanf("%s",c);
    int sum = 0;
    for(int i = 0;i < strlen(c);i++){
    	if(c[i] == 'x') sum++;
	}
	if(sum <= 7) printf("YES");
	else printf("NO");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;

#define ll long long 
#define N 1000000000000000000

ll A, B, C, K;


int solve(){
	if(A-B < -N || N < A-B){
		cout << "Unfair" << endl;
		return 0;
	}

	if(K%2 == 1){
		cout << B-A << endl;
	}else{
		cout << A-B << endl;
	}
	return 0;
}

int main(){
	cin >> A >> B >> C >> K;
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String S = sc.next();
        int len = 0;
        int max = 0;
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
                len++;
            } else {
                len = 0;
            }
            max = Math.max(max, len);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<ll> lucas(N + 1);
    lucas[0] = 2;
    lucas[1] = 1;
    rep(i, 2, N + 1)
    {
        lucas[i] = lucas[i - 1] + lucas[i - 2];
    }
    cout << lucas[N] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<cstdio>
using namespace std;
int A[100005];
int B[100005];
int C[100005];
int book[100005];
int  main()
{
    int n;
    cin>>n;
    long long sum=0;
    for(int i=0;i<n;++i)
    	{
    		cin>>A[i];
    		sum+=A[i];
    		book[A[i]]++;
    	}
    int m;
    cin>>m;
    for(int i=0;i<m;++i)
    	{
    		cin>>B[i]>>C[i];
    		sum=sum+book[B[i]]*(C[i]-B[i]);
    		cout<<sum<<endl;
    		book[C[i]] += book[B[i]];
    		book[B[i]]=0;
    	}

    return 0;
}



Measured memory_bytes: 4740
#include<stdio.h>
int main()
{
    int H,N,sum=0,i;
    scanf("%d%d",&H,&N);
    int ar[N];
    for(i=0;i<N;i++)
    {
        scanf("%d",&ar[i]);
        sum=sum+ar[i];
    }
    if(sum>=H)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1988
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL)

const ll modd=1e9+7;
const ll inff=1e18;

ll poww(ll a,ll b,ll modulo){
  ll ans=1;
  while(b){
    if(b&1LL) ans=(ans*a)%modulo;
    a=(a*a)%modulo;
    b=b>>1LL;
  }
  return ans;
}

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

int main(){
  fastt;
   
  ll n , rem[3] = {0} , tot = 0;
  string x;

  cin >> n >> x;

  for(auto j: x) tot += (j == '1' ? 1 : 0);

  for(ll i = 0; i < n; i++){
      if(tot - 1 > 0){
          rem[0] = (rem[0] + (x[i] - '0') * poww(2,n-i-1,(tot-1))) % (tot-1);
      }
      if(tot > 0){
          rem[1] = (rem[1] + (x[i] - '0') * poww(2,n-i-1,(tot))) % (tot);
      }
      if(tot+1 > 0){
          rem[2] = (rem[2] + (x[i] - '0') * poww(2,n-i-1,(tot+1))) % (tot+1);
      }
  }


  for(ll i = 0; i < n; i++){
      ll ans = 0 , num = 0 , cnt = 0;
      if(x[i] == '1'){
          if(tot - 1 > 0) {
              ans++;
              num = (rem[0] - poww(2,n-i-1,tot-1) + 2*(tot-1)) % (tot-1);
          }
          while(tot-1 > 0 && num > 0){
              cnt = __builtin_popcount(num);
              num %= cnt;
              ans++;
          }
          cout << ans << '\n';
      }
      else{
          if(tot + 1  > 0) {
              ans++;
              num = (rem[2] + poww(2,n-i-1,tot+1)) % (tot+1);
          }
          while(tot+1 > 0 && num > 0){
              cnt = __builtin_popcount(num);
              num %= cnt;
              ans++;
          }
          cout << ans << '\n';
      }
      
  }
 
  return 0;
}

Measured memory_bytes: 3744
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var t0,x0,y0 int
  var t1,x1,y1 int
  var dt,dd int
  var txy []int
  t0,x0,y0 = 0,0,0
  for i:=0;i<n;i++ {
    txy = NextIntArray()
    t1,x1,y1 = txy[0],txy[1],txy[2]
    dt = t1-t0
    dd = abs(x1-x0) + abs(y1-y0)
    if dt >= dd && (dt-dd)%2 == 0 {
      t0,x0,y0 = t1,x1,y1
      continue
    } else {
      fmt.Println("No")
      os.Exit(0)
    }
  }
  fmt.Println("Yes")
}
func abs(n int) int {
  if n < 0 { return -n }
  return n
}

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

int main(){
  int N; cin >> N;
  int tmp = N;
  int ans = 0;
  while(tmp > 0){
    ans+= tmp%10;
    tmp /= 10;
  }
  
  cout << (ans == 1?10:ans) << endl;
}

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

int main() {

int N,M;
cin >> N >> M;
int sum = 0;
vector<int> A(M);

for (int i=0; i<M; i++){
    cin >> A.at(i);
}

for (int i=0; i<M; i++){
    sum += A.at(i);
}

if (N < sum) {
    cout << -1 << endl;
}
else {
    cout << N - sum << endl;
}

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[8] = {-1,0,1,-1,1,-1,0,1};
int sj[8] = {-1,-1,-1,0,0,1,1,1};

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<ll> s(n-1);
  s[0] = a[0];
  rep(i,n-2){
    s[i+1] = (s[i] + a[i+1])%M;
  }

  ll ans = 0;
  for (int i = 1; i <n; i++){
    ans += (a[i] * s[i-1])%M;
    ans %= M;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6424
/*input
15
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
9
5 4 3 2 1 2 3 4 5
*/

#include <bits/stdc++.h>

using namespace std;
 
const int N = 200004;
int a[N], b[N];

int main() {
  int n,m;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", b+i);
  }

  sort(a,a+n);
  sort(b,b+m);

  int i = 0;
  for (int j = 0; j < n && i < m; ++j) {
    if (a[j] == b[i]) i++;
  }

  puts(i < m ? "NO" : "YES");
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    int n,a[200001],i,j,tmp;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(i=n-1; i>=0; i=i-2)
        printf("%d ",a[i]);
    if(i%2==0)i=1;
    else i=0;
    for(i; i<=n-2; i=i+2)
        printf("%d ",a[i]);
    return 0;
}


Measured memory_bytes: 2816
N, K = map(int, input().split())
H = list(map(int, input().split()))

cost = [0] * N
for i in range(1, N):
  #print('i=', i)
  st = max(i - K, 0)
  ci = 10**18

  for j in range(st, i):
    if cost[j] < ci:
      cj = cost[j] + abs(H[i] - H[j])
      #print('cj=', cj)
      ci = min(cj, ci)

  #print('ci=', ci)
  cost[i] = ci

#print(cost)
ans = cost[N-1]
print(ans)

Measured memory_bytes: 52448
S = input()
T = input()
ans = 0
if T in S:
    print(ans)
else:
    s = list(S)
    t = list(T)
    ans = 10000
    for i in range(len(S)-len(T)+1):
        count = 0
        for j in range(len(T)):
            if s[i+j] != t[j]:
                count += 1
        if count < ans:
            ans = count
    print(ans)

Measured memory_bytes: 9124
import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    X, Y = [], []
    for _ in range(n):
        x, y = map(int, input().split())
        X.append(x)
        Y.append(y)
    X_s = sorted(X)
    Y_s = sorted(Y)
    f_inf = float("inf")
    res = f_inf

    for x1 in range(n):
        for x2 in range(x1 + 1, n):
            for y1 in range(n):
                for y2 in range(y1 + 1, n):
                    lx, rx = X_s[x1], X_s[x2]
                    by, uy = Y_s[y1], Y_s[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, abs(rx - lx) * abs(uy - by))
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47964
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    }
}

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

int main() {
	int n,x;cin>>n>>x;
  	int gokei=0,small=1001;
  	vector<int> m(n);
  	for(int i=0;i<n;i++){
      cin>>m[i];
      gokei+=m[i];
      small=min(small,m[i]);
    }
  	cout<<n+(x-gokei)/small<<endl; 	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int cards[4][13];
	int x,i,j,n;
	char ch,d;
	
	/*配列の場所*/
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			cards[i][j]=0;
		}
	}
	
	scanf("%d", &n);		/*太郎が持っているカードの枚数ｎ*/
	
	/*カードの柄*/
	for(i=0;i<n;i++){
		scanf("%c", &d);		/*改行の分*/
		scanf("%c %d", &ch, &x);		/*与えられるｎ組*/
		
		if(ch == 'S'){
			cards[0][x]=1;		/*１はとりあえず入れなあかんからいれた数？*/
		}
		else if(ch == 'H'){
			cards[1][x]=1;
		}
		else if(ch == 'C'){
			cards[2][x]=1;
		}
		else if(ch == 'D'){
			cards[3][x]=1;
		}
	}
	
	/*カードの数字*/
	for(j=1;j<=13;j++){
		if(cards[0][j]!=1){		/*！＝１のとき出力やからないカードが出る！！*/
			printf("S %d\n", j);
		}
	}
	for(j=1;j<=13;j++){
		if(cards[1][j]!=1){
			printf("H %d\n", j);
		}
	}
	for(j=1;j<=13;j++){
		if(cards[2][j]!=1){
			printf("C %d\n", j);
		}
	}
	for(j=1;j<=13;j++){
		if(cards[3][j]!=1){
			printf("D %d\n", j);
		}
	}
	return 0;
}


Measured memory_bytes: 2036
#include<stdio.h>
int main(void)
{
   int a, i;
   char s[4];

   a = 700;
   scanf("%s", s);

   for(i=0;i<3;i++){
      if(s[i]=='o') a=a+100;
      }
   
   printf("%d\n", a);
   
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 100001

typedef struct{
    int p,l,r;
}Node;

Node N[M];

int depth(int i,int d){
    if(N[i].p==-1)    return d;
    else return depth(N[i].p,++d);
}

int main(void){
    int i,j,n,m,id,c,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        N[i].p=-1;
        N[i].l=-1;
        N[i].r=-1;
    }
    
    for(i=0;i<n;i++){
        scanf("%d %d",&id,&m);
        for(j=0;j<m;j++){
            scanf("%d",&c);
            if(j==0) N[id].l=c;
            else     N[l].r=c;
            l=c;
            N[l].p=id;
        }
    }
    
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,N[i].p,depth(i,0));
        if(N[i].p==-1) printf("root, ");
        else if(N[i].l==-1) printf("leaf, ");
        else printf("internal node, ");
        if(N[i].l==-1) printf("[]");
        else{
            printf("[%d",N[i].l);
            l=N[i].l;
            while(1){
                if(N[l].r==-1){
                    printf("]");
                    break;
                }
                else printf(",");
                printf(" %d",N[l].r);
                l=N[l].r;
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2952
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        Console.WriteLine(!(input[0]<=8&&input[1]<=8)?":(":"Yay!");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>
 
using namespace std;
 
int main()
{
    int N, K;
    cin >> N >> K;
    if (K <= (N + 1) / 2) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int result = 0;
        for (int i = 1; i <= N; i++) {
            int n = i;
            int digSum = 0;
            while (n > 0) {
                // 整数 n を10で割ると一桁目の数が余りとして出てくる
                // 一桁目が 0 ならば、割り切れるので余りは 0
                digSum += n % 10; // 各桁の合計digSum にこの余りの値を加えてやる。
                // 次の桁に行くために、整数 n を10で割ってやる。そうすると最下位の桁が捨てられる。
                n /= 10;
            }
            if (digSum >= A && digSum <= B) {
                result += i;
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21332
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn canadd(s: &str, adds: &Vec<&str>) -> bool {
    if s.len() < 5 { return false }

    let mut retb = false;

    for &a in adds {
        if s == a { return true }
        else if s.starts_with(a) {
            retb |= canadd(s.split_at(a.len()).1, adds);
        } else {
            retb |= false;
        }
    }

    retb
}

fn main() {
    let s = read::<String>();

    let adds = vec!["dream", "dreamer", "erase", "eraser"];

    match canadd(&s, &adds) {
        true => println!("YES"),
        false => println!("NO"),
    }
}


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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =1000005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main()
{
	fio;
	ll n,w;cin>>n>>w;
	vl wei(n),val(n);
	f(n){cin>>wei[i]>>val[i];}
	vl dp(w+1);
	f(n)
	{
		for(ll weight_rema=w-wei[i];weight_rema>=0;weight_rema--)
		{
			dp[weight_rema+wei[i]]=max(dp[weight_rema]+val[i],dp[weight_rema+wei[i]]);
		}
	}
	cout<<dp[w]<<"\n";
}

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

using namespace std;

const int MAX_S = 300;
const int MAX_K = MAX_S;
char s[MAX_S+1];
int dp[MAX_S+2][MAX_S+2][MAX_K+1];

int main()
{
  int k;
  cin >> (s+1) >> k;

  int n = strlen(s + 1);

  for (int l = n; l > 0; l--) {
    for (int r = l; r <= n; r++) {
      for (int c = 0; c <= k; c++) {
        if (s[l] == s[r])
          dp[l][r][c] = dp[l+1][r-1][c] + (l == r ? 1 : 2);
        dp[l][r][c] = max(dp[l][r][c], max(dp[l+1][r][c], dp[l][r-1][c]));
          if (c != 0)
            dp[l][r][c] = max(dp[l][r][c], dp[l+1][r-1][c-1] + (l == r ? 1 : 2));
      }
    }
  }
  cout << dp[1][n][k] << endl;
  
  return 0;
}


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

int main() {
 int a, b,c;
 cin >> a >> b >> c;
  int result;
  
  if(b+c>= a)result = c-(a-b) ;
  else result = 0;
 
 cout << result << endl;
}

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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = long.Parse(inputs[0]);
            var b = long.Parse(inputs[1]);

            var r1 = a + b;
            var r2 = a - b;
            var r3 = a * b;
            var result = new long[] { r1, r2, r3 };

            Console.WriteLine(result.Max());
        }
    }
}


Measured memory_bytes: 27888