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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  ll a, b, c;
  cin >> a >> b >> c;

  ll cab = c - a - b;

  if(cab < 0){
    cout << "No" << endl;
  }else{
    if(cab * cab > 4 * a * b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  }


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        string ans="";
        if(N==7||N==5||N==3)ans="YES";
        else ans="NO";
      Console.WriteLine(ans);
       
      
    }


}



class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  int a,b,k;
  cin >> k;
  cin >> a >> b;
  for(int i=a; i<=b; i++){
    if(i%k==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



const int MOD = (int) 1e9 + 7;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}

/*int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/

using namespace std;

int dp[100][3][3][2];
// 0 egal cu L
// 1 cu niciunul
// 2 egal cu R


int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    ll l, r;
    cin >> l >> r;

    if(l == r) {
        cout << 1;
        return 0;
    }

    int bit = 60, mx = 0;
    while((l & (1LL << bit)) == (r & (1LL << bit))) {
        if(l & (1LL << bit)) {
            mx = 1;
        }
        bit--;
    }

    dp[bit][0][0][max(mx, 0)] = 1;
    if(mx == 1) {
        dp[bit][0][2][1] = 1;
    }
    dp[bit][2][2][max(mx, 1)] = 1;

    for(i = bit; i > 0; i--) {
        int bitl = ((l & (1LL << (i - 1))) > 0);
        int bitr = ((r & (1LL << (i - 1))) > 0);

        for(int a = 0; a < 3; a++) {
        for(int b = a; b < 3; b++) {
        for(int c = 0; c < 2; c++) {
            if(dp[i][a][b][c] == 0) continue;
                for(int x = 0; x < 2; x++) {
                for(int y = x; y < 2; y++) {
                    if(a == 0 && x < bitl) continue;
                    if(b == 2 && y > bitr) continue;
                    if(c == 0 && x != y) continue;
                    int newa = 1;
                    if(a == 0) {
                        newa = (x == bitl ? 0 : 1);
                    }
                    if(a == 2) {
                        newa = (x == bitr ? 2 : 1);
                    }
                    int newb = 1;
                    if(b == 0) {
                        newb = (y == bitl ? 0 : 1);
                    }
                    if(b == 2) {
                        newb = (y == bitr ? 2 : 1);
                    }
                    add(dp[i - 1][newa][newb][max(c, y)], dp[i][a][b][c]);
                }
                }
            }
        }
        }
    }

    int ans = 2;
    add(ans, dp[0][0][1][1]);
    add(ans, dp[0][0][2][1]);
    add(ans, dp[0][1][1][1]);
    add(ans, dp[0][1][2][1]);
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>l>>r;

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

        cout<<ans<<endl;
    }

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_173
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            Array.Sort(array);
            Array.Reverse(array);

            long res = array[0];
            var que1 = new Queue<long>();
            var que2 = new Queue<long>();
            que1.Enqueue(array[1]);
            for (int i = 2; i < n; i++)
            {
                if (que2.Count == 0 || que1.Peek() > que2.Peek())
                {
                    que2.Enqueue(que1.Peek());
                    res += que1.Dequeue();
                }
                else
                {
                    res += que2.Dequeue();
                }
                que1.Enqueue(array[i]);
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 49432
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS


//FUNCTIONS
int arr[3001][3001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a,b; cin >> a >> b;
	for(int i = 0; i < 3001; i++){
		arr[0][i] = 0;
	}
	for(int i = 0; i < 3001; i++){
		arr[i][0] = 0;
	}
	// 1 \ 2| 3 _
	for(int i = 0; i < a.size(); i++){
		for(int j = 0; j < b.size(); j++){
			if(a[i] == b[j]){
				arr[i+1][j+1] = arr[i][j] + 1;
			}
			else{
				arr[i+1][j+1] = max(arr[i][j+1],arr[i+1][j]);
			}
		}
	}
	int ii,jj;
	int mx = 0;
	for(int i = 0; i < a.size(); i++){
		for(int j = 0; j < b.size();j++){
			if(arr[i+1][j+1] > mx){
				ii = i+1;
				jj = j+1;
				mx = arr[i+1][j+1];	
			}
		}
	}
	string f = "";
	
	while(arr[ii][jj]){
		if(a[ii-1] == b[jj-1]){
			f += a[ii-1];
			ii--;
			jj--;
		}
		else{
			
			if(arr[ii-1][jj] > arr[ii][jj-1]){
				ii = ii-1;
			}
			else{
				jj = jj-1; 
			}
		}
	}
	reverse(f.begin(),f.end());
	cout << f << endl;
	return 0;
}


Measured memory_bytes: 35456
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  string a[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  cin>>s;
  for(int i=0;i<7;i++){
  	if(s==a[i]){
    cout<<(7-i)<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#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; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    ll a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a+3);

    if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0) {
        cout << 0 << endl;
    } else {
        ll ans = LLINF;
        do {
            ll diff = a[0] * a[1];
            chmin(ans, diff);
        } while (next_permutation(a, a+3));
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
int ans;
int dfs(int m, int sum) {
	if (sum > n)return 0;
	else if (sum == n)ans++;
	else return dfs(m + 1, sum + m);
}
int main() {
	while (cin >> n, n) {
		ans = 0;
		for (int i = 1; i < n; i++) {
			dfs(i, 0);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n;cin>>n;
  map<string, bool> mp;
  string s;
  char t;
  cin>>s;
  t = s[s.size()-1];
  mp[s]=true;
  bool flag = true;
  fol(i,n-1){
    cin>>s;
    if(!mp[s]&&s[0]==t){
      mp[s]=true;
      t = s[s.size()-1];
    }else{
      flag = false;
    }
  }
  if(flag){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }
  return 0;
}


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

struct UF{
    vector<int> p;
    int n;
    UF(int siz){
        n = siz;
        p.resize(n, 0);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    int parent(int x){
        if(x != p[x])   p[x] = parent(p[x]);
        return p[x];
    }

    void unite(int x, int y){
        x = parent(x), y = parent(y);
        if(x == y)  return;
        p[x] = y;
    }
};

int base = 100005;

typedef long long ll;

int main(){
    UF uf(200100);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    map<int,int> xcnt, ycnt;
    set<int> xset, yset;
    for(int i = 0; i < n; i++)  cin >> x[i] >> y[i], uf.unite(x[i], y[i]+base), xset.insert(x[i]), yset.insert(y[i]);
    for(int p : xset)   xcnt[uf.parent(p)]++;
    for(int p : yset)   ycnt[uf.parent(p+base)]++;
    ll ans = 0;
    for(auto p : xcnt){
        ans += (ll)p.second * ycnt[p.first];
    }
    cout << ans-n << endl;
    return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"

#ifdef WINT_MIN
#define __MAI
#endif

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define repeat(l) for(auto cnt=0;cnt<(l);++cnt)
#define BIGINT 0x7FFFFFFF
#define E107 1000000007ll
void printbit(int u) { if (u == 0)cout << 0; else { int s = 0, k = 0; for (; 0<u; u >>= 1, k++)s = (s << 1) | (u & 1); for (; 0<k--; s >>= 1)cout << (s & 1); } }template<typename T1, typename T2>
    ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; }

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

namespace {
    std::chrono::system_clock::time_point t;
    void tic() { t = TIME; }
    void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); }
    std::chrono::system_clock::time_point tle = TIME;
#ifdef __MAI
    void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); }
#else
#define safe_tle(k) ;
#endif
}

#ifndef __MAI 
namespace {
    class MaiScanner {
    public:
        template<typename T>
        void input_integer(T& var) {
            var = 0;
            T sign = 1;
            int cc = getchar_unlocked();
            for (; cc<'0' || '9'<cc; cc = getchar_unlocked())
                if (cc == '-') sign = -1;
            for (; '0' <= cc&&cc <= '9'; cc = getchar_unlocked())
                var = (var << 3) + (var << 1) + cc - '0';
            var = var*sign;
        }
        void ign() { getchar_unlocked(); }
        MaiScanner& operator>>(int& var) {
            input_integer<int>(var);
            return *this;
        }
        MaiScanner& operator>>(long long& var) {
            input_integer<long long>(var);
            return *this;
        }
    };
}
MaiScanner scanner;
#else
#define scanner cin
#endif

int width, height;
ll m, n, te;

int main() {
    int i, j, k;
    ll x, y, a, b;

    scanner >> n >> te;

    ll flow = 0;
    ll last = 0;
    repeat(n) {
        scanner >> x;
        flow += min(x - last, te);
        last = x;
    }
    flow += te;

    cout << flow << endl;



    return 0;
}

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

const int maxn=1e5+10;

int N,M,K;
int prt[maxn];
int size[maxn];
std::vector<int> G1[maxn];
std::vector<int> G2[maxn];

int find(int x){
        if (x==prt[x])return x;
        return prt[x]=find(prt[x]);
}

int main (){
        std::cin >> N >> M >> K;
        for (int i=1;i<=N;i++)
                prt[i]=i,size[i]=1;
        for (int i=1,x,y;i<=M;i++){
                std::cin >> x >> y;
                G1[x].push_back(y);
                G1[y].push_back(x);
                x=find(x),y=find(y);
                if (x!=y)prt[x]=y,size[y]+=size[x];
        }
        for (int i=1,x,y;i<=K;i++){
                std::cin >> x >> y;
                G2[x].push_back(y);
                G2[y].push_back(x);
        }
        for (int i=1,tmp;i<=N;i++){
                tmp=size[find(i)]-G1[i].size()-1;
                for (int x:G2[i])
                        if (find(i)==find(x))
                                --tmp;
                std::cout << tmp << " \n"[i==N];
        }
        return 0;
}



Measured memory_bytes: 13176
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=100005;

int n,m,cnt,last[N],d[N],a[N],p[N];
struct edge{int to,next;}e[N*2];

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<n+m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		addedge(x,y);d[y]++;
	}
	int r=0;
	for (int i=1;i<=n;i++)
		if (!d[i]) a[++r]=i;
	for (int i=1;i<=n;i++)
	{
		int x=a[i];
		for (int j=last[x];j;j=e[j].next)
		{
			d[e[j].to]--;
			if (!d[e[j].to]) a[++r]=e[j].to,p[e[j].to]=x;
		}
	}
	for (int i=1;i<=n;i++) printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 3200
import collections
import numpy as np

N,M = map(int,input().split())
A=np.array([0]+[int(x) for x in input().split()])
B=np.mod(A.cumsum(),M)
answer=0
C = collections.Counter(B)

for x in C.values():
  answer += x*(x-1)//2
print(answer)

Measured memory_bytes: 23104
S = input()
if S[0] != '<':
    S = '<' + S
if S[-1] != '>':
    S = S + '>'

N = len(S)
ls = [[],[0]]
for i in range(N-1):
    if S[i] == '<' and S[i+1] == '>':
        ls[0].append(i+1)
    if S[i] == '>' and S[i+1] == '<':
        ls[1].append(i+1)
ls[1].append(N)
M = len(ls[0])
ans = 0
for i in range(M):
    s,t = max(ls[0][i]-ls[1][i], ls[1][i+1]-ls[0][i]),min(ls[0][i]-ls[1][i], ls[1][i+1]-ls[0][i])
    ans += s*(s+1) //2 + (t-1)*(t) //2

print(ans)


Measured memory_bytes: 13440
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 1e5 + 5;

int x [MAX_N];

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

  int n;
  cin >> n;

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

  Modint mul (0);
  Modint ans (0);
  for (int i = 1; i < n; i++) {
    mul += inv(Modint(i));
    ans += mul * Modint(x[i] - x[i - 1]);
  }

  for (int i = 1; i < n; i++) {
    ans *= Modint(i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    for(int i = 0; i <= k; i++) {
        for(int j = 0; j <= k; j++) {
            if (s-i-j >= 0 && s-i-j <= k)
                ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var alist = nextIntArray();
  var blist = nextIntArray();
  var positivelist = [];
  var negativeSum = 0;
  var diffSum = 0;
  var output = 0;
  for(var i = 0; i < N; i++){
    diffSum += alist[i] - blist[i];
    if(alist[i] - blist[i] >= 0){
      positivelist.push(alist[i] - blist[i]);
    }else{
      negativeSum += blist[i] - alist[i];
      output++;
    }
  }
  if(diffSum < 0){
    myout(-1);
  }else{
    positivelist.sort(function(a,b){
    	return b - a;
    });
    for(var i = 0; i < positivelist.length; i++){
      if(negativeSum <= 0){
        break;
      }
      negativeSum -= positivelist[i];
      output++;
    }
    
    myout(output);
  }
}

Measured memory_bytes: 51856
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<cstdio>
using namespace std;

int main(){
    int n;cin>>n;
    int v[n];
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v,v+n);
    stack<double> s;
    for(int i=n-1;i>=0;i--) s.push(v[i]);

    while(s.size()!=1){
        double x=s.top();s.pop();
        double y=s.top();s.pop();
        double z=(x+y)/2.0;
        s.push(z);
    }

    printf("%.8f\n",s.top());
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll a, b;
    cin >> a >> b;

    if(a%b == 0) ANS(0);
    ll a1 = (a/b)*b;
    ll a2 = a1+b;
    cout << min(abs(a1-a), abs(a2-a));
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3660
#include<stdio.h>
int main(void)
{
        int a,b,c,temp,i;
        scanf("%d %d %d",&a,&b,&c);
        for(i = 0;i <= 1;i++){
        if(a > b){
                temp = a;
                a = b;
                b = temp;
                if(b > c){
                        temp = b;
                        b = c;
                        c = temp;
                }
        }else if(b > c){
                temp = b;
                b = c;
                c = temp;
                if(a > b){
                        temp = a;
                        a = b;
                        b = temp;
                }
        }else{
                i++;
        }
        }
        printf("%d %d %d\n",a,b,c);
        return 0;
}

Measured memory_bytes: 596
s = list(input())
t = len(s)
if t==1 and s[0]=="?":
    s[0]="D"    
for i in range(t-1):
    if i==0 and s[i]=="?":
        s[i]="D"
        if s[i+1]=="?":
            s[i+1]="D"
    elif s[-1]=="?" and s[-2]=="D" and i==t-2:
        s[-1]="D"
    elif s[i]=="D" and s[i+1]=="?" and s[i+2]=="P":
        s[i+1]="D"
    elif s[i]=="P"  and s[i+1]=="?":
        s[i+1]='D'
    elif s[i]=="D" and s[i+1]=="?":
        s[i+1]='P'

print("".join(s))

Measured memory_bytes: 10976
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))


def solve():
    AA = [[-x, x] for x in A]

    heapq.heapify(AA)

    for i in range(M):
        x, y = heapq.heappop(AA)
        heapq.heappush(AA, [-(y//2), y//2])

    AAA = [x[1] for x in AA]
    return sum(AAA)


print(solve())


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

struct data{
	llong place;
	llong many;
	llong cost;

	data(){};
	data(llong place, llong many, llong cost) :
		place(place),
		many(many),
		cost(cost)
	{}

	bool operator<(const data &ri) const {
		return many == ri.many ?
			cost > ri.cost :
			many < ri.many;
	}
	bool operator<=(const data &ri) const {
		return many == ri.many ?
			cost >= ri.cost :
			many < ri.many;
	}
	bool operator>(const data &ri) const {
		return many == ri.many ?
			cost < ri.cost :
			many > ri.many;
	}
};

llong N, M, L;
vector<vector<data> > edges;

vector<llong> dijkstra(int start) {
	priority_queue<data, vector<data>, greater<data> > que;
	vector<data> dis(edges.size(), data(-1, inf, -inf));
	dis[start] = data(start, 0, L);

	que.push(dis[start]);
	while (que.size()) {
		data now = que.top();
		que.pop();
		if (dis[now.place] < now) continue;

		for (auto &edge: edges[now.place]) {
			data next(edge.place, now.many, now.cost - edge.cost);
			if (next.cost < 0) {
				next.cost = L - edge.cost;
				++next.many;
			}
			if(dis[next.place] <= next) continue;
			dis[next.place] = next;
			que.push(next);
		}
	}

	vector<llong> ret(N+1, -1);
	for (auto &d: dis) {
		if (d.many != inf)
			ret[d.place] = d.many;
	}

	return ret;
}


int main() {
	cin >> N >> M >> L;
	edges.resize(N + 1);
	llong A, B, C;
	for (int &&i = 0; i < M; ++i) {
		cin >> A >> B >> C;
		if (C > L) continue;
		edges[A].push_back(data(B, 0, C));
		edges[B].push_back(data(A, 0, C));
	}

	llong Q;
	vector<lpair> query;

	cin >> Q;
	query.resize(Q);
	for (auto &que: query)
		cin >> que.first >> que.second;

	vector<vector<llong>> ret(N + 1);
	for (int &&i = 1; i <= N; ++i) {
		ret[i] = dijkstra(i);
	}

	for (auto &que: query) {
		cout << ret[que.first][que.second] << endl;
	}

	return 0;
}

Measured memory_bytes: 9036
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)





int main() {
	ll n;
	in(n);
	string s;
	if (n % 2 != 0) {
		outn("No");
		return 0;
	}
	in(s);
	if (s.substr(0, n / 2) == s.substr(n / 2)) {
		outn("Yes");
		return 0;
	}
	outn("No");
	return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pr;

const ll INF = 1e18;

int N, M;
int a[2010], b[2010], c[2010];
ll x[1010];

int main()
{
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
	}

	for (int i = 1; i < N; i++)
		x[i] = -INF;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			x[b[j]] = max(x[b[j]],x[a[j]]+c[j]);
		}
	}

	ll A = x[N - 1];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			x[b[j]] = max(x[b[j]],x[a[j]]+c[j]);
		}
	}

	ll B = x[N - 1];
	if (A == B)cout << x[N - 1] << endl;
	else cout << "inf" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)450
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;

vector<pair<string,int>> vec;

bool cmp(pair<string,int>&a,pair<string,int>&b){
	if(a.first == b.first){
		return (a.second > b.second)?1:0;
	}else if(a.first < b.first)
		return 1;
	else
		return 0;

}

int main(){
	int n,p,i,map[101];
	string x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		cin >> x;
		cin >> p;
		vec.push_back(make_pair(x,p));
		map[p] = i+1;
	}
	
	sort(vec.begin(),vec.end(),cmp);
	for(i=0;i<n;i++)
		printf("%d\n",map[vec[i].second]);

	return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;


public class Main {
   static Scanner sc = new Scanner(System.in);

   public static void main(String[] args) {
	   while(sc.hasNext()){
		   new Main();
	   }
   }

   public Main() {
       new aoj0195().doIt();
   }
   class aoj0195 { 
	   String hitandblow(int a[], int b[]) {
		   int hit = 0;
			int hblow = 0;
			int blow = 0;
			String result = "";
			for (int i = 0; i < 4; i++) {
				if (a[i] == b[i]) {
					hit++;
				}
			}
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					if (a[i] == b[j]) {
						if(i != j){
							hblow++;
						}
					}
				}
			}
			blow = hblow ;

			result = hit + " " + hblow;

			return result;
		}
	   
       void doIt() {
   		int A[] = new int[4];
   		int B[] = new int[4];

   		for (int i = 0; i < 4; i++) {
   			A[i] = sc.nextInt();
   		}
   		for (int i = 0; i < 4; i++) {
   			B[i] = sc.nextInt();
   		}
   		System.out.println(hitandblow(A, B));
       }
   }
}

Measured memory_bytes: 18108
from operator import itemgetter

INF = 10 ** 10

H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

A_max = max(map(itemgetter(0), AB))

dp = [INF] * (H + A_max+1)
dp[0] = 0

for i in range(0, H+A_max+1):
    for A, B in AB:
        if A <= i:
            dp[i] = min(dp[i], dp[i-A] + B)

print(min(dp[H:]))

Measured memory_bytes: 40688
import Control.Monad
import Data.List

solve i n (x,y) []     | i > n = mod x 1000000007
                       | otherwise = solve (i+1) n ((x+y),x) []
solve i n (x,y) (a:as) | i > n = mod x 1000000007
                       | i == a = solve (i+1) n (0,x) as
                       | otherwise = solve (i+1) n ((x+y),x) (a:as)
                        
main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    as <- sort . map read <$>replicateM m getLine :: IO [Int]
    print $ solve 1 n (1,0) as

Measured memory_bytes: 60120
import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	if (n == 1) {
		println("Hello World")
	} else if (n == 2) {
		println(scanner.nextInt() + scanner.nextInt())
	}
	scanner.close()
}

Measured memory_bytes: 31256
#include <stdio.h>
#include<stdlib.h>
#define ll long long

int main(void){
  ll n,m;
  scanf("%lld %lld",&n,&m);
  ll array[n];
  for(ll i=0;i<n;++i) array[i] = 0;
  
  for(ll i=0;i<m;++i){
    ll a,b;
    scanf("%lld %lld",&a,&b);
    --a;
    --b;
    array[a]++;
    array[b]++;
  }
  for(ll i=0;i<n;++i){
    printf("%lld\n",array[i]);
  }

  return 0;
}



Measured memory_bytes: 1720
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

const int MAXN = 2e5 + 10;
typedef long long ll;

using namespace std;

int main()
{
	int x;
	cin >> x;
	if(x==0) cout << 1 <<endl;
	if(x==1) cout << 0 <<endl;
	return 0;
} 

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

template<unsigned long long SIZE> class unionFind{
    protected:
        long long uni[SIZE];
        long long diff_weight[SIZE];
    public:
        unionFind(){
            for(int i=0;i<SIZE;i++){
                uni[i]=-1;
                diff_weight[i]=0;
            }
        }
        unsigned long long root(unsigned long long a){
            if(a>=SIZE) throw std::range_error("与えられたインデックスが木の範囲外です");
            if(uni[a]<0) return a;
            else{
                unsigned long long r=root(uni[a]);
                diff_weight[a]+=diff_weight[uni[a]];
                return uni[a]=r;
            }
        }
        long long weight(unsigned long long a){
            root(a);
            return diff_weight[a];
        }
        long long diff(unsigned long long a, unsigned long long b){
            if(isSame(a,b)) return weight(b)-weight(a);
            else return INT64_MAX;
        }
        unsigned long long count(unsigned long long a){
            return -uni[root(a)];
        }
        bool merge(unsigned long long a, unsigned long long b, long long w=1){
            w+=weight(a);  w-=weight(b);
            a=root(a);  b=root(b);
            if(a==b) return false;
            if(uni[a]>uni[b]){
                swap(a, b);
                w=(-w);
            }
            uni[a]+=uni[b];
            uni[b]=a;
            diff_weight[b]=w;
            return true;
        }
        bool isSame(unsigned long long a,unsigned long long b){
            return root(a)==root(b);
        }
};

int main(){
    int N,M;
    cin >> N >> M;
    unionFind<100001> uf;
    for(int i=0;i<M;i++){
        int L,R,D;
        cin >> L >> R >> D;
        if(uf.isSame(L,R)){
            if(uf.diff(L,R)!=D){
                cout << "No" << endl;
                return 0;
            }
        }else uf.merge(L,R,D);
    }
    cout << "Yes" << endl;

    return 0; 
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll sum = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        if (i % 2 == 0){
            if (sum <= 0) {
                cnt += 1 - sum;
                sum = 1;
            }
        }else{
            if (sum >= 0){
                cnt += sum + 1;
                sum = -1;
            }
        }
    }

    sum = 0;
    ll cnt2 = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        if (i % 2 != 0){
            if (sum <= 0) {
                cnt2 += 1 - sum;
                sum = 1;
            }
        }else{
            if (sum >= 0){
                cnt2 += sum + 1;
                sum = -1;
            }
        }
    }

    cout << min(cnt, cnt2) << endl;
}

Measured memory_bytes: 1024
import collections 

N = int(input())
string = [""] * N

for i in range(N):
  s = input()
  string[i] = s

freq = collections.Counter(string)
mfreq = freq.most_common()
mtime = mfreq[0][1]

mosts = sorted([mfreq[i][0] for i in range(len(mfreq)) if mfreq[i][1] == mtime])

for s in mosts:
  print(s)

Measured memory_bytes: 49260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
  int sum = 0;
  REP(x, N) {
    sum += B.at(A.at(x)-1);
  }
  dv("sum", sum);
  REP(x, N-1) {
    if (A.at(x)+1 == A.at(x+1)) {
      sum += C.at(A.at(x)-1);
    }
  }
  dv("sum", sum);
  cout << sum << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&B[i]);
  }
  std::vector<long long> C(N-1);
  for(int i = 0 ; i < N-1 ; i++){
    scanf("%lld",&C[i]);
  }
  solve(N, std::move(A), std::move(B), std::move(C));
}


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

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

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    ll count = 0;
    cin >> N >> K;
    repi2(i, K, N + 1) {
        ll ma = (N + 1) * (N + 2) / 2 - (N + 1 - i) * (N + 1 - i + 1) / 2;
        ll mi = i * (i + 1) / 2;
        count += ma - mi + 1;
        count %= MOD;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<int > > g;
int v[100009][2];
int dp[100009][2],MOD=1e9+7;
//state 1 ->white
//state 0- >black
int solve(int node,int state,int parent)
{
//	cout<<"*"<<node<<" "<<state<<endl;
	v[node][state]=1;
	if(node!=1&&g[node].size()==1)
	{
		return 1;
	}
	if(dp[node][state]!=-1)
		return dp[node][state];
	else
	{
		if(state)
		{
			int ans=1;
			for(int x=0;x<g[node].size();x++)
			{
				
					if(g[node][x]!=parent)
					ans=((ans%MOD)*((solve(g[node][x],0,node)%MOD+solve(g[node][x],1,node)%MOD)%MOD))%MOD;
				
			}
			dp[node][state]=ans;

		}
		else
		{
			int ans=1;
			for(int x=0;x<g[node].size();x++)
			{
				if(g[node][x]!=parent)
					ans=((ans%MOD)*(solve(g[node][x],1,node)%MOD))%MOD;
			}
			dp[node][state]=ans;
		}	
	}
	return dp[node][state];
}
signed main()
{
	int n,a,b;
	cin>>n;
	g.resize(n+1);
	for(int i=1;i<n;i++)
	{
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(dp,-1,sizeof dp);
//	v.assign(n+1,-1);

	cout<<(solve(1,0,-1)+solve(1,1,-1))%MOD<<endl;
	//cout<<solve(1,0,-1)<<endl;
/*	for(int i=1;i<=n;i++)
	{
		cout<<dp[i][0]<<"  "<<dp[i][1]<<endl;
	}*/
}

Measured memory_bytes: 15744
N = int(input())
arr = sorted(list(map(int,input().split())))

carr = [0 for _ in range(10**5+1)]

for i in range(N):
    tmp = arr[i]
    carr[tmp] += 1
  
max = 0
for i in range(10**5-2):
    sum = carr[i] + carr[i+1] + carr[i+2]
    if max < sum:
        max = sum
print(max)

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main(){
  string w;
  cin >> w;
  int L=w.size()-1;
  sort(w.begin(),w.end());
  int num=0;
  int ans=0;
  for(int i=0; i<L; i++){
    if(w.at(i)==w.at(i+1)){
      num++;
    }
    else{
      if(num%2==0) ans++;
      num=0;
    }
  }
  if(L==0 or ans>0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

  ll n;
  cin >> n;
  
  unordered_map<string, int> M;
  set<string> ans;
  int max_occ=0;
  while(n--){
    string s;
    cin >> s;
    
    M[s]++;
    max_occ = max(max_occ, M[s]);
  }
  
  for(auto x: M){
    if(x.second == max_occ) ans.insert(x.first);
  }
  
  for(auto x: ans) cout << x << endl;
  
    return 0;
}

Measured memory_bytes: 33480
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int i,n,t,p=0,ara[100000],j,k;
   cin>>n;
   for(i=0;i<n;i++){
    cin>>ara[i];
   }
   sort(ara,ara+n);
   for(i=0;i<n-2;i++){
      for(j=i+1;j<n-1;j++){
        for(k=j+1;k<n;k++){
            if(ara[i]+ara[j]>ara[k]){
                p++;
            }
           // cout<<ara[k]<<" ";
        }
        //cout<<ara[j]<<" ";
      }
     // cout<<ara[i];
   }
   cout<<p<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in);){
			long a = sc.nextLong();
			long b = sc.nextLong();
			
			System.out.format("%d %d %.6f\n", a / b, a % b, (double)a / b);
		}
	}
}


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

using namespace std;

using int64 = long long;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
  int N, M, U[200000], V[200000];

  cin >> N >> M;
  UnionFind latte(N + N), malta(N);
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    latte.unite(x + N, y);
    latte.unite(y + N, x);
    malta.unite(x, y);
  }

  int64 uku = 0, one = 0, two = 0;
  for(int i = 0; i < N; i++) {
    if(malta.find(i) != i) continue;
    if(malta.size(i) == 1) ++uku;
    else if(latte.find(i) != latte.find(i + N)) ++two;
    else ++one;
  }
  cout << (uku * N + two * (one + two)) * 2 - uku * uku + one * one << endl;
}



Measured memory_bytes: 1408
//AtCoder Grand Contest 005 A問題
#include <bits/stdc++.h>
using namespace std;

int main(){
	char x[234567];
	scanf("%s", x);
	int len = strlen(x);
	int ans = strlen(x);
	int snum = 0;
	for(int i=0; i<len; i++){
		if(x[i] == 'S'){
			snum++;
		}
		if(x[i] == 'T' && snum > 0){
			ans -= 2;
			snum--;
		}
	}
	printf("%d\n", ans);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  cout << (a*n<b ? a*n :b) << endl;
  return 0;
} 

Measured memory_bytes: 3596