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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X,Y;
int A[2020];
int memoX[2020][2020];
int memoY[2020][2020];

int turnY(int op,int left);
int turnX(int op,int left) {
	if(memoX[left][op]>=0) return memoX[left][op];
	// all
	int ret=abs(A[0]-A[op]);
	if(left>1) ret=max(ret,turnY(left-1,left-1));
	if(left>1) ret=max(ret,turnX(op,left-1));
	return memoX[left][op]=ret;
}
int turnY(int op,int left) {
	if(memoY[left][op]>=0) return memoY[left][op];
	// all
	int ret=abs(A[0]-A[op]);
	// takeone
	if(left>1) ret=min(ret,turnX(left-1,left-1));
	if(left>1) ret=min(ret,turnY(op,left-1));
	return memoY[left][op]=ret;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X>>Y;
	FOR(i,N) cin>>A[i];
	reverse(A,A+N);
	A[N]=Y;
	MINUS(memoX);
	MINUS(memoY);
	cout<<turnX(N,N)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int dp[2][3];
/// dp[i][j] = 第 i 天做 j 的最高總滿足度

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

    int n, a, b, c;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a >> b >> c;
        dp[(i & 1)][0] = max(dp[!(i & 1)][1], dp[!(i & 1)][2]) + a;
        dp[(i & 1)][1] = max(dp[!(i & 1)][0], dp[!(i & 1)][2]) + b;
        dp[(i & 1)][2] = max(dp[!(i & 1)][0], dp[!(i & 1)][1]) + c;
    }
    cout << max(max(dp[(n & 1)][0], dp[(n & 1)][1]), dp[(n & 1)][2]) << '\n';

    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	ll a;
	while(cin>>a,a){
		ll out=1;
		for(ll i=2;i*i<=a;i++){
			ll t=0;
			while(a%i==0){
				t++;
				a/=i;
			}
			out*=2*t+1;
		}
		if(a!=1)out*=3;
		cout<<++out/2<<endl;
	}
}

Measured memory_bytes: 3120
#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 int
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)998244353
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n; 
    cin >> n ;
    vector<ll> v(n) ;
    multiset<ll> seta ;
    rep( i , 0 , n )
    {
        cin >> v[i] ;
        seta.insert(v[i]);
    }
    rep( i , 0 , n )
    {
        seta.erase(seta.find(v[i]));
        cout << *prev(seta.end()) << '\n' ;
        seta.insert(v[i]);
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}



Measured memory_bytes: 11776
#include <stdio.h>

int main(void)
{
  int x[3000], y[3000], i, tmp, j;

  for (i = 0; i < 3000; i++)  {
    scanf("%d %d", &x[i], &y[i]);
    if (x[i] == 0 && y[i] == 0)  {
      break;
    }
    else if (x[i] > y[i])  {
      tmp = y[i];
      y[i] = x[i];
      x[i] = tmp;
    }
  }
  for (j = 0; j < i; j++)  {
    printf("%d %d\n", x[j], y[j]);
  }

  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(void){
	scanf("%d",&n);
	if(n%10==3){
		printf("bon\n");
	}else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
		printf("pon\n");
	}else{
		printf("hon\n");
	}
	return 0;
}


Measured memory_bytes: 3760
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int a, b;
	cin >> a >> b;
	int count = 1, answer = 0;
	while(count < b)
	{
		count += (a - 1);
		++answer;
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int x,y;
  cin >>x>>y;
  cout << x+y/2 << endl;
}

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++)
int main(){
    int n; cin >> n;
    vector<int> v(n),ocnt(100001,0),ecnt(100001,0);
    rep(i,n){
        cin >> v[i];
        if(i%2 == 0){
            ocnt[v[i]]++;
        }else{
            ecnt[v[i]]++;
        }
    }
    int omax = 0,emax = 0,osec = 0,esec = 0;
    int omaxval,emaxval,osecval,esecval;
    rep(i,n){
        if(i%2 == 0){
            if(omax < ocnt[v[i]]){
                omax = ocnt[v[i]];
                omaxval = v[i];
            }
        }else{
            if(emax < ecnt[v[i]]){
                emax = ecnt[v[i]];
                emaxval = v[i];
            }
        }
    }
    rep(i,n){
        if(i%2 == 0){
            if(v[i] != omaxval){
                if(osec < ocnt[v[i]]){
                    osec = ocnt[v[i]];
                    osecval = v[i];
                }
            }
        }else{
            if(v[i] != emaxval){
                if(esec < ecnt[v[i]]){
                    esec = ecnt[v[i]];
                    esecval = v[i];
                }
            }
        }
    }
    if(omaxval == emaxval){
        if(omax > emax){
            cout << n - omax - esec << endl;
        }else if(omax < emax){
            cout << n - emax - osec << endl;
        }else{
            cout << n - omax - max(osec,esec) << endl;
        }
    }else{
        cout << n - omax - emax << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

bool pairCompare(const tuple<string, int, int>& a, const tuple<string, int, int>& b) {
    if(get<0>(a) != get<0>(b)){
        return get<0>(a) < get<0>(b);
    }
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) > get<1>(b);
    }
    else{
        return true;
    }
}

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

    vector<tuple<string, int, int>> SP;
    string a;
    int b;
    for(int i=0;i<N;i++) {
        cin >> a >> b;
        SP.emplace_back(a, b, i+1);
    }

    sort(SP.begin(), SP.end(), pairCompare);

    for(int i=0;i<N;i++) {
        cout << get<2>(SP.at(i)) << endl;
    }

    return (0);
}


Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  string s;
  cin >> n >> s;
  vector<set<ll>> pref(n); 
  vector<set<ll>> suff(n);
  set<ll> take;
  for(ll i = 0; i < n; i++) {
    for(auto it: take) pref[i].insert(it);
    take.insert(s[i] - '0');
  }
  ll ans[10][10][10];
  for(ll i = 0; i < 10; i++) {
    for(ll j = 0; j < 10; j++) {
      for(ll k = 0; k < 10; k++) {
        ans[i][j][k] = 0;
      }
    }
  }
  take.clear();
  for(ll i = n-1; i >= 0; i--) {
    for(auto it: take) suff[i].insert(it);
    take.insert(s[i] - '0');
  }
  for(ll i = 0; i < n; i++) {
    for(auto it: pref[i]) {
      for(auto et: suff[i]) {
        ans[it][s[i]-'0'][et]++;
      }
    }
  }
  ll res = 0;
  for(ll i = 0; i < 10; i++) {
    for(ll j = 0; j < 10; j++) {
      for(ll k = 0; k < 10; k++) {
        if(ans[i][j][k] > 0) res++;
      }
    }
  }
  cout << res << endl;
} //good night.

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::string s, t;
  std::cin >> N >> s >> t;

  int ans = 2 * N;
  for(int d = 1; d <= N; ++d) {
    if(s.substr(N - d) == t.substr(0, d)) ans = 2 * N - d;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			Dice d = new Dice();
			int sum = 1;
			for(int i=0;i<n;i++) {
				String cmd = sc.next();
				if (cmd.equals("North")) {
					d.rollBack();
				}else if(cmd.equals("East")) {
					d.rollRight();
				}else if(cmd.equals("West")) {
					d.rollLeft();
				}else if(cmd.equals("South")) {
					d.rollFront();
				}else if(cmd.equals("Right")) {
					d.turnClockwise();
				}else if(cmd.equals("Left")) {
					d.turnCounterClockwise();
				}
				sum += d.top;
			}
			System.out.println(sum);
		}
	}

}

class Dice {
	int top,bottom,front,back,left,right;
	public Dice() {
		top = 1;
		front = 2;
		right = 3;
		bottom = 6;
		back = 5;
		left = 4;
	}
	public void rollFront() {
		front = top;
		top = back;
		back = 7 - front;
		bottom = 7 - top;
	}
	public void rollBack() {
//		back = top;
//		top = front;
//		front = 7 - back;
//		bottom = 7 - top;
		rollFront();
		rollFront();
		rollFront();
	}
	public void rollRight() {
		right = top;
		top = left;
		left = 7 - right;
		bottom = 7 - top;
	}
	public void rollLeft() {
//		left = top;
//		top = right;
//		right = 7 - left;
//		bottom = 7 - right;
		rollRight();
		rollRight();
		rollRight();
	}
	public void turnClockwise() {
		front = right;
		right = back;
		back = 7 - front;
		left = 7 - right;
	}
	public void turnCounterClockwise() {
//		front = left;
//		left = back;
//		back = 7 - front;
//		right = 7 - left;
		turnClockwise();
		turnClockwise();
		turnClockwise();
	}
}

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

int main(void){
    constexpr long MAX = 1000000000000000000;
    long a, b, c, k;
    cin >> a >> b >> c >> k;
    long d = a-b;
    if(labs(d)>MAX){
        cout << "Unfair" << endl;
    }else{
        if(k%2==0){
            cout << d << endl;
        }else{
            cout << -d << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll=long long;
signed main()
{
	ll N,T; cin >> N >> T;
	vector<ll> TT(N); FOR(i,N) cin >> TT[i];
	ll ans = 0;
	ll now = 0;
	FOR(i,N-1) {		
		ans += min(now + T, TT[i+1]) - now;
		now = TT[i+1];
	}
	ans += T;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int J, O, I, ans = 0;;
  char c = getchar();
  while(c == 'J' || c == 'O' || c == 'I'){
    J = O = I = 0;
    while(c == 'J'){
      J++;
      c = getchar();
    }
    while(c == 'O'){
      O++;
      c = getchar();
    }
    while(c == 'I'){
      I++;
      c = getchar();
    }
    if(O <= J && O <= I && O > ans){
      ans = O;
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<ll,ll>

const int maxn=2e5+10;
const ll maxN=1e18+10;

ll ST[maxn],a[maxn];

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,k;
  ll a[maxn];
  double dp[maxn];
  cin >> n >> k;
  FOR(i,1,n) {
   cin >> a[i];
   double j=a[i]*(a[i]+1)/2;
   int so=a[i];
   dp[i]=dp[i-1]+((double)1/so)*j;
  }
  double lmax=0;
  FORd(i,n,k) lmax=max(lmax,dp[i]-dp[i-k]);
  cout << fixed << setprecision(12) << lmax;
}
    

Measured memory_bytes: 3328
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(M):
        x, y, z = map(int, input().split())
        x -= 1
        y -= 1
        uf.union(x, y)
    print(uf.group_count())


if __name__ == '__main__':
    main()

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int p[n][3], dp[n][3];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> p[i][j];
			dp[i][j] = 0;
		}
	}
	for (int j = 0; j < 3; j++) dp[0][j] = p[0][j];
	for (int day = 1; day < n; day++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i != j) {
					dp[day][i] = max(dp[day][i], dp[day - 1][j] + p[day][i]);
				}
			}
		}
	}
	int answer = 0;
	for (int i = 0; i < 3; i++) answer = max(answer, dp[n - 1][i]);
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Scanner;

// internous_atcoder_001 at 2018/02/15

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveB044();
	}

	private void solveA080() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (N * A < B) {
			System.out.println(N * A);
		} else {
			System.out.println(B);
		}
	}

	private void solveA044() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if (N <= K) {
			System.out.println(N * X);
		} else {
			System.out.println((K * X) + (N - K) * Y);
		}
	}

	private void solveB044() {
		Scanner sc = new Scanner(System.in);
		char w[] = sc.nextLine().toCharArray();
		ArrayList<Character> used = new ArrayList<>();
		for (char c : w) {
			if (!used.contains(c)) {
				if (!cnt(w, c)) {
					System.out.println("No");
					return;
				} else {
					used.add(c);
				}
			}
		}
		System.out.println("Yes");
	}
	private boolean cnt(char[] w, char t) {
		int count = 0;
		for (char c : w) {
			if (c == t) {
				count++;
			}
		}
		if (count % 2 == 1) {
			return false;
		}
		return true;
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

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

const int mod = 1000000007;
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 nCr(long long n, long long r) {
    mint ans = 1;
    for (long long i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (long long i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

mint pow(long long a, long long b) {
  mint res = 1;
  res = res.pow(b);
  return res;
}

int main() {
  long long n, a, b;
  cin >> n >> a >> b;

  mint sum = 2;
  sum = sum.pow(n);
  mint sub = (nCr(n, a) + nCr(n, b) + nCr(n, 0));
  sum -= sub;
  cout << sum.x << endl;
  return 0;

}


Measured memory_bytes: 256
def palindromeQ(num):
  if num%10==num//10000:
    if (num%100)//10==(num//1000)%10:
      return(1)
    else:
      return(0)
  else:
    return(0)
ans=0
A,B=[int(s) for s in input().split()]
for i in range(A,B+1):
  ans+=palindromeQ(i)
print(ans)
  

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

string s;

bool dfs(int cur){
  if(cur == s.size())
    return true;
  
  string s5, s6, s7, s10, s11;
  s5 = s6 = s7 = s10 = s11 = "";
  FOR(i, cur, cur+5)
    s5 += s[i];
  FOR(i, cur, cur+6)
    s6 += s[i];
  FOR(i, cur, cur+7)
    s7 += s[i];
  FOR(i, cur, cur+10)
    s10 += s[i];
  FOR(i, cur, cur+11)
    s11 += s[i];
  
  if(s11 == "dreameraser")
    return dfs(cur+11);
  else if(s10 == "dreamerase")
    return dfs(cur+10);
  else if(s7 == "dreamer")
    return dfs(cur+7);
  else if(s6 == "eraser")
    return dfs(cur+6);
  else if(s5 == "dream" || s5 == "erase")
    return dfs(cur+5);
  else
    return false;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> s;
  if(dfs(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
}

Measured memory_bytes: 6992
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	string s[n];
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	sort(s,s+n);
	i=0;
	int ans=1;
	while(i<(n-1))
	{
		if(s[i]!=s[i+1])
		ans++;
		i++;
	}
	cout<<ans<<endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int n;
vector<int> x;
vector<int> y;
vector<double> cost;

void averageTree(int depth, vector<int> path, vector<bool> mapping){
	if(depth == n - 1){
		double c = 0;

		rep(i, n - 1){
			c += sqrt(pow(x[path[i]] - x[path[i + 1]], 2) + pow(y[path[i]] - y[path[i + 1]], 2));
			
			if(i == n - 2){
				cost.push_back(c);
			}
		}		
	}
	else {


		
		rep(i, n){
			if(mapping[i] == false){
				vector<bool> newMapping = mapping;
				vector<int> newPath = path;
				newMapping[i] = true;
				newPath[depth + 1] = i;

				
				averageTree(depth + 1, newPath, newMapping);
			}
			else{
				continue;
			}
		}
	}
}

int main(){
	cin >> n;

	rep(i, n){
		int x_, y_;
		cin >> x_ >> y_;

		x.push_back(x_);
		y.push_back(y_);
	}
	
	rep(i, n){
		vector<int> path;
		path.push_back(i);
		
		rep(i, n - 1){
			path.push_back(-1);
		}

		vector<bool> mapping;
		rep(i, n){
			mapping.push_back(false);
		}
		mapping[i] = true;

		averageTree(0, path, mapping);
	}

	double ans = 0;
	rep(i, cost.size())
	{
		ans += cost[i];
	}

	ans /= cost.size();

	printf("%.10f", ans);
	return 0;
}


Measured memory_bytes: 896
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
char s[2000017];
void solve(){
	ll n,i,x,tot;
	tot=0;
	cin>>s;
	n=strlen(s);
	for(i=0;i<n;i++){
		x=s[i]-'0';
		tot+=x;
	}
	if(tot%9 == 0)
		cout<<"Yes";
	else
		cout<<"No";
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3840
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>

#define fst first
#define snd second

using namespace std;

typedef pair<int,int> pp;
set<int> G[105000];
//set<pp> res;
int dis[105000];
int S[105000];

int main(void) {
    int n,m,s,t;
    scanf("%d%d%d%d",&n,&m,&s,&t);
    s--, t--;
    memset(dis, 0x20, sizeof(dis));
    for(int i=0; i<m; i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        x--, y--;
        G[x].insert(y);
        G[y].insert(x);
    }

    {
        priority_queue<pp> q;
        q.push(pp(-0, s));

        while(!q.empty()) {
            pp t = q.top(); q.pop();
            int d = -t.fst, x = t.snd;

            if(dis[x] != 0x20202020) continue;
            dis[x] = d;
            S[d]++;

            for(int y : G[x])
                if(dis[y] == 0x20202020)
                    q.push(pp(-(d+1), y));
        }
    }

    int old = dis[t];
    memset(dis, 0x20, sizeof(dis));

    long long int res=0;
    {
        priority_queue<pp> q;
        q.push(pp(-0, t));

        while(!q.empty()) {
            pp t = q.top(); q.pop();
            int d = -t.fst, x = t.snd;

            if(dis[x] != 0x20202020) continue;
            dis[x] = d;

            if(old-2-d >= 0)
                res += S[old-2-d];

            for(int y : G[x])
                if(dis[y] == 0x20202020)
                    q.push(pp(-(d+1), y));
        }
    }

    printf("%lld\n", res);
    return 0;

}

Measured memory_bytes: 28304
#include<bits/stdc++.h>
using namespace std;
#define N 1000000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back
#define lc (id * 2)
#define rc (id * 2 + 1)
typedef long long ll;
const ll INF = (1e8);
const ll mod = (1e9 + 7);
int main(){
    ll a;scanf("%lld",&a);
    ll ans = a + a * a + a * a * a;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3816
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;


int main(){
    ll n;
    cin>>n;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    bool j=true;
    if(a[0]!=0){j=false;}
    for(int i=1;i<n && j;i++){
        if(a[i]>a[i-1]+1){j=false;}
    }
    if(!j){cout<<-1<<endl; return 0;}
    ll ans=a[n-1];
    for(ll i=n-2;i>=0;i--){
        if(a[i]==a[i+1]-1){continue;}
        ans+=a[i];
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 2420
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return x

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
N = int(input())
c = list(input())

cnt = 0
for i in range(0,N):
    if c[i] == "R":
        cnt += 1

cnt2 = 0
for i in range(0,cnt):
    if c[i] == "R":
        cnt2 += 1

print(cnt - cnt2)


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

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

int main(){
    
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    int ans=1000000;
    for(int bit=0;bit<(1<<(2*N));bit++){
        int a=0,b=0,c=0;
        int cnta=0,cntb=0,cntc=0;
        for(int i=0;i<N;i++){
            if(bit&(1<<2*i)&&bit&(1<<(2*i+1))) {a+=S[i];cnta++;}
            if(bit&(1<<2*i)&&!(bit&(1<<(2*i+1)))) {b+=S[i];cntb++;}
            if(!(bit&(1<<2*i))&&bit&(1<<(2*i+1))) {c+=S[i];cntc++;}
        }
        if(a!=0&&b!=0&&c!=0){int sum=abs(A-a)+abs(B-b)+abs(C-c)+(cnta+cntb+cntc-3)*10;
            ans=min(ans,sum);
    }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	double ans = a[0];
	for(int i=1;i<n;i++){
		ans = (ans + a[i]) / 2.0;
	}
	cout << setprecision(12) << fixed << ans << endl;
}

Measured memory_bytes: 256
//kaisetu yondemo wakaranai
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[100001];
    int n, i, t, m;
    
    scanf("%s", s);
    n = strlen(s);
    t = n;
    for(i = 1; i < n; i++){
        if(s[i-1] != s[i]){
            if(i > n - i) m = i;
            else m = n - i;
            if(t > m) t = m;
        }
    }
    printf("%d\n", t);
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
int main(){
    int a[5],i,j,m=100,ans=0;
	for(i=0;i<5;i++)scanf("%d",&a[i]);
    for(i=0;i<5;i++){
        if(a[i]%10==0)ans+=0;
        else if(m>a[i]%10){
            m=a[i]%10;
            j=i;
        }
    }
    for(i=0;i<5;i++){
        if(i==j)ans+=a[i];
        else if(a[i]%10==0)ans+=a[i];
        else ans+=a[i]+(10-a[i]%10);
    }
   printf("%d",ans);
	
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[][] = new int[n][3];
        int res[][] = new int[n][3];
        for(int i=0;i<n;i++) {
            for(int j=0;j<3;j++) {
                a[i][j] = sc.nextInt();
                if(i == n-1) {
                    res[i][j] = a[i][j];
                }
            }
        }
        for(int i=n-2;i>=0;i--) {
            for(int j=0;j<3;j++) {
                if(j==0) {
                    res[i][j] = a[i][j] + Math.max(res[i+1][1], res[i+1][2]);
                }
                else if(j==1) {
                    res[i][j] = a[i][j] + Math.max(res[i+1][0], res[i+1][2]);
                }
                else if(j==2) {
                    res[i][j] = a[i][j] + Math.max(res[i+1][1], res[i+1][0]);
                }
            }
        }
        int max = Integer.MIN_VALUE;
        for(int j=0;j<3;j++) {
            max = Math.max(max, res[0][j]);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 103100
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
const long long inf = 1LL << 60;
vector<long long> IL(int n) {
    vector<long long> vec(n);
    for (int i=0; i<vec.size(); i++) cin >> vec.at(i);
    return vec;
}
vector<string> IS(int n) {
    vector<string> vec(n);
    for (int i=0; i<vec.size(); i++) cin >> vec.at(i);
    return vec;
}

void PA(vector<long long> vec) {
    for (int i=0; i<vec.size()-1; i++) cout << vec.at(i) << " ";
    cout << vec.at(vec.size()-1) << endl;
    return;
}
map<long long, long long> CL(vector<long long> vec) {
    map<long long, long long> count;
    for (long long x: vec) {
        count[x] += 1;
    }
    return count;
}

map<string, long long> CS(vector<string> vec) {
    map<string, long long> count;
    for (string s : vec) {
        count[s] += 1;
    }
    return count;
}


int main() {
    using ll = long long;
    using vl = vector<long long>;


    
    int n, k; cin >> n >> k;

    vl h = IL(n);
    vl dp(n, inf);
    dp[0] = 0;

    for (int i=0; i<n; i++) {
        if (i<k) {
            for (int j=0; j<i; j++) {
                dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
            }
        }
        else {
            for (int j=k; j>0; j--) {
                dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }

    cout << dp[n-1] << endl;




}


Measured memory_bytes: 4848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble();
        double ans = 1;

        for(int i=0; i<n; i++){
            ans*=(i+1);
            ans = ans%(Math.pow(10, 9)+7);
        }

        System.out.println((int)(ans));
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(c >= a && c <= b ? "Yes" : "No");
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

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

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

		int ans = 0, sum = 0;
		for(int i = 0; i < k - 1; ++i)
			sum += a[i];

		for(int i = k - 1; i < n; ++i) {
			sum += a[i];
			chmax(ans, sum);
			sum -= a[i - k + 1];
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1532
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.size() ;
	if(len<2){
		cout<<len<<endl;
		return 0;
	} 
	for(int i=0;i<len-1;i++){
		if(s[i]=='S'&&s[i+1]=='T'){
			s.erase(i,2);
			len-=2;
			i-=2;
			if(i<-1)i=-1;
			len=s.size() ;
		}
	}
	cout<<s.size()<<endl;
} 

Measured memory_bytes: 640
import math
n, d = map(int, input().split())
x = []

for i in range(n):
    xi = [int(s) for s in input().split()]
    x.append(xi)

count = 0
for i in range(0, n - 1):
    for j in range(i + 1, n):
        distance = 0
        for k in range(d):
            distance += (x[i][k] - x[j][k]) ** 2
        norm = math.sqrt(distance)
        if norm.is_integer():
            count += 1
print(count)

Measured memory_bytes: 9060
#include <iostream>
#include <string>

using namespace std;

int main(void){
    
    string passO={}, passE={}, answer={}; cin >> passO >> passE;
    
    
    
    int count = passE.size();
    
    
    
    for(int i=0; i<count; i++){
        
       cout << passO[i]; cout << passE[i];
        
    }
    
    if(passE.size() < passO.size()){
        
        int longsize = passO.size() - 1;
        
        cout << passO[longsize] << endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef pair<long , long> pll;

const ll mx = 105;
const ll maxn = 1000001;
const ll mod = 1000000007;

vector<vector<int>> adj;
vector<ll> lis;


int main(){
       
 
  ll t = 1;

  //cin>>t;

  while(t--){
     ll n, i, j ,k;

     cin>>n;

     vector<string> v(n);

     for(i= 0;i < n;i++)
       cin>>v[i];
       set<string> s;

     for(i = 0;i < n;i++)
      s.insert(v[i]);  

    cout<<sz(s)<<"\n";

  }     
        
}



Measured memory_bytes: 25016
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////
struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	vector<ll> edges_cost; // edge cost
	
	//for dijkstra
	bool done; //conform or not
	ll cost; // now cost
	int from;
	
	bool operator<(const Vertex& another) const { // priority --> min
        return another.cost < cost; // order(cost)
    }
	
	bool operator==(const Vertex& another) const {
        return another.cost == cost; // order(cost)
    }
};

static Vertex V[100002];
static int in[100002] = {};
static int height[100002] = {};
static int ans[100002] = {};

int main(){
	int N,M;
	vector<PII> edgepair;
	SCD2(N,M);
	REP(i,N-1+M){
		int A,B; SCD2(A,B);
		V[A].edges_to.PB(B);
		in[B]++;
		edgepair.PB((MP(A,B)));
	}

	stack<int> S;

	int par;
	int fixed = 1;

	FORq(i,1,N){
		if (in[i] == 0) par = i;
	}

	S.push(par);

	height[par] = 0;
	int nowH = 0;

	while(fixed < N){
		stack<int> nextS;
		nowH++;
		while(S.size()){
			par = S.top();
			REP(i,V[par].edges_to.size()){
				int next = V[par].edges_to[i];
				in[next]--;
				if (in[next] == 0){
					height[next] = nowH;
					nextS.push(next);
					fixed++;
				}
			}

			S.pop();

		}
		S = nextS;
	}

	REP(i,N-1+M){
		int a = edgepair[i].fst;
		int b = edgepair[i].snd;
		if (height[b] == height[a] + 1){
			ans[b] = a;
		}
	}

/* 	FORq(i,1,N){
		cout << height[i] << "\n";
	}
	cout << "----" << "\n"; */

	FORq(i,1,N){
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 12916
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H1, M1, H2, M2, K;
  cin>>H1>>M1>>H2>>M2>>K;
  int length = H2*60+M2-(H1*60+M1);
  cout<<max(0, length-K)<<endl;
}



Measured memory_bytes: 3616
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <set>

using namespace std;

    int n,m,x ;
int min(int a, int b){
    if(a<b) return a ;
    else return b ;
}

int main() {

    cin>>n>>m>>x ;  
    int c[n] ;
    int a[n][m] ;
   for (int i = 0; i < n; i++){
           cin >> c[i] ;
      for (int j = 0; j < m; j++)
      {
          cin >> a[i][j] ;
      }
   }


    long long all_ans = (1LL<<60)-1 ;

    for (int bit = 0; bit < (1 << n); ++bit) {
    
     int ans[m] ;
     for (int k = 0; k < m; k++) ans[k] = 0 ;
          
        // 部分集合に対応する総和
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)){
              for (int k = 0; k < m; k++){
                  ans[k] += a[i][k] ;
              }  
              sum+=c[i] ;
            } 
        }
        //cout << sum << endl ;
        // 判定
        bool jd = true ;
        for (int k = 0; k < m; k++)
        {
            if(ans[k]<x) jd = false ;
        }
        
        if(jd){
            all_ans = min(all_ans,sum);
        } 
    }

if(all_ans==(1LL<<60)-1)
 cout << -1 << endl ;
else 
 cout << all_ans << endl ; 

  return 0 ;
}

Measured memory_bytes: 3580
/**
 *      purpose : ABC 122 C
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

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

  int n, q; cin >> n >> q;
  string str; cin >> str;

  int s[n];

  s[0] = 0;
  int cnt = 0;

  for (int i = 1; i < n; ++i){
    if (str[i - 1] == 'A' && str[i] == 'C') {
      ++cnt; s[i] = cnt;
    }
    else s[i] = cnt;
  }
  
  //  for (int i = 0; i < n; ++i)print(s[i]);

  for (int i = 0; i < q; ++i){
    int l, r; cin >> l >> r;
    --l; --r;
    print(s[r] - s[l]);

  }


  return 0;
}

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

using namespace std;

int main() {
	string s, p;

	cin >> s >> p;
	s += s;
	if (s.find(p) == string::npos) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3232
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
struct edge {int to, cost;};
int a[501][501];
vector<int>a1, a2, a3, a4;
signed main() {
	int h, w; cin >> h >> w;
	rep(i, h)rep(j, w)cin >> a[i][j];
	
	rep(i, w) {
		for (int j = h - 1; j >= 1; j--) {
			if (a[j][i] & 1) {
				a1.push_back(j + 1);
				a2.push_back(i + 1);
				a3.push_back(j);
				a4.push_back(i+1);
				a[j - 1][i]++;
				a[j][i]--;
			}
		}
	}
	rep(i, w-1) {
		if (a[0][i] & 1) {
			a1.push_back(1);
			a2.push_back(i + 1);
			a3.push_back(1);
			a4.push_back(i + 2);
			a[0][i]--;
			a[0][i + 1]++;
		}
	}
	cout << a1.size() << endl;
	rep(i, a1.size())cout << a1[i] << ' ' << a2[i] << ' ' << a3[i] << ' ' << a4[i] << endl;
}

Measured memory_bytes: 8148
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int a[100010];
    for(int i=0; i < n; i++){
        scanf("%d", &a[i]);
        a[i]--;
    }
    int x=0;
    for(int i=0; i < 100010; i++){
        if(x == 1){
            cout << i << endl;
            return 0;
        }
        x = a[x];
    }
    cout << -1 << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
    llin(n);
    vll b(n-1);
    FOR(i,0,n-2){
        cin >>b[i];
    }
    ll k=b[0]+b[n-2];
    FOR(i,0,n-3){
        k+=min(b[i],b[i+1]);
    }
    sal(k)
}


Measured memory_bytes: 256