akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static PrintWriter out;
    static Scanner sc;

    static void solve() {
        int n = nextInt();
        int[] a = nextIntArray(n);
        int[] aDelta = new int[n + 1];
        int total = 0;
        for (int i = 0; i <= n; i++) {
            if (i == 0) {
                aDelta[i] = Math.abs(a[0]);
            } else if (i == n) {
                aDelta[i] = Math.abs(a[n - 1]);
            } else {
                aDelta[i] = Math.abs(a[i] - a[i - 1]);
            }
            total += aDelta[i];
        }

        for (int i = 0; i < n; i++) {
            int ans = total;
            ans -= (aDelta[i] + aDelta[i + 1]);
            if (i == 0) {
                ans += Math.abs(a[1]);
            } else if (i == n - 1) {
                ans += Math.abs(a[n - 2]);
            } else {
                ans += Math.abs(a[i + 1] - a[i - 1]);
            }
            out.println(ans);
        }
    }

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

    static long nextLong() {
        return Long.parseLong(sc.next());
    }

    static String nextString() {
        return sc.next();
    }

    static int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    static List<Integer> nextIntList(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextInt());
        }
        return list;
    }

    static List<Long> nextLongList(int n) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextLong());
        }
        return list;
    }

    static <T extends Comparable<? super T>> void sort(List<T> list) {
        Collections.sort(list);
    }

    // greatest common divisor
    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

    // intをlength桁のbit文字列に変換
    static String toBinaryString(int input, int length) {
        return toBinaryString(input).substring(29 - length);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

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

        solve();

        out.flush();
        sc.close();
    }

}


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

# define C continue;
# define R return

# define D double
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(-1,1);
const D tpie = 2*pie;

void solve( int test_case )
{
    int age , cost;
    cin>>age>>cost;

    if ( age>=13 ) cout<<cost;
    else if ( 6<=age && age<=12 ) cout<<(cost/2);
    else cout<<0;
}

int main()
{
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}



Measured memory_bytes: 256
import sys

n = int(input())
a = list(sorted(map(int, input().split())))
M = 10**9 + 7

end = lambda x: print(x) or sys.exit()
result = 1
n2 = n % 2
if n2 == a[0] % 2:
    end(0)
tmp = None
if n2:
    if a[0]:
        end(0)
else:
    if not a[0] == a[1] == 1:
        end(0)
for a1, a2 in zip(a[n2::2], a[n2 + 1::2]):
    if a1 - a2:
        end(0)
    if tmp:
        if a1 - tmp - 2:
            end(0)

    tmp = a1
    result *= 2
    if result >= M:
        result %= M
end(result)


Measured memory_bytes: 14008
import sys
sys.setrecursionlimit(10**6)


def dfs(h, w):
    if visited[h][w]:
        return 0
    elif grid[h][w] == 0:
        visited[h][w] = True
        return 0
    else:
        visited[h][w] = True
        for m in moves:
            nh, nw = h + m[0], w + m[1]
            if nh < 0 or nw < 0 or nh >= H or nw >= W:
                continue
            else:
                dfs(nh, nw)
        return 1


moves = [[1, 0], [-1, 0], [0, 1], [0, -1], [1, 1], [-1, 1], [-1, -1], [1, -1]]


while True:
    W, H = map(int, input().split())
    if W == 0 and H == 0:
        sys.exit()

    grid = [list(map(int, input().split())) for _ in range(H)]

    visited = [[False] * W for _ in range(H)]

    cnt = 0
    for h in range(H):
        for w in range(W):
            cnt += dfs(h, w)

    print(cnt)


Measured memory_bytes: 7988
#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;
#define ll long long
typedef pair<int , int > pii;
#define MOD 1000000007
#define MOD1 998244353
#define ff first
#define ss second
#define bn cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define sz(a) int((a).size())
#define o(a) cout << a
#define MAX6 1000006
#define int ll
#define all(x) x.begin(), x.end()
#define ppii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<ppii>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define MAX5 300005
#define MAX7 10000007
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,b,a)  for (__typeof((b)) i=(b);i>=(a);i--)
#define mem(a) memset(a,0,sizeof(a))
#define memneg(a) memset(a,-1,sizeof(a))
//#define se second
#define LN 14
#define LIM 22
#define MAX_ALPHA 26
const long long INF64 = 1e18;
const ll INF = 1e9;
const double PI = acos(-1);
#define ld long double
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline void max_self(ll &a, ll b)
{
  a = max(a,b);
}
 
inline void min_self(ll &a,ll b)
{
  a = min(a,b);
}
 
inline void add_self(ll &a, ll b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
inline void sub_self(ll &a, ll b) {
  a -= b;
  if (a < 0) a += MOD;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % MOD);
}
 
 
ll gcd(ll a,ll b)
{
  if(b == 0)
    return a;
  else 
    return gcd(b, a%b);
}
 
 
int countDigits(int x)
{
  int cnt = 0;
  while(x)
  {
    x /= 10;
    cnt++;
  }
  return cnt;
}
 
 
ll binExpo(ll a,ll b)
{
  ll res = 1;
  while(b)
  {
    if(b&1)
      res = (res * a)%MOD;
    a = (a * a)%MOD;
    b /= 2;
  }
  return res%MOD;
}
 
int sum(int a) {
    int result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}

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

  int n, w;
  cin>>n>>w;
  vector<int > dp(w + 1);
  rep(i, 0, n-1)
  {
    int weight, value;
    cin>>weight>>value;
    for(int weight_already = w - weight;weight_already >= 0;weight_already--)
    {
      max_self(dp[weight_already + weight] , dp[weight_already] + value);
    }
  }
  int ans = 0;
  rep(i, 0, w)
    max_self(ans, dp[i]);
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

long long cnt = 0;

struct Dsu {
    int n;
    vector<int> p;
    vector<int> r;
    
    Dsu(int _n) { n = _n; p.resize(n); r.resize(n); init(); }
    inline void init() {
        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 1;
        }
    }
    inline int find(int x) {
        return p[x] == x ? x: p[x] = find(p[x]);
    }
    inline bool join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        cnt += 1ll*r[x]*r[y];
        if (r[x] < r[y]) swap(x, y);
        p[y] = x; r[x] += r[y];
        return true;
    }
    inline bool check(int x, int y) {
        return find(x) == find(y);
    }
};

void solve() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> e;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        e.emplace_back(x, y);
    }
    long long tot = 1ll*n*(n-1)/2;
    Dsu dsu(n);
    vector<long long> res(m);
    for (int i = m-1; i >= 0; i--) {
        int x,y;
        tie(x,y) = e[i];
        res[i] = tot - cnt;
        dsu.join(x, y);
    }
    for (auto& x: res) {
        cout << x << "\n";
    }
}

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


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

void brute(ll n,ll x,ll m)
{
    ll i,j ;
    ll ans = x ;
	for(i=2;i<=n;++i)
	{
	    j = (x*x)%m ;
	    if(!j)
	        break ;
	    x = j ;
	    ans = ans + j ;
	}
	cout << ans endl ;
}

int main()
{
	FAST_IO ;
	ll i,j,k,n,m,x;
	cin >> n >> x >> m;
	if(n<=1000000)
	{
	    brute(n,x,m) ;
	    return 0 ;
	}
	set < pair<ll,ll> > ms;
	vector <ll> arr ;
	ms.insert({x,1}) ;
	arr.pb(x) ;
	for(i=2;i<=n;++i)
	{
	    j = (x*x)%m ;
	    auto it = ms.lower_bound({j,-1}) ;
	    if(it!=ms.end())
	    {
	        if((*it).F == j)
	        {
	            i = (*it).S ;
	            break ;
	        }
	    }
	    x = j;
	    arr.pb(x) ;
	    ms.insert({x,i}) ;
	}
	ll temp = i ;
	ll sum1 = 0,sum2 = 0,sum3 = 0;
	ll x1 = (ms.size()) - i + 1;
	j = (n-(temp-1))/x1 ;
	k = (n-(temp-1))%x1 ;
	for(i=0;i<temp-1;++i)
		sum3 += arr[i] ;
	for(i=temp-1;i<arr.size();++i)
	    sum1 += arr[i] ;
	 i = temp - 1;
	while(k--)
	{
	    sum2 += arr[i++] ;
	}
	cout << j*sum1 + sum2 + sum3 endl ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere

Measured memory_bytes: 6668
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

class BIT:
    def __init__(self, n):
        self.n = n
        self.nums = [0] * (n+1)
        
    def add(self, i, x):
        n, nums = self.n, self.nums
        i += 1
        while i <= n:
            nums[i] += x
            i += i & -i
    
    def sum(self, i):
        nums = self.nums
        s = 0
        i += 1
        while i:
            s += nums[i]
            i -= i & -i
        return s
    
    def search(self, x):
        n, nums = self.n, self.nums
        s, p = 0, 0
        for i in range(n.bit_length(), -1, -1):
            np = p + (1<<i)
            if np <= n and s+nums[np] < x:
                s += nums[np]
                p = np
        return p


N = ri()
S = rs()
Q = ri()
queries = []
for i in range(Q):
	q = rs().split()
	if q[0] == '1':
		q = (int(q[0]), int(q[1])-1, q[2])
	else:
		q = (int(q[0]), int(q[1])-1, int(q[2])-1)
	queries.append(q)

import collections
h = collections.defaultdict(lambda: BIT(N))

S = list(S)
for i, s in enumerate(S):
	h[s].add(i, 1)
for q in queries:
	if q[0] == 1:
		i, c = q[1], q[2]
		h[S[i]].add(i, -1)
		h[c].add(i, 1)
		S[i] = c
	else:
		l, r = q[1], q[2]
		cnt = 0
		for c, bit in h.items():
			if bit.sum(r) - bit.sum(l-1) > 0:
				cnt += 1
		print(cnt)


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

const ll mod = 1e9 + 7;
int main(){
    int n, x;
    cin >> n >> x;
    vector<int>l(n);
    for(int i=0;i<n;i++) cin >> l[i];

    int sum = 0;
    int ans = 1;
    for(int i=0;i<n;i++){
        sum += l[i];
        if(sum <= x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  string X; cin >> X;
  int res=0,ans=0;
  rep(i,X.size()){
    if(X[i]=='S') res++;
    else{
      if(res==0) ans++;
      else{
        res--;
      }
    }
  }
  cout << ans+res << endl;
  return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		for (long i = -1000; i <= 1000; i++) {
			for (long j = -1000; j <= 1000; j++) {
				if (i*i*i*i*i- j*j*j*j*j == X) {
					System.out.println(i + " " + j);
					return;
				}
			}
		}
	}

}


Measured memory_bytes: 38856
#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
bool get1[2001], get2[2001];
string s, t;
int dp[2][2001][2001];
int main()
{
	cin >> n >> m >> s >> t;
	memset(dp[1], -1, sizeof(dp[1]));
	for(int i = 0; i < n; ++i)
		get1[i] = (s[i] == 'I');
	for(int i = 0; i < m; ++i)
		get2[i] = (t[i] == 'I');
	for(int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= m; ++j)
		{
			if(i != n)
				dp[get1[i]][i + 1][j] = max(dp[get1[i]][i + 1][j], dp[get1[i] ^ 1][i][j] + 1);
			if(j != m)
				dp[get2[j]][i][j + 1] = max(dp[get2[j]][i][j + 1], dp[get2[j] ^ 1][i][j] + 1);
			ans = max(ans, dp[1][i][j]);
		}
	}
	cout << ans << endl;
}

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

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, k;
vector<int> g[N];
pair<int, int> E[N];

bool read() {
    if (!(cin >> n >> k))
        return false;

    for (int i = 0; i < n - 1; ++i) {
        auto& u = E[i].first;
        auto& v = E[i].second;
        cin >> u >> v;
        --u, --v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    return true;
}

void dfs(int v, int pr, int& cnt, int h, int mxh) {
    if (h > mxh)
        return ;
    ++cnt;
    for (auto to : g[v])
        if (to != pr)
            dfs(to, v, cnt, h + 1, mxh);
}

int calc(int v, int pr, int mxh) {
    int cnt = 0;
    dfs(v, pr, cnt, 0, mxh);
    return cnt;
}

void solve() {
    auto ans = n;
    auto d = k / 2;

    for (int i = 0; i < n; ++i)
        ans = min(ans, n - calc(i, -1, d));

    d = (k - 1) / 2;

    for (int i = 0; i < n - 1; ++i)
        ans = min(ans, n - calc(E[i].first, E[i].second, d) - calc(E[i].second, E[i].first, d));

    cout << ans << '\n';
}
 
int main() {
    while (read())
        solve();
    return 0;
}

Measured memory_bytes: 5120
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll MOD = 1000000007;
const int SIZE = 1010;
ll inv[SIZE],fac[SIZE],finv[SIZE];
void make(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++){
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll Combination (int a,int b) {
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
ll dp[1010][1010];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  make();
  FOR(i,0,1010) dp[i][0] = 1;
  FOR(i,a,b+1) {
    FOR(j,0,n+1) {
      if(dp[i][j] == 0) continue;
      if(j != 0) (dp[i+1][j] += dp[i][j]) %= MOD;
      ll p = 1;
      for(int k = 1; k <= d && j + i * k <= n; k++) {
        p = (((p * Combination(n - j - i * (k - 1), i) % MOD) * inv[k]) % MOD) % MOD;
        if(k >= c) (dp[i+1][j+i*k] += (dp[i][j] * p) % MOD) %= MOD;
      }
    }
  }
  cout << dp[b+1][n] << endl;
  return 0;
}

Measured memory_bytes: 8192
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=500;
int f[N],t[N],p[N],du[N];
int get(int x)
{
	if (f[x]==x) return x;
	return f[x]=get(f[x]);
}
int main()
{
	int n,h;
	scanf("%d%d",&n,&h);
	for (int i=1;i<=400;i++) f[i]=i;
	for (int i=1;i<=n;i++)
	{
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int l=200,r=200;
		if (c) l=l-c;else l=l+a;
		if (d) r=r+d;else r=r-b;
		du[l]++;
		du[r]--;
		t[l]=t[r]=1;
		f[get(l)]=get(r);
	}
	for (int i=1;i<=200;i++) if (du[i]>0) 
	{
		puts("NO");
		return 0;
	}
	for (int i=201;i<=400;i++) if (du[i]<0)
	{
		puts("NO");
		return 0;
	}
	for (int i=1;i<=400;i++) 
	{
		if (du[i]) p[get(i)]=1;
		t[get(i)]=t[get(i)]|t[i];
	}
	for (int i=0;i<=400;i++) if (i==get(i)&&t[i]&&!p[i]) 
	{
		puts("NO");
		return 0;
	}
	 puts("YES");
	 return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A_cnt = sc.nextInt();
		int B_cnt = sc.nextInt();
		int C_cnt = sc.nextInt();
		int D_cnt = sc.nextInt();
		//初期値設定
		int A_1 = 1;
		int B_zero = 0;
		int C_mainas = -1;

		//入力されたデータを配列に代入しておく
		int[] data = new int[3];
		data[0] = 0; //A
		data[1] = 0; //B
		data[2] = 0; //C

		//最大値演算
		//数値が大きい順にカウントしていく
		//D回文繰り返す。
		for(int i = 0;D_cnt > 0 && A_cnt > 0 ; i++) {
			D_cnt--;
			A_cnt--;
			data[0]++;
		}
		for(int i = 0;D_cnt > 0 && B_cnt > 0 ; i++) {
			D_cnt--;
			B_cnt--;
			data[1]++;
		}
		for(int i = 0;D_cnt > 0 && C_cnt > 0 ; i++) {
			D_cnt--;
			C_cnt--;
			data[2]++;
		}
		int Total = A_1 * data[0] + B_zero * data[1] + C_mainas * data[2];
		System.out.println(Total);
		sc.close();
		 }
		}

Measured memory_bytes: 35832
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A;
int main(){
  int Lj4PdHRW, res=0;
  rd(N);
  for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
    rd(A);
    while(A%2==0){
      A/=2;
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, A;
// {
//   int res = 0;
//   rd(N);
//   rep(N){
//     rd(A);
//     while(A%2==0) A/=2, res++;
//   }
//   wt(res);
// }


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

using namespace std;
#define PB(a) push_back(a)
#define PF(a) push_front(a)
#define REPS(i,a,b) for (int i = a; i<b; i++)

int main() {
    string S;
    char Ci;
    bool isReversed = false;
    int Q, Ti, Fi;
    deque<char> Ans;
    cin >> S;
    cin >> Q;
    for (char x : S) Ans.push_back(x);
    REPS(i,0,Q) {
        cin >> Ti;
        if (Ti == 2){
            cin >> Fi >> Ci;
            if (Fi == 1){
                if (isReversed) Ans.PB(Ci);
                else Ans.PF(Ci);
            }
            else {
                if (isReversed) Ans.PF(Ci);
                else Ans.PB(Ci);
            }
        }
        else {
            if (isReversed) isReversed = false;
            else isReversed = true;
        }
    }
    if (isReversed) reverse(Ans.begin(), Ans.end());
    for (char y : Ans) cout << y;
}


Measured memory_bytes: 896
using System;

namespace ABC154A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] arr = Console.ReadLine().Split(' ');
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            string u = Console.ReadLine();
            for (int i = 0; i < 2; i++)
            {
                if (arr[i] == u)
                {
                    ab[i]--;
                }
            }
            Console.Write("{0} {1}", ab[0], ab[1]);
        }
    }
}


Measured memory_bytes: 13140
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = len(set(list(S())))
if a == 1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38384
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		double[] x = new double[3];
		double[] y = new double[3];

		while(scan.hasNext()){
			double S_abc, S_pab, S_pac, S_pbc;
			for(int i = 0; i < 3; i++){
				x[i] = scan.nextDouble();
				y[i] = scan.nextDouble();
			}
			double xp = scan.nextDouble();
			double yp = scan.nextDouble();
			
			S_abc = 1.0 / 2.0 * Math.abs(x[0]*y[1] + x[1]*y[2] + x[2]*y[0]
					- y[0]*x[1] - y[1]*x[2] - y[2]*x[0]);
			S_pab = 1.0 / 2.0 * Math.abs(xp*y[0] + x[0]*y[1] + x[1]*yp
					- yp*x[0] - y[0]*x[1] - y[1]*xp);
			S_pac = 1.0 / 2.0 * Math.abs(xp*y[0] + x[0]*y[2] + x[2]*yp
					- yp*x[0] - y[0]*x[2] - y[2]*xp);
			S_pbc = 1.0 / 2.0 * Math.abs(xp*y[1] + x[1]*y[2] + x[2]*yp
					- yp*x[1] - y[1]*x[2] - y[2]*xp);
			if(S_abc == S_pab + S_pac + S_pbc){
				list.add("YES");
			} else{
				list.add("NO");
			}
		}

		for(String s : list){
			System.out.printf("%s\n", s);
		}
	}
}

Measured memory_bytes: 31820
/*  -*- coding: utf-8 -*-
 *
 * 2800.cc: Mod!Mod!
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500000;

/* typedef */

/* global variables */

int ms[3];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

int calc(int st, int m1, int m2) {
  int minm = min(m1, m2);
  m1 -= minm, m2 -= minm;
  int d = minm * 2;
  while (m1 > 0 && st) d++, m1--, st = (st + 1) % 3;
  while (m2 > 0 && st) d++, m2--, st = (st + 2) % 3;
  return d;
}

/* main */

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

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    ms[ai % 3]++;
  }
  //printf("%d %d %d\n", ms[0], ms[1], ms[2]);

  int maxd = 1;
  if (ms[1] > 0) {
    int d = 1 + calc(1, ms[1] - 1, ms[2]) + ms[0];
    setmax(maxd, d);
  }
  if (ms[2] > 0) {
    int d = 1 + calc(2, ms[1], ms[2] - 1) + ms[0];
    setmax(maxd, d);
  }

  printf("%d\n", maxd);
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 305;
ll A[MAX_N][MAX_N];
ll d[MAX_N][MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		rep(j,N)
		{
			cin >> A[i][j];
			d[i][j] = A[i][j];
		}
	}

	rep(k,N)
	{
		rep(i,N)
		{
			rep(j,N)
			{
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}

	rep(i,N)
	{
		rep(j,N)
		{
			if (d[i][j] < A[i][j])
			{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	ll ans = 0;
	rep(i,N)
	{
		rep(j,N)
		{
			bool flag = true;
			rep(k,N)
			{
				if (i != k && j != k && d[i][k] + d[k][j] == d[i][j])
				{
					flag = false;
					break;
				}
			}
			if (flag) ans += d[i][j];
		}
	}
	cout << ans/2 << endl;
	return 0;
}

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

int main() {
  vector<int> vec;
  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    int query;
    cin >> query;
    if(query == 0){
      int x;
      cin >> x;
      vec.push_back(x);
    }else if(query == 1){
      int p;
      cin >> p;
      cout << vec[p] << endl;
    }else{
      vec.pop_back();
    }
  }
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  set<string> acgt;
 
  int n;
  scanf("%d",&n);
 
  for(int i = 0; i < n; i++){
    char op[10], str[20];
    scanf("%s%s",op,str);
    if(op[0] == 'f'){
      if(acgt.find(str) != acgt.end()) printf("yes\n");
      else printf("no\n"); 
    }else acgt.insert(str);
  }
 
 
}

Measured memory_bytes: 27048
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

LL ans=0;
void Saiki(LL a,LL b){
    if(b==0)return;
    ans+=b*(a/b);
    Saiki(b,a%b);
}
LL N,K;
int main(){
    cin>>N>>K;
    Saiki(N-K,K);
    cout<<ans*3<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():

    S = deque(list(input()))

    r = False
    for i in range(int(input())):
        Query = input().split()
        if Query[0] == "1":
            r = not r
        else:
            if (r==False and Query[1] == "1") or (r==True and Query[1] == "2"):
                S.appendleft(Query[2])
            else:
                S.append(Query[2])

    if r == True:
        S.reverse()

    print("".join(list(S)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 8420
using System;
using System.Collections.Generic;
 
namespace Aizu
{
    public class OnlineJudge
    {
        public static void Main()
        {
            var ids = new HashSet<string>();
            for(int i = int.Parse(Console.ReadLine()); i > 0; --i) {
                ids.Add(Console.ReadLine());
            }
            for(int i = int.Parse(Console.ReadLine()), key = 1; i > 0; --i) {
                var id = Console.ReadLine();
                if(ids.Contains(id)) {
                    Console.WriteLine((key ^= 1) == 0 ? "Opened by {0}" : "Closed by {0}", id);
                    
                }
                else {
                    Console.WriteLine("Unknown {0}", id);
                }
            }
        }
    }
}

Measured memory_bytes: 20016
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int cnt1 = c/b;
  if(c%b != 0){
    cnt1++;
  }
  int cnt2 = a/d;
  if(a%d != 0){
    cnt2++;
  }
  if(cnt1 > cnt2){
    cout << "No" << endl;
  }
  else if(cnt1 <= cnt2){
    cout << "Yes" << endl;
  }
}
   

Measured memory_bytes: 3588
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


def count_digit(number: int):
    return len(str(number))


if __name__ == '__main__':
    from math import sqrt

    n = int(input())
    result = 11

    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            candidate = max(count_digit(i), count_digit(n // i))
            result = min(result, candidate)

    print(result)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;

int sti(string a)
{
    ll k=0;
    for(int i=0;i<(int)a.size();++i)
    {
        k*=10;
        k+=a[i]-'0';
    }
    return k;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    string a1;
    a1+= s[0];
    a1+= s[1];
    string a2;
    a2 += s[2];
    a2+=s[3];
    int x = sti(a1);
    int y = sti(a2);
    if(x>12)
    {
        if(y>12 || y<1)
        {
            cout << "NA";
        }
        else 
        {
            cout << "YYMM";
        }    
    }
    else if(x<1)
    {
        if(y<1 || y>12)
        {
            cout << "NA";
        }
        else 
        {
            cout << "YYMM";
        }
    }
    else if(x<=12)
    {
        if(y<=12 && y>0)
        {
            cout << "AMBIGUOUS";
        }
        else
        {
            cout << "MMYY";
        }
        
    }
}

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
for i in range(N-1):
	if A[i]<0:
		A[i]=-A[i]
		A[i+1]=-A[i+1]
if A[N-1]>0:
	print(sum(A))
else:
	A[N-1]=-A[N-1]
	aa=min(A)
	print(sum(A)-aa-aa)

Measured memory_bytes: 14412
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vector<vector<int>> e(n,vector<int>(n,0));
    rep(i,n){
        int a; cin >> a;
        int tmp; cin >> tmp;

        rep(j,tmp) {
            int to; cin >> to;
            e[i][to-1] = 1;
        }
    }

    cout << e << endl;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int x,y; cin >> x >> y;
    x--; y--;
    vector<bool> a(3,true);
    a[x] = false; a[y] = false;
    rep(i,3) if(a[i]) cout << i+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 100

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}  

ll lcm(ll a, ll b){
  return a*(b/gcd(a, b));
}

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

    ll N;
    ll T[MAX_N];

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

    ll ans;
    
    if (N == 1) cout << T[0] << endl;
    else {
      ans = T[0];
      for(int i = 1; i < N; i++) ans = lcm(ans, T[i]);
      cout << ans << endl;      
    }
    return 0;
}


Measured memory_bytes: 888
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using flt = double;
const flt eps = 1e-12, inf = 1e18, PI = acos(-1.0);
template<typename T>
inline T sqr(T x) {return x * x;}
inline flt cmp(flt a, flt b, flt e = eps) {
  return fabs(a - b) >= e + fabs(a) * e ? a - b : 0;
}
inline int sgn(flt x, flt e = eps) {return x < -e ? -1 : (x > e);}
inline flt fix(flt x, flt e = eps) {return cmp(x, 0, e);}

struct point {
  flt x, y;
  point(flt x = 0, flt y = 0): x(x), y(y) {}
  bool operator < (const point &rhs) const {
    return cmp(x, rhs.x) < 0 || (cmp(x, rhs.x) == 0 && cmp(y, rhs.y) < 0);
  }
  bool operator == (const point &rhs) const {
    return cmp(x, rhs.x) == 0 && cmp(y, rhs.y) == 0;
  }
  point operator + (const point &rhs) const {
    return point(x + rhs.x, y + rhs.y);
  }
  point operator - (const point &rhs) const {
    return point(x - rhs.x, y - rhs.y);
  }
  point operator * (const flt k) const {
    return point(x * k, y * k);
  }
  point operator / (const flt k) const {
    return point(x / k, y / k);
  }
  point operator ~ () const {// counter clockwise rotate 90 degree
    return point(-y, x);
  }
  flt dot(const point &rhs) const {
    return x * rhs.x + y * rhs.y;
  }
  flt det(const point &rhs) const {
    return x * rhs.y - y * rhs.x;
  }
  flt norm2() const {
    return x * x + y * y;
  }
  flt norm() const {
    return hypot(x, y);
  }
  point rot(flt a) const {// counter clockwise rotate A rad
    return point(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a));
  }
  point rot(flt cosa, flt sina) const {// counter clockwise rotate using cos/sin
    return point(x * cosa - y * sina, x * sina + y * cosa);
  }
  point trunc(flt a = 1.0) const {
    return (*this) * (a / this->norm());
  }
};

int main() {
  point A, B;
  scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    point O;
    scanf("%lf%lf", &O.x, &O.y);
    int side = sgn((B - A).det(O - A));
    if (side > 0) {
      puts("COUNTER_CLOCKWISE");
    } else if (side < 0) {
      puts("CLOCKWISE");
    } else {
      int d1 = sgn((B - A).dot(O - A));
      int d2 = sgn((A - B).dot(O - B));
      if (d1 < 0) puts("ONLINE_BACK");
      else if (d2 < 0) puts("ONLINE_FRONT");
      else puts("ON_SEGMENT");
    }
  }
  return 0;
}

Measured memory_bytes: 2756
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int L[8];int n,A,B,C;
int dfs(int k,int a,int b,int c)
{
    if(k == n)
    {
        if(min(a,b)>0 && min(b,c)>0)
            return abs(a-A)+abs(b-B)+abs(c-C);
        else
            return 1e9;
    }
    int ans=1e9;
    int ret0=dfs(k+1,a,b,c);
    int ret1=dfs(k+1,a+L[k],b,c) + (a>0 ? 10 : 0);
    int ret2=dfs(k+1,a,b+L[k],c) + (b>0 ? 10 : 0);
    int ret3=dfs(k+1,a,b,c+L[k]) + (c>0 ? 10 : 0);
    ans=min(ans,min(ret0,ret1));
    ans=min(ans,min(ret2,ret3));
    return ans;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   cin>>n>>A>>B>>C;
   rep(i,0,n)
   cin>>L[i];
   cout<<dfs(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
if n>=m:
  print(0)
  exit()
a=list(map(int,input().split()))
a=sorted(a)
b=[0]*(m-1)
for i in range(m-1):
	b[i]=a[i+1]-a[i]
b=sorted(b)
b=b[:m-1-(n-1)]
print(sum(b))

Measured memory_bytes: 13968
package main

import (
	"fmt"
)

func main() {

	var N, M int

	fmt.Scanln(&N, &M)

	var N_array [101][101]string
	var M_array [101][101]string

	for i := 0; i < N; i++ {
		var l string
		fmt.Scanln(&l)
		for j := 0; j < N; j++ {
			N_array[i][j] = string(l[j])
		}
	}

	for i := 0; i < M; i++ {
		var l string
		fmt.Scanln(&l)
		for j := 0; j < M; j++ {
			M_array[i][j] = string(l[j])
		}
	}

	var flag bool

	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			flag = true
			for k := 0; k < M; k++ {
				for l := 0; l < M; l++ {
					if N_array[i+k][j+l] != M_array[k][l] {
						flag = false
						break
					}
				}
				if flag == false {
					break
				}
			}
			if flag {
				fmt.Println("Yes")
				return
			}
		}
	}

	fmt.Println("No")
}

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

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

const int M1 = 10000, S5 = 5000, S1 = 1000;
int main() {
    int N, Y;
    cin >> N >> Y;
    int r10000 = -1, r5000 = -1, r1000 = -1;
    rep(i, N + 1) {
        rep(j, N - i + 1) {
            int k = N - i - j;
            if (M1 * i + S5 * j + S1 * k == Y) {
                r10000 = i;
                r5000 = j;
                r1000 = k;
            }
        }
    }
    cout << r10000 << " " << r5000 << " " << r1000 << endl;
    return 0;
}

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

using namespace std;

int main()
{
    char s[4] = "abc";
    char a[4];
    cin >> a;
    sort(a, a + 3);
    if (!strcmp(a, s))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int A, B;
    cin>>A>>B;
    if(B==1) cout<<0<<endl;
    else cout<<(B-2)/(A-1)+1<<endl;
    return 0;
}


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

#define MAX_N 15

int main() {
    int N, A[MAX_N], x[MAX_N][MAX_N], y[MAX_N][MAX_N];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    int is_honest[MAX_N];
    int max_honest_persons = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        for (int i = 0; i < N; i++) {
            is_honest[i] = 0;
        }
        int honest_persons = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                is_honest[i] = 1;
                honest_persons++;
            }
        }
        
        bool is_consistent = true;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < A[i]; j++) {
                if (is_honest[i]) {
                    if (is_honest[x[i][j]-1] && y[i][j] == 0) {
                        is_consistent = false;
                    }
                    if (!is_honest[x[i][j]-1] && y[i][j] == 1) {
                        is_consistent = false;
                    }
                }
            }
        }

        if (is_consistent) {
            max_honest_persons = fmax(max_honest_persons, honest_persons);
        }
    }
    cout << max_honest_persons << endl;
    return 0;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
ll n, cnt;
std::vector<ll> v = {3, 5, 7};
void dfs(ll x, int cnt3, int cnt5, int cnt7)
{
	if(x > n) return;
	if(cnt3 > 0 && cnt5 >0 && cnt7 > 0) 
		cnt++;
	for(ll z: v)
	{
		ll xx = x*10 + z;
		//cout<<xx<<endl;
		if(z == 3) dfs(xx, cnt3+1, cnt5, cnt7);
		else if(z == 5) dfs(xx, cnt3, cnt5+1, cnt7);
		else dfs(xx, cnt3, cnt5, cnt7+1);
	}
}

int main()
{
	cin>>n;
	dfs(0, 0, 0, 0);
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {
	
	public static class Walk implements Comparable<Walk>{
		int foot_x, foot_y;
		int using_foot;
		int time;
		
		public Walk(int foot_x, int foot_y, int using_foot, int denger) {
			super();
			this.foot_x = foot_x;
			this.foot_y = foot_y;
			this.using_foot = using_foot;
			this.time = denger;
		}

		@Override
		public int compareTo(Walk o) {
			return this.time - o.time;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int w = sc.nextInt();
			final int h = sc.nextInt();
			
			if(w == 0 && h == 0){
				break;
			}
			System.gc();
			
			int[][] times = new int[h][w];
			boolean[][] is_goal = new boolean[h][w];
			
			boolean[][][] is_visited = new boolean[h][w][2];
			PriorityQueue<Walk> queue = new PriorityQueue<Main.Walk>();
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					String str = sc.next();
					
					if("T".equals(str)){
						is_goal[i][j] = true;
						times[i][j] = 0; 
					}else if("S".equals(str)){
						queue.add(new Walk(j, i, 0, 0));
						queue.add(new Walk(j, i, 1, 0));
						times[i][j] = 0;
					}else if("X".equals(str)){
						times[i][j] = -1;
					}else{
						times[i][j] = Integer.parseInt(str);
					}
				}
			}
			
			boolean flag = false;
			while(!queue.isEmpty()){
				Walk walk = queue.poll();
				
				if(is_visited[walk.foot_y][walk.foot_x][walk.using_foot]){
					continue;
				}else{
					is_visited[walk.foot_y][walk.foot_x][walk.using_foot] = true;
				}
				
				if(is_goal[walk.foot_y][walk.foot_x]){
					flag = true;
					System.out.println(walk.time);
					break;
				}
				
				for(int x = 1; x <= 3; x++){
					for(int y = -2; y <= 2; y++){
						if(x + Math.abs(y) > 3){
							continue;
						}
						
						//using_foot : 0 -> left 1 -> right
						final int nx = walk.foot_x + (walk.using_foot == 0 ? x : -x);
						final int ny = walk.foot_y + y;
						
						if(ny < 0 || ny >= h || nx < 0 || nx >= w){
							continue;
						}else if(times[ny][nx] < 0){
							continue;
						}else if(is_visited[ny][nx][1 - walk.using_foot]){
							continue;
						}
						
						queue.add(new Walk(nx, ny, 1 - walk.using_foot, walk.time + times[ny][nx]));
					}
				}
				
				
			}
			
			if(!flag){
				System.out.println(-1);
			}
			
		}
	}

}

Measured memory_bytes: 44104
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=800;
int n,m,mp[N][N],vi[N];
int tot,first[N],nxt[N*N],point[N*N];
int cnt,ca,cb,dp[N][N];
bool bl;
inline void add_edge(int x,int y)
{
	tot++;
	nxt[tot]=first[x];
	first[x]=tot;
	point[tot]=y;
}
void dfs(int x)
{
	if (vi[x]==1) ca++;
	else cb++;
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i];
		if (vi[u])
		{
			if (vi[x]==vi[u]) bl=0;
			continue;
		}
		vi[u]=3-vi[x];
		dfs(u);
	}
}
signed main()
{
	tot=-1;
	memset(first,-1,sizeof(first));
	memset(nxt,-1,sizeof(nxt));
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		mp[u][v]=mp[v][u]=1;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=i+1;j<=n;j++)
		{
			if (mp[i][j]) continue;
			add_edge(i,j);add_edge(j,i);
		}
	}
	bl=1;
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		if (vi[i]) continue;
		vi[i]=1;
		ca=cb=0;
		cnt++;
		dfs(i);
		if (!bl)
		{
			printf("-1\n");
			return 0;
		}
		for (int j=n;j>=ca;j--) dp[cnt][j]|=dp[cnt-1][j-ca];
		for (int j=n;j>=cb;j--) dp[cnt][j]|=dp[cnt-1][j-cb];
	}
	int ans=inf;
	for (int i=1;i<=n;i++)
	{
		if (dp[cnt][i]) ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
	}
	printf("%d\n",ans);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> B;
  for (int i = 0; i < N; i += 2) {
    B.emplace_back(A[i] ^ A[i + 1]);
  }
  int tot = 0;
  for (int b : B) {
    tot ^= b;
  }
  for (int i = 0; i < N; i++) {
    cout << (tot ^ A[i]) << (i == N - 1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 4636
#include<stdio.h>
int main()
{
    int a[1000],n,i,sum;
    scanf("%d",&n);
    for(i=0;i<n-1;i++)
    {
        scanf("%d",&a[i]);
    }
    sum=a[0];

    for(i=0;i<n-2;i++)
    {
        if(a[i]>=a[i+1])
        {
           sum+=a[i+1];
        }
        else
        {
           sum+=a[i];
        }

    }
    sum+=a[n-2];
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128