akhauriyash/Code-Regression huggingface dataset:
import java.lang.*;
import java.io.*;
import java.math.*;

public class Main{
    public static void main(String[] args)throws IOException{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br=new BufferedReader(isr);
	String nst = br.readLine();
	int n = Integer.parseInt(nst);
	int x,cnt=0;
	for(int i=0;i<n;i++){
	    boolean flag = true;
	    nst = br.readLine();
	    x=Integer.parseInt(nst);
	    for(int j=2;j*j<=x;j++)
		if(x%j==0)
		    flag=false;
	    if(flag)
		cnt++;
	}
	System.out.println(cnt);
    }
}

Measured memory_bytes: 22456
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

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

int main() {
  int n,x;
  cin>>n>>x;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  ll ans=0;
  for(int i=0;i<n-1;i++){
    if(a[i]+a[i+1]<=x)continue;
    else{
      if(a[i]<=x){
        ans+=(a[i+1]+a[i])-x;
        a[i+1]-=(a[i+1]+a[i])-x;
      }
      else{
        ans+=(a[i+1]+a[i])-x;
        a[i+1]=0;
        a[i]-=(x-a[i+1]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	int sum = 0;
	int p;
	int m = 0;
	for (int i = 0; i < n; i++) {
		cin >> p;
		sum += p;
		m = max(m, p);
	}
	
	sum -= m/ 2;
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define MAX 30
using namespace std;


int main(){

  double ft; //ft:first term
  double sum = 0;
  while (cin >> ft){

    for(int i=0;i<10;i++){

      if(i==0){
      }
      else if(i%2==1){ //偶数
        ft = ft*2;
      }
      else if(i%2==0){ //奇数
        ft = ft/3;
      }
      sum+=ft;
    }
    cout << setprecision(10) << sum << endl;

    sum=0;
  }

 return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll H,W;
  cin>>H>>W;
  vector<string> S(H);
  vector<vector<ll>> Hnum(H,vector<ll>(W,0));
  vector<vector<ll>> Wnum(H,vector<ll>(W,0));
  FORi(H){
    cin>>S[i];
  }
  FORi(H){
    ll num=0;
    FORj(W){
      if(S[i][j]=='.'){
        num++;
      }else{
        FORk(num){
          Wnum[i][j-1-k]=num;
        }
        num=0;
      }
    }
    FORk(num){//終端
      Wnum[i][W-1-k]=num;
    }
  }
  FORi(W){
    ll num=0;
    FORj(H){
      if(S[j][i]=='.'){
        num++;
      }else{
        FORk(num){
          Hnum[j-1-k][i]=num;
        }
        num=0;
      }
    }
    FORk(num){//終端
      Hnum[H-1-k][i]=num;
    }
  }
  ll max_=0;
  FORi(H){
    FORj(W){
      if(S[i][j]=='.'){
        max_=max(Wnum[i][j]+Hnum[i][j]-1,max_);
      }
    }
  }
  cout<<max_<<endl;
  return 0;
}


Measured memory_bytes: 68992
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc166_e
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    int n;
    scanf("%d", &n);
    vector<ll> h(n+1);
    for(int i=1; i<=n; i++) {
        scanf("%lld", &h[i]);
    }
    unordered_map<ll, ll> mp;
    ll rs = 0;
    for(int i=1; i<=n; i++) {
        ll v = i - h[i];
        if(mp.find(v) != mp.end()) {
            rs += mp[v];
        }
        mp[i+h[i]]++;
    }
    printf("%lld\n", rs);
}


Measured memory_bytes: 12948
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] counts = new int[n + 1];
	    for (int x = 1; x * x * 6 <= n; x++) {
	        for (int y = x; x * x + y * y * 3 + x * y * 2 <= n; y++) {
	            for (int z = y; x * x + y * y + z * z + x * y + y * z + z * x <= n; z++) {
	                int a = x * x + y * y + z * z + x * y + y * z + z * x;
	                if (x == y && y == z) {
	                    counts[a]++;
	                } else if (x == y || y == z) {
	                    counts[a] += 3;
	                } else {
	                    counts[a] += 6;
	                }
	            }
	        }
	    }
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
		    sb.append(counts[i]).append("\n");
		}
		System.out.print(sb);
	}
}


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

using namespace std;

int main()
{
	int t;
t=1;
	while(t--)
	{
	
	

	
	int i,j,k,n,a,b;
	
	cin>>n>>a;
	k=0;
	i=0;
	j=0;
	b=0;

     for(i=0;i<=n;i++)
	 {
	 	
	 	if(   2*i+ 4*(n-i)==a)
	 	k=-1;
	 	
	 	
	  } 
  
  
    if(k==-1)
    cout<<"Yes\n";
    
    else
    cout<<"No\n";
  
	}



}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))

dic_a = {i+1:0 for i in range(N)}
for i in range(1, N+1):
    dic_a[i] = A[i-1]

s_dic_a = sorted(dic_a.items(), key=lambda x:x[1])

for s_dic_a in s_dic_a:
    print(s_dic_a[0], end=" ")


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

int main() {
  int H,W;
  cin>>H>>W;
  for(int i= 0;i<W+2;i++){
  cout<<'#';
  }
  cout<<endl;
  for(int i= 0;i<H;i++){
  string s;
    cin>>s;
  cout<<'#'<<s<<'#'<<endl;
  }
  for(int i= 0;i<W+2;i++){
  cout<<'#';
  }
   cout<<endl;

}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()
lt = [n] * (l[n-1] + l[n-2] + 1)
ans = 0
for i in range(l[0]+1):
    lt[i] = 0
length = l[0]
for i in range(1, n):
  if length < l[i]:
    for j in range(length+1, l[i]+1):
      lt[j] = i
    length = l[i]
for i in range(n):
  for j in range(i+1, n):
    right = l[i]+l[j]
    ans += max(0,  lt[right] - (j+1))
print(ans)

Measured memory_bytes: 42860
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int A, P;
    cin >> A >> P;
    P += A * 3;
    cout << P / 2 << endl;
}

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

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

    if (n <= 111) {
        cout << 111 << endl;
    } else if (n <= 222) {
        cout << 222 << endl;
    } else if (n <= 333) {
        cout << 333 << endl;
    } else if (n <= 444) {
        cout << 444 << endl;
    } else if (n <= 555) {
        cout << 555 << endl;
    } else if (n <= 666) {
        cout << 666 << endl;
    } else if (n <= 777) {
        cout << 777 << endl;
    } else if (n <= 888) {
        cout << 888 << endl;
    } else if (n <= 999) {
        cout << 999 << endl;
    }
}
    

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  string hoge = str;
  reverse(ALL(hoge));
  if (str == hoge) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

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

unsigned int getdigit(unsigned long long int n)
{
    unsigned int d = 0;
    while(n != 0){
        n /= 10;
        d++;
    }
    return d;
}

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

    for(a = floor(sqrt((double)n)); a > 0; a--){
        if(!(n % a)) break;
    }

    cout << getdigit((n/a)) << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
using namespace std;
int A,B,K;
int main(){
  cin >> A >> B >> K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      if(A%2==1) A--;
      A /= 2; B += A;
    }else{
      if(B%2==1) B--;
      B /= 2; A += B;
    }
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[200005], sorted[200005];
int main()
{
    int n;
    cin >> n;
    for ( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
        sorted[i] = a[i];
    }
    sort(sorted+1, sorted+1+n);
    int x = 0;
    if ( sorted[n/2] == sorted[n/2 + 1] )
    {
        for ( int i = 1; i <= n; i++ )
        {
            cout << sorted[n/2] << endl;
        }
    }
    else
    {
        for ( int i = 1; i <= n; i++ )
        {
            if ( a[i] <= sorted[n/2] )
            {
                cout << sorted[n/2 + 1] << endl;
            }
            else
            {
                cout << sorted[n/2] << endl;
            }
        }
    }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int f(int k){
    int res=0;
    while(k>0){
        res+=k%10;
        k/=10;
    }
    return res;
}

signed main()
{
    int N; cin>>N;
    cout<<(N%f(N)==0? "Yes":"No")<<endl;
}


Measured memory_bytes: 256
#define s(a,b) t=a,a=b,b=t
f(int*a){*a=(*a&7)<<4|*a>>4;}char p[9];m,a,b,c,t,r;main(n){while(scanf("%d",&n),n){r=1,a=97,b=82,c=67;while(n--){scanf("%s",p);m=*p-76;t=m%6==0?(s(b,c),f(m>0?&c:&b)):1<m&&m<8?(s(a,b),f(m^7?&b:&a)):(s(a,c),f(m>0?&c:&a));r+=a&7;}printf("%d\n",r);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
typedef int64_t ll;
const int MAX_N = 10000;
const int INF = 1000000000;


int main() {
	string a, b;
	cin >> a >> b;
	string c = a + b;
	int d = stoi(c);
	for (int i = 0; i * i <= d; i++)
	{
		if (i * i == d) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();

  var arr = [];
  for (var i = 0; i < n; i++) {
    var s = o.a(String);
    var p = o.a();
    arr.push({i: i+1, s, p});
  }

  arr.sort((a, b) => {
    if (a.s < b.s) {
      return -1;
    } else if (a.s > b.s) {
      return 1;
    } else {
      return b.p - a.p;
    }
  })

  arr.forEach(x => {
    console.log(x.i);
  })
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  vector<int> o(0),e(0);
  int memo;
  
  rep(i,0,n){
    if(i%2 == 0){
      cin >> memo;
      o.pb(memo);
    }
    else{
      cin >> memo;
      e.pb(memo);
    }
  }
  
  if(n%2==0) {
    reverse(ALL(e));
    rep(i,0,o.size()){
      e.pb(o[i]);
    }
    rep(i,0,n-1){
      cout << e[i] << ' ';
    }
    cout << e[n-1] << endl;
    return 0;
  }
  else {
    reverse(ALL(o));
    rep(i,0,e.size()){
      o.pb(e[i]);
    }
    rep(i,0,n-1){
      cout << o[i] << ' ';
    }
    cout << o[n-1] << endl;
    return 0;
  }
  
  
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e2 + 5;
const int M = 1e5 + 5;

ll n, W, w[N], v[N], dp[M];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n >> W;

    for (int i = 0; i < n; ++i)
        cin >> w[i] >> v[i];

    memset(dp, 0x3f, sizeof(dp));

    dp[0] = 0;
    for (int i = 0; i < n; ++i)
        for (int j = M; j >= v[i]; --j)
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);

    ll ans = 0;
    for (int i = 0; i < M; ++i)
        if (dp[i] <= W)
            ans = i;

    cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)

static auto generate_id ()
{
  static int res = 0;
  return res ++;
}

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

  size_t n, m;
  cin >> n >> m;

  vector <int> connected_graph_ids (n + 1, -1);
  vector <vector <size_t>> goable (n + 1);

  rep (i, m)
  {
    size_t x, y;
    int z;
    cin >> x >> y >> z;

    goable [x].emplace_back (y);
    goable [y].emplace_back (x);
  }

  queue <size_t> q;

  for (size_t i = 1; i <= n; ++ i)
  {
    if (connected_graph_ids [i] == -1)
    {
      connected_graph_ids [i] = generate_id ();
      q.push (i);
      while (! q.empty ())
      {
        auto node = q.front ();
        q.pop ();
        for (auto && elem : goable [node])
        {
          if (connected_graph_ids [elem] == -1)
          {
            connected_graph_ids [elem] = connected_graph_ids [node];
            q.push (elem);
          }
        }
      }
    }
  }

  for (size_t i = 1; i <= n; ++ i)
  {
    if (connected_graph_ids [i] == -1)
    {
      connected_graph_ids [i] = generate_id ();
    }
  }

#ifdef DEBUG
  cerr << "debug:";
  for (size_t i = 1; i <= n; ++ i)
  {
    cerr << connected_graph_ids [i] << " ";
  }
  cerr << endl;
#endif

  cout << generate_id () << endl;
}


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

const int N = 1e5 + 6;
vector<int> a(N);

int main() {
    int n, q, b, c;
    long long sum = 0ll;
    cin >> n;
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        sum += static_cast<long long> (x);
        ++a[x];
    }
    
    cin >> q;
    while (q--) {
        cin >> b >> c;
        sum += static_cast<long long> ((c-b) * a[b]);
        a[c] += a[b];
        a[b] = 0;
        cout << sum << '\n';
    }
    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF INT_MAX/3
#define MAX_V 300

struct edge{
  int to,cap,cost,rev;
};

int V;
vector<edge> g[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init(int v){
  V=v;
  for(int i=0;i<MAX_V;i++){
    g[i].clear();
  }
}

void add_edge(int from,int to,int cap,int cost){
  g[from].push_back((edge){to,cap,cost,(int)g[to].size()});
  g[to].push_back((edge){from,0,-cost,(int)g[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  int res=0;
  memset(h,0,sizeof(h));
  while(f>0){
    fill(dist,dist+V,INF);
    dist[s]=0;
    bool update=true;
    while(update){
      update=false;
      for(int v=0;v<V;v++){
        if(dist[v]==INF)continue;
        for(int i=0;i<(int)g[v].size();i++){
          edge &e=g[v][i];
          if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
            dist[e.to]=dist[v]+e.cost;
            prevv[e.to]=v;
            preve[e.to]=i;
            update=true;
          }
        }
      }
    }
    if(dist[t]==INF) return INF;

    int d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,g[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*dist[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=g[prevv[v]][preve[v]];
      e.cap-=d;
      g[v][e.rev].cap+=d;
    }
  }
  return res;
}

bool cmp(__int128 p1,__int128 q1,__int128 p2,__int128 q2){ // p1/q1 <= p2/q2
  return p1*q2 <= p2*q1;
}

int N,M,s,t;
vector<ll> cs;

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

  cin>>N>>M>>s>>t;
  s--;t--;
  init(N);
  rep(i,M){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;
    add_edge(a,b,c,d);
  }

  ll maxf=0,crtc=0;
  cs.push_back(0);
  while(1){
    int tmp=min_cost_flow(s,t,1);
    if(tmp==INF)break;
    crtc+=tmp;
    cs.push_back(crtc);
    maxf++;
  }

  P resc=P(maxf*maxf,1);

  rep(i,maxf){
    __int128 fl=i,fr=i+1;
    __int128 cl=cs[i],cr=cs[i+1];
    __int128 d=cr-cl;
    __int128 rp=maxf+d*d*fl-d*cl,rq=d*d+1;
    if(cmp(fl,1,rp,rq)&&cmp(rp,rq,fr,1)){
      __int128 bp=(d*(rp-rq*fl)+rq*cl)*(d*(rp-rq*fl)+rq*cl)+(rq*maxf-rp)*(rq*maxf-rp),bq=rq*rq;
      if(cmp(bp,bq,resc.fi,resc.se)){
        __int128 gc=__gcd(bp,bq);
        resc=P(bp/gc,bq/gc);
      }
    }else{
      __int128 bl=cl*cl+(maxf-fl)*(maxf-fl);
      __int128 br=cr*cr+(maxf-fr)*(maxf-fr);
      if(bl<=br){
        if(cmp(bl,1,resc.fi,resc.se)){
          resc=P((ll)bl,1);
        }
      }else{
        if(cmp(br,1,resc.fi,resc.se)){
          resc=P((ll)br,1);
        }
      }
    }
  }

  cout<<resc.fi<<"/"<<resc.se<<endl;

  return 0;
}



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

int main0() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
	int N, K;
	cin >> N >> K;
	long long arr[100001]={};
	int num, qty;
	long long count = 0;
	for (long long i=0; i<N; i++){
		cin >> num >> qty;
		arr[num]+=qty;
	}
	for (int i=1; i<100001; i++){
		count += arr[i];
		if (count >= K){
			cout << i << endl;
			return 0;
		}
	}
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n , k;
    cin >> n >> k;
    long long arr[100001] = {};
    for (long long i = 0 ; i < n ; i++){
        int num , qty;
        cin >> num >> qty;
        arr[num] += qty;
    }
    long long count = 0;
    for (long long i = 1 ; i < 100001 ; i++ ){
       count += arr[i];
       if( count >= k ){
         cout << i;
         return 0;
       }
    }
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/
template<typename T=lnt>
struct RangeMax
{
	T v;
	static RangeMax I() { return RangeMax(std::numeric_limits<T>::min()); }
	RangeMax(T v) : v(v) {}
	static RangeMax f(const RangeMax& lhs, const RangeMax& rhs) {
		return std::max(lhs,rhs);
	}
	operator T() const { return v; }
};

template<typename M>
struct SegmentTree
{
	const int n;
	std::vector<M> data;
	SegmentTree(int n) : n(n),data(n<<1,M::I()) {}
	M& operator[](int i) { return data[i+n]; } // get / pair with build
	void update(int i, const M& a) { data[i+n]=a; for(i+=n;i>1;i>>=1) data[i>>1]=M::f(data[i],data[i^1]); }
	void build() { for(int i=n-1;i>0;i--) data[i]=M::f(data[i<<1],data[i<<1|1]); }
	M fold(int l, int r) const {
		M L=M::I(),R=M::I();
		for(l+=n,r+=n;l<r;l>>=1,r>>=1) {
			if(l&1) L=M::f(data[l++],L);
			if(r&1) R=M::f(R,data[--r]);
		}
		return M::f(L,R);
	}
};


int main() {
	int n,k;
	std::cin >> n >> k;
	V<int> a(n);
	fill(a);
	using M=RangeMax<>;
	int N=3e5+1;
	SegmentTree<M> seg(N);
	rep(i,N) seg[i]=0;
	seg.build();
	rep(i,n) {
		int x=seg.fold(std::max(0,a[i]-k),std::min(N,a[i]+k+1));
		seg.update(a[i],x+1);
	}
	print((int)seg.fold(0,N));
}


Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    vector<string> s(3); cin >> s;
    cout << "A" << s[1][0] << "C\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, k;
    cin >> n >> k;
    vector<int> h(n);
    vector<int> dp(n);  // cost up to stone i
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    dp[0] = 0;
    for (int x = 1; x < n; x++) {
        dp[x] = 1e9 + 1;
        for (int i = 0; i <= k; i++) {
            if (x - i >= 0) {
                dp[x] = min(dp[x], dp[x - i] + abs(h[x] - h[x - i]));
            }
        }
    }
    // for (int i = 0; i < n; i++) {
    cout << dp[n - 1] << endl;
    // }
}

Measured memory_bytes: 1024
S = input()

if len(S) == 2:
  if S[0] == S[1]:
    print('1 2')
    exit()
else:
  for i in range(len(S)-2):
    if any([S[i:i+3].count(S[j]) >= 2 for j in range(i,i+3)]):
      print(i+1,i+3)
      exit()
print('-1 -1')


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

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

  int n; cin >> n;
  vector<int> p(n+1);
  cin >> p[0] >> p[1];
  for(int i = 0; i < n-2; i++){
    int a, b; cin >> a >> b;
    p[i+2] = b;
  }
  {
    int a, b; cin >> a >> b;
    p[n] = b;
  }

  int dp[101][101];
  memset(dp, 0, sizeof(dp));

  n = p.size() - 1;
  for(int l = 2; l <= n; l++){
    for(int i = 1; i <= n-l+1; i++){
      int j = i+l-1;
      dp[i][j] = INT_MAX/10;
      for(int k = i; k < j; k++){
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << dp[1][n] << endl;
  return 0;
}

Measured memory_bytes: 1244
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoderABC114
{
    class Program
    {
        public static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            Console.WriteLine(
                (X == 3 || X == 5 || X == 7)? "YES":
                "NO"
            );
        }
    }
}

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

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int k,x;cin>>k>>x;
  
  //$B$3$l$i$N@P$N$&$A!"$"$kO"B3$9$k(B
  //K $B8D$N@P$,9u$GEI$i$l$F$*$j!"(B
  //$B$=$l0J30$N@P$OGr$GEI$i$l$F$$$^$9!#(B
  //$B$^$?!":BI8(B X $B$K$"$k@P$O9u$GEI$i$l$F$$$k$3$H$,(B
  //$BJ,$+$C$F$$$^$9!#(B
  //$B9u$GEI$i$l$F$$$k@P$,CV$+$l$F$$$k(B
  //$B2DG=@-$N$"$k:BI8$r$9$Y$F!">.$5$$=g$K=PNO$7$F$/$@$5$$!#(B
  rep2(i,x-k+1,x+k)cout<<i<<" ";
  cout<<endl;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "2", "5 2 8 5 1 5" ].parse.expand.solve == 10 );
	assert( [ "10", "1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000" ].parse.expand.solve == 10000000000 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	as.sort!( ( a, b ) => b < a );
	auto ans = 0L;
	for( auto i = 1L; i < as.length / 3 * 2; i += 2 )
	{
		ans += as[ i ];
	}
	return ans;
}


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

public class Main {
	Scanner sc = new Scanner(System.in);
	int m;
	int n;
	char chair[];

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

	private void start() {
		n = sc.nextInt();
		m = sc.nextInt();
		while (n != 0) {
			chair = new char[n];
			Arrays.fill(chair, '#');
			for (int i = 0; i < m; i++) {
				sit(sc.next().charAt(0));
			}
			for (int i = 0; i < n; i++) {
				System.out.print(chair[i]);
			}
			System.out.println();
			n = sc.nextInt();
			m = sc.nextInt();
		}
	}

	private void sit(char c) {
		switch (c) {
		case 'A':
			for (int i = 0; i < n; i++) {
				if (chair[i] == '#') {
					chair[i] = 'A';
					return;
				}
			}
			break;
		case 'B':
			for (int i = n - 1; i >= 0; i--) {
				if (chair[i] == '#') {
					if ((i > 0 && chair[i - 1] == 'A')
							|| (i < n - 1 && chair[i + 1] == 'A'))
						continue;
					chair[i] = 'B';
					return;
				}
			}
			for (int i = 0; i < n; i++) {
				if (chair[i] == '#') {
					chair[i] = 'B';
					return;
				}
			}
			break;
		case 'C':
			for (int i = 0; i < n; i++) {
				if (chair[i] != '#') {
					if (i < n - 1 && chair[i + 1] == '#') {
						chair[i + 1] = 'C';
						return;
					}
					if (i > 0 && chair[i - 1] == '#') {
						chair[i - 1] = 'C';
						return;
					}
				}
			}
			if (n % 2 != 0) {
				chair[((n + 1) / 2) - 1] = 'C';
			} else {
				chair[n / 2] = 'C';
			}
			break;
		case 'D':
			int max = 0;
			int maxindex = 0;
			int count = 1000;
			int distance[] = new int[n];
			for (int i = 0; i < n; i++) {
				if (chair[i] == '#') {
					count++;
				} else {
					count = 0;
				}
				distance[i] = count;
			}
			count = 1000;
			for (int i = n - 1; i >= 0; i--) {
				if (chair[i] == '#') {
					count++;
				} else {
					count = 0;
				}
				distance[i] = distance[i] < count ? distance[i] : count;
				if (max <= distance[i]) {
					max = distance[i];
					maxindex = i;
				}
			}
			if (max >= 1000)
				chair[0] = 'D';
			else
				chair[maxindex] = 'D';
			break;
		}
	}
}

Measured memory_bytes: 25860
package main

import "fmt"

func solve() {
	var N int
	fmt.Scan(&N)

	fmt.Println(luca(N))
}

func luca(N int) int {
	ans := 0
	pre := 1
	prepre := 2
	if N == 0 {
		return 2
	}
	if N == 1 {
		return 1
	}
	for i := 2; i <= N; i++ {
		ans = pre + prepre
		prepre = pre
		pre = ans
	}
	return ans
}

func main() {
	solve()
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
/*#include <atcoder/modint>
using namespace atcoder;
using mint = modint1000000007;*/
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;

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; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

/*-----------------------------------------------------------------------------------------------------*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vvi G(3 * n);
	rep(i,m){
		int a, b; cin >> a >> b;
		--a; --b;
		for(int i = 0; i < 3; i++){
			G[a + i * n].push_back((b + (i + 1) * n) % (3 * n));
		}
	}
	int s, t; cin >> s >> t;
	s--; t--;
	queue<int> que;
	que.push(s);
	vi dist(3 * n, -1);
	dist[s] = 0;
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int nv : G[v]){
			if(dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}
	if(dist[t] == -1) cout << -1 << endl;
	else cout << dist[t] / 3 << endl;
}

Measured memory_bytes: 20824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

int n,m;

int main(void){
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int x,a,b;
	cin >> x >> a >>b;
	if (a>=b) cout << "delicious" << endl;
	if ((a + x) >= b && a <b) cout << "safe" << endl;
	if ((a +x) <b) cout << "dangerous" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int x, y;
int main() {
	scanf("%d%d", &x, &y);
	if (y % 2) {
		printf("No\n");
		return 0;
	}
	if (2 * x <= y && y <= 4 * x)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 1664
import sys
n = int(input())
a = list(map(int, input().split()))

box = [0 for _ in range(n+1)]
result = []
for i in range(n, 0, -1):
    counter = 0
    for j in range(1, (n//i)+1):
        counter += box[j*i]
    if counter % 2 != a[i-1]:
        box[i] = 1
        result.append(i)
for i in range(1, n+1):
    counter = 0
    for j in range(1, (n//i)+1):
        counter += box[j*i]
    if counter%2 != a[i-1]:
        print(-1)
        sys.exit()

print(len(result))
if len(result) != 0:
    print(*result[::-1])        

Measured memory_bytes: 15512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
	ll k;
	cin >> k;
	ll a = 7%k;
	ll ans = 0;
	for (ll i = 0; i <= k; i++) {
		if (a  == 0) {
			ans = i + 1;
			break;
		}
		else {
			a = 10 * a + 7;
			a %= k;
			
		}

	}
	if (ans == 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3584
using System;
using System.Runtime.CompilerServices;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int A = cin.NextInt();
            int B = cin.NextInt();
            int C = cin.NextInt();
            int K = cin.NextInt();
            string ans = "No";


            while (0 < K)
            {
                if (A >= B)
                {
                    B = B * 2;
                    K--;
                }else if (B >= C)
                {
                    C = C * 2;
                    K--;
                }
                if (A < B && B < C)
                {
                    ans = "Yes";
                    break;
                }
            }

            if (A < B && B < C)
            {
                ans = "Yes";
            }
            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 string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        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: 27472
#include <bits/stdc++.h>

using namespace std;
/*---------------------SAUGATA KUNDU---------------------------*/

#define int long long int
#define INF (int)1e9+5
#define MoD (int)1e9 + 7
#define debug(a) cerr << '[' << a << ']' << '\n'

#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for(int i = a; i < b; i++)
#define fos(i, b) for(int i = 0; i < b; i++)
#define foe(i, a) for(auto &i: a)
#define re(i, a, b) for(int i = b; i > a; i--)
#define pb push_back
#define all(c) c.begin(), c.end()
#define sz(x) (int)(x).size()
#define Fast ios::sync_with_stdio(0);cin.tie(0)
//data_structures
#define vt vector
#define que queue
#define sta stack
#define pque priority_queue
#define dque deque

#define point(pt) vt<int>::iterator pt
template<typename T> void read(vt<T> &a){
	fos(i, sz(a)) cin >> a[i];
}

#define endl '\n'
template<typename T> void write(vt<T> a){
	fos(i, sz(a)) cout << a[i] << ' ';
	cout << endl;
}
int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89};
string alpha = "abcdefghijklmnopqrstuvwxyz";
void solve(){
	int n, a, b, ans=0;
	pque<int> nn;
  	nn.push(0);

	cin >> n;
	for(int i=0; i<n; i++){
	   cin >> a >> b;
	   if(a==b) ans++;
	   else {
		   nn.push(ans);
		   ans=0;
	   }
	}
  	if(ans) nn.push(ans);

	cout << ((nn.top()>=3)?"Yes":"No") << endl;
}/*5
1 1
2 2
3 4
5 5
6 6*/

int32_t main() {
	Fast;

	int t=1;
	for(int i=1; i<=t; ++i) {
		solve();
	}

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll x,y;
bool vis[200001];
vector<int> adj[200001];
void dfs(int s)
{
    if(s<=1e5) x++;
    else y++;
    for(auto v: adj[s])
    {
    if(!vis[v])
    {
        vis[v]=true;
        dfs(v);
    }
    }
}
int main()
{
    ll i,n,res=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(100000+v);
        adj[100000+v].pb(u);
    }
   
    
   
    for(i=0;i<200001;i++)
    {
        if(!vis[i] && !adj[i].empty())
        {
            x=0;y=0;
            vis[i]=true;
            dfs(i);
            res+=(x*y);
        }
    }
    cout<<res-n;
    return 0;
}

Measured memory_bytes: 10240
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    S = sum(A)
    cunt_A = Counter(A)
    for q in range(Q):
        b, c = map(int,input().split())
        S += (c-b)*cunt_A[b]
        cunt_A[c] += cunt_A[b]
        cunt_A[b] = 0
        print(S)

if __name__=='__main__':
    main()

Measured memory_bytes: 24116
#include <stdio.h>

int main()
{
	int i, j;
	char A[11], B[11], C[11];
	scanf("%s %s %s", &A, &B, &C);
	for (i = 0; A[i+1] != 0; i++);
	for (j = 0; B[j+1] != 0; j++);
	if (A[i] == B[0] && B[j] == C[0]) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}

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

#define xx first
#define yy second

typedef pair<int,int> pii;
typedef long long LL;

const int N = 1e5 + 10;
int p[N];

int main() {
  //freopen("in", "r", stdin);
  int n;
	LL a, b, res = 0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) scanf("%d", p + i);
	for (int i = 1; i < n; i++) {
		res += min(b, a * (p[i] - p[i - 1]));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>

std::string str;
int ans;

int main()
{
    std::cin >> str;
    int l = str.size();
    for (int i = 0; i < l / 2; ++i)
        if (str[i] != str[l - i - 1])
            ++ans;
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

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

  if (b % a == 0) cout << a + b << endl;
  else cout << b - a << endl;
  return 0;
}


Measured memory_bytes: 256
s, l = map(int, input().split())
l_list = [[int(i)-1 for i in input().split()[1:]] for _ in range(l)]
mod_list = list(map(int, input().split()))
ans = 0


for i in range(2**s):
  on_off = [int(i) for i in "{:0>{}b}".format(i, s)]
  for i, s_list in enumerate(l_list):
    sum_s = sum([on_off[s_num] for s_num in s_list])
    if sum_s%2 != mod_list[i]: break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

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

typedef long long ll;

using namespace std;
int main(){
    int W, a, b;
    cin >> W >> a >> b;
    int ans;

    if (b >= a + W) ans = b - (a + W);
    else if (b >= a) ans = 0;
    else if (b + W >= a) ans = 0;
    else ans = a - (b + W); 

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    string ans="";
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='0'){
            ans+='0';
        }
        else if(s[i]=='1'){
            ans+='1';
        }
        else if(s[i]=='B' && s.length()>0){
            ans=ans.substr(0,ans.length()-1);
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back
#define INF 1e17
#define fst first
#define snd second
typedef long long ll;

const int N = 2e5;
ll n, m;

vector<int> g[N];
ll dp[N];

ll dfs1(int x, int y) {
    ll r = 1;
    for(auto v : g[x]) {
        if(v != y) r *= (dfs1(v, x) + 1);
        r %= m;
    }
    fore(i, 0, g[x].size()) if(g[x][i] == y) {
        swap(g[x][i], g[x].back());
        g[x].pop_back();
        break;
    }
    dp[x] = r;
    return r;
}
void dfs2(int x, ll ant) {
    if(x != 0) dp[x] *= ant; dp[x] %= m;

    vector<ll> val = {1};
    vector<ll> rval;
    for(auto v : g[x]) {
            val.pb((dp[v] + 1) % m);
            rval.pb((dp[v] + 1) % m);
    }
    rval.pb(1);
    
    fore(i, 1, val.size()) val[i] *= val[i - 1], val[i] %= m;
    for(int i = rval.size() - 2; i >= 0; i--) rval[i] *= rval[i + 1], rval[i] %= m;
    // fore(i, 0, val.size()) cout << val[i] << " "; cout << endl;
    // fore(i, 0, rval.size()) cout << rval[i] << " "; cout << endl;
    fore(i, 0, g[x].size()) {
        ll nant = val[i] * rval[i + 1];
        nant %= m; nant *= ant; nant %= m; nant++;
        dfs2(g[x][i], nant % m);
    }
}

int main() {
    cin >> n >> m; 
    fore(i, 0, n - 1) {
        int x, y; cin >> x >> y; x--, y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs1(0, 0);
    dfs2(0, 1);
    fore(i, 0, n) cout << dp[i] % m << endl;
}

Measured memory_bytes: 25856
#include <stdio.h>

int main(void)
{
    int N, M, A, B;
    int max;
    int total;
    int i;
    
    scanf("%d%d", &N, &M);
    
    
    max = 0;
    total = 0;
    for (i = 0; i < M; i++){
        scanf("%d%d", &A, &B);
        
        if (A < N){
            if (max < N - A){
                max = N - A;
            }
            total += N - A;
        }
    }
    
    printf("%d\n", total - max);

    return (0);
}



Measured memory_bytes: 2084
n,m,r = map(int,input().split())
r = list(map(int,input().split()))
node = [list(map(int,input().split())) for _ in range(m)]
dp = [[float('inf')]*(n+1) for _ in range(n+1)]
for x,y,z in node:
    dp[x][y] = z
    dp[y][x] = z
for i in range(n+1):
    dp[i][i] = 0
def wf(d,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j]>d[i][k]+d[k][j]:
                    d[i][j] = d[i][k]+d[k][j]
    return d
dp = wf(dp,n+1)
import copy
import sys
rest = set(r[:])
def dfs(cost,pre,rest):
    if 0==len(rest):
        return cost
    ret = sys.maxsize
    for i in rest:
        if pre==None:
            next_cost = 0
        else:
            next_cost = cost + dp[pre][i]
        next_rest = copy.copy(rest)
        next_rest.remove(i)
        tmp_ret = dfs(next_cost, i, next_rest)
        ret = min(ret,tmp_ret)
    return ret
print(dfs(0,None,rest))

Measured memory_bytes: 65368
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

const long long P = 1000000007;


long long build(long long k)
{
    return (k*(k+1))/2;
}

int main()
{
    long long n;
    long long k;
    
    cin >> n >> k;
    
    long long ans = 0;
    for (long long i = k;i <= n;i++){
        ans += ((build(n)-build(n-i)-build(i-1)+1))%P;
    }
    cout << (ans+1)%P << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	rep(i, n) {
		cin >> a[0][i];
	}
	rep(i, n) {
		cin >> a[1][i];
	}
	int ans = 0;
	rep(i, n) {
		int now = 0;
		int k = 0;
		rep(j, n) {
			if(i == j) {
				k = 1;
				now += a[0][j];
			}
			now += a[k][j];
		}
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = gets.strip.split('')
l,r = s.each_slice(2).to_a

l = l.join('').to_i
r = r.join('').to_i

if l == 0
  if r ==0
    puts 'NA'
  elsif r<=12
    puts 'YYMM'
  else
    puts 'NA'
  end
elsif l <= 12
  if r ==0
    puts 'MMYY'
  elsif r<=12
    puts 'AMBIGUOUS'
  else
    puts 'MMYY'
  end
elsif
  if r ==0
    puts 'NA'
  elsif r<=12
    puts 'YYMM'
  else
    puts 'NA'
  end
end

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int x, t;
    cin >> x >> t;

    // 処理
    // 出力
    cout << ((x - t) < 0 ? 0 : x - t) << endl;

    return 0;
}


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

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

Measured memory_bytes: 256