akhauriyash/Code-Regression huggingface dataset:
import sys

n = int(input())
As = list(map(int, input().split()))

Flag = True
ans = 1

if (0 in As):
  print(0)
  sys.exit()


for i in range(n):
  ans = ans * As[i]
  if (ans > 10**18):
    if (Flag):
      print(-1)
      Flag = False
      sys.exit()
  
if (Flag):
  print(ans)

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

int main()
{
	int a, b;

	cin >> a >> b;

	if (a >= 13)
		cout << b << endl;
	else if (a >= 6 && a <= 12)
		cout << b / 2 << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
X = int(input())

if X >= 400 and X <= 599:
    print("8")
elif X >= 600 and X <= 799:
    print("7")
elif X >= 800 and X <= 999:
    print("6")
elif X >= 1000 and X <= 1199:
    print("5")
elif X >= 1200 and X <= 1399:
    print("4")
elif X >= 1400 and X <= 1599:
    print("3")
elif X >= 1600 and X <= 1799:
    print("2")
else:
    print("1")

Measured memory_bytes: 9184
#include<cstdio>
int max(int x,int y) {return x>y?x:y;}
int abs(int x) {return x>0?x:-x;}
int main()
{
	int n,x,y,a,b;
	scanf("%d%d%d",&n,&x,&y);
	if(n==1)
	{
		scanf("%d",&a);
		return printf("%d\n",abs(a-y)),0;
	}
	for(int i=1;i<=n;i++) a=b,scanf("%d",&b);
	printf("%d\n",max(abs(b-y),abs(a-b)));
	return 0;
}

Measured memory_bytes: 128
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n, ans = -1;
int a[N * 2];
bool f[N * 2];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    f[0] = true;
    for (int i = 1; i <= n; i++) {
        if (f[a[i] - 1]) {
            f[a[i]] = true;
            ans = std::max(ans, a[i]);
        }
    }
    printf("%d\n", ans == -1 ? ans : n - ans);
    return 0;
}

Measured memory_bytes: 1280
a,b,c,d=map(int,list(input()))
n=3
ans=''
for i in range(n**2):
  op=[]
  for j in range(n):
    if (i>>j & 1):
      op.append(True)
    else:
      op.append(False)
  tmp=a
  tmp=tmp+b if op[0] else tmp-b
  tmp=tmp+c if op[1] else tmp-c
  tmp=tmp+d if op[2] else tmp-d
  if tmp==7:
    ans=str(a)
    ans+='+' if op[0] else '-'
    ans+=str(b)
    ans+='+' if op[1] else '-'
    ans+=str(c)
    ans+='+' if op[2] else '-'
    ans+=str(d)
    break
print(ans+'=7')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,k;
	cin>>n>>k;
	ll dp[k+1]={0};
	ll x,y,z;
	ll dp1[k+1];
	for(ll a=k;a>=1;a--)
	{
		x=1;
		z=k/a;
		if(z==1)
		dp[a]=1;
		else if(k/a==k/(a+1))
		dp[a]=dp[a+1];
		else
		{
			for(int b=1;b<=n;b++)
			{
				x=(x*z)%mod;
			}
			dp[a]=x;
		}
		dp1[a]=dp[a];
		for(ll c=2*a;c<=k;c+=a)
		{
			dp1[a]=(dp1[a]-dp1[c]+mod)%mod;
		}
	}
//	for(int a=1;a<=k;a++)
//	cout<<dp[a]<<" ";
	ll ans=0;
	for(int a=1;a<=k;a++)
	{
		y=dp1[a]*a;
		y%=mod;
		ans=(ans+y)%mod;
	}
	cout<<ans;
	return 0;
}


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

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

  int res=INT_MAX;
  for(int mask=0; mask<(1<<n); ++mask){
    vector<int> level(m);
    int cost=0;
    for(int i=0; i<n; ++i){
      if((mask>>i) & 1){
        cost += c[i];
        for(int j=0; j<m; ++j){
          level[j] += v[i][j];
        }
      }
    }
    bool flag=true;
    for(int i=0; i<m; ++i){
      if(level[i] < x) flag=false;
    }
    if(flag) res=min(res, cost);
  }
  if(res == INT_MAX) cout<<"-1"<<endl;
  else cout<<res<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, k; cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; i++)
    {
        ans += p[i];
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>

using namespace std;

int n,a[300003], sorted[300003], q, qu[300003][2], diff = 0;

int main(){
	//input
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sorted[i] = a[i];
	}
	cin >> q;
	for(int i=0; i<q; i++){
		cin >> qu[i][0] >> qu[i][1];
	}

	//do
	sort(sorted, sorted+n);
	for(int i=0; i<n; i++){
		if(sorted[i] != a[i]) diff++;
	}
	if(diff==0)cout << 0 << endl;
	else{
		for(int i=0; i<q; i++){
			int x = qu[i][0], y = qu[i][1];
			x--; y--;
			int t1 =(sorted[x] == a[x] ? 0 : 1) + (sorted[y] == a[y] ? 0 : 1);
			swap(a[x], a[y]);
			int t2 =(sorted[x] == a[x] ? 0 : 1) + (sorted[y] == a[y] ? 0 : 1);
			diff += t2 - t1;
			if(diff == 0){
				cout << i + 1 << endl;
				break;
			}
		}
		if(diff)cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 7856
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] l = new int[m];
		int[] r = new int[m];
		for (int i = 0; i < m; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		int left = 1;
		int right = n;
		for (int i = 0; i < m; i++) {
			left = Math.max(left, l[i]);
			right = Math.min(right, r[i]);
		}
		System.out.println(Math.max(0, right - left + 1));
	}
}

Measured memory_bytes: 82208
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  int a=0;
  r(i, n) {
    int b;
    cin >> b;
    if (b>=k) a++;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
d = {}
for _ in range(n):
  s = input()
  k = tuple(sorted(list(s)))
  if k in d:
    d[k] += 1
  else:
    d[k] = 1
ans = 0
for k in d:
  n = d[k]
  ans += n * (n - 1) // 2
print(ans)


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

int main(){
  string s,t;
  cin >>s >>t;
  bool can = false;
  rep(i,s.size()){
    char ss = s[0];
    rep(j,s.size()){
      if(j==s.size()-1) s[j] = ss;
      else s[j] = s[j+1];
    }
    if(s==t) {
      can = true;
      break;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int a,ans = n+x;
  for(int i = 0;i<n;++i){
    cin >> a;
    for(int j = 1;a*j+1 <= d;j++){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int D, N;

int main(void){
    
    scanf("%d %d", &D, &N);
    int num = pow(100, D), p = num;
    for(int i = 1; i < N; ++i) num += p;
    printf("%d\n", (N == 100) ? num + p : num);
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
using ll = long long;
int main(int argc, char const *argv[]) {
  ll a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    cout<<(a+b)/2<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int N; cin >> N;
    vector<double> p(N);
    for(int i=0; i<N; ++i) cin >> p[i];

    // dp[i+1][j] := i番目までのコインの中で表が出たのがj回であるような確率
    vector< vector<double> > dp(N+5, vector<double>(N+5, 0));

    dp[0][0] = 1.0;

    for(int i=0; i<N; ++i){
        for(int j=0; j<=i+1; ++j){
            // omote
            if(j) dp[i+1][j] += dp[i][j-1]*p[i];
            
            // ura
            dp[i+1][j] += dp[i][j]*(1.0-p[i]);
        }
    }

    // for(int i=1; i<=N; ++i){
    //     for(int j=0; j<=i; ++j){
    //         printf("%5.5lf", dp[i][j]);
    //         printf("  ");
    //     }
    //     cout << endl;
    // }

    double ans = 0;
    for(int i=N/2+1; i<=N; ++i) ans += dp[N][i];
    printf("%.10lf\n", ans);

	return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};


int main()
{
    int h, w; cin >> h >> w;
    vector<string> S;
    string s;
    rep(i, h)
    {
        cin >> s;
        S.push_back(s);
    }
  
    bool can = true;
  	int flag = 1;
    rep(i, h)
    {
        rep(j, w)
        {
            if (S[i][j] == '#')
            {
                bool can = false;
                rep(k, 4)
                {
                    int x = j + dx[k];
                    int y = i + dy[k];
                    if (x < 0 || x >= w) continue;
                    if (y < 0 || y >= h) continue;
                    if (S[y][x] == '#')
                    {
                        can = true;
                    }
                }
              	if (!can)
                {
                  cout << "No" << endl;
                  return 0;
                }
              	
            }
            else continue;
        }
    }

    // int flag = 1;
    // rep(i, h) if (!can[i]) flag = 0;
    cout << "Yes" << endl;
}

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

using namespace std;

struct S {
  int i, d, c;
  S(int i, int d, int c): i(i), d(d), c(c) {}
  bool operator<(const S&r) const {
    return d - r.d ? d > r.d : c > r.c;
  }
};

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

  int n, m, u, v, d, c, i, r, x[10001];
  vector<S> e[10001];
  priority_queue<S> q;

  while (cin >> n >> m && n) {
    for (int i = r = 0; i <= n; i++) {
      e[i].clear();
      x[i] = INT_MAX;
    }
    while (m--) {
      cin >> u >> v >> d >> c;
      e[u].push_back(S(v,d,c));
      e[v].push_back(S(u,d,c));
    }
    q.push(S(1,0,0));
    while (!q.empty()) {
      S s(q.top()); q.pop();
      if (x[s.i] <= s.d) continue;
      x[s.i] = s.d;
      r += s.c;
      for (int i = 0; i < e[s.i].size(); i++) {
        q.push(S(e[s.i][i].i, s.d+e[s.i][i].d, e[s.i][i].c));
      }
    }
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 5172
s = gets.strip
n = s.length
c = Array.new(n,0)
l,r,j,k = nil,nil,nil,-1
n.times do |i|
  if s[i,2] === "RL"
    j = i
    r = j - k
  elsif s[i,2] === "LR" || s[i,2] === "L"
    k = i
    l = k - j
    c[j] = ((r - 1)/2) + 1 + (l/2)
  	c[j + 1] = (r/2) + 1 + ((l - 1)/2)
  end
end
puts "#{c.join(" ")}"

Measured memory_bytes: 3324
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    struct Rest {
        public int num { get; set; }
        public string S { get; set; }
        public int P { get; set; }
    }
   
    public void Solve() {
        var N = sc.nextInt();
        var SP = new Rest[N];
        for (int i = 0; i < N; i++) {
            SP[i] = new Rest {
                num = i + 1,
                S = sc.next(),
                P = sc.nextInt()
            };
        }
        SP.OrderBy(sp => sp.S).ThenByDescending(sp => sp.P).ToList().ForEach(sp => WriteLine(sp.num));
    }
}


class Scanner {
    string[] s;
    int i;

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

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

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13660
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll H;
    int N;
    in2(H, N);

    ll total = 0;

    rep(_, N)
    {
        ll a;
        in(a);

        total += a;
    }

    if (total >= H)
        outl("Yes");
    else
        outl("No");


    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <queue>

using namespace std;

typedef long long LL;

const int N = 1e5+5;
const int P = 998244353;

const int INF = 0x3f3f3f3f;
const LL INFLL = 0x3f3f3f3f3f3f3f3f;

int n, m, top = -1;
int col[N];
LL ans;

struct edge {
    int v, len;
    edge *next;
}pool[3 * N], *h[N];

inline void addedge(int u, int v, int len) {
    edge *tmp = &pool[++top];
    tmp -> v = v; tmp -> len = len; tmp -> next = h[u]; h[u] = tmp;
}

bool dfs(int u, int c[], int &cnt_edge) {
    c[col[u]]++;
    bool flag = true;
    for(edge *tmp = h[u]; tmp != NULL; tmp = tmp -> next) {
        int v = tmp -> v, len = tmp -> len;
        cnt_edge++;
        if(col[v] == -1) {
            col[v] = (col[u] + len) % 3;
            if(dfs(v, c, cnt_edge) == false) flag = false;
        }
        else if(col[v] != (col[u] + len) % 3) flag = false;
    }
    return flag;
}

inline LL calc(LL x, LL y, LL z) { // 0, 1, 2
    return x * y + y * z + z * x;
}

inline void init() {
    int x, y;
    int cnt[3] = {0, 0, 0}, cnt_edge = 0;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++) {
        scanf("%d%d", &x, &y);
        addedge(x, y, 1);
        addedge(y, x, 2);
    }
    for(int i = 1; i <= n; i++) col[i] = -1;
    for(int i = 1; i <= n; i++) {
        if(col[i] == -1) {
            cnt[0] = 0;
            cnt[1] = 0;
            cnt[2] = 0;
            cnt_edge = 0;
            col[i] = 0;
            if(dfs(i, cnt, cnt_edge) == true) {
                LL res = calc(cnt[0], cnt[1], cnt[2]);
                if(cnt[0] == 0 || cnt[1] == 0 || cnt[2] == 0) ans += cnt_edge / 2;
                else ans += res;
            }
            else ans += 1ll * (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]);
        }
    }
    printf("%lld\n", ans);
}

int main() {
    init();
    return 0; 
}

Measured memory_bytes: 11008
n=int(input())
box={}
for i in range(n):
  vote=input()
  if not(vote in box):
    box[vote]=1
  else:
    box[vote]+=1
m=0
win=[]
for num in box.values():
  if num > m:
    m=num
for name,num in box.items():
  if num==m:
    win.append(name)
win=sorted(win)
for i in win:
  print(i)

Measured memory_bytes: 32988
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int Ans=0;
  for(int i=1;i<=N;i++)
  {
    int X;
    cin>>X;
    if(i%2&&X%2)
      Ans++;
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 3588
#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 ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n';
int main()
{
    fastIO;
    ll n;
    cin>>n;
    string str[n];
    map<string,ll>m;
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
        m[str[i]]++;
    }
    set<string>s;
    ll x,y,val,val1;
    x=INT_MIN;
    for(auto itr=m.begin();itr!=m.end();itr++)
    {
        if(itr->se>x)
        {
            x=itr->se;    
        }
    }
    for(auto itr=m.begin();itr!=m.end();itr++)
    {
        if(itr->se==x)
        {
            s.insert(itr->fi);
        }
    }
    for(auto itr=s.begin();itr!=s.end();itr++)
    {
        cout<<*itr<<endl;
    }
    return 0;
}

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

typedef pair<int, int> pii;

vector<pii> g[100005];
int ans[100005];
int mx=0;

void solve(int v, int p, int pc){
  int color = 1;
  for(int i=0;i<g[v].size();i++){
    int u = g[v][i].first;
    int id = g[v][i].second;
    if(u==p)continue;
    if(color == pc)color++;
    ans[id] = color;
    mx = max(color, mx);
    // cout<<id<<':'<<':'<<mx<<endl;
    solve(u, v, color);
    color++;
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b;cin>>a>>b;a--,b--;
    g[a].push_back({b,i});
    g[b].push_back({a,i});
  }

  solve(0, -1, 0);

    cout<<mx<<endl;
  for(int i=0;i<n-1;i++){
    cout<<ans[i]<<endl;
  }

  return 0;
}


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

int main(void)
{
  char a[100010];
  int count=0;
  scanf("%s",a);
  int len=strlen(a);
  int j=0;

  int start=0,end=len-1;

  while(start<end){
    // printf("%d %d\n",start,end);
    if(a[start]==a[end]){
      start++;
      end--;
      //  puts("a");
    }else if(a[start]=='x'){
      count++;
      start++;
      //  puts("b");
    }else if(a[end]=='x'){
      count++;
      end--;
      // puts("c");
    }else{
      puts("-1");
      return 0;
    }
  }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		for(int i = N - 1 ;; i--) {
			if(check(S.substring(0, i))) {
				System.out.println(i);
				break;
			}
		}
	}

	public static boolean check(String S) {
		int N = S.length();
		if(N % 2 == 1) {
			return false;
		} else {
			return S.substring(0, N / 2).equals(S.substring(N / 2));
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

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

	if (a == b && a != c || a == c && a != b || b == c && a != b) 
	{
		cout << "Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    K, T = LI()
    a = LI()

    # aを2グループに分けて交互に食べれば良い
    # 最も差の少ない2グループの分け方を知りたい

    a.sort(reverse=True)
    a_cum = [0] * (T + 1)
    for i in range(T):
        a_cum[i+1] = a_cum[i] + a[i]

    ans = INF
    for i in a_cum:
        ans = min(max(abs(2 * i - K) - 1, 0), ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10128
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+:---test
4
---+/
/+:---test
5
---+/
/+---test
1
---+/

void main(string[] args) {
  const N = readln.chomp.to!int;

  double ans;
  if (N%2 == 0) {
    ans = 0.5;
  } else if (N == 1) {
    ans = 1;
  } else {
    ans = (N/2 + 1)*1.0 / N;
  }
  "%.8f".writefln(ans);
}


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


int main() {
  string s; cin >> s;
  int flag = 0; long long x = -1;
  
  for(long long i=0; i < s.size() - 2; i++){
    if(s.at(i) == s.at(i+1)||s.at(i+1) == s.at(i+2)||s.at(i) == s.at(i+2)){
      flag = 1;
      x=i; 
      break;
    }
  }
  
  if(flag == 1) cout << x+1 << ' ' << x+3 << endl;
  else if(s.at(0) == s.at(1)) cout << 1 << ' ' << 2 << endl;
  else cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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


int main(){
    ll N;
    cin >> N;
    ll a[101000];

    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    sort(a, a+N);
    vector<P> res;
    for(int i = 1; i < N-1; i++){
        if(a[i] > 0){
            res.emplace_back(a[0], a[i]);
            a[0] -= a[i];
        }
        else{
            res.emplace_back(a[N-1], a[i]);
            a[N-1] -= a[i];
        }
    }
    res.emplace_back(a[N-1], a[0]);
    a[N-1] -= a[0];
    cout << a[N-1] << endl;
    for(P p: res){
        cout << p.fs << " " << p.sc << endl;
    }



    return 0;
}


Measured memory_bytes: 4336
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
int main() {
	long long int N = 0,counter=0,a=0,b=0,c=0;
	cin >> a;
	for (int i = 1; i <= a; i++) {
		if (1 <= i && i <= 9)counter++;
		if (100 <= i && i <= 999)counter++;
		if (10000 <= i && i <= 99999)counter++;

	}
	cout << counter << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxn = 345, mod = 998244353;
int n;

int a[maxn];
int dp[2][maxn * maxn * 2];
int dp2[2][maxn * maxn * 2];

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	F1 (i, n) cin >> a[i];
}

int power(int x)
{
	if (x == 1) return 3;
	int ret = power(x / 2);
	ret = ret * ret % mod;
	if (x & 1) ret = (ret * 3) % mod;
	return ret;
}

void solve()
{
	dp[0][maxn * maxn] = 1;
	F1 (i, n)
	{
		int cur = i & 1;
		int last = cur ^ 1;
		F (j, maxn * maxn * 2) dp[cur][j] = 0;
		F (j, maxn * maxn * 2)
		{
			if (j + a[i] < maxn * maxn * 2)
				dp[cur][j + a[i]] = (dp[cur][j + a[i]] + dp[last][j]) % mod; 
			if (j - a[i] >= 0)
				dp[cur][j - a[i]] = (dp[cur][j - a[i]] + 2 * dp[last][j]) % mod; 
		}
	}
	int ans = 0;
	for (int i = maxn * maxn; i < maxn * maxn * 2; ++i) ans = (ans + dp[n & 1][i]) % mod;
	
	int sum = 0;
	F1 (i, n) sum += a[i];
	dp2[0][0] = 1;
	F1 (i, n) 
	{
		int cur = i & 1;
		int last = cur ^ 1;
		F (j, maxn * maxn * 2) dp2[cur][j] = 0;
		F (j, maxn * maxn)
		{
			dp2[cur][j] = dp2[last][j];
			if (j >= a[i]) dp2[cur][j] = (dp2[cur][j] + dp2[last][j - a[i]]) % mod;
		}
	}
	if (sum % 2 == 0) ans -= dp2[n & 1][sum / 2];
	cout << ((power(n) - 3 * ans) % mod + mod) % mod << '\n';
}

main()
{
	input();
	solve();
}


Measured memory_bytes: 7680
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,y; cin >> n >> y; y/=1000;
    REP(i,n+1) REP(j,n-i+1){
        if(y-(10*i+5*j)==n-i-j){
            cout << i << ' ' << j << ' ' << n-i-j << endl;
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#abc167d
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=1
l=[1]
f=[1]*n
f[0]=0
for i in range(k):
 x=a[x-1]
 if f[x-1]:
  l.append(x)
  f[x-1]=0
 else:
  break
y=l.index(x)
res=(k-y)%(len(l)-y)+y
print(l[res])


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

int main(){
    string w;
    cin >> w;
    map<char,int> ans;
    for (int i = 0;i < w.size();i++){
        ans[w[i]]++;
    }
    bool a = true;
    for (int i = 0;i < w.size();i++){
        if (ans[w[i]] % 2 != 0){
            a = false;
            break;
        }
    }
    if(a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int h, w, n;
map<pair<int, int> , int> mp;
map<pair<int, int> , int>::iterator it;
long long ans[22];

int main() {
	scanf("%d%d%d", &h, &w, &n);
	mp.clear();
	for(int i=0;i<n;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		for(int j=x;j<x+3;j++)
			for(int k=y;k<y+3;k++)
				if(j<=h && k<=w && j>=3 && k>=3)
					mp[make_pair(j, k)] ++;
	}
	memset(ans, 0, sizeof ans);
	ans[0] = 1LL*(w-2)*(h-2);
	for (it = mp.begin(); it!= mp.end(); it++) {
		int cnt = (*it).second;
		ans[cnt] ++;
		ans[0]--;
	}
	for(int i=0;i<10;i++) cout<<ans[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 42496
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
const int INF=1<<30;
using namespace std;

int main() {
	// your code goes here
	int n,m,price[10],minium=INF;
	string ans;
	cin >> n >> m;
	REP(i,10){
	cin >> price[i];
	minium=min(minium,price[i]);
	}
	REP(i,10)
	price[i]-=minium;
	m-=minium*n;
	REP(i,10)
		while(price[i]<=m && ans.size()<n){
			m-=price[i];
			ans+=i+'0';
		}
	if(ans.size()>=n)
	cout << ans;
	else
	cout <<"NA";
	cout << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int main() {
	int n,k;
	cin >> n >> k;
	int h[n];
	int dif[n-1];
	int now = 0;
	int ans = 1e9+10;
	for (int i = 0;i < n;i++) {
		cin >> h[i];
		if (i != 0) {
			dif[i-1] = h[i] - h[i-1];
		}
		if (i < k) {
			now += h[i];
		}
	}
	sort(h,h+n);
	for (int i = 0;i < n - k + 1;i++) {
		now = h[i+k-1] - h[i];
		ans = min(now,ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 105
#define int long long int
using namespace std;


int32_t main()
{
    int n,m;
    cin >> n >> m;
    char v[n][m];
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> v[i][j];
    int dp[n][m];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    
    for(int i = 1 ; i < m ; i++)
    {
        if(v[0][i] == '.')
            dp[0][i] += dp[0][i-1];
        else break;
    }
    for(int i = 1 ; i < n ; i++)
    {
        if(v[i][0] == '.')
            dp[i][0] += dp[i-1][0];
        else break;
    }
    int mod = 1000000007;
    for(int i = 1 ; i < n ; i++)
    {
        for(int j = 1 ; j < m ; j++)
        {
            if(v[i][j] == '.')
                dp[i][j] = ((dp[i-1][j]%mod)+(dp[i][j-1]%mod))%mod;
        }
    }
    
    cout << dp[n-1][m-1]%mod;
    
    
    return 0;
}


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



int main() {
 //入力を受け取る
  //直属の部下数を表す配列bを作る
  //a(i)はi番目の社員の上司
  //bのa(i)番目に部下数＋１する
  //b配列を0から出力する
  int N;
  cin>>N;
  vector<int>a(N-1);
  for(int i=0;i<N-1;i++){
    cin>>a.at(i);}
  vector<int>b(N);
  for(int i=0;i<N-1;i++){
    b.at(a.at(i)-1)++;}
  for(int i=0;i<N;i++){
    cout<<b.at(i)<<endl;}
  
  return 0;}
  

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

const int MAX_N = 110000;

int memo[MAX_N];
int rec(int n) {
    if (n == 0) return 0;
    if (memo[n] != -1) return memo[n];

    int res = n;
    for (int pow6 = 1; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1);

    for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1);

    return memo[n] = res;
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < MAX_N; ++i) memo[i] = -1;
    cout << rec(N) << endl;
}

Measured memory_bytes: 3840
n=int(input())
a_list=list(map(int,input().split()))
A=[0]*(10**5+2)
for i in a_list:
    A[i]+=1
    A[i+1]+=1
    A[i+2]+=1
ans=0
for i in A:
    ans=max(ans,i)
print(ans)


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	sort(p.begin(), p.end(), greater<int>());
	p[0] /= 2;
	int ans = 0;
	for (int tmp : p)
		ans += tmp;
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(){
	
	int jumlah;
	char kata[jumlah+5];
	int max = 0;
	scanf ("%d",&jumlah);
	getchar();
	scanf ("%s",kata);
	getchar();
	int x=0;
	for (int a=0;a<jumlah;a++){
		if (kata[a] == 'D'){
			x-=1;
			if (max <x){
				max=x;
			}
		}
		else if (kata[a]=='I'){
			x+=1;
			if (max<=x){
				max=x;
			}
		}
	}
	printf ("%d\n",max);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <map>
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
#define ll long long
constexpr ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) {return b % a ? gcd(b % a, a) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
using namespace std;
using P = pair<ll, ll>;
using VI = vector<ll>;

int main() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
        return 0;
    }
    if (abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void sieve(int length){
    int i, primes[1000000], j, count=0;
    
    for(i=2; i<999999; i++){
        primes[i]=1;
    }
    primes[1]=0;

    for(i=2; i<=length/2; i++){
        for(j=2; i*j<=length; j++){
            primes[j*i]=0;
        }
        
    }
    
    for(i=1; i<=length; i++){
        if(primes[i]==1) count++;
        
    }
    printf("%d\n", count);
}



int main(void){
    int length, count, i, j, primes[1000000];
   
    while(scanf("%d", &length) != EOF){
        sieve(length); 
    }
    return 0;
    
}



Measured memory_bytes: 5692
#include <stdio.h>

int main(void){
    int num, i;
    int flag = 0;
    scanf("%d", &num);
    char moji[4];

    snprintf(moji, 4, "%d", num);


    for(i = 0; i < 3; i++){
        if(moji[i] == '7'){
            flag = 1;
        }
    }

    if(flag == 1){
        printf("Yes\n");
    }

    else printf("No\n");

    return 0;
    
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int a = 0;
    int b = 0;
    int ab  = 0;
    int abab = 0;
    cin >> n;
    rep(i, n){
        string s;
        cin >> s;
        if(s[0] == 'B') b ++;
        rep(j, s.size() - 1){
            if(s[j] == 'A' && s[j + 1] == 'B') ab ++;
        }
        if(s[s.size() - 1] == 'A') a ++;
        if(s[0] == 'B' && s[s.size() - 1] == 'A') abab++;


    }
    if(abab != 0) {
        if(abab == n) cout << ab + min(a, b) - 1 << endl;
        else if(b - abab != 0 || a - abab != 0)cout << abab - 1 + ab + min(a - abab+ 1, b - abab+ 1) << endl;
        else cout << abab - 1 + ab << endl;
    }
    else cout << ab + min(a, b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define st first
#define nd second
#define INF 1000000007LL
using namespace std;

int main(){
#ifndef LOCAL
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++)  cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  for(int i = 0; i < n && i < k; i++) sum += a[i];
  cout << sum << '\n';
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b >= c) puts("delicious");
    else if(a >= c-b) puts("safe");
    else puts("dangerous");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	char arr [20];
	scanf ("%[^\n]", arr);
	for (int i = 0; i < 19; i++){
		if (i == 5 || i == 13) {
			printf (" ");
			continue;
		}
	printf("%c", arr[i]);
	}
	return 0;
}

Measured memory_bytes: 1600
X,Y = list(map(int, input().split()))

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
      
if (X+Y) % 3 > 0:
  print(0)
  exit(0)
  
K = (X+Y)//3

if X < K or Y < K:
  print(0)
  exit(0)

comb = Combination(int(1e6+10))
print(comb(K, X-K))

Measured memory_bytes: 125148
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	string st;
	cin>>st;
	cout<<st[0]<<st[1]<<st[2];
	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n; vector< ll> A(n,0),B(n,0),C(n-1,0);
    for (int i=0;i<n;i++)
    {
        cin >> A[i];
    }
    for (int i=0;i<n;i++)
    {
        cin >> B[i];
    }
    for (int i=0;i<n-1;i++)
    {
        cin >> C[i];
    }
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ans+=B[A[i]-1];
        if (i>0 && A[i]==A[i-1]+1)
        {
            ans+=C[A[i-1]-1];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
n = input()
co = 0
max = 0
for i in range(len(n)) :
    if n[i] == "A" or n[i] == "T" or n[i] == "G" or n[i] == "C" :
        co += 1
    else :
        if co >= max :
            max = co
        co = 0
if co >= max :
    max = co
print(max)


Measured memory_bytes: 2940