akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F(j,a,b) for(int j=(a);j<=(b);++j)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define Mod 1000000007
			
using namespace std;
typedef long long ll;
typedef pair<ll,int> pli;
 
int n,m,S,T;
ll Ans;
int U[200001],V[200001],D[200001];
int h[100001],nxt[400001],to[400001],w[400001],tot;
void ins(int x,int y,int z){nxt[++tot]=h[x];to[tot]=y;w[tot]=z;h[x]=tot;}
 
ll d1[100001],d2[100001],g1[100001],g2[100001];bool v1[100001],v2[100001];
priority_queue<pli,vector<pli>,greater<pli> > pq;
 
void Dij(ll*d,ll*g,bool*v,int s){
    d[s]=0ll;
    pq.push(pli(0ll,s));
    g[s]=1;
    while(!pq.empty()){
        pli P=pq.top(); pq.pop();
        int u=P.second; ll du=P.first;
        if(v[u]||d[u]<du) continue;
        v[u]=1;
        eF(i,u){
            if(d[to[i]]==du+w[i])
                g[to[i]]=(g[to[i]]+g[u])%Mod;
            if(d[to[i]]>du+w[i])
                g[to[i]]=g[u],
                d[to[i]]=du+w[i], pq.push(pli(d[to[i]],to[i]));
        }
    }
}
 
int main(){
    int x,y,z;
    scanf("%d%d",&n,&m);
    scanf("%d%d",&S,&T);
    F(i,1,m) scanf("%d%d%d",&x,&y,&z), ins(x,y,z), ins(y,x,z), U[i]=x, V[i]=y, D[i]=z;
    memset(d1,0x3f,sizeof d1);
    Dij(d1,g1,v1,S);
    memset(d2,0x3f,sizeof d2);
    Dij(d2,g2,v2,T);
    ll Dist=d1[T];
    Ans=g1[T]*g1[T]%Mod;
    F(i,1,n){
        if(d1[i]+d2[i]==Dist&&d1[i]==d2[i])
            Ans=(Ans-g1[i]*g1[i]%Mod*g2[i]%Mod*g2[i]%Mod)%Mod;
    }
    int u,v,d;
    F(i,1,m){
        u=U[i], v=V[i], d=D[i];
        if(d1[u]+d+d2[v]==Dist && d1[u]+d>d2[v] && d2[v]+d>d1[u]){
            Ans=(Ans-g1[u]*g2[v]%Mod*g1[u]%Mod*g2[v]%Mod)%Mod;
        }
        u=V[i], v=U[i], d=D[i];
       
	    if(d1[u]+d+d2[v]==Dist && d1[u]+d>d2[v] && d2[v]+d>d1[u]){
            Ans=(Ans-g1[u]*g2[v]%Mod*g1[u]%Mod*g2[v]%Mod)%Mod;
        }
    }
    printf("%lld",(Ans%Mod+Mod)%Mod);
    return 0;
}

Measured memory_bytes: 12656
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

_int64 d[5000];
int a[5000][3];

int main()
{
  _int64 ans1,ans2;
  int i,j,n,m;
  scanf("%d%d",&n,&m);
  for (i=0;i<m;i++)
  {
    scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    a[i][0]--;
    a[i][1]--;
  }
  for (i=0;i<n;i++)
    d[i]=-(1LL<<60);
  d[0]=0;
  
  for (i=0;i<n+n+n;i++)
  {
    for (j=0;j<m;j++)
    {
      if (d[a[j][0]]!=-(1LL<<60))
      {
        if (d[a[j][0]]+a[j][2]>d[a[j][1]])
          d[a[j][1]]=d[a[j][0]]+a[j][2];
      }
      /*
      if (d[a[j][1]]!=-(1LL<<60))
      {
        if (d[a[j][1]]+a[j][2]>d[a[j][0]])
          d[a[j][0]]=d[a[j][1]]+a[j][2];
      }
      */
    }
  }
  ans1=d[n-1];
  for (i=0;i<n;i++)
  {
    for (j=0;j<m;j++)
    {
      if (d[a[j][0]]!=-(1LL<<60))
      {
        if (d[a[j][0]]+a[j][2]>d[a[j][1]])
          d[a[j][1]]=d[a[j][0]]+a[j][2];
      }
      /*
      if (d[a[j][1]]!=-(1LL<<60))
      {
        if (d[a[j][1]]+a[j][2]>d[a[j][0]])
          d[a[j][0]]=d[a[j][1]]+a[j][2];
      }
      */
    }
  }
  ans2=d[n-1];
  if (ans1==ans2)
    printf("%lld\n",d[n-1]);
  else printf("inf\n");
  return 0;
}

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

using namespace std;

int main () {
  int five_count = 0,seven_count = 0;
  vector<int> vec(3);
  
  for(int i = 0; i < 3; i++){
    cin >> vec.at(i);
    if(vec.at(i) == 5) five_count++;
    if(vec.at(i) == 7) seven_count++;
  }
  if(five_count == 2 && seven_count == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 256
import java.io.*;
 
class Main
{
       public static void main (String[] args) throws IOException
       {
 
       BufferedReader br =
        new BufferedReader(new InputStreamReader(System.in));
 
       String str1 =br.readLine();
       String str2[] =str1.split(" ");
       int a =Integer.parseInt(str2[0]);
       int b =Integer.parseInt(str2[1]);
       int c =a*b;       
       int d =2*(a+b);
 
       System.out.println(c + " " + d);
 
    }
}

Measured memory_bytes: 24148
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

int h, w, v[9][9];
char arr[9][9];

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>h>>w;
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			cin>>arr[i][j];
		}
	}
	int a=0, b=0;
	if(arr[0][0]!='#'){
		cout<<"Impossible";
		return 0;
	}
	while(a!=h-1||b!=w-1){
		v[a][b]=1;
		if(arr[a+1][b]=='#'&&arr[a][b+1]!='#'){
			a++;
		}else if(arr[a][b+1]=='#'&&arr[a+1][b]!='#'){
			b++;
		}else{
			cout<<"Impossible";
			return 0;
		}
	}
	v[h-1][w-1]=1;
	for (int i = 0; i < h; ++i){
		for (int j = 0; j < w; ++j){
			if(arr[i][j]=='#'&&v[i][j]!=1){
			cout<<"Impossible";
			return 0;
		}
		}
	}
	cout<<"Possible";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  int anscount = 0;
  int max = 0;
  
  for(int i = 1; i <= N; i++){
    anscount = 0;
    if(i %2 != 0){//奇数のみ取得
      //その奇数を1からiまで割り続けて割り切れる値が何個あるか考える
      int gg = i;
      while(gg){//iがゼロになるまで
        if(i %gg == 0){
          anscount++;
          gg--;
        }else{
          gg--;
        }
      }
      if(anscount >= 8){
         max++;
      }
    }
  }
  cout << max << endl;

}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
void chmin(T &x, T y) {
    x = min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
    x = max(x, y);
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//-----------------------------------------------------------------------------

const int maxn = 1e5 + 5;
int cnt[maxn];
int can[maxn];

int main() {
    srand(time(NULL));

    retry:
#ifdef LOCAL
    //gen();
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("lock.in", "r", stdin);
    //freopen("lock.out", "w", stdout);
#endif

    int n, m;
    scanf("%d %d", &n, &m);
    fill(cnt + 1, cnt + n + 1, 1);
    can[1] = 1;

    for (int i = 0; i < m; i++) {
        int x, y;
        scanf("%d %d", &x, &y);

        if (cnt[x] == 1) {
            cnt[x]--;
            cnt[y]++;
            if (can[x]) {
                can[x] = 0;
                can[y] = 1;
            }
        } else {
            cnt[x]--;
            cnt[y]++;
            if (can[x]) {
                can[y] = 1;
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += can[i];
    }

    printf("%d\n", ans);

    return 0;
}

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

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

    int64_t count = 0;

    if (a == 0) count++;
    int64_t b2 = b - (b % x);
    if (a > 0) {
        count += b2 / x - (a - 1) / x;
    } else {
        count += b2 / x - a / x;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n;
	cin >> n;
	vector<int>a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	vector<P>c(n), d(n);
	rep(i, n) {
		c[i].first = b[i];
		c[i].second = a[i];
	}
	sort(c.begin(), c.end());
	int time(0);
	rep(i, n) {
		time += c[i].second;
		if (time > c[i].first) {
			//cout << c[i].first << " " << c[i].second;
			cout << "No";
			return 0;
		}
		
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 7980
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
auto scan = []{ static LL a; scanf("%lld", &a); return a;};



int main() {
  string s;
  getline(cin, s);
  for (LL i = 0; i < s.size() - 1; ++i) if(s[i] == 'A' && s[i+1] == 'C') return 0 * puts("Yes");
  puts("No");
}


/*
 4
 3
 0 0
 1 1
 1 2
 3
 1 2
 2 4
 4 8
 4
 1 1
 2 2
 3 3
 4 4
 5
 0 0
 2 0
 0 2
 2 2
 1 1
 
 */


Measured memory_bytes: 256
#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 < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n; cin>>n;
	map<ll,ll> mp;
	vl vec(0);
	rep(i,0,n){
		ll a; cin>>a;
		mp[a]++;
	}
	for(auto c:mp){
		rep(i,0,c.second/2){
			vec.push_back(c.first);
		}
	}
	if(vec.size()<2){
		cout<<0<<endl;
		return 0;
	}
	sort(all(vec));
	cout<<vec[vec.size()-1]*vec[vec.size()-2]<<endl;



	return 0;
}

Measured memory_bytes: 9656
#include<iostream>
#include<vector>
#include<queue>
#include<string>
using namespace std;
queue<vector<int> >Q;
string S; int p[14];
int main() {
	while (cin >> S) {
		vector<int>s; int g[10] = { 0,0,0,0,0,0,0,0,0,0 };
		for (int i = 0; i < 13; i++) {
			p[i] = S[i] - '0'; g[p[i]]++;
		}
		for (int i = 0; i < 10; i++)s.push_back(g[i]);
		s.push_back(1); int f[10] = { 0,0,0,0,0,0,0,0,0,0 };
		for (int h = 1; h < 10; h++) {
			s[h]++; Q.push(s); int OK = 0;
			while (!Q.empty()) {
				vector<int>t = Q.front(), u; Q.pop(); int sum = 0;
				for (int i = 0; i < 10; i++) sum += t[i];
				if (sum == 0)OK = 1;
				for (int i = 0; i < 10; i++) {
					if (t[i] >= 2 && t[10] >= 1) { u = t; u[i] -= 2; u[10] = 0; Q.push(u); }
					if (t[i] >= 3) { u = t; u[i] -= 3; Q.push(u); }
				}
				for (int i = 0; i < 8; i++) {
					if (t[i] >= 1 && t[i + 1] >= 1 && t[i + 2] >= 1) {
						u = t; u[i] -= 1; u[i + 1] -= 1; u[i + 2] -= 1; Q.push(u);
					}
				}
			}
			for (int i = 0; i < 10; i++) {
				if (s[h] >= 5)OK = 0;
			}
			f[h] = OK; s[h]--;
		}
		int V = 0;
		for (int i = 1; i < 10; i++) {
			if (f[i] == 1) {
				if (V >= 1) { cout << ' '; }
				cout << i; V++;
			}
		}
		if (V == 0)cout << '0';
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    for(int rs=0; rs<=n; rs+=r){
        for(int gs=0; gs<=n-rs; gs+=g){
            if((n-gs-rs)%b==0) ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    ll n;
    cin>>n;
    vi a(n);
    fo(i,0,n) cin>>a[i];
    ll ans=0;
    fo(i,0,n)
    {
      if(i%2==0 && a[i]%2) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    if (a < b){
        ans = ans + 1;
    }
    if (b < c){
        ans = ans + 1;
    }
    if (ans == 2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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


using namespace std;


template<long long M>
class modint {
    public:
        long long a;
        modint(const long long x = 0LL) : a((x % M + M) % M) {}
        long long &value() { return a; }
        modint operator+(const modint rhs) const {
            return modint(*this) += rhs;
        }
        modint operator-(const modint rhs) const {
            return modint(*this) -= rhs;
        }
        modint operator*(const modint rhs) const {
            return modint(*this) *= rhs;
        }
        modint operator/(const modint rhs) const {
            return modint(*this) /= rhs;
        }
        modint &operator+=(const modint rhs) {
            a += rhs.a;
            if (a >= M) {
                a -= M;
            }
            return *this;
        }
        modint &operator-=(const modint rhs) {
            if (a < rhs.a) {
                a += M;
            }
            a -= rhs.a;
            return *this;
        }
        modint &operator*=(const modint rhs) {
            a = a * rhs.a % M;
            return *this;
        }
        modint pow(long long n) const {
            modint ret(1);
            modint x = *this;
            while (n) {
                if ((n & 1) == 1) {
                    ret *= x;
                }
                n >>= 1;
                x *= x;
            }
            return ret;
        }
        modint inv() const {
            return pow(M - 2);
        }
        modint &operator/=(const modint rhs) {
            return *this *= rhs.inv();
        }
};

const long long M = 1000000007;

using mint = modint<M>;
using ll = long long;


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

    ll acc = accumulate(A.begin(), A.end(), 0LL);
    mint ans = 0;
    for (ll i = 0; i < A.size() - 1; i++) {
        acc -= A[i];
        ans += mint(A[i]) * mint(acc);
    }
    cout << ans.a << endl;
}


Measured memory_bytes: 4844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
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;
}
ll stack[LIMIT2],queue[LIMIT2];
int enqueue(ll n){
    if(queue[0]+queue[1]>=LIMIT2) return -1;
    queue[queue[0]+queue[1]] = n;
    queue[1]++;
    return 1;
}
ll dequeue(){
    ll result;
    if(queue[1]<=0) return -1;
    result = queue[queue[0]];
    queue[0]++;
    queue[1]--;
    if(queue[1]==0){
        queue[0] = 2;
    }
    return result;
}
void initialize(){
    //stack[0] = 0;
    queue[0] = 2;
    queue[1] = 0;
}
std::vector<int> bfs[100005];
std::vector<int> to[100005];
int main(void){
  initialize();
  ll n,m,i,j,k;
  int result[100005]={0};
  int a,b;
  int visited[LIMIT2]={0};
  int parent[LIMIT2]={0};
  int deg[LIMIT2]={0};
  int tmp,size;
  std::vector<int> uf;
  scanf("%lld %lld %lld",&n,&m,&k);
  rep(i,n){
    parent[i]=-1;
  }
  rep(i,m){
    scanf("%d %d",&a,&b);
    a--;
    b--;
    deg[a]++;
    deg[b]++;
    bfs[a].push_back(b);
    bfs[b].push_back(a);
  }
  rep(i,k){
    scanf("%d %d",&a,&b);
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n){
    if(visited[i]==1) continue;
    enqueue(i);
    size=0;
    while(queue[1]>=1){
      j = dequeue();
      if(visited[j]==1) continue;
      uf.push_back(j);
      visited[j]=1;
      while(bfs[j].size()>0){
        tmp = bfs[j][bfs[j].size()-1];
        if(visited[tmp]==0) enqueue(tmp);
        bfs[j].pop_back();
      }
    }
    size = uf.size();
    while(uf.size()>0){
      tmp = uf[uf.size()-1];
      result[tmp] = size;
      parent[tmp] = i;
      uf.pop_back();
    }
  }
  rep(i,n) {
    int ans = result[i]-1-deg[i];
    for (int u : to[i]) {
      if (parent[i]==parent[u]) --ans;
    }
    printf("%d%c", ans, i==n-1?'\n':' ');
  }
  return 0;
}



Measured memory_bytes: 19960
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int doubles, lengths, dat[8002], tmp[8002], rank_[8002];
bool compare_suffix(int i, int j) {
	if (dat[i] == dat[j]) {
		int ri = (i + doubles <= lengths ? dat[i + doubles] : -1);
		int rj = (j + doubles <= lengths ? dat[j + doubles] : -1);
		return ri < rj;
	}
	return dat[i] < dat[j];
}
inline vector<int> suffix_array(string S) {
	lengths = S.size();
	vector<int> arrays(lengths + 1);
	for (int i = 0; i <= lengths; i++) {
		arrays[i] = i;
		dat[i] = i < lengths ? S[i] : -1;
	}
	for (doubles = 1; doubles <= lengths; doubles <<= 1) {
		sort(arrays.begin(), arrays.begin() + lengths + 1, compare_suffix);
		tmp[arrays[0]] = 0;
		for (int i = 1; i <= lengths; i++) tmp[arrays[i]] = tmp[arrays[i - 1]] + (compare_suffix(arrays[i - 1], arrays[i]) ? 1 : 0);
		for (int i = 0; i <= lengths; i++) dat[i] = tmp[i];
	}
	return arrays;
}
inline vector<int> lcp(string s, vector<int> sa) {
	vector<int> ret; ret.resize(lengths + 1);
	for (int i = 0; i <= lengths; i++) rank_[sa[i]] = i;
	int h = 0; ret[0] = 0;
	for (int i = 0; i < lengths; i++) {
		int j = sa[rank_[i] - 1];
		if (h > 0) h--;
		for (; j + h < lengths && i + h < lengths; h++) {
			if (s[j + h] != s[i + h]) break;
		}
		ret[rank_[i] - 1] = h;
	}
	return ret;
}
string s, t; int sl;
int main() {
	while (cin >> s >> t) {
		sl = s.size();
		s += '$' + t;
		vector<int> v1 = suffix_array(s);
		vector<int> v2 = lcp(s, v1);
		int ret = 0;
		for (int i = 0; i < lengths; i++) {
			if ((v1[i] < sl) != (v1[i + 1] < sl)) {
				ret = max(ret, v2[i]);
			}
		}
		printf("%d\n", ret);
	}
	return 0;
}

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

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int r; cin >> r;
  cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < 9; ++i) {
        for (int j = 0; j < 9; ++j) {
            if((i+1)*(j+1) == n) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

VI d(6);

void change(int i,int j,int k,int l){
    i--; j--; k--; l--;
    int tem=d[i];
    d[i]=d[j];
    d[j]=d[k];
    d[k]=d[l];
    d[l]=tem;
}

int main(){
    int i,j;
    while(1){
        int n;
        cin>>n;
        if(n==0) return 0;
        d={1,2,3,4,5,6};
        int sum=1;
        for(i=0;i<n;i++){
            string s;
            cin>>s;
            switch(s[0]){
                case 'N': change(1,2,6,5); break;
                case 'E': change(1,4,6,3); break;
                case 'W': change(1,3,6,4); break;
                case 'S': change(1,5,6,2); break;
                case 'R': change(2,3,5,4); break;
                case 'L': change(2,4,5,3); break;
            }
            sum+=d[0];
            //cout<<d[0]<<endl;
        }
        cout<<sum<<endl;
    }

}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

int main() {
    int N,M;cin >> N >> M;
    P A[N] = {};
    for (int i = 0;i < N;i++){
        cin >> A[i].first >> A[i].second;
    }
    sort(A,A + N);
    ll ans = 0;
    for (int i = 0;i < N;i++){
        if (A[i].second < M){
            ans += (A[i].first * A[i].second);
            M -= A[i].second;
        }
        else{
            ans += A[i].first * M;
            break;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N,D;cin>>N>>D;
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++) cin>>X.at(i).at(j);
  }
  int Nt=N*(N-1)/2;
  vector<int> A(Nt);
  int dist=0;
  int F=0;
  for(int i=0;i<N-1;i++){
    for(int k=i+1;k<N;k++){
      for(int j=0;j<D;j++) dist +=(X.at(i).at(j)-X.at(k).at(j))*(X.at(i).at(j)-X.at(k).at(j));
      A.at(F)=dist;
      dist=0;
      F++;
    }
  }
  int count=0;
  for(int h=1;h<130;h++){
    for(int i=0;i<Nt;i++){
      if(A.at(i)==h*h) count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k,dice; cin>>n>>k;
	vector<double>pref(n+1,0.0);
	for(int i=1;i<=n;i++){
		cin>>dice;
		pref[i]=(double)dice*(dice+1.0)/2.0;
		pref[i]/=dice;
		pref[i]+=pref[i-1];
	}
	double mx=0;
	for(int i=k;i<=n;i++)
		mx=max(mx, pref[i]-pref[i-k]);
	cout<<fixed<<setprecision(12)<<mx<<'\n';
	return 0;
}


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

int main(){
    int line[3];
    
    cin >> line[0];
    cin >> line[1];
    cin >> line[2];

    if (line[0] == line[1]){
        if(line[1] == line[2]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  rep(i,h) {
    string s;
    cin >> s;
    rep(i,2) cout << s << endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//整数の合計入力数
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int in = Integer.parseInt(line1);

		//半角空白区切りで数値がStringで入力→int配列yを作成
		String line2 = sc.nextLine();
		String[] x = line2.split(" ");
		int[] y = new int [in];

		//String配列xの文字を数値にしてint配列ｙに入れる
		for (int i = 0; i < in; i++) {
			y[i] = Integer.parseInt(x[i]);
		}

		//long変数ｚを初期化し、配列ｙの値を合計していく
		long z = 0;
		for (int i = 0; i < in; i++) {
			z += y[i];
		}

		//配列ｙを昇順にて並べ替える
		Arrays.sort(y);

		//最小値、最大値、合計値の順で出力する
		System.out.println(y[0] + " " + y[in-1] + " " + z);

	}

}



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

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

    vector<int> cnt(55);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#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>;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(s == u) a--;
	else b--;
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main()
{
	int a, b;
 
	cin >> a >> b;
 
	if (((a + b) % 3) == 0)
	{
		cout << "Possible" << endl;
	}
	else if ((a % 3) == 0)
	{
		cout << "Possible" << endl;
	}
	else if ((b % 3) == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
int w, h, c;

int gcd(int x, int y) {
	if (y == 0)return x;

	int add = x % y;
	gcd(y, add);
}

int main() {

	cin >> w >> h >> c;

	int n = gcd(max(w, h), min(w, h));

	cout << (w/n)*(h/n)*c << endl;

}


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

int main(){
	int n, minj, count = 0;
	cin >> n;
	int A[n];
	for(int i = 0; i < n; i++)
		cin >> A[i];

	for(int i = 0; i < n; i++){
		minj = i;
		for(int j = i; j < n; j++){
			if(A[j] < A[minj])
				minj = j;
		}
      swap(A[i], A[minj]);
	   if(i != minj)
           count++;
	}

	for(int i = 0; i < n; i++){
		if(i > 0)
			cout << " ";
		cout << A[i];
	}
	cout << endl << count << endl;
	return 0;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> x(N + 1);
	for (int i{}; i < N; i++) scanf("%lld", &x[i]);
	x[N] = x[N - 1] + 1;
	int64_t L;
	scanf("%lld", &L);

	using vi = std::vector<int>;
	int size{1};
	while ((1 << (size - 1)) < N) size++;
	std::vector<vi> table(N + 1, vi(size));
	table.back()[0] = N;
	for (int i{N - 1}, prev{N}; i >= 0; i--)
	{
		while (x[prev] > x[i] + L)
			prev--;
		table[i][0] = prev;
	}
	for (int i{}; i + 1 < size; i++)
		for (int j{}; j <= N; j++)
			table[j][i + 1] = table[table[j][i]][i];
	

	// for (int i{}; i < N; i++)
	// {
	// 	printf("%lld: ", x[i]);
	// 	for (auto& f: table[i]) printf("%d ", f);
	// 	putchar('\n');
	// }
	int Q;
	scanf("%d", &Q);
	for (int i{}; i < Q; i++)
	{
		int from, to;
		scanf("%d%d", &from, &to);
		from--;
		to--;
		if (from > to) std::swap(from, to);
		int ans{}, now{from};
		for (int i{size - 1}; i >= 0; i--)
		{
			if (table[now][i] > to) continue;
			ans += 1 << i;
			now = table[now][i];
		}
		if (now < to) ans++;
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 11776
H,W=[int(x) for x in input().split()]
N=int(input())
a=[int(x) for x in input().split()]
s=[]
for i in range(N):
    s= s+([str(i+1)]*a[i])
for l in range(H):
    if l%2==0:
        print(" ".join(s[W*l:W*(l+1)]))
    else:
        print(" ".join(s[W*l:W*(l+1)][::-1]))

Measured memory_bytes: 48476
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
const int SQ=10000;
const int MAX_N=200000;
deque<int> a[MAX_N/SQ+10];
multiset<int> Min[MAX_N/SQ+10];
int N,Q;
int main()
{
	scanf("%d %d",&N,&Q);
	for(int i=0;i<N;i++)
	{
		int x=i/SQ,k;
		scanf("%d",&k);
		a[x].pb(k);
		Min[x].insert(k);
	}
	for(int i=0;i<Q;i++)
	{
		int type,l,r,pos,val;
		scanf("%d",&type);
		if(type==0)
		{
			scanf("%d %d",&l,&r);
			int lx=l/SQ,ly=l%SQ,rx=r/SQ,ry=r%SQ;
			if(lx==rx)
			{
				int f=a[rx][ry];
				a[rx].erase(a[rx].begin()+ry);
				a[rx].insert(a[rx].begin()+ly,f);
			}
			else
			{
				int f=a[rx][ry];
				a[rx].erase(a[rx].begin()+ry);
				Min[rx].erase(Min[rx].find(f));
				for(int j=lx;j<rx;j++)
				{
					int b=a[j].back();
					a[j].pop_back();
					Min[j].erase(Min[j].find(b));
					a[j+1].push_front(b);
					Min[j+1].insert(b);
				}
				a[lx].insert(a[lx].begin()+ly,f);
				Min[lx].insert(f);
			}
		}
		else if(type==1)
		{
			scanf("%d %d",&l,&r);
			int lx=l/SQ,ly=l%SQ,rx=r/SQ,ry=r%SQ;
			int ans=INF;
			if(lx==rx)
			{
				for(int j=ly;j<=ry;j++)ans=min(ans,a[lx][j]);
			}
			else
			{
				for(int j=ly;j<SQ;j++)ans=min(ans,a[lx][j]);
				for(int j=lx+1;j<rx;j++)ans=min(ans,*Min[j].begin());
				for(int j=0;j<=ry;j++)ans=min(ans,a[rx][j]);
			}
			printf("%d\n",ans);
		}
		else
		{
			scanf("%d %d",&pos,&val);
			int px=pos/SQ,py=pos%SQ;
			int f=a[px][py];
			Min[px].erase(Min[px].find(f));
			Min[px].insert(val);
			a[px][py]=val;
		}
	}
	return 0;
}

Measured memory_bytes: 11480
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=998244353;
const ll mod=998244353;
signed main(){
    string s;cin>>s;
    reverse(all(s));
    int n=s.size();
    int ma;cin>>ma;
    int cnt=0;
    vector<int>b(0);
    int la=0;
    rep(i,n){
        if(s[i]=='1')cnt++;
        else{
            b.pb(cnt-la);
            la=cnt;
        }
    }
    if(cnt==n){
        cout<<1<<endl;
        return 0;
    }
    ma=min(cnt,ma);
    int m=b.size();
    b.pb(cnt-la);
    vector<vector<vector<int> > > dp(m+1,vector<vector<int> >(ma+2,vector<int>(cnt+2)));
    dp[0][0][0]=1;
    rep(i,m){
        rep(j,ma+1){
            vector<ll>c(cnt+1);
            rep(k,cnt+1){
                c[k]+=dp[i][j][k];
                REP(l,1,b[i]+1){
                    if(j+l>ma)continue;
                    dp[i+1][j+l][k+l]+=dp[i][j][k];
                    dp[i+1][j+l][k+l]%=mod;
                }
                //cout<<dp[i][j][k]<<' ';
            }
            for(int k=cnt-1;k>=0;k--){
                c[k]+=c[k+1];
                c[k]%=mod;
            }
            rep(k,cnt+1){
                dp[i+1][j][k]+=c[k];
                dp[i+1][j][k]%=mod;
            }
            //cout<<endl;
        }
        //cout<<endl;
    }
    ll ans=0;
    rep(j,ma+1){
        rep(k,cnt+1){
            ans+=dp[m][j][k];
            ans%=mod;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 17696
n=int(input())
words = [input() for i in range(n)]
already = []
for i in range(n):
  word = words[i]
  if i==0:
    already.append(word)
    bottom = word[-1]
  else:
    top = word[0]
    if top != bottom or word in already:
      print("No")
      exit()
    bottom = word[-1]
    already.append(word)
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],cnt[1000010],ma;
int main(){
	int i,j,k;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		ma=max(ma,a[i]);
		cnt[a[i]]++;
	}
	sort(a+1,a+1+n);
	int ans=0;
	for(i=1;i<=n;i++){
		if(cnt[a[i]]>1)cnt[a[i]]=0;
		for(j=2;a[i]*j<=ma;j++){
			if(cnt[a[i]*j]>0){
				//cout<<a[i]<<' ';
				cnt[a[i]*j]=0;
			}
		}
	}
	for(i=1;i<=n;i++){
		if(cnt[a[i]]>0){
			//cout<<a[i]<<' ';
			ans++;
		}
	}
	//cout<<endl;
	cout<<ans;
}

Measured memory_bytes: 8156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, K;
	cin >> n >> K;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 1e18;
	for (int i = 0; i < 1 << n; i++) {
		int cnt = 0;
		int mx = 0;
		long long cost = 0;
		for (int j = 0; j < n; j++) {
			if (mx >= a[j]) {
				if (i >> j & 1) {
					cnt++;
					cost += mx - a[j] + 1;
					mx++;
				}
			} else {
				cnt++;
				mx = a[j];
			}
		}
		if (cnt >= K) {
			ans = min(ans, cost);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

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

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

int main(void) {
    int N, D;
    cin >> N >> D;
    ll p[N][D];
    vector<ll> sq;
    for (ll i=0;i<100000;i++) sq.push_back(i*i);
    for (int i=0;i<N;i++) for (int j=0;j<D;j++) cin >> p[i][j];

    ll dist[N][N], cnt = 0;
    for (int i=0;i<N;i++) for (int j=i+1;j<N;j++) {
        dist[i][j] = 0;
        for (int k=0;k<D;k++) {
            dist[i][j] += (p[i][k] - p[j][k])*(p[i][k] - p[j][k]);
        }
        if (find(sq.begin(), sq.end(), dist[i][j]) != sq.end()) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 1400
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
int a[2][105],dp[2][105];

ll solve(){
   dp[1][1]=a[1][1];
   dp[2][1]=dp[1][1]+a[2][1];
   for(int i=2;i<=n;i++)dp[1][i]=dp[1][i-1]+a[1][i];
   for(int i=2;i<=n;i++)dp[2][i]=max(dp[1][i],dp[2][i-1])+a[2][i];

   return dp[2][n];
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    for(int i=1;i<=2;i++)
     for(int j=1;j<=n;j++)
        cin>>a[i][j];
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
string s, SS;

void dfs(int t, string S, int sum) {
    if (t == 4) {
        if (sum == 7) SS = S;
        return;
    }

    dfs(t + 1, S + "-" + s[t], sum - (s[t] - '0'));
    dfs(t + 1, S + "+" + s[t], sum + (s[t] - '0'));
}
int main( ) {
    cin >> s;
    dfs(1, "", s[0] - '0');
    cout << s[0] << SS << "=7" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l,r,d;
    cin >> l >> r >> d;
    PRINT(r/d-(l-1)/d);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 5e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,M;
    cin >> N >> M;
    queue<int>que;
    vector<int>cnt(N),ans(N,-1);
    vector<vector<int>>road(N);
    for(int i = 0; i < N+M-1; i++) {
        int A,B;
        cin >> A >> B;
        A--;B--;
        road[A].push_back(B);
        cnt[B]++;
    }
    for(int i = 0; i < N; i++) {
        if(cnt[i] == 0) {
            que.push(i);
            ans[i] = -1;
        }
    }
    while (!que.empty()) {
        int x = que.front();
        que.pop();
        for(int i = 0; i < road[x].size(); i++) {
            cnt[road[x][i]]--;
            if(cnt[road[x][i]] == 0) {
                que.push(road[x][i]);
                ans[road[x][i]] = x;
            }
        }
    }
    for(int i = 0; i < N; i++) {
        cout << ans[i]+1 << endl;
    }
}


Measured memory_bytes: 10284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

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

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

int main (){
	int n,i,p[100005],ans=0;
	cin >> n;
	for(i=0;i<n;i++) cin >> p[i];
	sort(p,p+n);
	cout << p[n/2]-p[n/2-1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){

int a,b,c,d=0;

scanf("%d %d %d",&a,&b,&c);

if(a>b){

d=a;

a=b;

b=d;

}

if(a>c){

d=a;

a=c;

c=d;

}

if(b>c){

d=b;

b=c;

c=d;

}

printf("%d %d %d\n",a,b,c);

return 0;

} 

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

int main(){
  int p[3],j[2],ans=0;
  for(int i=0;i<3;i++){
    cin >> p[i];
  }
  for(int i=0;i<2;i++){
    cin >> j[i];
  }
  ans += min(p[0],min(p[1],p[2]));
  ans += min(j[0],j[1]);
  ans -= 50;
  cout << ans << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

bool lookup[][7] = {
  {1,1,1,1,1,1,0},
  {0,1,1,0,0,0,0},
  {1,1,0,1,1,0,1},
  {1,1,1,1,0,0,1},
  {0,1,1,0,0,1,1},
  {1,0,1,1,0,1,1},
  {1,0,1,1,1,1,1},
  {1,1,1,0,0,1,0},
  {1,1,1,1,1,1,1},
  {1,1,1,1,0,1,1}
};
int main()
{
  int n;
  while(cin >> n, ~n) {
    bool display[7] = {};
    while(n--) {
      int digit;
      cin >> digit;
      for(int i = 6; i >= 0; i--) {
        cout << (lookup[digit][i] ^ display[i]);
        display[i] = lookup[digit][i];
      }
      cout << endl;
    } 
  }
}

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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int cnt=0;
  while(b <= a){
    b *= 2;
    k--;
  }
  while(c <= b){
    c *= 2;
    k--;
  }
  if(k>=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

n = inp()
K = inp()
s = list(str(n))
l = len(s)

dp = [[[0 for _ in range(2)] for j in range(4)] for i in range(l+5)]
dp[0][0][0] = 1

for i in range(l):
    nd = int(s[i])
    # print(nd)
    for j in range(4):
        for k in range(2):
            for d in range(10):
                ni = i+1; nj = j; nk = k
                if d>0: nj += 1
                if nj >= 4: continue

                if k == 0:
                    if d < nd: nk += 1
                    elif d > nd: continue
                dp[ni][nj][nk] += dp[i][j][k]
# print(dp)
print(sum(dp[l][K]))

Measured memory_bytes: 66156
var
  s:string;
  i,min,max:longint;
begin
  readln(s);
  min:=length(s);
  max:=1;
  for i:=1 to length(s) do
  begin
   if s[i]='C' then if i<min then min:=i;
   if s[i]='F' then if i>max then max:=i;
   end;
  if max>min then writeln('Yes') else writeln('No');
end.


Measured memory_bytes: 128
fun main(args:Array<String>) {
  val base = setOf("P", "W", "G", "Y")
  readLine()
  val target = readLine()!!.split(" ").toSet()

  val size = base.intersect( target ).size
  when {
    size == 4 -> "Four"
    size == 3 -> "Three"
    else -> null
  }.let { println(it) }
}

Measured memory_bytes: 35904
#include <iostream>
#include<string>
using namespace std;
int main(){
  string s="wakstnhmyrw";
  string str;
  cin>>str;
  for(int i=0;i<str.size();i+=2){
    if(str[i]=='0'&&str[i+1]=='U')cout<<"nn";
    else if(str[i]=='1'){
      if(str[i+1]=='T')cout<<"a";
      else if(str[i+1]=='L')cout<<"i";
      else if(str[i+1]=='U')cout<<"u";
      else if(str[i+1]=='R')cout<<"e";
      else if(str[i+1]=='D')cout<<"o";
      
    }
    else if(str[i+1]=='T')cout<<s[str[i]-'0']<<"a";
    else if(str[i+1]=='L')cout<<s[str[i]-'0']<<"i";
    else if(str[i+1]=='U')cout<<s[str[i]-'0']<<"u";
    else if(str[i+1]=='R')cout<<s[str[i]-'0']<<"e";
    else if(str[i+1]=='D')cout<<s[str[i]-'0']<<"o";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1188
c = [list(map(int, input().split())) for _ in range(3)]

ans = "Yes"
for i in range(1,3):
  if c[i][0]-c[0][0] != c[i][1]-c[0][1] or c[i][1]-c[0][1] != c[i][2]-c[0][2]:
    ans = "No"
print(ans)

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

namespace bla
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string[] s = Console.ReadLine ().Split ();
			int a = int.Parse (s [0]);
			int b = int.Parse (s [1]);
			int an = b - a - 1;
			Console.WriteLine ((an*(an+1))/2 - a);
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main()
{
	int A, B;
	cin >> A;
	cin >> B;
	if (A >= 13) {
		cout << B;
	}
	if (A <= 12 && A >= 6) {
		cout <<B / 2;
	}
	if (A <= 5) {
		cout << "0";
	}
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
//const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
const LL mod = 998244353ll;
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

LL N,K;
LL L[10],R[10];

LL ans = INF;

void solve(){
    //マスiに行く方法の数をaccum[i]とおく
    vector<mint> accum(N,0);
    accum[0] = 1;
    for(int i=0;i<N;i++){
        if(i>=1) accum[i] += accum[i-1];
        if(i==1) accum[i] -= mint(1);
        for(int k=0;k<K;k++){
            LL left = i + L[k];
            LL right = i + R[k] + 1;
            if(left>=N) continue;
            accum[left] += accum[i];
            if(right<=N-1) accum[right] -= accum[i];
        }
    }
    ans = accum[N-1].x;
}
 
int main(){
	cin >> N >> K;
    for(int i=0;i<K;i++) cin >> L[i] >> R[i];
 
    solve();

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

Measured memory_bytes: 4376