akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()
 
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
 
int H, W;
int ey, ex;
char maps[201][201];
 
int bfs1() {
  bool used[201][201] = {{0}};
  queue<Pip> q;
  q.push(Pip(0, Pii(ey, ex)));
  while ( !q.empty() ) {
    Pip p = q.front(); q.pop();
    int c = p.fr,  y = p.sc.fr, x = p.sc.sc;    
 
    if ( maps[y][x] == '@' ) {
      return c;
    }
 
    if ( used[y][x] ) continue;
    used[y][x] = true;
 
    Rep(i, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if ( ny < 0 || nx < 0 || ny >= H || nx >= W || maps[ny][nx] == '#' || maps[ny][nx] == '$' ) continue;
      q.push(Pip(c+1, Pii(ny, nx)));
    }
  }
 
  return INF;
}
 
int bfs2() {
  bool used[201][201] = {{0}};
  queue<Pip> q;
  q.push(Pip(0, Pii(ey, ex)));
  while ( !q.empty() ) {
    Pip p = q.front(); q.pop();
    int c = p.fr,  y = p.sc.fr, x = p.sc.sc;    
 
    if ( maps[y][x] == '$' ) {
      return c;
    }
 
    if ( used[y][x] ) continue;
    used[y][x] = true;
 
    Rep(i, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if ( ny < 0 || nx < 0 || ny >= H || nx >= W || maps[ny][nx] == '#' ) continue;
      q.push(Pip(c+1, Pii(ny, nx)));
    }
  }
 
  return INF;
}
 
signed main() {
  cin >> H >> W;
  Rep(i, H) Rep(j, W) {
    cin >> maps[i][j];
    if ( maps[i][j] == '%' ) ey = i, ex = j;
  }
 
  if ( bfs1() < bfs2() ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int res[1234567], aa[12345678];
signed main() {
	int n, m, x4 = 0, x2 = 0, x1 = 0, ans = 0; cin >> n >> m;
	char a; vector<int>ok(26);
	for (int h = 0; h < n; h++) {
		for (int i = 0; i < m; i++) {
			cin >> a; ok[(int)a - 97]++;
		}
	}
	sort(ok.begin(), ok.end()); reverse(ok.begin(), ok.end());
	x4 = (n / 2) * (m / 2);
	if (n % 2 == 1) { x2 += m / 2; }
	if (m % 2 == 1) { x2 += n / 2; }
	if (n % 2 == 1 && m % 2 == 1) { x1 = 1; }
	int x = 0;
	for (int h = 0; h < x4; h++) {
		while (ok[x] < 4) { x++; if (x == 26) { cout << "No" << endl; return 0; } }
		ok[x] -= 4;
	}
	x = 0;
	for (int h = 0; h < x2; h++) {
		while (ok[x] < 2) { x++; if (x == 26) { cout << "No" << endl; return 0; } }
		ok[x] -= 2;
	}
	x = 0;
	for (int h = 0; h < x1; h++) {
		while (ok[x] < 1) { x++; if (x == 26) { cout << "No" << endl; return 0; } }
		ok[x] -= 1;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int n,m,x,y;
	cin >> n >> m >> x >> y;
	int temp;
	for(int i=0; i<n; i++){
		cin >> temp;
		x=max(x,temp);
	}
	for(int i=0; i<m; i++){
		cin >> temp;
		y=min(y,temp);
	}
	cout << (x<y?"No War":"War") << endl;
	return 0;
}	

Measured memory_bytes: 256
//Joy Shree Kriskna
    #include<bits/stdc++.h>
    #define fast  ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=n-1;i>=0;i--)
    #define rep2(j,t) for(j=1;j<=t;j++)
    #define rep3(i,a,b) for(i=a;i<=b;i++)
    #define remove(s) s.erase(unique(s.begin(),s.end()),s.end());
    #define e return 0
    #define endl "\n"
    #define al(v) v.begin(),v.end()
    #define ll long long
    using namespace std;
    int main()
      {
           fast;
           int i,n;
           cin>>n;
           cout<<n*n<<endl;
           e;
      }
//arupsaha52
//Template
// if(s2.find(s1[i])!=-1)/*find function*/
//s=to_strings(n);/*digit to string conversion*/
/*set<int>s;
set<int>::iterator it;
s.insert(x);s.clear() for(it = s.begin(); it != s.end(); it++) {
        cout << *it << endl;}*/
//vector<vector<int> >v;/*2d vector*/
//vector<string>s
//stack<int>st;st.push(v);st.pop();st.top();
//queue<int>q;q.push(v);q.pop();q.front();q.back();
//priority_queue<int>q;q.push(v);q.pop();q.top();
//pair<int,int>p;


Measured memory_bytes: 256
_n = int(raw_input())
_a = [int(x) for x in raw_input().split()]

_flg = 1
cnt = 0

while _flg:
    _flg = 0
    for i in reversed(range(1, _n)):
        if _a[i] < _a[i-1]:
            _a[i], _a[i-1] = _a[i-1], _a[i]
            cnt += 1
            _flg = 1

print(" ".join([str(x) for x in _a]))
print(cnt)

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b<c*d)cout<<c*d;
  else if(a*b>c*d)cout<<a*b;
  else if(a*b==c*d)cout<<c*d;
  return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

vector<int> divisor(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, ans;
  cin >> n;
  vector<int> x(n);
  rep(i, 0, n) {
    cin >> x[i];
    if (i == 0) ans = x[i];
    ans = gcd(ans, x[i]);
  }
  if (ans != 1) {
    cout << "not coprime\n";
    return 0;
  }
  uset<int> se;
  rep(i, 0, n) {
    auto now = divisor(x[i]);
    arep(i, now) {
      if (i == 1) continue;
      if (se.find(i) != se.end()) {
        cout << "setwise coprime\n";
        return 0;
      } else
        se.insert(i);
    }
  }
  cout << "pairwise coprime\n";
  return 0;
}

Measured memory_bytes: 11124
#include <stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail + 1 == MAX)
    tail=0;
  else 
    tail++;
}

P dequeue(void){
  P x;
  x=Q[head];
  if(head+1==MAX)
    head=0;
  else head++;
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
    head = 0;
    tail = n;
    while(head != tail){
      u = dequeue();
      if(q>u.t)c=u.t;
      else c=q;
      u.t -= c;
      elaps += c;
      if(u.t>0)enqueue(u);
      else printf("%s %d\n",u.name,elaps);
    }
    return 0;
  }

Measured memory_bytes: 10752
import sys
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)

# 最小全域木
# プリム法 #
# 部分木から、最小コストの辺を貪欲に追加

# Kruskal法 #
# クラスカル法 #
# 辺でソートして、最小コストの辺から、ループにならないよう貪欲に追加
# UnionFindを使う


N = int(input())

# x,yでそれぞれソート
POINT_x = []
POINT_y = []
for _ in range(N):
    x, y = map(int, input().split())
    POINT_x.append((x, y))
    POINT_y.append((x, y))

POINT_x = sorted(POINT_x, key=lambda x: x[0])
POINT_y = sorted(POINT_y, key=lambda x: x[1])

EDGE = defaultdict(list)
for i in range(N):
    p = POINT_x[i]

    if i != 0:
        prev = POINT_x[i-1]
        EDGE[p].append((abs(p[0]-prev[0]), prev))

    if i != N-1:
        nxt = POINT_x[i+1]
        EDGE[p].append((abs(p[0]-nxt[0]), nxt))

for i in range(N):
    p = POINT_y[i]

    if i != 0:
        prev = POINT_y[i-1]
        EDGE[p].append((abs(p[1]-prev[1]), prev))

    if i != N-1:
        nxt = POINT_y[i+1]
        EDGE[p].append((abs(p[1]-nxt[1]), nxt))


INF = 10 ** 12
mincost = [INF] * N
used = defaultdict(lambda: False)

point = POINT_x[0]
used[point] = True
q = []
ans = 0

for e in EDGE[point]:
    heapq.heappush(q, e)

while(True):
    update = False
    for _ in range(len(q)):
        cost, point = heapq.heappop(q)
        if used[point]:
            continue

        update = True
        ans += cost
        used[point] = True

        for e in EDGE[point]:
            if not used[e[1]]:
                heapq.heappush(q, e)

    if not update:
        break

print(ans)


Measured memory_bytes: 92284
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    int x;
    cin >> x;
    int table[1010];
    fill(table,table+1010,0);
    table[1]=1;
    for(int i=2;i<=31;i++){
        int tmp = i*i;
        while(tmp<=1000){
            table[tmp]=1;
            tmp*=i;
        }
    }
    int ans = 1;
    for(int i=1;i<=x;i++){
        if(table[i]==1)ans = i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
N, T = [int(x) for x in stdin.readline().rstrip().split()]
ct = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]
path = [k[0] for k in ct if k[1] <= T]
path.sort()
if len(path) == 0:
    print('TLE')
else:
    print(path[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int N,M;
ll C,A;
ll B[25];

int main(){
  ll cnt=0;
  ll t;
  cin >> N >> M >> C;
  rep(i,0,M)cin >> B[i];
  rep(i,0,N){
    t = C;
    rep(j,0,M){
      cin >> A;
      t += A*B[j];
    }
    if(t>0)cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#define ma 100001
#define mod 1000000007
#define ll long long int
using namespace std;
int main(){
	ll n=0,W=0,v=0,w=0,ans=0;
	cin >> n >> W;
	ll f[ma];
	for(int i=1;i<ma;i++){
		f[i]=1e9+5;
	}
	for(int i=0;i<n;i++){
		scanf("%d%d",&w,&v);
		for(int j=ma-1;j>0;j--){
			if(v>j)
				continue;
			f[j]=min(f[j],f[j-v]+w);
		}
	}
	for(int j=0;j<ma;j++){
		if(f[j]<=W){
			ans=j;	
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1152
//Maximum Sum Sequence ?
#include<bits/stdc++.h>
using namespace std;
#define INF 100000

int n;
vector<vector<int> > a;
int v[100][100];//a_11を左上、a_ijを右下とする四角形内部の数字の和
int ans=-INF;

int main(){
  cin>>n;
  for(int i=0; i<n; i++){
    vector<int> tmp;
    for(int j=0; j<n; j++){
      int t;
      cin>>t;
      tmp.push_back(t);
    }
    a.push_back(tmp);
  }

  while(!a.empty()){
    /*
    cout<<"a"<<endl;
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++)
        cout<<a[i][j]<<' ';
      cout<<endl;
    }
    cout<<endl;
    */
    v[0][0]=a[0][0];
    for(int i=1; i<n; i++){
      v[i][0]=v[i-1][0]+a[i][0];//左側
      v[0][i]=v[0][i-1]+a[0][i];//上側
    }
    for(int i=1; i<n; i++)
      for(int j=1; j<n; j++)
        v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1]+a[i][j];

    for(int i=0; i<n; i++)
      for(int j=0; j<n; j++)
        if(ans<v[i][j])ans=v[i][j];
    /*
    cout<<"v"<<endl;
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++)
        cout<<v[i][j]<<' ';
      cout<<endl;
    }
    cout<<endl;
    */
    //行方向
    for(int i=0; i<n; i++){
      int min_v=v[i][0], mx=v[i][0];
      for(int j=1; j<n; j++){
        if(mx<v[i][j]-min_v)mx=v[i][j]-min_v;
        if(min_v>v[i][j]){min_v=v[i][j];}
      }
      if(ans<mx)ans=mx;
    }
    //列方向
    for(int i=0; i<n; i++){
      int min_v=v[0][i], mx=v[0][i];
      for(int j=1; j<n; j++){
        if(mx<v[j][i]-min_v)mx=v[j][i]-min_v;
        if(min_v>v[j][i]){min_v=v[j][i];}
      }
      if(ans<mx)ans=mx;
    }
    for(int i=0; i<n; i++)a[i].erase(a[i].begin());
    a.erase(a.begin());
    n--;
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1320
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

vector<pair<ll, ll> > v;
ll n, d, a;

int main() {
	cin >> n >> d >> a;
	for (int i = 0; i < n; i++) {
		ll x, h;
		cin >> x >> h;
		v.push_back(make_pair(x, h));
	}
	sort(v.begin(), v.end());
	ll j = -1;
	ll ret = 0;
	ll sum = 0;
	vector<pair<ll, ll> > bombs;
	for (int i = 0; i < n; i++) {
		pair<ll, ll> cur = v[i];
		while ((j + 1 < bombs.size()) && (bombs[j + 1].first <= cur.first - 2 * d - 1)) {
			j++;
			sum -= bombs[j].second * a;	
		}
		ll b = max((cur.second + a - 1 - sum) / a, (ll)0);
		sum += b * a;
		ret += b;
		bombs.push_back(make_pair(cur.first, b));
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 12008
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			List<Integer> lst = new ArrayList<Integer>();
			lst.add(a);
			lst.add(b);
			lst.add(c);
			
			long count = lst.stream().distinct().count();
			
			System.out.println(count == 2 ? "Yes" : "No");
			
		}
	}
}

Measured memory_bytes: 30676
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main()
{
    int x, n;
    std::cin >> x >> n;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    std::sort(v.begin(), v.end());
    int pos = std::lower_bound(v.begin(), v.end(), x) - v.begin();
    if (std::find(v.begin(), v.end(), x) == v.end()) {
        std::cout << x << "\n";
        return 0;
    }
    bool fa = false;
    int ans;
    for (int i = 1; (pos - i) >= 0; i++) {
        if ((v[pos - i]) < (v[pos - i + 1] - 1)) {
            ans = v[pos - i + 1] - 1;
            fa = true;
            break;
        }
    }
    for (int i = 1; (pos + i) < n; i++) {
        if ((v[pos + i - 1] + 1) < v[pos + i]) {
            if (fa && std::abs(x - ans) <= std::abs(x - (v[pos + i - 1] + 1))) {
                std::cout << ans << "\n";
            } else {
                std::cout << v[pos + i - 1] + 1 << "\n";
            }
            return 0;
        }
    }
    if (fa) {
        std::cout << ans << "\n";
        return 0;
    }
    if (std::abs(v[0] - x) <= std::abs(v[n - 1] - x)) {
        std::cout << v[0] - 1 << "\n";
    } else {
        std::cout << v[n - 1] + 1 << "\n";
    }

    return 0;
}


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

int n,m,dp[51111],ans,A[11111];

signed main(){
  r(i,51110)dp[i+1]=1e16;
  cin>>n>>m;
  r(i,n)cin>>A[i+1];
  sort(A+1,A+n+1,greater<int>());
  r(i,n)A[i+1]+=A[i];
  r(i,m){
    int x,y;
    cin>>x>>y;
    for(int j=n;j>=0;j--){
      dp[j+x]=min(dp[j+x],dp[j]+y);
    }
  }
  r(i,51110) ans=max(ans,A[min(i,n)]-dp[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
int A,B,SUM=0;
cin >>A>>B;
if(A>B){
SUM=A;A--;
}
else{
SUM=B;B--;
}
if(A>B)SUM+=A;
else{SUM+=B;}
cout<<SUM<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 998244353
#define pai acos(-1)
#define N 1000000

ll ar[N],cnt[N],exact[N];

ll bigmod(ll a,ll p)
{
   ll res,x;
   res=1%mod,x=a%mod;
   while(p){
      if(p&1) res=((res%mod)*(x%mod))%mod;
      x=((x%mod)*(x%mod))%mod;
      p>>=1;
   }
   return res;
}

ll mod_Inverse(ll n){
   return bigmod(n,mod-2);
}

int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
      int ar;cin>>ar;
      cnt[ar]++;
    }
    for(int i=1;i<=N;i++){
      for(ll j=i;j<=N;j+=i) ar[i]+=(j*cnt[j]);
      ar[i]=(ar[i]%mod);
    }
    ll ans=0;
    for(ll i=N;i>=1;i--){
      exact[i]=(ar[i]*ar[i])%mod;
      for(int j=i+i;j<=N;j+=i){
         exact[i]=(exact[i]-exact[j])%mod;
      }
      ans=(ans+exact[i]*mod_Inverse(i))%mod;
      ans=(ans-i*cnt[i])%mod;
    }
    ans=(ans*mod_Inverse(2ll))%mod;
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 27004
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char ch[200];
int n;
int main(){
	scanf("%d",&n);
	scanf("%s",ch+1);
	int now=0,ans=0;
	for (int i=1;i<=n;i++){
		if (ch[i]=='I') now++; else now--; ans=max(ans,now);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int solve(int n, int sum, int amax) {
	if (n == 0) {
		if (sum == 0) {
			return 1;
		}
		else {
			return 0;
		}
	}
	else if (amax*n < sum ||0 * n>sum)return 0;
	else {
		int nans=0;
		for (int x =0; x <= amax; ++x) {
			nans+=solve(n-1,sum-x,x-1);
		}
		return nans;
	}
}


int main() {
	char x, y;
	vector<int>v{ 1,0,0 };
	string st;
	while(cin>>st){
		int n=st[0]-'A';
		int m=st[2]-'A';

		swap(v[n],v[m]);
	}
	int ans=find(v.begin(),v.end(),1)-v.begin();
	cout<<char(ans+'A')<<endl;
	return 0;
}


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

int main() {
  int n;
  int a;
  int minOpeCnt = 0;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    int opeCnt = 0;
    while(a % 2 == 0) {
      a = a >> 1;
      opeCnt++;
    }
    if(i == 0 || opeCnt < minOpeCnt) {
      minOpeCnt = opeCnt;
    }
  }

  cout << minOpeCnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N;
  int a = N/11;
  N %= 11;
  a *=2;
  if(N>6) a+=2;
  else if (N==0){}
  else a++;
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
static const int MAX = 65000;
typedef long long llong;

void merge(llong *J, int l, int m, int r){
  llong T[MAX];
  int i, j, k;
  for ( i = l; i < m; i++ ) T[i] = J[i];
  for ( i = m; i < r; i++ ) T[(r-1)-(i-m)] = J[i];
  i = l;
  j = r - 1;
  for ( k = l; k < r; k++ ){
    if ( T[i] >= T[j] ) J[k] = T[i++];
    else J[k] = T[j--];
  }
}

void mergeSort(llong *J, int l, int r){
  int m;
  if ( l+1 < r ){
    m = (l+r)/2;
    mergeSort(J, l, m);
    mergeSort(J, m, r);
    merge(J, l, m, r);
  }
}


int main(){
  llong n, totalp, totalj, j, t, v, maxv;
  llong P[MAX], J[MAX];
  int i;                                                                                                                  while(1){                                                                                                                 scanf("%lld", &n);
    if ( n == 0 ) break;                                                                                                    totalp = 0;                                                                                                             for ( i = 0; i < n; i++ ) {
      scanf("%lld", &P[i]);
      totalp += P[i];                                                                                                       }
    for ( i = 0; i < n-1; i++ ) scanf("%lld", &J[i]);

    maxv = 0;
    mergeSort(J, 0, (n-1));
                                                                                                                            totalj = 0;
    for ( j = 0, t = n; t >= 1; t--, j++ ){
      v = t*(totalj + totalp);
      totalj += J[j];                                                                                                         maxv = v > maxv ? v : maxv;
    }
    printf("%lld\n", maxv);
  }                                                                                                                       return 0;
}




Measured memory_bytes: 3272
S = list(input())
T = list(input())
S_l = len(S)
T_l = len(T)
ans = 10**9
for i in range(S_l - T_l  + 1):
    c = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            c += 1
    ans = min(ans, c)
print(ans)

Measured memory_bytes: 65136
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#define LL long long
#define MAXN 110
#define debug(x) cerr << #x << " " << x << endl
using namespace std;

inline int read() { int x = 0, f = 1; char ch = getchar();
    for(; !isdigit(ch); ch = getchar()) f = ch == '-' ? -1 : 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; return x * f;
}

const int MOD = 1e9 + 7;int D;


int main() {
    D = read();
    switch(D){
        case 22: printf("Christmas Eve Eve Eve\n");
            break;
        case 23: puts("Christmas Eve Eve");break;

        case 24: puts("Christmas Eve");break;
        case 25: puts("Christmas");break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  if(a * b % 2 == 1)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		int count5 = 0;
		int count7 = 0;
		switch (a) {
		case 5:
			count5++;
			break;
		case 7:
			count7++;
			break;
		default:
			break;
		}
		switch (b) {
		case 5:
			count5++;
			break;
		case 7:
			count7++;
			break;
		default:
			break;
		}
		switch (c) {
		case 5:
			count5++;
			break;
		case 7:
			count7++;
			break;
		default:
			break;
		}
		if (2 == count5 && 1 == count7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


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

void solve(){	
	
	int s,w ;
	cin>>s>>w ;

	if(w>=s){
		cout<<"unsafe" ;
	}	
	else{
		cout<<"safe" ;
	}

}

int main(){

	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	const int d[9]={1,10,100,1000,10000,100000,1000000,10000000,100000000};
	
	for(int N;cin>>N,N;){
		string n[12];
		for(int i=0;i<N;i++)
			cin>>n[i];
		
		map<char,int> m;
		for(int i=0;i<N;i++)
			for(int j=0;j<n[i].size();j++)
				if(m.find(n[i][j])==m.end())
					m.insert(make_pair(n[i][j],m.size()));
		int M=m.size();
		
		int c[10]={},z[10]={};
		for(int i=0;i<N;i++){
			if(n[i].size()>1)
				z[m[n[i][0]]]=1;
			reverse(n[i].begin(),n[i].end());
			for(int j=0;j<n[i].size();j++)
				c[m[n[i][j]]]+=i==N-1?-d[j]:d[j];
		}
		
		int p[10]={0,1,2,3,4,5,6,7,8,9};
		int res=0;
		do{
			int x=0;
			for(int i=0;i<M;i++){
				if(p[i]==0 && z[i]==1){
					x=-1;
					break;
				}
				x+=c[i]*p[i];
			}
			if(x==0)
				res++;
			reverse(p+M,p+10);
		}while(next_permutation(p,p+10));
		
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 932
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


bool is_prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

	return true;
}


int main() {
	
	ll N;
	cin >> N;

	ll i = 1;
	while(N) {
		ll tmp = i * 5 + 1;
		if (is_prime(tmp)) {
			cout << tmp << endl;
			--N;
		}
		++i;
	}
}

Measured memory_bytes: 256
import fractions, math
n,x=map(int, input().split())
a=list(map(int, input().split()))
mina=min(a+[x])
a=[i-mina for i in a]+[x-mina]
f=max(a)
for i in a:
    if i!=0:
        f=fractions.gcd(f,i)
print(f)

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

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

modint choose(modint n, int k) {
  /* O(k) */
  modint c = 1;
  for(int i=1; i<=k; i++) c *= (n-i+1) / i;
  return c;
}



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

  cout << modint(2).pow(n) - choose(n, a) - choose(n, b) - 1 << endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def check(s):
    h = 0
    for p in s:
        b = h + p[0]
        if b < 0: return False
        h += p[1]
    return True

N = int(input())
S = [input().strip() for i in range(N)]

total = 0
ps, ms = [], []
for s in S:
    h, b = 0, 0
    for c in s:
        if c == '(':
            h += 1
        else:
            h -= 1
        b = min(b, h)
    if h > 0:
        ps.append([b, h])
    else:
        ms.append([b-h, -h])
    total += h

ps.sort(reverse=True)
ms.sort(reverse=True)
if check(ps) and check(ms) and total == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 103692
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n, ans;
int a[114514];
signed main() {
	scanf("%lld", &n);
	rep(i, n) {
		scanf("%lld", &a[i]);
	}
	rep(i, n - 1) {
		if (a[i] == i + 1) {
			swap(a[i], a[i + 1]);
			ans++;
		}
	}
	if (a[n - 1] == n) {
		ans++;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    ll n;  cin >> n;
    vector<ll> v(n), key(n);
    for(ll i=0; i<n; i++){
        cin >> v.at(i); key.at(i) = v.at(i);
    }

    sort(v.begin(), v.end());
    ll lm=v[n/2-1], rm=v[n/2];
    for(int i=0; i<n; i++){
        if(key[i]<rm) cout << rm;
        else cout << lm;
        cout << endl;
    }

}

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

using namespace std;

const int MAX_N = 2e3 + 10;

int N, ans = INT_MAX, F[MAX_N], G[MAX_N], H[MAX_N];
char S[MAX_N];
vector<int> edge[MAX_N];

void dfs(int x, int y) {
    F[x] = S[x] - '0'; G[x] = H[x] = 0;
    vector<int> ch;
    for (int i : edge[x]) {
        if (i == y) continue;
        dfs(i, x);
        ch.push_back(G[i] + F[i]);
        F[x] += F[i];
        H[x] += H[i] + F[i];
    }
    int mx = 0, sum = 0;
    for (int i : ch)
        mx = max(mx, i), sum += i;
    if (mx * 2 >= sum) {
        G[x] = 2 * mx - sum;
    } else {
        G[x] = sum & 1;
    }
}

int main() {
    scanf("%d", &N);
    scanf("%s", S + 1);
    for (int i = 1; i < N; i++) {
        int a, b; scanf("%d%d", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for (int i = 1; i <= N; i++) {
        dfs(i, 0);
        int res = H[i];
        if (res & 1) continue;
        bool flag = true;
        for (int j : edge[i]) {
            if ((G[j] + F[j]) * 2 > res + G[j] - H[j]) flag = false;
        }
        if (flag) ans = min(ans, res / 2);
    }
    printf("%d\n", ans == INT_MAX ? -1 : ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 2019;

void solve(long long L, long long R){
    if (R - L >= MOD) {
        L = 0;
        R = MOD;
    }

    int res = MOD;

    for(int i = L; i <= R; ++i) {
        for(int j = i + 1; j <= R; ++j) {
            res = min(res, i * j % MOD);
        }
    }

    cout << res << endl;
}

signed main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    solve(L, R);
    return 0;
}


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

const int INF = 1e8;

int rec(int bit, int v, vector<vector<int>> &dp, vector<vector<int>> &g){
	int n = dp.at(0).size();
	if(dp.at(bit).at(v)!=-1) return dp.at(bit).at(v);
	if(bit==(1<<v)) return dp.at(bit).at(v)=0;
	
	int dist = INF;
	int pbit = bit & ~(1<<v);
	for(int i=0; i<n; i++){
		if(!(pbit&(1<<i))) continue;
		if(dist > rec(pbit, i, dp, g)+g.at(i).at(v)) {
			dist = rec(pbit, i, dp, g)+g.at(i).at(v);
		}
	}
	return dp.at(bit).at(v) = dist;
}
int main() {
	
	int n,m;
	cin >> n >> m;
	vector<vector<int>> g(n+1,vector<int>(n+1,INF));
	for(int i=0; i<m; i++){
		int s,t,d;
		cin >> s >> t >> d;
		g.at(s).at(t) = d; 
	}
	vector<vector<int>> dp(1<<(n+1),vector<int>(n+1,-1));
	int ans{INF},cnt;
	for(int i=0; i<n; i++){
		auto dp1 = dp;
		auto g1 = g;
		for(int j=0; j<n+1; j++){
			for(int k=0; k<n+1; k++){
				if(j!=n&&k==n) g1.at(j).at(k) = INF;
				if(j==n) g1.at(j).at(k) = g.at(i).at(k); 
			}
		}
		ans = min(ans, rec((1<<(n+1))-1, i, dp1, g1));
		
	}
	cout << (ans==INF?-1:ans) << endl;
}


Measured memory_bytes: 15936
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll a,b;
    cin>>a>>b;
    if( a + b == 15 ){
	cout<<'+'<<endl;
    }else if( a*b == 15 ){
	cout<<'*'<<endl;
    }else{
	cout<<'x'<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
int n,t,x,y,pt,px,py,f,d;
int main(){
	std::cin>>n;
    for(;n--;pt=t,px=x,py=y)std::cin>>t>>x>>y,d=abs(x-px)+abs(y-py),f=(t-pt<d||(d-t+pt)%2)?1:0;
    std::cout<<(f?"No":"Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    int N, L;
    cin >> N >> L;
    int ans = 0;
    int eat = INF;
    rep(i,N) {
        int a = L + i;
        ans += a;
        if (abs(a) < abs(eat)) eat = a;
    }
    ans -= eat;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 12 + 5;

i64 a[MAXN][MAXN];
i64 c[MAXN];

i64 n, m, x;

bool check(i64 v, i64& r) {
    r = 0;

    vector<i64> z;
    z.assign(m, 0);

    for (i64 i = 0; i < n; i++) {
        if ((v & (1 << i)) == 0) {
            continue;
        }
        r += c[i];

        for (i64 j = 0; j < m; j++) {
            z[j] += a[i][j];
        }
    }

    for (auto t : z) {
        if (t < x) {
            return false;
        }
    }

    return true;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
    cin >> n >> m >> x;
    for (i64 i = 0; i < n; i++) {
        cin >> c[i];
        for (i64 j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    bool f = false;
    i64 R = 0;
    for (i64 i = 0; i < (1 << n); i++) {
        i64 r;
        bool t = check(i, r);
        if (!t) {
            continue;
        }
        if (!f) {
            f = true;
            R = r;
            continue;
        }
        R = min(R, r);
    }
    if (!f) {
        cout << -1 << endl;
    }
    else {
        cout << R << endl;
    }


    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int n;
int check(int n) {
    for (int i = 1; i*(i-1)/2 <= n; i++) {
     //       cout << i << endl;
        if (i*(i-1)/2 == n) return i;
    }
    return 0;
}
int mp[505][505];
int main() {
    scanf("%d", &n);
    int k = check(n);
    if (!k) puts("No");
    else {
        puts("Yes");
        for (int i = 1; i <= k; i++)
            for (int j = i+1; j <= k; j++)
                mp[i][j] = mp[j][i] = n--;
        printf("%d\n", k);
        for (int i = 1; i <= k; i++) {
            printf("%d", k-1);
            for (int j = 1; j <= k; j++) {
                if (j == i) continue;
                printf(" %d", mp[i][j]);
            }
            puts("");
        }
    }
}


Measured memory_bytes: 2304
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash(){
    ll n;
    cin>>n;
    pll a[n];
    ll cnt = 0;
    ll mxCnt = 0;
    for (ll i = 0; i < n; i++) {
        cin>>a[i].f>>a[i].s;
        if (a[i].f == a[i].s) {
            ++cnt;
        } else {
            cnt = 0;
        }
        mxCnt = max(mxCnt, cnt);
    }
    if (mxCnt >= 3) {
        cout<<"Yes\n";
    } else {
        cout<<"No\n";
    }
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m , l;
const int inf = 1e9 + 7;
int ans[305][305];
bool vis[305];
vector<pair<int,int>> a[maxn];
using pii = pair<int,int>;
#define mp make_pair
bool cmp(const pii & x, const pii &y){
    if(x.first == y.first) return x.second > y.second;
    return x.first < y.first;
}
pair<int,int> dp[305];
struct S{
    int nod, cnt, val;
    S(int x,int y,int z) : nod(x) , cnt(y), val(z){}
    bool operator <(const S &x) const{
        if(cnt == x.cnt) return val < x.val;
        return cnt > x.cnt;
    }
};

void greedy(int start){
    priority_queue<S> q;
    for(int i = 1 ;i <= n + 1;i ++){
        dp[i] = mp(inf , -inf);
        vis[i] = false;
    }
    dp[start] = make_pair(0 , l);
    q.push(S(start, 0 , l));
    while(!q.empty()){
        auto p = q.top();
        q.pop();
        if(vis[p.nod]) continue;
        for(auto i:a[p.nod]){
            if(!vis[i.first] && p.val >= i.second && cmp(mp(p.cnt,p.val - i.second), dp[i.first])){
                q.push(S(i.first, p.cnt, p.val - i.second));
                dp[i.first] = mp(p.cnt, p.val - i.second);
            }
            else if(!vis[i.first] && p.val < i.second && cmp(mp(p.cnt + 1, l - i.second) , dp[i.first])){
                q.push(S(i.first, p.cnt + 1 , l - i.second));
                dp[i.first] = mp(p.cnt + 1, l  - i.second);
            }
        }
    }
    for(int i = 1 ;i <= n;i ++){
        if(i != start){
            if(dp[i] != mp(inf,-inf)){
                ans[start][i] = dp[i].first;
            }
            else ans[start][i] = -1;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m >> l;
    while(m -- ){
        int x, y, z;
        cin >> x >> y >> z;
        if(z > l) continue;
        a[x].push_back({y, z});
        a[y].push_back({x, z});
    }
    for(int i = 1 ;i<= n;i++){
        greedy(i);
    }
    int q,x,y;
    cin >> q;
    while(q -- ){
        cin >> x >> y;
        cout <<ans[x][y] << '\n';
    }
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 9088
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

int gcd(int a,int b){
    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

/*----------------------------------------------------------------*/
signed main(){

	int n;
	cin >> n;
	vector<pair<string,int>> st;
	rep(i,n){
		string x;
		int y;
		cin >> x >> y;
		st.pb(MP(x,y));
	}
	string X;
	cin >> X;

	int ans = 0;
	int f = 0;
	rep(i,n){
		if(f)ans += st[i].se;
		if(st[i].fi == X)f = 1;
	}
	cout << ans << endl;







	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://dwacon6th-prelims.contest.atcoder.jp/tasks/dwacon6th_prelims_a

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    ll K;
    cin >> n >> K;

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

    ll ng = 0, ok = 1000000001;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;

        ll cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt += (a[i] + mid - 1) / mid - 1;
        }

        (cnt <= K ? ok : ng) = mid; 
    }
    
    cout << ok << newl;
    return 0;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=5e5+5;
const ll mod=1e9+7;
ll quick(ll x,ll y)
{
    ll ans=1;
    while(y)
    {
        if(y&1)
            ans=ans*x%mod;
            x=x*x%mod;
            y/=2;
    }
    return ans;
}
ll C(ll x,ll y)
{
    ll ans=1;
    for(ll i=y;i>=1;i--)
    {
        ans=ans*x%mod;
        x--;
        ans=ans*quick(i,mod-2)%mod;
    }
    return ans;
}
int main()
{
    int i,j;
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=quick(2,n);
    ans--;
    ll u=C(n,a),v=C(n,b);
    ans=ans-u-v;
    ans=(ans%mod+mod)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "tmp.cpp"

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

  ll ans = 0;
  int n;
  cin >> n;
  vi a(n);
  REP(i, n) { cin >> a[i]; }

  vi cum(n, 0);
  FOR(i, 1, n) {
    if (0 <= (i + 1) - a[i] && (i + 1) - a[i] < n) {
      cum[(i + 1) - a[i]]++;
    }
  }

  REP(i, n) {
    if (0 <= a[i] + (i + 1) && (i + 1) + a[i] < n) {
      ans += cum[a[i] + (i + 1)];
    }
    if (0 <= (i + 1) - a[i] && (i + 1) - a[i] < n) {
      cum[(i + 1) - a[i]]--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4748
n=int(input())
arr1=[]
arr2=[]
for i in range(n):
    x,y=map(int,input().split())
    arr1.append(x-y)
    arr2.append(x+y)
ma2=max(arr2)-min(arr2)
ma1=max(arr1)-min(arr1)
print(max(ma1,ma2))

Measured memory_bytes: 96764
N,K = map(int,(input().split()))
V = list(map(int,(input().split())))
left = [0]*(N+1)
right = [0]*(N+1)
ans = []

for i in range(1,N+1):
    left[i] = left[i-1] + V[i-1]

for i in range(1,N+1):
    right[i] = right[i-1] + V[N-i]


for i in range(min(N+1,K+1)):
    negal = []

    l = i
    for count in range(l):
        if l > 0 and V[count] < 0:
            negal.append(V[count])

    for j in range(min(N+1-i,K+1-i)):
        negar = []

        r = j
        for count in range(1,r+1):
            if r > 0 and V[N-count] < 0:
                negar.append(V[N-count])

        b = max(0,K-i-j)
        now = left[i] + right[j]

        nega = []
        nega.extend(negal)
        nega.extend(negar)
        nega.sort()
        s = 0
        for k in range(min(b,len(nega))):
            s += nega[k]
        
        if nega:
            ans.append(now-s)
        else:
            ans.append(now)

print(max(ans))

Measured memory_bytes: 40816