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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

class UnionFind {
    public:
        UnionFind(){}
        UnionFind(int size) { Init(size); }
        // size: Union-Find で扱いたい要素の数
        void Init(int size) { m_Data.assign(size, -1); }

        // x と y の属する集合を併合
        // 既に一緒な集合内にいるなら false を
        // 新たに併合されたなら true を返す
        bool Unite(int x, int y) {
            x = Find(x), y = Find(y);
            if(x == y) { return (false); }
            if(m_Data[x] > m_Data[y]) { swap(x, y); }
            m_Data[x] += m_Data[y];
            m_Data[y] = x;
            return (true);
        }

        // 要素 k が属する集合の根を返す
        int Find(int k) {
            if(m_Data[k] < 0) { return (k); }
            return (m_Data[k] = Find(m_Data[k]));
        }

        // 要素 k と同じ集合の要素数を返す
        int Size(int k) { return (-m_Data[Find(k)]); }

        // 要素のうち独立しているグループの数 O(NlogN)
        int GetGroupNum() {
            map<int, bool> groups;
            for(int i = 0; i < m_Data.size(); ++i) { groups[Find(i)] = true; }
            return static_cast<int>(groups.size());
        }

    private:
        vector<int> m_Data;
};

const int MOD = 1000000007;
const int MAX_N = 100010;

int N, M;

signed main() {
    IOS;

    cin >> N >> M;
    UnionFind uf(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.Unite(a, b);
    }
    int ans = 0;
    REP(i, N) {
        chmax(ans, uf.Size(i));
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 4776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20180307_AOJ
{
    class ALDS1_6C
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                Card[] A = new Card[n];
                List<Card> L = new List<Card>();
                for (int i = 0; i < n; i++)
                {
                    string[] s_n = Console.ReadLine().Split(' ');
                    A[i] = new Card(s_n[0], int.Parse(s_n[1]));
                    L.Add(A[i]);
                }

                QuickSort(A, 0, n - 1);

                bool isStable = true;
                for (int i = 0; i < n; i++)
                {
                    Card t = L.Find(x => x.Number == A[i].Number);
                    if (t.Suit == A[i].Suit)
                    {
                        L.Remove(t);
                    }
                    else
                    {
                        isStable = false;
                        break;
                    }
                }

                if (isStable)
                {
                    Console.WriteLine("Stable");
                }
                else
                {
                    Console.WriteLine("Not stable");
                }

                foreach (var v in A)
                {
                    Console.WriteLine(v);
                }
            }
        }

        static void QuickSort(Card[] A, int p, int r)
        {
            if (p < r)
            {
                int q = Partition(A, p, r);
                QuickSort(A, p, q - 1);
                QuickSort(A, q + 1, r);
            }
        }

        static int Partition(Card[] A, int p, int r)
        {
            int x = A[r].Number;
            int i = p - 1;
            Card t;
            for (int j = p; j < r; j++)
            {
                if (A[j].Number <= x)
                {
                    i++;
                    t = A[i];
                    A[i] = A[j];
                    A[j] = t;
                }
            }

            i++;
            t = A[i];
            A[i] = A[r];
            A[r] = t;

            return i;
        }
    }

    class Card
    {
        public string Suit { get; set; }
        public int Number { get; set; }
        public Card(string suit, int number)
        {
            Suit = suit;
            Number = number;
        }

        public override string ToString()
        {
            return string.Format("{0} {1}", Suit, Number);
        }
    }
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 200005
#define mx 1005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll fact[lim], ifact[lim];

ll powmod(ll b, ll e)
{
	ll ret = 1; b = b%mod; e %= (mod-1);
	while(e)
	{
		if(e&1) ret = (ret*b)%mod;
		b = (b*b)%mod;
		e >>= 1;
	}
	return ret;
}

ll inv(ll n){ return powmod(n, mod-2); }

void pre()
{
	fact[0] = 1;
	for(int i=1; i<lim; i++) fact[i] = (fact[i-1]*i)%mod;
	ifact[lim-1] = inv(fact[lim-1]);
	for(int i=lim-2; i>=0; i--) ifact[i] = (ifact[i+1]*(i+1))%mod;
}

ll nCr(int n, int r)
{
	return n<r?0:(((fact[n]*ifact[r])%mod)*ifact[n-r])%mod;
}

int main()
{
	pre();
	int i,j,h,w,n,r,c;
	cin>>h>>w>>n;
	vector<pair<int,int>> pts;
	for(i=0; i<n; i++) {
		cin>>r>>c;
		pts.pb(mp(r,c));
	} pts.pb(mp(h,w)); n++;
	sort(pts.begin(), pts.end());
	ll dp[n] = {};
	for(i=0; i<n; i++){
		dp[i] = nCr(pts[i].ff+pts[i].ss-2, pts[i].ff-1);
		for(j=0; j<i; j++) if(pts[j].ss<=pts[i].ss)
			dp[i] = (dp[i] + ((mod - ((dp[j]*nCr(pts[i].ff+pts[i].ss-pts[j].ff-pts[j].ss,pts[i].ff-pts[j].ff))%mod))%mod))%mod;
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming2
{

    class Circle
    {
        public double x;
        public double y;
        public double r;
        public Circle(double x,double y,double r)
        {
            this.x = x;
            this.y = y;
            this.r = r;
        }

        public static double Length(Circle c1,Circle c2)
        {
            double x = c1.x - c2.x;
            double y = c1.y - c2.y;
            return Math.Sqrt(x * x + y * y);
        }

    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                double[] data = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                Circle c1 = new Circle(data[0], data[1], data[2]);
                Circle c2 = new Circle(data[3], data[4], data[5]);
                double pointLength = Circle.Length(c1, c2);
                double radiusSum = c1.r + c2.r;
                double radiusMinus = Math.Abs(c2.r - c1.r);
                if (radiusSum < pointLength)
                {
                    Console.WriteLine("0");
                }else if (radiusMinus <= pointLength && pointLength <= radiusSum)
                {
                    Console.WriteLine("1");
                }else
                {
                    if (c1.r > c2.r&&pointLength<radiusMinus)
                    {
                        Console.WriteLine("2");
                    }else if (c2.r > c1.r && pointLength < radiusMinus)
                    {
                        Console.WriteLine("-2");
                    }
                }
            }
        }

    }

}

Measured memory_bytes: 9400
#include<bits/stdc++.h>
using namespace std;
const int _max = 1e7 + 10;
const int mod = 1e9 + 7;
typedef long long ll;

ll a[_max];

void init(){

    for(int i=1;i<=_max;i++){
        int begin=i;
        while(1){
            if(begin>_max){
                break;
            }
            a[begin]++;
            begin=begin+i;
        }
    }
}

int main() {
    init();
    int n;
    cin>>n;
    ll he=0;
    for(int i=1;i<=n;i++){
        he=he+a[i]*i;
    }
    cout<<he<<endl;
    return 0;
}

Measured memory_bytes: 81700
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;
    int m =0;
    int sum = 0;
    for (int i=0; i<n; i++) {
        int p;
        cin >> p;

        sum += p;
        m = max(p, m);
    }

    cout << sum - m/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
#define fr first
#define sc second
#define rep(i,n) for(int i = 0 ; i < n ; ++i )

int n,m,p,q,r;int a;
deque<P> card;

int query(){
  int sum = 0,ans = 0;
  while(sum + card.front().sc - card.front().fr + 1 < p){
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }
  if(sum + 1 != p) card.front().fr = card.front().fr + p - sum;
  sum = p;
  while(sum + card.front().sc - card.front().fr + 1 <= q){
    if(card.front().sc <= r){ //完全に含む
      ans += card.front().sc - card.front().fr + 1;
    }else if(card.front().fr <= r){ //微妙に含む
      ans += r - card.front().fr + 1;
    }
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }
  if(!card.empty() && sum != q){
    card.push_front(P(card.front().fr,card.front().fr+q-sum-1));
    if(card.front().sc <= r){ //完全に含む
      ans += card.front().sc - card.front().fr + 1;
    }else if(card.front().fr <= r){ //微妙に含む
      ans += r - card.front().fr + 1;
    }
  }
  return ans;
}

void deb(deque<P>& tmp){
  cout << endl;
  for(deque<P>::iterator it = tmp.begin();it!=tmp.end();it++){
    cout << (*it).fr << " " << (*it).sc << endl;
  }
}
void shuffle(int x,int y){
  deque<P> A;
  int sum = 0;
  while(sum + card.front().sc - card.front().fr + 1 <= x){
    A.push_back(card.front());
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }

  if(sum != x){
    A.push_back(P(card.front().fr,card.front().fr + x - sum - 1));
    card.front().fr = card.front().fr + x - sum;
    sum = x;
  }
  while(sum + card.front().sc - card.front().fr + 1 <= y){
    card.push_back(card.front());
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }
  if(sum != y){
    card.push_back(P(card.front().fr,card.front().fr + y - sum - 1));
    card.front().fr = card.front().fr + y - sum;
    sum = y;
  }
  card.insert(card.end(),A.begin(),A.end());
}

int main(){
  while(cin >> n , n){
    cin >> m >> p >> q >> r;
    p--;
    card.push_back(P(1,n));
    while(m--){
      int x,y;
      cin >> x >> y;
      shuffle(x,y);
    }
    cout << query() << endl;
    card.clear();
  }
}

Measured memory_bytes: 1328
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var dict = new Dictionary<string, int>();
            dict["AC"] = 0;
            dict["WA"] = 0;
            dict["TLE"] = 0;
            dict["RE"] = 0;
            for (var i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                dict[s]++;
            }
            Console.WriteLine($"AC x {dict["AC"]}");
            Console.WriteLine($"WA x {dict["WA"]}");
            Console.WriteLine($"TLE x {dict["TLE"]}");
            Console.WriteLine($"RE x {dict["RE"]}");
        }
    }
}


Measured memory_bytes: 30948
#include<iostream>
#include<queue>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

typedef long long ll;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll x[n];
    ll y[n];
    ll perm[8];
    double ans=0;
    REP(i, n){
        cin >> x[i] >> y[i];
        perm[i] = i;
    }

    do{
        REP(i, n-1){
            ans += sqrt((x[perm[i+1]]-x[perm[i]])*(x[perm[i+1]]-x[perm[i]]) + (y[perm[i+1]]-y[perm[i]])*(y[perm[i+1]]-y[perm[i]]));

        }
    } while(next_permutation(perm, perm+n));
    for(int i=1; i<=n; i++){
        ans /= i;
    }
    cout << fixed;
    cout << setprecision(7) << ans<<endl;
    return 0;
}

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

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

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

int main() {
  ll H;
  std::cin >> H;

  if(H == 1) {
    std::cout << 1 << '\n';
    return 0;
  }

  ll sub = 2;
  while(sub <= H) {
    sub *= 2;
  }

  std::cout << sub - 1 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MAX = 2e5 + 1e4 + 10;
typedef long long i64;
using namespace std;


int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'


    int a, b, c;
    cin >> a >> b >> c;
    int res = 0;
    for(int i = 0; i < 33; i++){
    	if(a %2 == 1 or b % 2 == 1 or c % 2 == 1)break;
    	res++;
    	int na = (b + c) / 2, nb = (c + a) / 2, nc = (a + b) / 2;
    	a = na, b = nb, c = nc;
    }
    if(res == 33)res = -1;
    cout << res << endl;


}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] sum = new long[a.Length + 1];
        sum[0] = a[0];
        sum[a.Length] = 0;
        for (int i = 1; i < a.Length; i++)
        {
            sum[i] = sum[i - 1] + a[i];
        }
        Dictionary<long, long> dict = new Dictionary<long, long>();
        foreach (var i in sum)
        {
            if (!dict.ContainsKey(i)) dict.Add(i, 0);
            dict[i]++;
        }
        Console.WriteLine(dict.Values.Where(x => x >= 2).Sum(x => (x * (x - 1)) / (2 * 1)));
    }
}

Measured memory_bytes: 42548
/*input
5 1
100 200 300 400 500
*/

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

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    rep(i, n) {
        int h;
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
}

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

typedef long long int ll;


int main()
{
    ll n;
    cin >> n;
    vector<ll> a;
    if(n == 1){
        cout << 0 ;
        return 0;
    }

    for(ll i = 1;i * i <= n;i++){
        if(n % i == 0){
            a.push_back(i);
            a.push_back(n / i);
        }
    }

    sort(a.begin(), a.end());
    vector<ll> t(a.size());

    for(ll i = 1;i < (ll)a.size();i++){
        if(t[i] != 1){
            for(ll j = i + 1;j < (ll)a.size();j++){
                if(a[j] % a[i] == 0){
                    t[j] = 1;
                }
            }
        }
    }

    vector<ll> ans(a.size());

    for(ll i = 1;i < (ll)a.size();i++){
        if(t[i] == 0){
            ll ta = a[i];
            ll j = i;
            while(ta <= a[a.size() - 1] && j < a.size()){
                if(a[j] / ta == 1 && a[j] % ta == 0){
                    ans[i]++;
                    ta *= a[i];
                }
                else if(a[j] / ta == 0){
                    j++;
                }
                else{
                    ta *= a[i];
                }
            }
        }
    }

    ll cnt = 0;
    for(ll i = 1;;i++){
        bool f = true;
        for(ll j = 0;j < (ll)ans.size();j++){
            if(ans[j] - i >= 0){
                ans[j] -= i;
                cnt++;
                f = false;
            }
        }
        if(f){
            break;
        }
    }

    cout << cnt;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll l,r; cin>>l>>r;
	r=min(r,l+4038);
	ll ans=2018;
	//vl v(0);
	rep(i,l,r+1){
		rep(j,i+1,r+1){
			ll x=i*j%2019;
			ans=min(ans,x);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using ld=long double;
struct P{
    ld x,y,z;
};
struct Line{
    P a,b;
};
P operator-(P lhs,P rhs){
    return P{lhs.x-rhs.x,lhs.y-rhs.y,lhs.z-rhs.z};
}
ld dot(P a,P b){
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

ld sq(ld x){
    return x*x;
}
ld dist2(P lhs,P rhs){
    return sq(lhs.x-rhs.x)+sq(lhs.y-rhs.y)+sq(lhs.z-rhs.z);
}
ld dist2_sp(Line s,P p){
    if(dot(p-s.a,s.b-s.a)>0 && dot(p-s.b,s.a-s.b)>0){
        return dist2(p,s.a)-pow(dot(p-s.a,s.b-s.a)/sqrt(dist2(s.a,s.b)),2);
    }
    else return min(dist2(s.a,p),dist2(s.b,p));
}

ld solve(int n,int m,int r){
    vector<P> s(n);
    vector<ld> sr(n);
    for(int i=0;i<n;i++) cin>>s[i].x>>s[i].y>>s[i].z>>sr[i];
    vector<P> t(m);
    vector<ld> tb(m);
    for(int i=0;i<m;i++) cin>>t[i].x>>t[i].y>>t[i].z>>tb[i];
    P e;
    cin>>e.x>>e.y>>e.z;
    ld res=0;
    vector<bitset<2000>> bs(m);
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            int condL=dist2(t[i],s[j])<sr[j]*sr[j];
            int condE=dist2(e,s[j])<sr[j]*sr[j];
            ld d2=dist2_sp(Line{t[i],e},s[j]);
            if(condL && condE || !condE && !condL && d2>sr[j]*sr[j]) continue;
            bs[i][j]=true;
        }
    }
    for(int bit=0;bit<(1<<m);bit++){
        ld sum=0;
        bitset<2000> x;
        for(int i=0;i<m;i++){
            if((bit>>i)&1){
                sum+=tb[i]/dist2(t[i],e);
                x|=bs[i];
            }
        }
        int cnt=x.count();
        if(cnt<=r){
            res=max(res,sum);
        }
    }
    return res;
}
int main(){
    cout<<fixed<<setprecision(10);
    int n,m,r;
    while(cin>>n>>m>>r,!(n==0 && m==0 && r==0)){
        cout<<solve(n,m,r)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> A(114514);
    REP(i,N){
        ll get;
        cin >> get;
        A[get]++;
    }
    ll sum = 0;
    REP(i,114514)sum += A[i]*i;
    ll Q;
    cin >> Q;
    REP(i,Q){
        int B,C;
        cin  >> B >> C;
        sum += A[B]*(C-B);
        cout << sum << "\n";
        A[C] += A[B];
        A[B] = 0;
    }
}

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

int main(){
  string s;
  cin >> s;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  string s;
  cin >> s;
  int r = 0, b = 0, c = 0;
  rep(i, s.size()) {
    if (s[i] == '0') {
      if (b > 0) {
        c += 2;
        --b;
      } else {
        ++r;
      }
    } else {
      if (r > 0) {
        c += 2;
        --r;
      } else {
        ++b;
      }
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3736
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A, B = map(int, input().split())

    print('Possible') if not A%3 or not B%3 or not (A+B)%3 else print('Impossible')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10368
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int n;
    set < int > s;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        s.insert(x);
    }
    cout << 2 * ((s.size() - 1) / 2)  + 1;
    return 0;
}

Measured memory_bytes: 4992
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		long input = in.nextLong();
		Map<Long, Integer> m = primeFactorize(input);
		System.out.print(input+":");
		for(Entry<Long, Integer> e : m.entrySet()) {
			long prime = e.getKey();
			int ite = e.getValue();
			for (int i=0;i<ite;i++) {
				System.out.print(" "+prime);
			}
		}
		System.out.println();
	}

	static public Map<Long, Integer> primeFactorize(long n) {
		Map<Long, Integer> res = new LinkedHashMap<Long, Integer>();
		long tmp=n;
		for (long i=2;i*i<=n;i++) {
			int count=0;
			while (tmp%i==0) {
				tmp/=i;
				count++;
			}
			if (count!=0) res.put(i, count);
		}
		if (tmp!=1) res.put(tmp, 1);
		if (res.size()==0) res.put(n, 1);
		return res;
	}
}

Measured memory_bytes: 26360
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        int all = 1;
        int bad = 1;
        for (int i = 0; i < n; i++) {
            int x = a.get(i);
            all *= 3;
            if (x % 2 == 0) {
                bad *= 2;
            }
        }
        int ans = all - bad;
        System.out.println(ans);
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define mo 998244353
using namespace std;
int x[200010],y[200010],mi[200010];
set<pair<int,int> >mp;
int main()
{
	int n,w=0;scanf("%d",&n);mi[0]=1;
	for (int i=1;i<=n;i++)
	{
		mi[i]=mi[i-1]*2%mo;
		scanf("%d%d",&x[i],&y[i]);
	}
	w=mi[n];
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++)
	{
		bool err=false;
		for (int k=i+1;k<=n;k++) if (k!=j) if ((x[k]-x[i])*(y[j]-y[i])==(x[j]-x[i])*(y[k]-y[i])) err=true;
		if (!err)
		{
			int js=0;
			for (int k=1;k<=n;k++) if ((x[k]-x[i])*(y[j]-y[i])==(x[j]-x[i])*(y[k]-y[i])) js++;
			w=(w-(mi[js]-js-1))%mo;
		}
	}
	printf("%d\n",(w+mo-n-1)%mo);
}
		

Measured memory_bytes: 256
from itertools import permutations
INF = float("inf")

n, m, r = map(int, input().split())
r = list(map(lambda x: int(x)-1, input().split()))
g = [[INF] * n for _ in range(n)]
abc = [tuple(map(int, input().split())) for _ in range(m)]
for a, b, c in abc:
    a -= 1; b -= 1
    g[a][b] = c
    g[b][a] = c

def warshall_floyd(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

d = warshall_floyd(g, n)
ans = INF
for route in permutations(r):
    res = 0
    for i in range(1, len(r)):
        res += d[route[i-1]][route[i]]
    ans = min(ans, res)

print(ans)


Measured memory_bytes: 59608
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> imos(n+1, 0);
    REP(i, n) imos[i+1] = imos[i] + a[i];

    // dp[l][r] := [l, r) を全部くっつける最小コスト
    vector<vector<ll>> dp(n, vector<ll>(n+1, LINF));
    REP(i, n) {
        dp[i][i+1] = 0;
    }
    RANGE(len, 2, n) {
        RANGE(l, 0, n-len) {
            const ll r = l + len;
            RANGE(r2, l+1, r-1) {
                chmin(dp[l][r], dp[l][r2] + dp[r2][r] + imos[r] - imos[l]);
            }
        }
    }
    cout << dp[0][n] << endl;
    
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
vector<int> v[1000];
int dq;
int main(){
	int n=read();
	for(int i=1;i*(i-1)/2<=n;i++){
		if(i*(i-1)/2==n){
			for(int j=1;j<=i;j++){
				for(int k=j+1;k<=i;k++){
					v[j].push_back(++dq); v[k].push_back(dq);
				}
			}
			puts("Yes");
			cout<<i<<endl;
			for(int j=1;j<=i;j++){
				wri(v[j].size()); for(auto k:v[j])wri(k); puts("");
			}
			return 0;
		}
	}
	puts("No");
}
/*
f[i][j]->f[i+1][j]
f[i][j]->f[i+1][i]
*/

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a, b, c, d;

ll count(ll x){
    return x - (x/c + x/d - x/(c*d/__gcd(c,d)));
}

int main(){
    cin >> a >> b >> c >> d;
    cout << count(b) - count(a-1) << endl;
    return 0;
}


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

using namespace std;

#define MAX 200005
vector<int> adj[MAX];
int path[MAX];
bool vis[MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i=1; i<=m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    memset(path, -1, sizeof path);
    memset(vis, false, sizeof vis);
    queue<int> Q;
    Q.push(1);
    vis[1] = true;
    int tot = 1;
    while(!Q.empty()){
        int u = Q.front();
        Q.pop();
        for(int i=0; i<adj[u].size(); i++){
            int v = adj[u][i];
            if(vis[v]) continue;
            vis[v] = true;
            Q.push(v);
            path[v] = u;
            tot++;
        }
    }
    if(tot != n){
        cout << "No" << endl;
        return 0;
    }
    else {
        cout << "Yes" << endl;
        for(int i=2; i<=n; i++) cout << path[i] << endl;
    }
}



Measured memory_bytes: 13468
N,M,C = map(int,input().split())
b_list = list(map(int,input().split()))
cnt = 0
for i in range(N):
    s = 0
    a_list = list(map(int,input().split()))
    for i in range(M):
        s += a_list[i]*b_list[i]
    if s + C > 0:
        cnt += 1

print(cnt)



Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hList = readLine()!!.split(' ').map(String::toLong).reversed()
    var cur = 0
    var ans = 0

    (1 until n).forEach {
        if (hList[it - 1] <= hList[it]) {
            cur++
        } else {
            cur = 0
        }
        ans = Math.max(ans, cur)
    }
    println(ans)
}

Measured memory_bytes: 59508
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

bool used[100005] = {};
vector<int> e[100005];
vector<int> top;
void dfs(int u)
{
  if (used[u])
    return;
  used[u] = true;
  for (auto s : e[u])
    dfs(s);
  top.push_back(u);
}

lli dp[100005] = {};
void solve(long long N, long long M, std::vector<long long> x,
           std::vector<long long> y)
{
  rep(i, M) x[i]--, y[i]--;
  rep(i, M) e[x[i]].push_back(y[i]);
  rep(i, N) dfs(i);
  lli ans = 0;
  rep(i, N)
  {
    // cout << top[i] << endl;
    for (auto s : e[top[i]])
      chmax(dp[top[i]], dp[s] + 1);
    chmax(ans, dp[top[i]]);
  }
  cout << ans << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> x(M);
  std::vector<long long> y(M);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  solve(N, M, std::move(x), std::move(y));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
bool f(string S) {
	if (S == "ABC") return 1;
	int n = S.size();
	if (n < 5) return 0;
	char x = (S.substr(0,3) == "ABC") ? 'A' : (S.substr(n-3) == "ABC" ? 'C' : 'B');
	string t = "";
	for (int i = 0; i < n; ++i) {
		if (S[i]+1 == S[i+1] && S[i+1]+1 == S[i+2]) { t += x; i += 2; }
		else if (S[i] == x) return 0;
		else t += S[i];
	}
	return t != S && f(t);
}
int main() {
	string S;
	cin >> S;
	cout << (f(S) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 21912
def count1s(n,i):
    """２進数のi桁目に、n以下で何個1があるか"""
    rn = n % (2**i)
    dn = n // (2**i)
    if rn < (2**(i-1)-1):
        cnt = dn*(2**(i-1))
    else:
        cnt = dn*(2**(i-1)) + rn - (2**(i-1)-1)
    return cnt

a, b = list(map(int, input().split()))

s = ''
for i in range(41):
    cai = count1s(a-1,i+1)
    cbi = count1s(b,i+1)
    if (cbi - cai) % 2 == 0:
        s = '0' + s
    else:
        s = '1' + s
ans = int(''.join(s), 2)

print(ans)    

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

int solve(int n, vector<int> a) {
    int count = 0;
    int b = 0;
    int v;
    while(count<n) {
        count ++;
        v = a[b];
        if(v == 2) return count;
        b = v-1;
    }
    return -1;
}
int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << (solve(n,a)) << endl;
}

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

using namespace std;

int main() {
  int n,d[200000];
  cin >> n;
  for(int i = 0; i < n; i++) 
    cin >> d[i];
  
  sort(d,d+n);
  
  int sum = 0, t = d[n/2 - 1] + 1;
  while(t != d[n/2]+1) {
    sum++;
    t++;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define pb push_back
#define prev prev_
#define stack stack_
#define inf 0x3f3f3f3f

int A,B;

int main(){
	cin>>A>>B;
	cout<<(A - 1) * (B - 1)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static int gcd(int x, int y) {
        if (x == 0) {
            return y;
        } else if (y == 0) {
            return x;
        } else if (x >= y) {
            return gcd(y, x % y);
        } else {
            return gcd(x, y % x);
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        System.out.println(gcd(x, y));
        scanner.close();
    }
}



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

// @author: pashka

const long MOD = 1000000007;

long fact(int x) {
    long res = 1;
    for (int i = 1; i <= x; i++) {
        res *= i;
        res %= MOD;
    }
    return res;
}

long pw(long x, long p) {
    long res = 1;
    while (p > 0) {
        if (p % 2 == 1) {
            res = (res * x) % MOD;            
        }
        x = (x * x) % MOD;
        p /= 2;
    }
    return res;
}

long inv(long x) {
    return pw(x, MOD - 2);
}

int main() {
    ios::sync_with_stdio(false);

    int x, y;
    cin >> x >> y;
    int n = (x + y) / 3;
    if ((x + y) % 3 != 0) {
        cout << 0;
        return 0;
    }

    x -= n;
    y -= n;
    // (0, 1) (1, 0)
    if (x < 0 || y < 0) {
        cout << 0;
        return 0;
    }

    // c(x + y, x)
    // (x + y)! / x! / y!

    long fxy = fact(x + y);
    long fx = fact(x);
    long fy = fact(y);

    long inv_fx = inv(fx);
    long inv_fy = inv(fy);

    long res = ((fxy * inv_fx) % MOD * inv_fy) % MOD;

    cout << res;
    
    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int m; cin >> m;
    // vector<ll> ds(m), cs(m);
    // ll ans = -1, acc = 0;
    // for(int i = 0; i < m; i++){
    //     cin >> ds[i] >> cs[i];
    //     ans += cs[i];
    //     acc += ds[i] * cs[i];
    // }
    // cout << ans + (acc - 1) / 9 << '\n';
    ll ans = -1, acc = 0;
    for(int i = 0; i < m; i++){
        ll d, c;
        cin >> d >> c;
        ans += c;
        acc += d * c;
    }
    cout << ans + (acc - 1) / 9 << '\n';
}


Measured memory_bytes: 888
#include <iostream>

int main()
{
    int count = 0;
    int array[3];
    std::cin >> array[0] >> array[1] >> array[2];
    for(int i=0; i<3; i++)
    {
        if(5 <= array[i] && array[i] <= 7){
            if(array[i]==6){
                std::cout << "NO" << std::endl;
                return 0;
            }
            if(array[i] == 7){
                count++;
                if(count==2){
                    std::cout << "NO" << std::endl;
                    return 0;
                }


            }
        }
    }
    std::cout << "YES" << std::endl;
    return 0;
}

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

int main(){
    vector<int> d(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> d[i];
    }

    sort(d.begin(), d.end());
    for (int i = 0; i < 3; i++)
    {
        cout << d.at(i);
        if(i == 2){
            cout << endl;
        }
        else cout << " ";
    }
        
}


Measured memory_bytes: 3156
def shakutori(a,M):
  left =0
  right = 0
  su = 0
  ans = 0
  for i in range(len(a)):
    su +=a[right]
    right +=1
    if su%M==0:
      ans+=1
      while su%M!=0:
        su -=a[left]
        left+=1
  return ans
from itertools import accumulate
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A = list(accumulate(A))
A = list(map(lambda x: x%M,A))
ans = {}
ans1=0
for i in range(N):
  if A[i] in ans:
    ans[A[i]] +=1
  else:
    ans[A[i]] =1
  ans1 += ans[A[i]]-1
if 0 in ans:
  ans1 += ans[0]
print(ans1)

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

int main() {
    int a, b;
    cin >> a >> b;
    
    int cnt = 0;
    for(int i = a; i <= b; i++){
        int l = i;
        vector<int> vec(5);
        rep(j, 5){
            vec[j] = l % 10;
            l /= 10;
        }
        if(vec[0] == vec[4] && vec[1] == vec[3]) cnt++;
    }
    
    cout << cnt << endl;
}

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


int main(){
    int N; cin >> N;
    vector<int> t(200000), x(200000), y(200000);
    for(int i = 0; i < N; i++) cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);

    bool can = true;
    for (int i = 0; i < N; i++)
    {
        int dt = t.at(i+1) + t.at(i);
        int dist = abs(x.at(i+1) + x.at(i)) + abs(y.at(i+1) - y.at(i));
        if(dt < dist) can = false;
        if(dist % 2 != dt % 2) can = false;
    }

    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    




    return 0;
}



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

int main() {
 int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  int zoro = 0;
   for(int i = 0; i < n; i++){
    if(a[i] == b[i]) zoro++;
    if(a[i]!= b[i] || i == n-1){
      if(zoro >= 3){
        cout << "Yes" << endl;
        return 0;
      }
      zoro = 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3632
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""

while True:
    inp = input().strip().split(" ")
    m = int(inp[0])
    f = int(inp[1])
    r = int(inp[2])
#    print(inp[1])
    
    if m < 0 and f < 0 and r < 0 :
        break
    
    if m < 0 or f < 0 :
        S = "F"
    else:
        t = m + f
        if t < 30:
            S = "F"
        elif t < 50:
            if r >= 50:
                S = "C"
            else:
                S = "D"
        elif t < 65:
            S = "C"
        elif t < 80:
            S = "B"
        else:
            S = "A"

    print(S)

Measured memory_bytes: 7620
n = int(input())
S = input()
ans = 0
nums = list(map(str, range(10)))
for i in nums:
    s1 = S.find(i)
    if s1 < 0:
        continue
    for j in nums:
        s2 = S.find(j, s1+1)
        if s2 < 0:
            continue
        for k in nums:
            s3 = S.find(k, s2+1)
            if s3 > 0:
                ans += 1
print(ans)

Measured memory_bytes: 9272
#include <cstdio>
#define max_n 12
#define max_m 12
using namespace std;
char c[max_n+1][max_m+1],d[max_n+1],e[max_m+1];
int m,n;
bool dfs2(int x){
	if(x>m)
		return 1;
	if(e[x])
		return dfs2(x+1);
	int t=0,r=0;
	for(int i=x-1; ++i<=m; !e[i]&&(++t));
	for(int i=x-1; ++i<=m; )
		if(!e[i]){
			e[x]=i,e[i]=x,r=1;
			for(int j=0; ++j<=n&&(c[j][x]==c[d[j]][i]&&c[d[j]][x]==c[j][i]||(r=0)); );
			if(i==x){
				if(r&&(t&1)&&dfs2(x+1))
					return 1;
			}
			else
				if(r)
					return dfs2(x+1);
			e[x]=e[i]=0;
		}
	return 0;
}
bool dfs1(int x){
	if(x>n)
		return dfs2(1);
	if(d[x])
		return dfs1(x+1);
	int t=0;
	for(int i=x-1; ++i<=n; !d[i]&&(++t));
	for(int i=x-1; ++i<=n; )
		if(!d[i]){
			d[x]=i,d[i]=x;
			if(((t&1)||(i!=x))&&dfs1(x+1))
				return 1;
			d[x]=0,d[i]=0;
		}
	return false;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0; ++i<=n; scanf("%s",c[i]+1));
	puts(dfs1(1)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 1664
import heapq

H,W = map(int,input().split())
maze = []
for i in range(H):
    maze.append(list(input()))
nodes = []
nodedict = {}
for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
            nid = len(nodes)
            nodedict[(i,j)] = nid
            nodes.append((i,j))

N = len(nodes)
INF = H*W
edges = [[False]*N for _ in range(N)]

def link(i1,j1,i2,j2):
    n1 = nodedict[(i1,j1)]
    n2 = nodedict[i2,j2]
    edges[n1][n2] = edges[n2][n1] = True

for i in range(H):
    for j in range(W):
        if maze[i][j] != '.': continue
        if i > 0 and maze[i-1][j]=='.': link(i,j,i-1,j)
        if i < H-1 and maze[i+1][j]=='.': link(i,j,i+1,j)
        if j > 0 and maze[i][j-1]=='.': link(i,j,i,j-1)
        if j < W-1 and maze[i][j+1]=='.': link(i,j,i,j+1)

dist = [INF] * len(nodes)

def solve():
    dist[0] = 0
    n0 = nodedict[(0, 0)]
    pq = [(0, n0)]
    determined = {n0}
    while pq:
        d, nid = heapq.heappop(pq)
        for i, linked in enumerate(edges[nid]):
            if linked and i not in determined:
                dist[i] = min(dist[i], d+1)
                determined.add(i)
                heapq.heappush(pq, (d+1, i))
    goal = nodedict[(H-1, W-1)]
    if dist[goal] == INF:
        return -1
    return len(nodes) - dist[goal] - 1

print(solve())

Measured memory_bytes: 52980
n, t = map(int, input().split())
dish = [list(map(int, input().split())) for _ in range(n)]

MAX = 10000
dish.sort()
dp = [[0] * MAX for _ in range(n+1)]

for i in range(n):
    time, value = dish[i]
    for j in range(t):
        dp[i+1][j+time] = max(dp[i+1][j+time], dp[i][j] + value)
    for j in range(MAX):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(max(dp[n]))

Measured memory_bytes: 310912
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
void solve(){
    int n;
    cin>>n;
    int spf[n+1];
    for(int i=0;i<=n;i++){
        spf[i]=i;
    }
    for(int i=2;i*i<=n;i++){
        if(spf[i]==i){
            for(int j=i*i;j<=n;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<n;i++){
        int x = n-i;
        int temp=1;
        while(x!=1){
            int z = x;
            int cnt=0;
            while(z%spf[x]==0){
                cnt++;
                z/=spf[x];
            }
            x = z;
            temp*=(cnt+1);
        }
        ans+=temp;
    }
    cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }
}


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

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

main(){
    int n=in(),t=in(),t1,t2,ans=t;
    cin >> t1;
    for (int i=1;i<n;i++){
    cin >> t2;
    ans+=min(t,t2-t1);
    t1=t2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int i,sum,k;
    char a[100];
    while(scanf("%s",a)==1)
    {
        sum=700,k=0;
        for(i=0;a[i];i++)
        {
            if(a[i]=='o')
                k++;
        }
        sum+=k*100;
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 998244353
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return sol;
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
ll a[200005];
void solve()
{
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << "0";
			return;
		}
	}
	ll ans = 1;
	for (int i = 0;i < n;i++)
	{
		if (ans <= (1000000000000000000 / a[i]))
		{
			ans = ans * a[i];
		}
		else
		{
			cout << "-1";
			return;
		}
	}
	cout << ans;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
}


Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,s;
	s=0;
	cin>>a>>b;
	for (int i=a;b>=i;i++){
		if (i/10000==i%10){
			if (i%10000/1000==i%100/10){
				s++;
			}
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256