akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int Grundy[105];

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = N;
  while(N--) {
    int t;
    cin >> t;
    if(t >= A and t < B) ans--;
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N;

	cin >> N;
	vector<vector<int>> A(N, vector<int>(N - 1));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> A[i][j];
			A[i][j]--;
		}
		reverse(A[i].begin(), A[i].end());
	}

	vector<pair<int, int>> q;
	auto check = [&](int i) {
		if (A[i].size() == 0) {
			return;
		}
		int j = A[i].back();
		if (A[j].size() == 0) {
			return;
		}
		if(A[j].back() == i) {
			pair<int, int> p = make_pair(i, j);
			if (p.second < p.first) {
				swap(p.first, p.second);
			}
			q.push_back(p);
		}
	};
	for (int i = 0; i < N; i++) {
		check(i);
	}
	int day = 0;
	while (q.size() > 0) {
		day++;
		sort(q.begin(), q.end());
		q.erase(unique(q.begin(), q.end()), q.end());
		vector<pair<int, int>> prevQ;
		swap(prevQ, q);
		for (pair<int, int> p : prevQ) {
			int i = p.first, j = p.second;
			A[i].pop_back();
			A[j].pop_back();
		}
		for (pair<int, int> p : prevQ) {
			int i = p.first, j = p.second;
			check(i);
			check(j);
		}
	}

	for (int i = 0; i < N; i++) {
		if (A[i].size() != 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << day << endl;

	return 0;
}

Measured memory_bytes: 4224
#import math
#=input()
#=int(input())
a,v=map(int,input().split())
b,w=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
t=int(input())

if w >= v:
    print('NO')
else:
    q = (v - w) * t
    if q >= abs(b - a):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9184
#include<iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	if(N%10==0)cout<<"pon"<<endl;
	if(N%10==1)cout<<"pon"<<endl;
	if(N%10==2)cout<<"hon"<<endl;
	if(N%10==3)cout<<"bon"<<endl;
	if(N%10==4)cout<<"hon"<<endl;
	if(N%10==5)cout<<"hon"<<endl;
	if(N%10==6)cout<<"pon"<<endl;
	if(N%10==7)cout<<"hon"<<endl;
	if(N%10==8)cout<<"pon"<<endl;
	if(N%10==9)cout<<"hon"<<endl;
}

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

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

long long a,b,c,tempa,tempb,tempc,ret=1e6;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>a>>b>>c;
    for(int i=0;i<1e6;i++)
    {
    	if(a%2==1 || b%2==1 || c%2==1) {
    		ret=i;
    		break;
		}
    	tempa=a;
    	tempb=b;
    	tempc=c;
    	a=tempb/2+tempc/2;
    	b=tempa/2+tempc/2;
    	c=tempa/2+tempb/2;
	}
	if(ret==1e6)
		cout<<-1<<endl;
	else
		cout<<ret<<endl;
}

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

bool allSumGreater(int sum[], int x, int m) {
  for(int i=0; i<m; i++) {
    if(sum[i]<x) return false;
  }
  return true;
}

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

  int n,m,x;
  cin>>n>>m>>x;

  vector<vector<int>> v(n);

  for(int i=0; i<n; i++) {
    int temp;
    cin>>temp;
    v[i].push_back(temp);
    for(int j=0; j<m; j++) {
      int a;
      cin>>a;
      v[i].push_back(a);
    }
  }

  int mn=LONG_LONG_MAX;

  for(int i=1; i<(1<<n); i++) {
    int val=i;
    int totalsum=0;
    int sum[m];
    memset(sum, 0, sizeof sum);
    int k=0;

    while(k<n) {
      if(val&1) {
      totalsum+=v[k][0];

      for(int j=1; j<=m; j++) {
        sum[j-1]+=v[k][j];
      }
      }

      val>>=1;
      k++;
    }

    if(allSumGreater(sum, x, m)) {
      mn=min(mn, totalsum);
    }
  }

  if(mn==LONG_LONG_MAX) {
    cout<<-1;
    return 0;
  }

  cout<<mn;

}

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

int main() {
  int N, p, w, g, y;
  p = 0, w = 0, g = 0, y = 0;
  string S;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "P") {
      p++;
    }
    else if (S == "W") {
      w++;
    }
    else if (S == "G") {
      g++;
    }
    else {
      y++;
    }
  }
  if (p * w * g * y == 0) {
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
using namespace std;
const int num = 100, INF = 20000000;
int v[num][num], n, d[num], c[num], p[num];
inline void mini() {
	for (int i = 1; i < n; i++) {
		d[i] = INF;
		c[i] = 0;
	}
	d[0] = 0;
	while (1) {
		int u = -1;
		int minv = INF;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && c[i] == 0) {
				minv = d[i];
				u = i;
			}
		}
		if (u == -1)break;
		for (int i = 0; i < n; i++) {
			if (c[i] == 0 && v[u][i] != 0) {
				if (d[i] > d[u] + v[u][i]) d[i] = d[u] + v[u][i];
				
			}
		}
		c[u] = 1;
	}

}
int main() {
	cin >> n;
	int u, k, s;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			cin >> v[u][s];
		}
	}
	mini();
	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    long long n; cin >> n;
    long long p[n];

    for(long long i = 0; i < n; i++){
        cin >> p[i];
    }

    long long ans = 0,curMin = 1e9;
    for(long long j = 0; j < n; j++){
        curMin = min(curMin,p[j]);
        if(curMin == p[j]) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    K = int(input())
    A = list(map(int, input().split()))

    maxAns = 2
    minAns = 2

    for a in reversed(A):
        maxAns = maxAns // a * a + a - 1
        minAns = -(-minAns // a) * a

    resMax = maxAns
    resMin = minAns

    for a in A:
        resMax = resMax // a * a
        resMin = resMin // a * a

    if resMax == resMin == 2:
        print(minAns, maxAns)
    else:
        print(-1)

sol()

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

#define mod 1000000007

int dfs(vector<vector<int>> &v,int cur,int used[])
{
    if(used[cur])
    {
        return 0;
    }

    int ans=1;
    used[cur]=1;
    for(int i: v[cur])
    {
        ans+=dfs(v,i,used);
    }

    return ans;
}

int main()
{
    int n,m;
    cin>>n>>m;

    vector<vector<int>> v(n,vector<int>());

    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        x--;y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    int used[n]={0};

    int ans=INT32_MIN;

    for(int i=0;i<n;i++)
    {
        if(!used[i])
        {
            ans=max(ans,dfs(v,i,used));
        }
    }

    cout<<ans;
}

Measured memory_bytes: 24212
#include <cstdio>

int main() {
  int R0, W0, C, R;
  while (true) {
    scanf("%d %d %d %d", &R0, &W0, &C, &R);
    if (R0 == 0 && W0 == 0 && C == 0 && R == 0) break;
    int X = 0;
    while (R0 + X*R < W0*C) X++;
    printf("%d\n", X);
  }
  return 0;
}

Measured memory_bytes: 2716
#include <iostream>
#include <algorithm>

using namespace std;
const int maxn = 1e5 + 10;
using namespace std;

int f[maxn];
int h[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d",&h[i]);
	f[0] = 0;
	f[1] = abs(h[1]-h[0]);
	for(int i = 2; i < n; i++)
		f[i] = min(f[i-1] + abs(h[i]-h[i-1]), f[i-2] + abs(h[i]-h[i-2]));
	// for(int i = 0; i < n; i++)
	// 	cout << f[i] << endl;
	printf("%d\n", f[n-1]);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		string S; cin >> S;
		if (S.size() % 2 == 1) { cout << "No" << endl; return; }
		rep(i, S.size()) {
			if (i % 2 == 0 && S[i] != 'h') { cout << "No" << endl; return; }
			if (i % 2 == 1 && S[i] != 'i') { cout << "No" << endl; return; }
		}
		cout << "Yes" << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll maxn=5e3+10, maxm=3e5+10, lg=21, mod=1e9+7, inf=1e18;

ll a,b;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>a>>b;
	if(a==b) return cout<<1,0;
	ll i=60,nw=0;
	while((a>>i&1)==(b>>i&1)) nw|=(a>>i&1)*(1ll<<i), i--;
	ll r=(1ll<<i)|nw;
	for(int j=i-1;j>=0;j--)if(b>>j&1) b|=(1ll<<(j+1))-1;
	cout<<min(b-a+1,1ll<<i)+r-a;
	
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
    
    int N, M;
    ll m[100010], MOD = 1e9+7;
    cin >> N >> M;
    m[0] = 0;
    m[1] = 1;
    for (int i = 2; i <= N+ 10; ++i){
        m[i] = (m[i-1] + m[i-2]) % MOD;
    }
    
    ll ans = 1, p = -1;
    for (int i = 0; i < M; ++i){
        ll n;
        cin >> n;
        ans *= m[n - p - 1];
        ans %= MOD;
        p = n;
    }
    ans *= m[(N+1) - p - 1];
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(bf.readLine());
        String[] str = bf.readLine().split(" ");
        int max = 0,
            sum = 0;
        for(int i = 0; i < N; i++){
            int value = Integer.parseInt(str[i]);
            sum += value;
            if(max < value){
                max = value;
            }
        }
        if(sum - max > max){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }        
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> f(n), a(n); for(int & i : a) cin >> i;
  for(int i = n - 2; i >= 0; i--) {
    f[i] = 1<<30;
    if(i + 1 < n) f[i] = min(f[i], abs(a[i] - a[i + 1]) + f[i + 1]);
    if(i + 2 < n) f[i] = min(f[i], abs(a[i] - a[i + 2]) + f[i + 2]);
  }
  cout << f[0] << endl;
  return 0;
}

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

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

    int a, b;
    for(int i=-120;i<=120;i++){
        for(int j=-120;j<=120;j++){
            if(pow(i,5) - pow(j,5) == x){
                a = i; b = j;
                break;
            }
        }
    }
    
    cout << a << " " << b << endl;
}

Measured memory_bytes: 4100
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b = inpl()
if a == 2 or b == 2:
    print(0)
elif a == 1 and b == 1:
    print(1)
elif a == 1 or b == 1:
    print(a*b-2)
else:
    print((a-2)*(b-2))


Measured memory_bytes: 10328
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> like(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> like[i];
	}

	int friendly_pairs = 0;
	for (int i = 1; i <= n; ++i) {
		if (i == like[like[i]]) {
			++friendly_pairs;
		}
	}

	cout << friendly_pairs / 2 << "\n";

	return 0;

}

Measured memory_bytes: 640
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x; cin >> x;
  int ans = 0;

  while(1)
  {
    string s;
    s = to_string(x);

    if(s[0] == s[1] && s[1] == s[2])
    {
      break;
    }
    x++;
  }

  cout << x << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		int sum = 0;
		for(int i = 0; i < 2; i++) {
			if(A < B) {
				sum += B;
				B--;
			}
			else {
				sum += A;
				A--;
			}

		}

		System.out.println(sum);
	}

}


Measured memory_bytes: 35668
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/29 16:55:44 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	string	s;
	cin >> s;
	int	n;
	n = s.size();

	vector<int> commands(n);
	rep(i, n)
	{
		if (s.at(i) == 'L')
			commands.at(i) = commands.at(i - 1) - 1;
	}
	rrep(i, n - 1)
	{
		if (s.at(i) == 'R')
		{
			if (commands.at(i + 1) < 0)
				commands.at(i) = 1;
			else
				commands.at(i) = commands.at(i + 1) + 1;
		}
	}
	rep(i, n)
	{
		if (commands.at(i) % 2)
		{
			if (commands.at(i) > 0)
				commands.at(i)--;
			else
				commands.at(i)++;
		}
	}
	vector<int>	V(n);
	rep(i, n)
		V.at(i + commands.at(i))++;
	rep(i, n)
	{
		if (i)
			cout << ' ';
		cout << V.at(i);
	}
	cout << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1488
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll dp0[MAX_N];
ll dp1[MAX_N];

ll modpow(ll a, ll n, ll mod){
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}

int main(){
    string l;
    cin>>l;
    ll ans=0;
    ll n=l.length();
    ll a=2;
    ans+=modpow(3,n-1,MOD);
    for(ll i=1;i<n;i++){
        if(l[i]=='1'){
            ans+=a*modpow(3,n-i-1,MOD);
            a=a*2%MOD;
            ans%=MOD;
        }
        //cout<<ans<<endl;
    }
    ans+=a;
    //for(int i=0;i<n;i++) cout<<dp1[i]<<" "; cout<<endl;
    //for(int i=0;i<n;i++) cout<<dp0[i]<<" "; cout<<endl;
    ans%=MOD;
    cout<<ans<<endl;
}

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

int main()
{
  string a,b;
  cin>>a>>b;
  if(a.length()>b.length())
  {
    cout<<"GREATER\n";return 0;
  }
  else if(b.length()>a.length())
  {
      cout<<"LESS\n";return 0;
  }
  else
  {
    for(int i=0;i<a.length();i++)
      if(a[i]>b[i])
      {
        cout<<"GREATER\n";
        return 0;
      }
      else if(a[i]<b[i])
      {
          cout<<"LESS\n";return 0;
      }
    cout<<"EQUAL\n";  
  }


  return 0;
}


Measured memory_bytes: 256
c,t,d[4010][4010]={1};char s[4010];i;main(j){for(gets(s);s[i/2];i++)for(j=c+=s[i]?t+=2,s[i]-48:0;j>i+c-t&&~j;j--)d[i+1][j]=(d[i][j]+d[i][j-1])%998244353;printf("%d",d[i][c]);}

Measured memory_bytes: 31744
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

K = ir()
A, B = lr()
left = -(-A//K)
right = B // K
bl = left <= right
if A % K == 0 or B % K == 0:
    bl = True
print('OK' if bl else 'NG')


Measured memory_bytes: 9128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;


int d[100000];int num[100000];
int cmp(int x,int y){return x<y;}

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

    for (int i=0;i<n;++i)scanf("%d",&d[i]);
    long long ans=1;
    if (d[0]!=0) ans=0;
    sort(d,d+n,cmp);

    for (int i=0;i<n;++i) num[d[i]]++;

    if (num[0]>1) ans=0;

    for (int i=1;i<n;++i)
    {
        ans*=num[d[i]-1];
        ans%=998244353;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	ll count=0,countB=0,countW=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='B'){
			countB++;
		}
		if(s[i]=='W')
		{
			count+=countB;
		}
	}
	cout<<count<<"\n";
	return 0;
} 
 


Measured memory_bytes: 640
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x, y;
	cin >> x >> y;
	cout << min({x + y / 2, x + y});
	return 0;
}



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

int main(void){
	
	string s;
	cin >> s;
	if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I'){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char input[20],input1[20],input2[20];
	scanf("%s %s %s",input,input1,input2);
	int len = strlen(input);
	int lens = strlen(input1);
	if(input[len-1] == input1[0] && input1[lens-1] == input2[0])
	{
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const long long inf = pow(10, 18);

int main(){
    int N;
    cin >> N;
    vector<long long> a(N);

    long long ans = 1;
    for(int i=0; i<N; ++i){
        long long num;
        cin >> num;
        if(num == 0) ans = 0;
        a[i] = num;
    }
    if(ans != 0){
        for(int i=0; i<N; ++i){

            long long original_ans = ans;
            ans = original_ans * a[i];

            //check overflow
            if( ans/a[i] != original_ans ){
                ans = -1;
                break;
            }

            if(ans > inf){
                ans = -1;
                break;
            }

            if(ans == 0){
                ans = -1;
                break;
            }
        }
    }

// 3
// 1000000000 1000000000 3

    cout << ans << endl;
}

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

int main(){
  long n; cin >>n;
  long R=0, G=0, B=0;
  vector<char> s(n+1);
  for(int i=1; i<=n; i++){
    cin >>s[i];
    if(s[i]=='G') G++;
    if(s[i]=='R') R++;
    if(s[i]=='B') B++;
  }
  
  long ans=0;
  ans=R*G*B;
  long NG=0;
  for (int i=1; i<=n; i++){
    for (int j=i+1; j<=n; j++){
      if(2*j-i<=n){
        if(s[i]!=s[j] && s[j]!=s[2*j-i] && s[i]!=s[2*j-i]) NG++;
      }
    }
  }
  cout <<ans-NG <<endl;
}


Measured memory_bytes: 3632
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(N):
    A = list(map(int, input().split()))
    num = C
    for i in range(M):
        num += A[i]*B[i]
    if num > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int x;
LL G(LL x){
  return x*x*x*x*x;
}
int main() {
  ios::sync_with_stdio(false);
//  cin>>x;
cin>>x;
  for(int i=-300;i<=300;i++){
    for(int j=-300;j<=300;j++){
      if(G(i)-G(j)==x){
        return cout<<i<<' '<<j<<endl,0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b;

signed main() {
	cin >> a >> b;
	cout << max(a*2-1, max(a+b, b*2-1)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
#define MAX 100

using namespace std;
 
struct Card { char suit, value; };
 
void bubbleSort(struct Card C[], int N) {
  REP(i, N) {
    for (int j = N - 1; j >= i + 1; j--) {
      if (C[j].value < C[j - 1].value) {
        Card temp = C[j];
        C[j] = C[j - 1];
        C[j - 1] = temp;
      }
    }
  }
}
 
void selectionSort(struct Card C[], int N) {
  REP(i, N) {
    int minj = i;
    FOR(j, i, N) {
      if (C[j].value < C[minj].value) {
        minj = j;
      }
    }
    Card temp = C[i];
    C[i] = C[minj];
    C[minj] = temp;
  }
}
 
void print(struct Card C[], int N) {
  REP(i, N) {
    if (i > 0) cout << " ";
    cout << C[i].suit << C[i].value;
  }
  cout << endl;
}
 
bool isStable (struct Card C1[], struct Card C2[], int N) {
  REP(i, N) {
    if (C1[i].suit != C2[i].suit) {
      return false;
    }
  }
  return true;
}
   
   
int main() {
  Card C1[MAX], C2[MAX];
  int N;
   
  cin >> N;
  REP(i, N) {
    cin >> C1[i].suit >> C1[i].value;
    C2[i] = C1[i];
  }
 
  bubbleSort(C1, N);
  selectionSort(C2, N);
 
  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if (isStable(C1, C2, N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define sci(x) scanf("%d",&x)
#define scs(s) scanf("%s",s)
#define scc(c) scanf("%c",c)
#define scd(d) scanf("%lf",&d)
#define scld(ld) scanf("%Lf",&ld)
using namespace std;

//********************************************
//Error tracking
#define show(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}
//********************************************

const int NMAX = 5005;

int n, k, a[NMAX];
bitset<NMAX>pref[NMAX], suf[NMAX];
int sum[2][NMAX];

void Knapsack()
{
	int i, j;

	//prefix
	pref[0][0] = 1;
	for (i = 1; i <= n; i++)
		for (j = 0; j < NMAX; j++)
		{
			pref[i][j] = pref[i - 1][j];
			if (j >= a[i] && pref[i - 1][j - a[i]])
				pref[i][j] = 1;
		}

	//sufix
	suf[n + 1][0] = 1;
	for (i = n ; i >= 1; i--)
		for (j = 0; j < NMAX; j++)
		{
			suf[i][j] = suf[i + 1][j];
			if (j >= a[i] && suf[i + 1][j - a[i]])
				suf[i][j] = 1;
		}
}

int main()
{
  //  freopen("input","r",stdin);
  //  freopen("output","w",stdout);
    cin.sync_with_stdio(false);
	
	int i;
	cin >> n >> k;
	for (i = 1; i <= n; i++) cin >> a[i];

	Knapsack();
	
	//answer
	int j, ans = 0;
	for (i = 1; i <= n; i++)
	{
		int st = max(0, k - a[i]), dr = k - 1; //the interval to search

		//partial sums
		for (j = 0; j < NMAX; j++) 
			{
				sum[0][j] = pref[i - 1][j];
				sum[1][j] = suf[i + 1][j];
			}

		for (j = 1; j < NMAX; j++)
			for (int l = 0; l <= 1; l++)
				sum[l][j] += sum[l][j - 1];


		bool ok = 0;
		for (j = 0; j <= dr; j++)
			if (pref[i - 1][j] != 0) //search for other
			{
				int left = max(0, st - j), right = dr - j;

				int minus = 0;
				if (left > 0) minus = sum[1][left - 1];
				if (sum[1][right] - minus > 0) ok = 1;
			}

		if (!ok) ans++;
	}	
	cout << ans << "\n";
	
    return 0;   
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;


int main(){
	int ans=0;
	vector<int> a(3);
	for(int i=0;i<3;i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ans = abs(a[0]-a[1]) + abs(a[1]-a[2]);
	cout << ans << endl; 
	
	
	return 0;
}


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

using namespace std;

int main(){
    
    string n;
    cin >> n;
    
    if (n == "A") {
        cout << "T" << endl;
    }else if (n == "T") {
        cout << "A" << endl;
    }else if (n == "C") {
        cout << "G" << endl;
    }else{
        cout << "C" << endl;
    }
    
    return 0;
    
}



Measured memory_bytes: 256
///https://codeforces.com/blog/entry/69629

/*
my logic is...
at first i took all possible combination of different material..nPr or nCr * 3! 
then i took two same and one is different combination... n*(n-1)this is combination
permutation will be n *(n-1) *3;

then i took all same which will be equal to n
*/
#include <bits/stdc++.h>
using namespace std;

int Factorial_of(int n)
{
    int fac = 1;
    for(int i = 1; i <= n; ++i)
    {
        fac *= i;
    }
    return fac;
}

int main()
{
    long long n, pass = 1, fac = 1;
    cin >> n;
    if(n == 1)cout << "1\n";
    else if(n == 2)cout << "8\n";
    else
    {
        for(int i = 1; i <= n; ++i)
        {
            fac *= i;
        }
        ///pass = (fac/6) * 6;
        pass = fac/Factorial_of((n-3))/*all different*/; ///nCr
        pass += (n * (n-1)) * 3 /*two same one diff*/ + n /*all same*/;
        cout << pass << endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	int x,k,d;
	cin>>x>>k>>d;
	int pl=(x%d+d)%d;
	if(abs(pl-x)/d%2!=k%2)
		pl-=d;
	cout<<(abs(pl-x)/d<=k?abs(pl):pl>=x?abs(x+d*k):abs(x-d*k))<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int p,y,w,g;
  p=0;
  y=0;
  w=0;
  g=0;
  
  string co;
  
  for(int i = 0; i < N; i++)
  {
   cin >> co;
   if(co == "P")
     p = 1;
   else if(co == "Y")
     y = 1;
   else if(co == "W")
     w = 1;
   else if(co == "G")
     g = 1;
  }
  
  int judge;
  judge = p+y+w+g;
  if(judge == 3){
    cout << "Three" << endl;
  }
  else if(judge == 4){
    cout << "Four" << endl;
  }
    
}

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

int main() {

	int n; cin >> n;

	int h_max = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		if (h_max <= h) ans++;
		h_max = max(h_max, h);
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX = 401;
const int INF = -9999999;
 
int main(){
    int n,m,a,b,c,g[MAX][MAX];
    fill(g[0],g[MAX],INF);
 
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
	cin >> a >> b >> c;
	g[a][b] = c;
    }
 
    for(int k = 0 ; k < n ; k++){
	for(int i = 0 ; i < n ; i++){
	    for(int j = 0 ; j < n ; j++){
		g[i][j] = max(g[i][j],g[i][k]+g[k][j]);
	    }
	}
    }
    
    cout << g[0][n-1] << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(void){
    int n,k;
    int x[100009];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int ans=abs(x[0])+abs(x[0]-x[k-1]);
    ans=min(ans,abs(x[k-1])+abs(x[0]-x[k-1]));
    for(int i=0;i<=n-k;i++){
        ans=min(ans,abs(x[i])+abs(x[i]-x[i+k-1]));
        ans=min(ans,abs(x[i+k-1])+abs(x[i]-x[i+k-1]));
    }
    cout<<ans;
}


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

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

    if (a <= 5)
        cout << 0 << endl;
    else if (a <= 12)
        cout << b/2 << endl;
    else // if a > 12
        cout << b << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const long long Max = 10e7;
typedef long long ll;
int mod = 1000000007;
const int Size = 1000-10;
int main()
{
    int r, c;
    cin >> r >> c;
    char grid[r+1][c+1] = {};
    int dp[r+1][c+1] = {};
    for(int i = 1; i <= r; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            cin >> grid[i][j];
        }
    }
    dp[1][1] = 1;
    for(int i = 2; i <= c; i++)
    {
        if(grid[1][i] == '.')
        {
            dp[1][i] = dp[1][i-1];
        }
    }
    for(int i = 2; i <= r; i++)
    {
        if(grid[i][1] == '.')
        {
            dp[i][1] = dp[i-1][1];
        }
    }
    for(int i = 2; i <= r; i++)
    {
        for(int j = 2; j <= c; j++)
        {
            //cout<< grid[i][j] << endl;
            if(grid[i][j] == '.')
            {
                if(dp[i-1][j] >= 1 && dp[i][j-1] >= 1)
                {
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
                }
                else
                {
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
            }
            else
            {
                dp[i][j] = 0;
            }
        }
    }
    cout << dp[r][c] << endl;
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
int main(){
    int i;
    int x,n,p[102];
    int ans;
    cin >> x >> n;
    rep(i,102){
        p[i] = 0;
    }
    rep(i,n){
        int t;
        cin >> t;
        p[t] = 1;
    }
    int diff1 = 101-x;
    for(i=x;i<100;i++){
        if(p[i] == 0){diff1 = i-x;break;}
    }
    int diff2 = x;
    for(i=x;i>=0;i--){
        if(p[i] == 0){diff2 = x-i;break;}
    }
    //cout << diff1 << "  " <<  diff2 << endl;
    if(diff2 <= diff1){
        ans = x-diff2;
    }else{
        ans = x+diff1;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3644
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n, r, ans;
	cin >> n >> r;
	if (n < 10) {
		ans = r + 100 * (10 - n);
	} else {
		ans = r;
	}
	cout << ans << endl;
	return 0;
}


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

class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
using edges = vector<edge>;
using graph = vector<edges>;

bool bellman_ford(graph &g, vector<Int> &d, vector<Int> &x){
	bool f = false;
	for(size_t i=0; i<g.size(); ++i){
		f = false;
		for(auto v:g)
			for(auto e:v)
				if(d[e.to] < d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
					if(x[e.to] == 1) f = true;
				}
	}
	return f;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, m, p; cin >> n >> m >> p;
	graph g(n), h(n);
	for(Int i=0; i<m; ++i){
		Int a, b, c; cin >> a >> b >> c;
		--a; --b;
		g[a].push_back(edge(c-p, a, b));
		h[b].push_back(edge(c-p, b, a));
	}
	vector<Int> x(n, 0), y(n, 0);
	queue<Int> q;
	q.push(0);
	x[0] = 1;
	while(!q.empty()){
		Int p = q.front(); q.pop();
		for(auto e:g[p])
			if(x[e.to] == 0){
				x[e.to] = 1;
				q.push(e.to);
			}
	}
	q.push(n-1);
	y[n-1] = 1;
	while(!q.empty()){
		Int p = q.front(); q.pop();
		for(auto e:h[p])
			if(y[e.to] == 0){
				y[e.to] = 1;
				q.push(e.to);
			}
	}
	for(Int i=0; i<n; ++i)
		x[i] *= y[i];
	vector<Int> d(n, -1e18);
	d[0] = 0;
	if(bellman_ford(g, d, x)) cout << -1 << "\n";
	else cout << max<Int>(0, d[n-1]) << "\n";
//	for(Int i=0; i<n; ++i)
//		cout << i << " " << d[i] << "\n";
}

Measured memory_bytes: 896
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        s: String
    }
    let ss =    if &s == "ABC" {
        "ARC"
    } else {
        "ABC"
    };
    println!("{}", ss);
}


Measured memory_bytes: 2132
//NEVER GIVE UP I AM GOING TO IMPROVE ONE DAY.
//PRACTICE,PRACTICE,PRACTICE!!!
#include<bits/stdc++.h>
#define int long long int
// #define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e18
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
const int M=1000000000;
const double pi = acos(-1.0);
using namespace std;
// cout<<"Case #"<<test-t<<":"<<" "<<"N"<<endl;
int32_t main(){

    // #ifndef ONLINE_JUDGE 
    // freopen("in.txt", "r", stdin); 
    // freopen("out.txt", "w", stdout); 
    // #endif 

    fast;
    int t;
    t=1;
    // cin>>t;
    // int test=t;
    while(t--){
        int n,k,i;
        cin>>n;
        int a[n];
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        int x,amt=1000;
        if(a[1]>=a[0]){
            x=amt/a[0];
            amt-=(x*a[0]);
        }
        for(i=1;i<n;i++){
            if(a[i]>=a[i-1]){
                int j=i;
                while(a[j]>=a[j-1] && j<n){
                    j++;
                }
                j--;
                i=j;
                amt+=(x*a[j]);
                x=0;
            }
            else{
                int j=i;
                while(a[j-1]>a[j] && j<n){
                    j++;
                }
                j--;
                i=j;
                if(i==n-1){
                    continue;
                }
                x+=(amt/a[j]);
                amt-=(x*a[j]);
            }
        }
        cout<<amt<<endl;
    }
}

Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  for(int tci = 0; ; tci++) {
    int H,W,C,M,NW,NC,NM; scanf("%d%d%d%d%d%d%d", &H, &W, &C, &M, &NW, &NC, &NM);
    if(H<0) break;
#define START 0
#define V_H(x)   (1+(x))
#define V_W(x)   (1+H+(x))
#define V_W2(x)  (1+H+W+(x))
#define V_NW(x)  (1+H+W+W+(x))
#define V_NW2(x) (1+H+W+W+NW+(x))
#define V_C(x)   (1+H+W+W+NW+NW+(x))
#define V_C2(x)  (1+H+W+W+NW+NW+C+(x))
#define V_NC(x)  (1+H+W+W+NW+NW+C+C+(x))
#define V_NC2(x) (1+H+W+W+NW+NW+C+C+NC+(x))
#define V_M(x)   (1+H+W+W+NW+NW+C+C+NC+NC+(x))
#define V_NM(x)  (1+H+W+W+NW+NW+C+C+NC+NC+M+(x))
#define TERMINAL (1+H+W+W+NW+NW+C+C+NC+NC+M+NM)
#define SIZE     (1+H+W+W+NW+NW+C+C+NC+NC+M+NM+1)

    vector<vector<int> > capa(SIZE, vector<int>(SIZE, 0));
    for(int i = 0; i < H; i++) {
      capa[START][V_H(i)] = 1;
    }
    for(int i = 0; i < W; i++) {
      int n; scanf("%d", &n);
      for(int j = 0; j < n; j++) {
        int k; scanf("%d", &k); k--;
        capa[V_H(k)][V_W(i)] = 1;
      }
    }
    for(int i = 0; i < NW; i++) {
      for(int j = 0; j < H; j++) {
        capa[V_H(j)][V_NW(i)] = 1;
      }
    }
    for(int i = 0; i < W; i++) {
      capa[V_W(i)][V_W2(i)] = 1;
    }
    for(int i = 0; i < NW; i++) {
      capa[V_NW(i)][V_NW2(i)] = 1;
    }
    for(int i = 0; i < C; i++) {
      int n; scanf("%d", &n);
      for(int j = 0; j < n; j++) {
        int k; scanf("%d", &k); k--;
        capa[V_W2(k)][V_C(i)] = 1;
      }
      for(int j = 0; j < NW; j++) {
        capa[V_NW2(j)][V_C(i)] = 1;
      }
    }
    for(int i = 0; i < NC; i++) {
      for(int j = 0; j < W; j++) {
        capa[V_W2(j)][V_NC(i)] = 1;
      }
    }
    for(int i = 0; i < C; i++) {
      capa[V_C(i)][V_C2(i)] = 1;
    }
    for(int i = 0; i < NC; i++) {
      capa[V_NC(i)][V_NC2(i)] = 1;
    }
    for(int i = 0; i < M; i++) {
      int n; scanf("%d", &n);
      for(int j = 0; j < n; j++) {
        int k; scanf("%d", &k); k--;
        capa[V_C2(k)][V_M(i)] = 1;
      }
      for(int j = 0; j < NC; j++) {
        capa[V_NC2(j)][V_M(i)] = 1;
      }
    }
    for(int i = 0; i < NM; i++) {
      for(int j = 0; j < C; j++) {
        capa[V_C2(j)][V_NM(i)] = 1;
      }
    }
    for(int i = 0; i < M; i++) {
      capa[V_M(i)][TERMINAL] = 1;
    }
    for(int i = 0; i < NM; i++) {
      capa[V_NM(i)][TERMINAL] = 1;
    }
    int flow = 0;
    while(true) {
      vector<int> par(SIZE, -1);
      vector<int> stk; stk.reserve(SIZE);
      stk.push_back(START);
      par[START] = -2;
      while(!stk.empty()) {
        int v = stk.back(); stk.pop_back();
        if(v == TERMINAL) {
          for(int w = v; w != START; w=par[w]) {
            capa[par[w]][w]--;
            capa[w][par[w]]++;
          }
          flow++;
          goto cont;
        }
        for(int w = 0; w < SIZE; w++) {
          if(capa[v][w] == 1 && par[w]==-1) {
            par[w]=v;
            stk.push_back(w);
          }
        }
      }
      break;
cont:continue;
    }
    printf("%d\n", flow);
  }
  return 0;
}

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

bool isEven(int n) {
    return n % 2 == 0;
}

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

    if (A == B and B == C and isEven(A)) {
        cout << -1 << endl;
        return 0;
    }

    int num = 0;
    bool can = true;

    while(can) {
        if (isEven(A) && isEven(B) && isEven(C)) {
            int tmpA = (B + C) / 2;
            int tmpB = (A + C) / 2;
            int tmpC = (A + B) / 2;
            A = tmpA;
            B = tmpB;
            C = tmpC;
            num++;
        } else {
            can = false;
        }
    }

    cout << num << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
 
	// ??°????????\???????????°????????????????????\???
	double num1, num2;
	scanf("%lf %lf", &num1, &num2);

	// ??\???????????????????????°????¨????????????????
	printf("%d %g %.6f\n", (int)(num1 / num2), fmod(num1, num2), num1 / num2);
 	return 0;
}

Measured memory_bytes: 1812
s = list(input())
l = ["A","T","G","C"]
maxcount = 0
count = 0
flag = False
for i in range(len(s)):
    if s[i] in l:
        flag = True
        if flag:
            count += 1
        if count > maxcount:
            maxcount = count
    else:
        count = 0
        flag = False
print(maxcount)

Measured memory_bytes: 3060
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    string str;
    cin>>str;
    if(str[2]==str[3] && str[4]==str[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 4992
N=gets.to_i
A=gets.split.map(&:to_i)
B=gets.split.map(&:to_i)
C=gets.split.map(&:to_i)
point=B.inject(:+)

pre=-10
N.times do |i|
  if pre + 1 == A[i]
    point += C[A[i] - 1 - 1]
  end
  pre = A[i]
end
p point

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  
  int t = 0;
  int c = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) == '-') {
      t = i;
      c++;
    }
  }
  if(t == a && c == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384