akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
using namespace std;

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

int main(void) {
    const int INF = 1 << 30;
    int a, max_a = INF * (-1), min_a = INF;

    REP(i, 3) {
        cin >> a;
        max_a = max(max_a, a);
        min_a = min(min_a, a);
    }

    cout << max_a - min_a << "\n";
    return 0;
}

Measured memory_bytes: 256
/*
ID: kiwio
LANG: C++14
TASK: 
*/

#include <bits/stdc++.h>
using namespace std;

int n, x[200005], lo, hi, fake[200005];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(NULL);/*
#ifndef turtle
	ofstream cout (".out");
	ifstream cin (".in");
#endif*/
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> x[i];
		fake[i]=x[i];
	}
	sort(fake+1, fake+n+1);
	lo=fake[n/2];
	hi=fake[n/2+1];
	for (int i=1; i<=n; i++) {
		if (x[i]>lo) {
			cout << lo << endl;
		}
		else {
			cout << hi << endl;
		}
	}
 }

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define upper(su) transform(su.begin(), su.end(), su.begin(), ::toupper);
#define lower(su) transform(su.begin(), su.end(), su.begin(), ::tolower);

#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << ' ' ;err(++it, args...);}





int main(){
   
    ll l,r,a,b;
    ll rem=-1;
    cin>>l>>r;


    if(l/2019LL<r/2019LL)cout<<0<<endl;
    else{
        l%=2019LL;
        r%=2019LL;
        ll i=l,j=r;
        for( i=l;i<r;i++){
            for( j=i+1;j<=r;j++){
                if(rem==-1)rem=(i*j)%2019;
                rem=min(rem,(i*j)%2019);
               // bug(rem)
            }
        }
        cout<<rem<<endl;

    }


}


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

int main() {
    int n,k,d,a,ans=0;
    cin>>n>>k;
    int sun[n]={0};
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>a;
            sun[a-1]++;
        }
    }
    rep(i,n){
        if(sun[i]==0)ans++;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3636
N, Q = [int(x) for x in input().split(" ")]

s = input()
AinAC = [0]
CinAC = [0]
c = 0
for i in range(len(s) - 1):
  if s[i] == "A" and s[i + 1] == "C":
    CinAC.append(c)
    c += 1
    AinAC.append(c)
  else:
    AinAC.append(c)
    CinAC.append(c)
else:
  AinAC.append(c)
  CinAC.append(c)

ans = []
for i in range(Q):
  l, r = [int(x) for x in input().split(" ")]
  right = min([AinAC[r], CinAC[r]])
  left = max([AinAC[l - 1], CinAC[l - 1]])
  ans.append(str(right - left))

print("\n".join(ans))
  

Measured memory_bytes: 20540
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var H = new HashSet<long>();
        var s = cin.nextlong;
        H.Add(s);
        for (int i = 2; i < 2000000; i++)
        {
            if (s % 2 == 0)
            {
                s /= 2;
            }
            else
            {
                s = 3 * s + 1;
            }
            if (H.Contains(s))
            {
                WriteLine(i);
                return;
            }
            H.Add(s);
        }
     }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

void solve(){
     int n,m;
     cin >> n >> m;
     priority_queue<int>pq;
     vector< vector<int> >a(m+1);
     for(int i = 0;i<n;i++){
        int v,u;cin >> v >> u;
        if(v>m) continue;
        a[v].push_back(u);
     }
     int ans = 0;
     for(int i = 1;i<=m;i++){
        for(int j = 0;j<a[i].size();j++)
            pq.push(a[i][j]);
        if(pq.size()>0){
            ans += pq.top();
            pq.pop();
        }
     }
     cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 8272
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
# include<cmath>
using namespace std;
const int MAX=1e3+4;
int n;
double a[MAX];
int main()
{
	double s;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	  scanf("%lf",&a[i]),s+=a[i];
	s=s/n;
	double minn=1e18,k=0;
	for(int i=1;i<=n;++i)
	  if(abs(a[i]-s)<minn) k=i-1,minn=abs(a[i]-s);
	printf("%d",int(k));
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

struct grid
{
	ll to, cost;
};

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	vector<vector<grid>> G(N);
	REP(i, M)
	{
		ll l, r, d; cin >> l >> r >> d;
		--l, --r;
		G[l].push_back(grid{r, d});
		G[r].push_back(grid{l, -d});
	}

	vector<ll> dist(N, INF);
	queue<ll> que;
	REP(i, N)
	{
		if (dist[i] != INF) continue;
		que.push(i);
		dist[i] = 0;
		while (!que.empty())
		{
			ll n = que.front();
			que.pop();
			for (auto &p : G[n])
			{
				ll to = p.to;
				ll c = p.cost;

				if (dist[to] == INF)
				{
					dist[to] = dist[n] + c;
					que.push(to);
				}
				else if (dist[to] != dist[n] + c)
				{
					std::cout << "No" << std::endl;
					return 0;
				}
			}
		}
	}

	std::cout << "Yes" << std::endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int d, e; cin >> d >> e;
    if (d == 0) return;
    f80 ans = 1e9;
    rep(i, d) {
      int x = i;
      int y = d - i;
      amin(ans, abs(e - sqrt((f80) pow(x, 2) + (f80) pow(y, 2))));
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3276
#ABC076C
S=input()
T=input()
for s in range(len(S)-len(T)+1)[::-1]:
	for t in range(len(T)):
		if S[s+t]!='?':
			if S[s+t]!=T[t]:
				break
	else:
		ans=''
		for ss in S[:s]:
			if ss=='?':
				ans+='a'
			else:
				ans+=ss
		ans+=T
		for ss in S[s+len(T):]:
			if ss=='?':
				ans+='a'
			else:
				ans+=ss
		print(ans)
		exit()
print('UNRESTORABLE')
				


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

int main() {
  int a, b, c, d, l, r;
  string ans;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if (l > r) ans = "Left";
  else if (l < r) ans = "Right";
  else ans = "Balanced";
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    ll ans;
    if(k&1) {
        ll nn = n/k;
        ans = nn*nn*nn;
    } else {
        ll nn = n/k;
        ans = nn*nn*nn;
        nn = n/(k/2) - nn;
        ans += nn*nn*nn;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mid(l,r) ((l+r)/2)    
using namespace std;

const int N=1e5+5;

int32_t main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		cout<<"bust";
	else
		cout<<"win";
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
count = [0 for i in range(n+1)]
ans = 0
for i in range(n):
    count[a[i]] += 1
for i in range(n+1):
    ans += count[i]*(count[i]-1)//2
for i in range(n):
    num = count[a[i]]
    p = ans-(num*(num-1)//2)+((num-1)*(num-2)//2)
    print(p)


Measured memory_bytes: 24996
//#Circumscribed Circle of a Triangle

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
	double x1, y1, x2, y2, x3, y3;
	double px, py, r;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		px = ((x2*x2+y2*y2-x1*x1-y1*y1)*(y1-y3) - (x3*x3+y3*y3-x1*x1-y1*y1)*(y1-y2)) / (-2*((x1-x2)*(y1-y3) - (x1-x3)*(y1-y2)));
		py = ((x2*x2+y2*y2-x1*x1-y1*y1)*(x1-x3) - (x3*x3+y3*y3-x1*x1-y1*y1)*(x1-x2)) / (-2*((y1-y2)*(x1-x3) - (y1-y3)*(x1-x2)));
		r = sqrt((x1-px)*(x1-px) + (y1-py)*(y1-py));
		
		printf("%.3f %.3f %.3f\n", px, py, r);
	}
	return 0;
}

Measured memory_bytes: 1244
import java.io.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private boolean[][] b;

    private void solve(Scanner sc, PrintWriter out) {
        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        int[] a = new int[N];
        for (int i = 0; i < N; ++i) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }

        b = new boolean[H][W];

        for (int i = 0; i < N; ++i) {
            switch (a[i]) {
            case 1:
                blackout(0, x[i] - 1, 0, H - 1);
                break;
            case 2:
                blackout(x[i], W - 1, 0, H - 1);
                break;
            case 3:
                blackout(0, W - 1, 0, y[i] - 1);
                break;
            case 4:
                blackout(0, W - 1, y[i], H - 1);
                break;
            }
        }

        int count = 0;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (!b[i][j]) {
                    ++count;
                }
            }
        }
        if (debug) {
            for (int i = b.length - 1; i >= 0; --i) {
                for (int j = 0; j < b[i].length; ++j) {
                    System.err.print(b[i][j] ? '#' : ' ');
                }
                System.err.println();
            }
        }

        out.println(count);
    }
    private void blackout(int x0, int x1, int y0, int y1) {
        for (int i = y0; i <= y1; ++i) {
            for (int j = x0; j <= x1; ++j) {
                b[i][j] = true;
            }
        }
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            System.err.println((G - S) + "ms");
        }
    }
}

Measured memory_bytes: 10452
import queue

N, M = map(int, input().split())
adjacent = [[False] * N for i in range(N)]
bridges = []
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    bridges.append((a, b))
    adjacent[a][b] = adjacent[b][a] = True

ans = 0
for a, b in bridges:
    adjacent[a][b] = adjacent[b][a] = False
    visited = [0] * N

    visited[0] = 1
    q = queue.Queue()
    q.put(0)
    while not q.empty():
        u = q.get()
        for v in range(N):
            if not adjacent[u][v]:
                continue
            if visited[v] == 1:
                continue
            visited[v] = 1
            q.put(v)

    if sum(visited) < N:
        ans += 1
    adjacent[a][b] = adjacent[b][a] = True
print(ans)


Measured memory_bytes: 3952
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int pay = min(N*A, B);
  cout << pay << endl;
  return 0;
}


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

if 4 * X - Y < 0:
        print("No")
        exit()

if (4 * X - Y)  % 2 == 0:
        tsuru = (4 * X - Y) // 2
        if X - tsuru < 0:
                print("No")
                exit()
        kame = X - tsuru
        if kame * 4 + tsuru * 2 == Y:
                print("Yes")
                exit()
        else:
                print("No")
                exit()
else:
        print("No")
        exit()


Measured memory_bytes: 9188
#include <iostream>
using namespace std;
int main() {
    string S; cin >> S;
    int N = S.length();
    if (N % 2 != 0) {
        printf("%s\n", "No");
        return 0;
    }
    for (int i = 0; i < N - 1; i += 2)
    {
        if (S[i] == 'h' && S[i + 1] == 'i') {
            printf("%s\n", "Yes");
            return 0;
        }
    }
    printf("%s\n", "No");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a%3 ==0 || b%3 == 0|| (a+b)%3==0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MN 510000
#define ll long long
using namespace std;

const int MOD=1e9+7;
int n,k,b[MN],a[MN],o[MN],v[MN],w=0,ans=1e9;
inline int min(int x,int y){return x>y?y:x;}
bool cmp(int x,int y){return a[x]>a[y];}
inline void add(int x){while(x<=2*n) v[x]++,x+=x&(-x);}
inline int ask(int x){int ans=0;while(x) ans+=v[x],x-=x&(-x);return ans;}
inline ll work(int x){
	b[0]=0;
	ll ans=0;
	for (int i=1;i<=n;i++) b[i]=b[i-1]+(a[i]<=a[x]?1:-1);
	for (int i=0;i<=2*n;i++) v[i]=0;
	add(n);
	for (int i=1;i<=n;i++) ans+=ask(b[i]+n-1),add(b[i]+n);
	return ans;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),o[i]=i;
	sort(o+1,o+n+1,cmp);
	int l=1,r=n,mid;
	ll m=(1LL*n*(n+1)/2)/2+1;
	while(l<r){
		mid=l+r+1>>1;
		if (work(o[mid])>=m) l=mid;else r=mid-1;
	}
	printf("%d\n",a[o[l]]); 
}

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<double> p(N);
    for(int i=0;i<N;i++) {
        cin >> p.at(i);
    }

    vector<double> E(N);
    for(int i=0;i<N;i++) {
        E.at(i) = (p.at(i)+1)/2;
    }

    vector<double> S(N+1);
    for(int i=0;i<N+1;i++) {
        if(i==0) S.at(i) = 0;
        else S.at(i) = S.at(i-1) + E.at(i-1);
    }

    double ans=0, tmp;
    for(int i=0;i<N-K+1;i++) {
        tmp = S.at(i+K) - S.at(i);
        ans = max(ans, tmp);
    }

    cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;
int main()
{
    int i,j,sum=0,m,n,t=0,r;
    cin>>n;
    int a;
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum=sum+a;
        m=(a*(a-1))/2;
        t=t+m;

    }
    r=(sum*(sum-1))/2;
    cout<<r-t<<endl;


    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string str;
int main() {
  while (cin >> str) {
	int a = 0;
	for (a = 0; a < str.size(); ++a) if (str[a] == 'A') break;
	int b = str.size()-1;
	for (b = str.size()-1; b >= 0; --b) if (str[b] == 'Z') break;
	cout << b - a + 1 << endl;
  }
}










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


using namespace std;
using ll = long long;

#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define trav(a, x) for(auto& a: x)

bool cc(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
  
int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    char c; cin>> c;
    if (c == toupper(c)) {
        cout << "A" << '\n';
    }else cout << "a" << '\n';
    
    
    
  
    return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

int main(){

  int A,B,C,N; 
  int i;
  int rate;
  int nrate;
  int k=0;

  int price;
  int kcal;

  cin >> N;
  cin >> A >> B; 
  cin >> C;
  
  price=A;
  kcal=C;
  rate=kcal/price;
  
  int T[N];

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

  sort(T,T+N);

  for(i=N-1;i>=0;i--){
    k++;
    kcal+=T[i];
    price+=B;
    nrate=kcal/price;
   
  if(nrate>=rate){
    rate=nrate;
  }
      
    else{
      break;
    }
  }
  
  cout << rate << endl;

  return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 50;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, m; cin >> n >> m;
    vi a(m), b(m), c(m);
    rep(i, m) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--;
    vll dp(n, -inf);
    dp[0] = 0;
    int last = 0;
    rep(i, 4000){
        rep(j, m){
            if(dp[a[j]] != -inf and chmax(dp[b[j]], dp[a[j]] + c[j]) and b[j] == n - 1){
                last = i;
            }
            chmin(dp[b[j]], inf);
        }
    }

    if(last > 2100){
        cout << "inf" << endl;
    }
    else {
        cout << dp[n - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
vector<pair<long long, long long> > prime_factorize(long long q) {
  ll N = q;
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
int main() {
  int N;
  cin >> N;
  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll gc = A[0];
  for (int i = 1; i < N; i++) {
    gc = __gcd(gc,A[i]);
  }
  for (int i = 0; i < N; i++) {
    A[i] /= gc;
  }
  ll sum[1000010];
  ll mx[1000010];
  for (int i = 0; i < 1000010; i++) {
    sum[i] = 0;
    mx[i] = 0; 
  }
  for (int i = 0; i < N; i++) {
    ll a = A[i];
    vector<pair<ll,ll>> S = prime_factorize(a);
    for (int j = 0; j < (int)S.size(); j++) {
      sum[S[j].first] += S[j].second;
      if (mx[S[j].first] < S[j].second) {
        mx[S[j].first] = S[j].second;
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll res = 1;
    for (int j = 0; j < N; j++) {
      if (j != i) {
        res *= A[j];
        res %= Mod;
      }
    }
    ans += res;
    ans %= Mod;
  }
  for (ll i = 1; i < 1000010; i++) {
    if (mx[i] != 0) {
      ll a = 1;
      for (int j = 0; j < sum[i]-mx[i]; j++) {
        a *= i;
        a %= Mod;
      }
      ans *= modinv(a,Mod);
      ans %= Mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19252
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  string A; cin >> A;
  ll n = A.size();

  map<char,int> C;
  rep(i,n) C[A[i]]++;

  ll ans = n*(n-1)/2 + 1;
  for(auto c : C) {
    ll num = c.second;
    ans -= num*(num-1)/2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
//AとBの最小公倍数を出力する問題
#include <bits/stdc++.h>
using namespace std;

int main(){
  long long A , B , C;
  cin >> A >> B ;
  for(int i=1;i<=B;i++){
    if(A*i%B==0) {
      cout << A*i << endl;
      break;
    }
  }
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish{
    ll time;
    ll taste;
};
int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    ll K;
    cin >> K;

    cout << (A + B + C + max({A, B, C}) * (pow_fast(2, K) - 1)) << endl;
}

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

long long func(long long n, long long x) {
  if (n == -1) return 0;
  else return n / x + 1;
}

int main() {
  long long a, b, x; cin >> a >> b >> x;
  cout << func(b, x) - func(a-1, x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace boost::multiprecision;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
void solve() {
	int64 N; cin >> N;
	vector<long long int> A(N);
	cpp_int ans = 1;
	for (int64 i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] == 0) {
			cout << 0 << endl;
			return;
		}
	}
	sort(all(A));
	for (int64 i = 0; i < N; ++i) {
		ans *= A[i];
		if (ans > 1000000000000000000) {
			cout << -1 << endl;
			return;
		}
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4104
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/






int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  string s; cin >> s;
  int ret = 0;
  for (char c : s) {
    ret = (ret + c - '0') % 9;
  }
  if (ret == 0) cout << "Yes\n";
  else cout << "No\n";





/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 3372
import java.util.Scanner;
import java.math.*; 
    
class Main{
    public static void main(String [] args){
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        System.out.println(x*y + " " + 2*(x+y));
    }
}

Measured memory_bytes: 17160
#include<stdio.h>

int main(){
  int n1,n2,b,cnt=0;
  int i=0,j=0;
  int a[10010];
  scanf("%d",&n1);
  while(i!=n1){
    scanf("%d",&a[i]);
    i++;
  }
  scanf("%d",&n2);
  while(j!=n2){
    scanf("%d",&b);int k=0;
    while(k!=n1){
      if(a[k]==b){
        cnt++;break;
      }
      k++;
    }
    j++;
  }
  printf("%d\n",cnt);

}



Measured memory_bytes: 2076
s = input()
t = input()

result = 0
for i in range(len(s) - len(t) + 1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            cnt += 1
    result = max(result, cnt)
        
print(len(t) - result)


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

int main() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int whole_time = (h2 - h1)*60 + (m2 - m1);
    cout << max(0, whole_time - k) << endl;
    return 0;

}

Measured memory_bytes: 3604
N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1
    
    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        
        used[i] = True
        ans += dfs(i, used)
        used[i] = False
    
    return ans

used = [False] * N
used[0] = True

print(dfs(0, used))

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    cin >> n >> k;
    set<int> s;
    rep(i,k){
        int x;
        cin >> x;
        s.insert(x);
    }
    for(int i = n; i < 100000; i++){
        int num = i;
        bool ok = true;
        while(num){
            int x = num % 10;
            if (s.find(x) != s.end()){
                ok = false;
                break;
            }
            num /= 10;
        }
        if (ok){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3588
def slv(n):
    if n==3:return [2,5,63]
    ary=[]
    sumb=0
    for i in range(2,30001,2):
        ary.append(i)
        sumb+=i
        if len(ary)==n-2:break
    if sumb%3==0:
        pass
    elif sumb%3==1:
        ary.remove(4)
        sumb-=4
    elif sumb%3==2:
        ary.remove(8)
        sumb-=8
    for i in range(3,30001,3):
        if i%2!=0:
            ary.append(i)
            sumb+=i
        if len(ary)==n+1:break
    if len(ary)==n+1 and sumb%2==1:
        sumb-=9
        ary.remove(9)
    elif len(ary)==n+1:
        sumb-=6
        ary.remove(6)
    elif sumb%2==1:
        sumb-=9
        ary.remove(9)
        sumb+=29997
        ary.append(29997)

    return ary

n=int(input())
ary=slv(n)
print(*ary,sep=' ')

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

#include <math.h>
#include <stdlib.h>


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


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n, k; cin >> n >> k;
    if(n >= k) n %= k;
    cout << min(n, k-n) << endl;


    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N) cin >> a[i];

  map<int,int> cnt;
  REP(i,N) ++cnt[a[i]];

  vector<int> side;
  for(auto e: cnt) {
    REP(i,e.second / 2) side.push_back(e.first);
  }
  sort(side.rbegin(), side.rend());

  ll ret = 0;
  if(side.size() >= 2) ret = (ll)side[0] * side[1];

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 5376
from collections import Counter
from itertools import permutations
N,C = map(int, input().split())
cost = [list(map(int, input().split())) for _ in range(C)]
color = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

# 3 groups
mod3 = {0:[], 1:[], 2:[]}
for i in range(N):
    for j in range(N):
        m = (i+j)%3
        mod3[m].append(color[i][j])

cnts = [Counter(mod3[i]) for i in range(3)]

ans = float('inf')
for p in permutations(range(C), 3):
    cond = 0
    for i in range(3):
        for col in cnts[i].keys():
            cond += cnts[i][col]*cost[col][p[i]]
    ans = min(ans, cond)
    #print(cond, p)
print(ans)
    

Measured memory_bytes: 7968
using System;
using System.Collections.Generic;

public class Patrol {
    public static void Main(){
        string org = "";
        while ((org = Console.ReadLine()) != null)
        {
            string[] line = org.Split(' ');
            int[,] map = new int[101 , 101];
            int size = 0;
            while (!(line[0] == "0" && line[1] == "0"))
            {
                int a = int.Parse(line[0])-1;
                int b = int.Parse(line[1])-1;
                map[a, b]++;
                map[b, a]++;
                if (size < a) size = a;
                if (size < b) size = b;
                line = Console.ReadLine().Split(' ');
            }
            // PrintMap(map, size);
            // This program needs to judge whether the graph constructed by inputs is a semi-Eulerian graph or not.
            if (CheckSemiEulerGraph(map, size))
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("NG");
            }
        }
    }
    
    private static void PrintMap(int[,] map)
    {
        for (int i=0;i<101;i++)
        {
            for (int j=0;j<101;j++)
            {
                map[i,j] = 0;
            }
        }
    }
    
    private static void PrintMap(int[,] map, int size)
    {
        for (int i=0;i<size;i++)
        {
            for (int j=0;j<size;j++)
            {
                Console.Write(map[i,j]);
            }
            Console.WriteLine();
        }
    }
    
    private static bool CheckSemiEulerGraph(int[,] map, int size)
    {
        int countOddVertexes = 0;
        bool isAlmostOK = false;
        for (int i=0;i<2;i++)
        {
            int countVertexes = 0;
            for (int j=0;j<101;j++)
            {
                if (map[i, j] > 0)
                {
                    countVertexes += map[i, j];
                }
            }
            if (countVertexes % 2 == 1)
            {
                countOddVertexes++;
            }
        }
        if (countOddVertexes == 2)
        {
            isAlmostOK = true;
        }
        if (isAlmostOK)
        {
            for (int i=2;i<101;i++)
            {
                int countVertexes = 0;
                for (int j=0;j<101;j++)
                {
                    if (map[i, j] > 0)
                    {
                        countVertexes += map[i, j];
                    }
                }
                if (countVertexes % 2 == 1)
                {
                    countOddVertexes++;
                }
            }
            if (countOddVertexes > 2)
            {
                return false;
            }
            return true;
        }
        //Console.WriteLine(countOddVertexes);
        return false;
    }
}


Measured memory_bytes: 16756
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

static int *
read_arr(FILE *f, int size) {
  int *arr;
  int *tmp_arr;
  int n;

  arr = (int *) malloc(sizeof(int) * size);
  if (arr == NULL) return NULL;

  tmp_arr = arr;
  while (1) {
    n = fscanf(f, "%d", tmp_arr++);
    if (errno != 0) perror("fscanf");
    if (n == EOF) break;
  }

  return arr;
}

static int
count_g_arr(int max) {
  int cnt, val;

  for (cnt = 0, val = 1; val < max; ++cnt) {
    val = val * 3 + 1;
  }

  return cnt == 0 ? 1 : cnt;
}

static int *
build_g_arr(int size, int max) {
  int *arr;
  int i, j, tmp;

  arr = (int *) malloc(sizeof(int) * size);
  if (arr == NULL) return NULL;

  for (i = 0, tmp = 1; i < size; ++i) {
    arr[i] = tmp;
    tmp = tmp * 3 + 1;
  }

  for (i = 0, j = size - 1; i < size / 2; ++i, --j) {
    tmp = arr[i];
    arr[i] = arr[j];
    arr[j] = tmp;
  }

  return arr;
}

static void
print_horizontal(FILE *f, int *arr, int size) {
  int i;

  for (i = 0; i < size; ++i) {
    if (i > 0) fprintf(f, " ");
    fprintf(f, "%d", arr[i]);
  }
  fprintf(f, "\n");
}

static void
print_vertical(FILE *f, int *arr, int size) {
  int i;

  for (i = 0; i < size; ++i) fprintf(f, "%d\n", arr[i]);
}

static int
insertion_sort(int *a, int n, int g) {
  int i, j, v, cnt;

  cnt = 0;
  for (i = g; i < n; ++i) {
    v = a[i];
    j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j = j - g;
      ++cnt;
    }
    a[j + g] = v;
  }

  return cnt;
}

static int
shell_sort(int *a, int n, int m, int g[]) {
  int cnt, i;

  cnt = 0;
  for (i = 0; i < m; ++i) {
    cnt += insertion_sort(a, n, g[i]);
  }

  return cnt;
}

int
main(int argc, char **argv) {
  int *arr;
  int *g;
  int m, n, ret, cnt;

  ret = fscanf(stdin, "%d", &n);
  if (errno != 0) perror("fscanf");
  if (ret < 1) exit(1);

  arr = read_arr(stdin, n);
  if (arr == NULL) exit(1);

  m = count_g_arr(n);;
  g = build_g_arr(m, n);

  cnt = shell_sort(arr, n, m, g);
  fprintf(stdout, "%d\n", m);
  print_horizontal(stdout, g, m);
  fprintf(stdout, "%d\n", cnt);
  print_vertical(stdout, arr, n);

  free(arr);
  arr = NULL;
  free(g);
  g = NULL;
  exit(0);
}


Measured memory_bytes: 5448
MOD = 1000000007
n, m = gets.split.map(&:to_i).sort
if m - n >= 2
    p 0
elsif m - n == 1
    ans = 1
    1.upto(n) do |x|
        ans = ans * x % MOD
    end
    ans = ans * ans * m % MOD
    p ans
else
    ans = 1
    1.upto(n) do |x|
        ans = ans * x % MOD
    end
    ans = ans * ans * 2 % MOD
    p ans    
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main();
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    _main();
}
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
//---------------------------------------------------------------------------------------------------
struct BellmanFordMax {
    BellmanFordMax() {}
    BellmanFordMax(int n) { init(n); }
    vector<vector<pair<int, int>>> E;
    int N;
    void init(int n) {
        N = n;
        E.resize(0);
        E.clear();
        E.resize(n);
    }
    void add(int a, int b, int c) { E[a].push_back({b, c}); }
    vector<ll> solve(int s) {
        vector<ll> res(N, -infl);
        res[s] = 0;

        rep(i, 0, N - 1) {
            rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
                chmax(res[p.first], res[cu] + p.second);
            }
        }

        vector<bool> pos(N);
        rep(i, 0, N) {
            rep(cu, 0, N) if (-infl < res[cu]) fore(p, E[cu]) {
                if (chmax(res[p.first], res[cu] + p.second)) {
                    pos[p.first] = true;
                }
                if (pos[cu])
                    pos[p.first] = true;
            }
        }

        rep(cu, 0, N) if (pos[cu]) res[cu] = infl;

        return res;
    }
};

int N, M, P;
vector<pair<int, int>> E[2500];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> P;

    BellmanFordMax bf(N);

    rep(i, 0, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        bf.add(a, b, c - P);
    }

    ll ans = bf.solve(0)[N - 1];

    if (ans == infl)
        ans = -1;
    else if (ans < 0)
        ans = 0;

    cout << ans << endl;
}


Measured memory_bytes: 512
# もし全部が9なら、9*N
# 一桁目が9以外なら (一桁目-1) + (len(N)-1 * 9)
# 一桁目が9なら　一桁目が8 + len(N)-1 * 9
S = (input())

if S.count("9") == len(S):
    print(len(S)*9)

elif len(S) == 1:
    print(int(S))

elif S.count("9") == (len(S)-1) and (S[0]!="9"):
    print((int(S[0])) + (len(S)-1)*9)

elif S[0] == "9":
    print(8 + ((len(S)-1)*9))
else:
    print((int(S[0])-1) + (len(S)-1)*9)

Measured memory_bytes: 3064
//Problem: ABC 172 A
//Progress: Working
#include <iostream>
typedef long long int ll;
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t;
	cin >> t;
	cout << t + t*t + t*t*t;
	return 0;
}

Measured memory_bytes: 3648