akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    private static final String SUNNY = "Sunny";
    private static final String CLOUDY = "Cloudy";
    private static final String RAINY = "Rainy";

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        if (A > B * 2) {
            System.out.println(A - B * 2);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	string s; cin>>s;
	int a=0;
	if(s[0]=='o')a++;
	if(s[1]=='o')a++;
	if(s[2]=='o')a++;

	cout<<700+a*100<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<ll> cumsum(n + 1);
    cumsum[0] = 0;
    rep(i, 0, n)
    {
        int a;
        cin >> a;
        cumsum[i + 1] = a + cumsum[i];
    }

    ll ans = 1000000000000000;
    rep(i, 1, n)
        ans = min(ans, abs(2 * cumsum[i] - cumsum[n]));

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

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import itertools

def comb1(n, r):
    if n == 0 or r == 0: return 1
    return comb1(n, r-1) * (n-r+1) / r

a = int(input())
# スペース区切りの整数の入力
m_members = []
a_members = []
r_members = []
c_members = []
h_members = []

for i in range(a):
    member = input()
    if(member[0:1] == 'M'):
        m_members.append(member)
    elif(member[0:1] == 'A'):
        a_members.append(member)
    elif(member[0:1] == 'R'):
        r_members.append(member)
    elif(member[0:1] == 'C'):
        c_members.append(member)
    elif(member[0:1] == 'H'):
        h_members.append(member)

member_info = []
count = 0
result = 0

if(len(m_members) != 0):
    member_info.append(len(m_members))
    count += 1
if(len(a_members) != 0):
    member_info.append(len(a_members))
    count += 1
if(len(r_members) != 0):
    member_info.append(len(r_members))
    count += 1
if(len(c_members) != 0):
    member_info.append(len(c_members))
    count += 1
if(len(h_members) != 0):
    member_info.append(len(h_members))
    count += 1

if(count >= 3):
    for i in (list(itertools.combinations(member_info, 3))):
        result += i[0] * i[1] * i[2]
    print(result)
else:
    print(0)


Measured memory_bytes: 10228
def gcd(a,b):
    if b<a:
        a,b = b,a
    while b>0:
        a,b = b,a%b
    return a
N,X = map(int,input().split())
A = list(map(int,input().split()))
if N==1:
    D = abs(X-A[0])
else:
    D = gcd(abs(X-A[0]),abs(X-A[1]))
    for i in range(2,N):
        D = gcd(D,abs(X-A[i]))
print(D)


Measured memory_bytes: 14224
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
//#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef pair<int, int>P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


const int MAX = 500010;
const int MOD = 1000000007;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;


vector<int>G[100010];

int dfs(int s) {
	int res = 0;
	vector<int>v;
	for (auto ns : G[s]) {
		v.pb(dfs(ns));
	}
	VSORT(v);
	REP(i, v.size()) {
		res = max(res + 1, v[i]);
	}
	return res + 1;
}

signed main() {
	int N; cin >> N;
	REP(i, N - 1) {
		int a; cin >> a;
		a--;
		G[a].pb(i + 1);
	}
	print(dfs(0) - 1);
}

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

int main()
{
   int n;
   cin>>n;
   int arr[n+1],minarr[n+1]={0};
   for(int i=1;i<=n;i++)
      cin>>arr[i];
    minarr[1]=0;
    minarr[2]=abs(arr[2]-arr[1]);
    int mincost = INT_MAX;
    for(int i=3;i<=n;i++)
    {
	    int j = i-2;
	    minarr[i] = min(minarr[j] + abs(arr[j]-arr[i]), minarr[j+1] + abs(arr[j+1]-arr[i]));
//	    cout<<i<<" "<<minarr[i]<<endl;
    }
    cout<<minarr[n];
    return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
l = 0
r = n
for i in range(m):
    ll, rr = map(int, input().split())
    l = max(ll, l)
    r = min(rr, r)
if (r >= l):
    print(r - l + 1)
else:
    print(0)

Measured memory_bytes: 3060
while True:
    x = int(input())
    if x == 0: break
    else:
        def digitSum(x): # 数値を文字列に変換
            s = str(x)       # １文字ずつ数値化し配列にする。
            array = list(map(int, s))    # 合計値を返す
            return sum(array)
        print(digitSum(x))


Measured memory_bytes: 5596
N  = int(input())
A = list(map(int, input().split()))
f=0
for i in range(N):
    if A[i]%2==0:
        if A[i]%3==0 or A[i]%5==0:
            continue
        else:
            f+=1
            break
if f==0:
    print('APPROVED')
else:
    print('DENIED')

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vvl dp(n+1, vl(K+1));  // dp[i+1][j] : i番目の子供まででj個の飴を分け合う方法の個数
    exrep(i, 0, n) {
        dp[i][0] = 1;
    }
    rep(i, n) {
        exrep(j, 1, K) {
            if(a[i] < j) {
                dp[i+1][j] = dp[i][j] + dp[i+1][j-1] + mod - dp[i][(j-1) - a[i]];
            }
            else {
                dp[i+1][j] = dp[i][j] + dp[i+1][j-1];
            }
            dp[i+1][j] %= mod;
        }
    }
    
    out(dp[n][K]);
    re0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {
	//int a, b, c,d; cin >> a>>b>>c>>d ;
	string s,t,u; cin >> s>>t>>u;
	cout << s[0] << t[0] << u[0];

	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return (halfpower*halfpower) % modd;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (((halfpower*halfpower)%modd)*a)%modd;
      }
  }
};
 
int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, 1000);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        vector<ll> x;
        forr(i,0,n) { readll(xx); x.push_back(xx); }
        vector<ll> d;
        forr(i,0,n-1) {
            d.push_back(x[i+1]-x[i]);
        }

        ll ret = 0;
        ll harmonic = 0;
        ll i = 0;
        for(auto dd : d) {
            ++i;
            harmonic += fastpower<ll>(i, modd-2); harmonic = harmonic % modd;
            ret += harmonic * dd; ret = ret % modd;
        }
        forr(i,1,n-1) {
            ret *= i; ret = ret % modd;
        }
        cout << ret << endl;

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

Measured memory_bytes: 5592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}
vector<vector<int>> a;
int n;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	a.assign(n,vector<int>(n));
	rep(i,0,n)rep(j,0,n){
		cin>>a[i][j];
	}
	vector<int> dp(1<<n);
	dp[0]=1;
	// i th bit of mask denotes whether the i th woman has been paired up
	// we assume we are going from man no. 1 to man no. n in increasing order, so the number of men already assigned is the no. of bits in the mask.
	for(int mask=0;mask<(1<<n)-1;mask++){
		int x = num1bit(mask);
		for(int y = 0;y<n;y++){
			if((!((1<<y)&mask))&&(a[x][y])){
				int m2 = mask^(1<<y);
				dp[m2]=add(dp[m2],dp[mask]);			
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    ll n,k,q; cin >> n >> k >> q;
    ll a[n]; rep(i,n) a[i] = -q+k;
    ll ind;
    rep(i,q) {
        cin >> ind;
        a[ind-1]++;
    }
    rep(i,n) {
        if (a[i] > 0) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4416
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// Solution
public class Main {
  static Scanner in;
  static PrintWriter out;
  static String INPUT = "";

  static void solve() {
    int h1 = ni();
    int m1 = ni();
    int h2 = ni();
    int m2 = ni();
    int k = ni();

    System.out.println((h2 * 60 + m2) - (h1 * 60 + m1) - k);
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  static int ni() {
    return Integer.parseInt(in.next());
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty()) System.out.println(Arrays.deepToString(o));
  }
}


Measured memory_bytes: 38624
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

string S;

void solve(){
	REP(i,S.size()-1){
		if(S[i]==S[i+1]){
			cout<<"Bad"<<endl;
			return;
		}
	}
	cout<<"Good"<<endl;
}

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

	cin >> S;
	solve();
	return 0;
}

//}}}



Measured memory_bytes: 256
A, B = map(int,input().split())

if A == B:
    print(A+B)
elif A > B and A-1 > B:
    print(A+A-1)
elif A > B and A-1 == B:
    print(A+B)
elif A < B and A < B-1:
    print(B+B-1)
elif A < B and A == B-1:
    print(A+B)

Measured memory_bytes: 9124
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a<b){
			if(b<c) System.out.println("Yes");
			else System.out.println("No");
		}
		else System.out.println("No");
	}
}


Measured memory_bytes: 26352
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    T = {i: set() for i in range(1, n+1)}
    for ab in map(str.split, args[1:]):
        a, b = map(int, ab)
        T[a].add(b)
        T[b].add(a)

    R = set()
    B = set()

    stack = [(1, 0)]
    while stack:
        i, d = stack.pop()
        if i in R or i in B:
            continue
        if d % 2:
            R.add(i)
        else:
            B.add(i)
        for j in T[i]:
            stack.append((j, d+1))

    R, B = (R, B) if len(R) < len(B) else (B, R)

    ret = [0]*(n+1)
    if len(R) <= n//3:
        for i in range(1, n+1):
            if i % 3:
                ret[B.pop()] = i
            else:
                ret[R.pop() if R else B.pop()] = i
    else:
        for i in range(1, n+1, 3):
            ret[R.pop()] = i
        for i in range(2, n+1, 3):
            ret[B.pop()] = i
        for i in range(3, n+1, 3):
            ret[R.pop() if R else B.pop()] = i

    return ' '.join(map(str, ret[1:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 132388
// AOJ 0277
#include <iostream>

using namespace std;

int main(void)
{
	int data[] = {6000, 4000, 3000, 2000};
	int t, n;
	for (int i = 0; i < 4; i++){
		cin >> t >> n;
		cout << (data[t - 1] * n) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pqb               priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //fir defining the precision int the decimal upto y places.
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)     type *a=new type[n];
#define test(t)          int t; cin>>t; while(t--)
#define REP(i,a,b)       for(int i=a;i<b;i++)
 
 
void io()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);
 
 
}
 
 
int32_t main()
{
  io();
 
  
    string s, t;
    cin >> s >> t;
 
    int ctr = 0;
    for (int i = 0; i < s.length(); i++)
    {
      if (s[i] != t[i])
        ctr++;
    }
    cout << ctr << "\n";

  
 
  return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int x, y, z;
cin >> x >> y >> z;
int ans = (x-z) / (y + z);
cout << ans << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string A;
    cin >> A;
    map<char,ll> mp;
    rep(i,A.size()){
        mp[A[i]]++;
    }
    ll ans = A.size()*(A.size()-1)/2 + 1;
    for(char c='a';c<='z';c++){
        ans -= mp[c]*(mp[c]-1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

void hawawa()
{
  int n, l;
  cin >> n >> l;
  Vec<string> strs(n);
  for (auto&& i : strs) {
    cin >> i;
  }
  sort(begin(strs), end(strs));
  for (auto&& i : strs) {
    cout << i;
  }
  cout << "\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
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;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  int n; cin >>n;
  string s,t; cin >>s >>t;
  for (int i=0; i<n; i++){
    cout <<s.at(i) <<t.at(i);
  }
  cout <<endl;
}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

s=int(input())

mod=10**9+7
MAX_N = s+5
fac = [1,1] + [0]*MAX_N
finv = [1,1] + [0]*MAX_N
inv = [0,1] + [0]*MAX_N
for i in range(2,MAX_N):
  fac[i] = fac[i-1] * i % mod
  inv[i] = mod - inv[mod % i] * (mod // i) % mod
  finv[i] = finv[i-1] * inv[i] % mod

def nCk(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod

lim=s//3
ans=0
for i in range(1,lim+1):
  zan=s-3*i
  ans+=nCk(zan+i-1,zan)
  ans%=mod
#  print(zan,i,nCk(zan+i-1,zan))

print(ans)

Measured memory_bytes: 9156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n, k;
    cin >> n >> k;
    ll res = k;
    rep(i, n - 1) res *= (k - 1);
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)
 
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
 
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];
 
struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}
 
mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}
 
int main() {
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double e,f;
     static const double pi = 3.141592653589793;
 
    e = 30 * h;
    f = 6 * m;
    e += 30 * (m/60.0);
    double t = min(e-f, (360-e)+f);
    double n = cos((t*pi)/180.0);
 
    printf("%.20f\n",sqrt(abs(a*a + b*b -2 * a * b * n)) );
 
}

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

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

int main(void){

	int a, b, c, d; cin >> a >> b >> c >> d;
	int l = a+b;
	int r = c+d;

	if(l > r){
		cout << "Left" << endl;
	}else if(l == r){
		cout << "Balanced" << endl;
	}else{
		cout << "Right" << endl;
	}

	return 0;
}


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

int a[101];

int main(){
	int n;
	while( cin >> n, n ){
		for(int i=0 ; i < n ; i++ )
			cin >> a[i];
		int mx, mn;
		mx = mn = a[0];
		for(int i=1 ; i < n ; i++ ){
			mx = max( mx , a[i] );
			mn = min( mn , a[i] );
		}
		int s = 0;
		for(int i=0 ; i < n ; i++ ){
			if( a[i] == mn ){
				a[i] = 0;
				break;
			}
		}
		for(int i=0 ; i < n ; i++ ){
			if( a[i] == mx ){
				a[i] = 0;
				break;
			}
		}
		for(int i=0 ; i < n ; i++ ){
			s += a[i];
		}
		cout << s/(n-2) << endl;
	}
}

Measured memory_bytes: 0
def solve(A):
    cumsum = [0]
    for elem in A:
        cumsum.append(cumsum[-1]+elem)
    d = dict()
    for i in cumsum:
        try:
            d[i] += 1
        except:
            d[i] = 1
    res = 0
    for value in d.values():
        res += (value * (value - 1)) // 2
    return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    res = solve(A)
    print(res)

main()

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

using ll = long long;

// n=62,r=29まで
template<typename T>
T combination(T n, T r) {
  if (r > n - r)
    r = n - r;
  if (!n || !r)
    return 1;
  T p{n};
  T j{2};
  for (T i = n - 1; i > n - r; --i) {
    p *= i;
    while (j <= r && p % j == 0) {
      p /= j++;
    }
  }
  for (T i = r; i > j; --i)
    p /= i;
  return p;
}

constexpr int MAX_N = 1e5;

string s[MAX_N];

int main() {
  int N; cin >> N;
  for (int i{}; i < N; ++i) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s, s+N);

  string prev{s[0]};
  ll num{1};
  ll ans{};
  for (int i{1}; i < N; ++i) {
    if (s[i-1] != s[i]) {
      if (num > 1) {
        ans += combination<ll>(num, 2);
      }
      prev = s[i];
      num = 0;
    }
    ++num;
  }
  if (num > 1) {
    ans += combination<ll>(num, 2);
  }

  cout << ans << endl;
}


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

int main(){
    int w,h,c;
    int ans;
    cin >> w >> h >> c;
    for(int i=1;i<=min(w,h);i++){
        if ( w % i == 0 && h % i == 0 ){
            ans = (w * h) / (i * i);
        }
    }
    cout << ans * c << "\n";
    return 0;
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a - b + 1 << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

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

bool is_prime(int x) { //素数判定
    if (x<=1) return false;
    for(int i=2; i*i<=x; i++) 
        if (x%i==0) return false;
    return true;
}

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

    while(!is_prime(p)) p++;
    cout<<p<<endl;
}


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////





int main(){fastio
    ll n,s;cin>>n>>s;
    vector<ll>ans(s+1);
    ans[0]=1;
    for(ll i=0;i<=n-1;i++){
        ll t;cin>>t;
        vector<ll>nxt(s+1);
        for(ll j=0;j<=s;j++){
            Add(nxt[j],ans[j]*2);
            if(j+t<=s)Add(nxt[j+t],ans[j]);
        }
        ans=nxt;
    }
    //for(auto x:ans)cout<<x<<" ";cout<<endl;
    cout<<mod(ans[s])<<endl;
    
    return 0;
}





Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>=(0);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)


int dp[110][10100];

int main(){
    int N,W;
    cin>>N>>W;
    vector<int> V(N),w(N);
    rep(i,N) cin >> V[i] >> w[i];

    rep(i,N+1)rep(j,W+1) dp[i][j] = -1;
    dp[0][0] = 0;

    for(int i=0;i<N;++i){
        for(int j = 0;j <= W;++j){
            dp[i+1][j] = dp[i][j]; 
            if(j < w[i]) continue;
            dp[i+1][j] = max(dp[i+1][j],dp[i][j - w[i]] + V[i]);
        }
    }

    int ans = -1;
    rep(i,W+1) ans = max(ans,dp[N][i]);
    cout << ans << endl;


}


Measured memory_bytes: 7044
#include<iostream>
#include<cstdio>
using namespace std;
long long n,a[200005],ans=0;
int main(){
	a[0]=-1;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(a[i]-a[i-1]>1){
			printf("-1\n");
			return 0;
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]==(a[i-1]+1)&&i!=1) ans++;
		if(a[i]<=a[i-1]) ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, a[N], ans = 1, x;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x;
        a[x]++;
    }
    if ( n % 2 ) {
        if ( a[0] != 1 ) {
            cout << 0;
            return 0;
        }
    }
    for ( int i = 1 + (n % 2); i < n; i += 2 ) {
        if ( a[i] != 2 ) {
            cout << 0;
            return 0;
        }
        ans = ans * 2 % mod;
    }
    cout << ans;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		try (Scanner sc = new Scanner(System.in)) {
			/*
			 * author: 31536000
			 * AtCoder Beginner Contest 160 D問題
			 * 考察メモ
			 * iを決め打つと、i->jの距離は次のmin
			 * 1. j-i (iからjへ真っすぐ)
			 * 2. i->X->Y->j, よって|X-i|+|Y-j|+1(X->Yを経由)
			 * ここで|X-i|は定数であり、|Y-j|は凹関数であることを利用すると答えは実は(高々)3本の傾き1の直線で表せる
			 * よって区間加算さえできれば良く、imos法などで解ける
			 * O(N)ですね！
			 *
			 */
			int N = sc.nextInt(), X = sc.nextInt(), Y = sc.nextInt();
			int[] imos = new int[2 * N];
			for (int i = 1;i < X;++ i) {
				// 1. i->jに加算
				++ imos[0];
				-- imos[(X + Y + 1) / 2 - i];
				// 2. i->X->Y->j (j≦Y)に加算、ただしこの際1で数えてる分は除外
				++ imos[X - i];
				-- imos[(X + Y) / 2 - i];
				// 3. i->X->Y->j (j>Y)に加算
				++ imos[X - i + 1];
				-- imos[X - i + N - Y + 1];
			}
			for (int i = X;i < (X + Y + 1) / 2;++ i) {
				// 1. i->jに加算
				++ imos[0];
				-- imos[(Y - X + 1) / 2];
				// 2. i->X->Y->j (j≦Y)に加算、ただしこの際1で数えてる分は除外
				++ imos[i - X];
				-- imos[(Y - X) / 2];
				// 3. i->X->Y->j (j>Y)に加算
				++ imos[i - X + 1];
				-- imos[i - X + N - Y + 1];
			}
			for (int i = (X + Y + 1) / 2;i < N;++ i) {
				// 明らかにXが遠いので、i->jしかない
				++ imos[0];
				-- imos[N - i];
			}
			int[] ans = new int[N - 1];
			System.out.println(ans[0] = imos[0]);
			for (int i = 1;i < ans.length;++ i) 	System.out.println(ans[i] = ans[i - 1] + imos[i]);
		}
	}
}

Measured memory_bytes: 24276
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n,m;
	cin>>n>>m;
	int M=0;
	rep(i,n){
		int tmp=0;
		rep(j,m){
			int t;
			cin>>t;
			if(t) tmp++;
		}
		M=max(M,tmp);
	}
	cout<<M<<endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int c[100005];

int main() {
  int n;
  cin >> n;
  vi d(n);
  int md = 0;
  
  rep(i,n){
    cin >> d[i];
    maxs(md,d[i]);
    c[d[i]]++;
    if(i==0 && d[i]!=0){
      cout<<0<<endl;
      return 0;
    }
  }

  mint ans = 1;
  if(c[0] != 1){
      cout<<0<<endl;
      return 0;
  }
  rep(i,md+1){
    if(c[i] == 0){
      cout<<0<<endl;
      return 0;
    }
    if(i>0){
      rep(k,c[i]){
        mint t = c[i-1];
        ans*=t;
      }
    }
  }
  cout<<ans.x<<endl;
  return 0;
}

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

#define endl '\n'
#define PI acos(-1.0)

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	
	bool seven = false;
	while(n > 0) {
		if(n % 10 == 7) {
			seven = true;
			break;
		}
		n /= 10;
	}
	
	if(seven) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3588
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int n,x,y,a[100005],b[100005],q,w;
vector<int>v[100005];
bool vis1[100005],vis2[100005];
void dfs1(int p,int d)
{
    vis1[p]=true;
    a[p]=d;
    for(auto i : v[p])
        if(!vis1[i])
            dfs1(i,d+1);
}
void dfs2(int p,int d)
{
    vis2[p]=true;
    b[p]=d;
    for(auto i:v[p])
        if(!vis2[i])
            dfs2(i,d+1);
}
int32_t main()
{
    speed upp
    cin>>n>>x>>y;
    f(i,1,n-1)
    {
        cin>>q>>w;
        v[w].pb(q);
        v[q].pb(w);
    }
    dfs1(x,0);
    dfs2(y,0);
    int ans=0;
    f(i,1,n)
        if(a[i]<b[i])
            ans=max(ans,b[i]);
    cout<<ans-1;
    
}

Measured memory_bytes: 10240
#include <iostream>
#include <bitset>

constexpr int MAX_N=2000,MAX_VAL=2000*2000;

using Bit = std::bitset<MAX_VAL+1>;

int n;
int a[MAX_N];
int sum;
Bit bit;

int main() {

    std::cin>>n;

    for(int i=0;i<n;++i){
        std::cin>>a[i];
        sum+=a[i];
    }

    bit=Bit("1");

    for(int i=0;i<n;++i)
        bit = bit | (bit << a[i]);

    int ans=(sum+1)/2;

    while(!bit[ans])
        ++ans;

    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <bitset>
using namespace std;

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

int main()
{
    int n, m, x; cin >> n >> m >> x;
    vector<int> ci(n);
    vector<vector<int> > aij(n, vector<int>(m));
    rep(i, n){
        cin >> ci[i];
        rep(j, m){
            cin >> aij[i][j];
        }
    }

    int ans = -1, cost;
    vector<int> skills(m);
    bool ok;
    rep(bits, 1<<n){
        ok = true;
        cost = 0;
        fill(skills.begin(), skills.end(), 0);

        rep(i, n){
            if(!((bits>>i) & 1)) continue;

            cost += ci[i];
            rep(j, m){
                skills[j] += aij[i][j];
            }
        }

        rep(j, m){
            if(skills[j] < x){
                ok = false;
                break;
            }
        }

        if(ok){
            ans = (ans == -1 ? cost : min(ans, cost));
        }
    }

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

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.IO.Pipes;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            long N = cin.nextLong();
            long K = cin.nextLong();
            long ans = 0;
            ans = N / K;
            N %= K;
            Console.WriteLine(Math.Min(N, Math.Abs(N - K)));
        }

    }
}


Measured memory_bytes: 27828
import numpy as np
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
L = [i - j for (i,j) in zip(a,b)]
check = np.sum(x < 0 for x in L)
if check == 0:
  print(0)
else:
  neg = np.sum(x for x in L if x < 0)
  pos = sorted([x for x in L if x > 0], reverse=True)
  sum = 0
  finish = 0
  for i in range(len(pos)):
    sum += pos[i]
    if neg + sum >= 0:
      print(i + 1 + check)
      finish = 1
      break
  if finish == 0:
    print(-1)

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

using namespace std;

typedef long long ll;

const int N(2e5 + 9);

int T, n, m, ans;

struct A
{
    int x, y;
    char d;
}a[N];

long double calc(long double t)
{
    long double minx = 1e19, maxx = -1e19, miny = 1e19, maxy = -1e19;
    for (int i = 0; i < n; i++)
    {
        minx = min(minx, t * (a[i].d == 'L' ? -1 : a[i].d == 'R') + a[i].x);
        maxx = max(maxx, t * (a[i].d == 'L' ? -1 : a[i].d == 'R') + a[i].x);
        miny = min(miny, t * (a[i].d == 'D' ? -1 : a[i].d == 'U') + a[i].y);
        maxy = max(maxy, t * (a[i].d == 'D' ? -1 : a[i].d == 'U') + a[i].y);
    }
    return (maxx - minx) * (maxy - miny);
}

int main()
{
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i].x>>a[i].y>>a[i].d;
    }
    long double l = 0, r = 1e18, midl, midr;
    for (int i = 0; i< 500; i++)
    {
        midl = (2 * l + r) / 3;
        midr = (2 * r + l) / 3;
        if (calc(midl) < calc(midr))
        {
            r = midr;
        }
        else l = midl;
    }
    cout<<fixed<<setprecision(16)<<calc(l)<<endl;

    return 0;
}


Measured memory_bytes: 1408
/*Insertion Sort*/
#include <stdio.h>
#include <stdlib.h>
#define N 1000
int main (){
  int i, j, k, v, n, tmp, a[N];
  
  scanf("%d", &n);

  for (i=0; i<n; i++)
    scanf("%d", &a[i]);
  
  for(k=0; k<n; k++){
    if (k == n-1){
      printf("%d", a[k]);
      break;
    }
    printf("%d ", a[k]);
  }
  printf("\n");

  for (i=1; i<n; i++){
    v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    for(k=0; k<n; k++){
      if (k == n-1){
	printf("%d", a[k]);
	break;
      }
      printf("%d ", a[k]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2072