akhauriyash/Code-Regression huggingface dataset:
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class Dice
  attr_accessor:node,:top,:s,:e,:num
  def initialize(arr)
    @node=Array.new(6){|i| i+1}
    @num=arr
    @top=1
    @s=2
    @e=3
  end

  def reverse_num(x)
    return 7-x
  end

  def S()
    top=@top
    s=@s
    e=@e
    @top=reverse_num(s)
    @s=top
  end

  def E()
    top=@top
    s=@s
    e=@e
    @top=reverse_num(e)
    @e=top
  end

  def W()
    top=@top
    s=@s
    e=@e
    @top=e
    @e=reverse_num(top)
  end

  def N()
    top=@top
    s=@s
    e=@e
    @top=s
    @s=reverse_num(top)
  end
end

n=gets.to_i
dices=Array.new(n)
n.times do|i|
  a=get_i
  dices[i]=Dice.new(a)
end
flag=false
(n-1).times do|i|
  dice1=dices[i]
  (i+1).upto(n-1) do|j|
    dice2=dices[j] 
    x=dice1.num.sort
    y=dice2.num.sort
    f=false
    6.times do|k|
      f=true if x[i]!=y[i]
    end
    if f
      next
    end
    4.times do
      4.times do
        break if dice1.num[dice1.s-1]==dice2.num[dice2.s-1]
        dice2.S 
      end
      4.times do
        break if dice1.num[dice1.top-1]==dice2.num[dice2.top-1]
        dice2.W
      end

      break if dice1.num[dice1.s-1]==dice2.num[dice2.s-1] and dice1.num[dice1.top-1]==dice2.num[dice2.top-1]
      dice2.S
      dice2.W
    end

    if ((dice1.num[dice1.s-1]==dice2.num[dice2.s-1]) and (dice1.num[dice1.top-1]==dice2.num[dice2.top-1]) and (dice1.num[dice1.e-1]==dice2.num[dice2.e-1]) and (dice1.num[dice1.reverse_num(dice1.s)-1]==dice2.num[dice2.reverse_num(dice2.s)-1]) and (dice1.num[dice1.reverse_num(dice1.top)-1]==dice2.num[dice2.reverse_num(dice2.top)-1]) and (dice1.num[dice1.reverse_num(dice1.e)-1]==dice2.num[dice2.reverse_num(dice2.e)-1]))
      flag=true
      break
    end
  end
  if flag
    break
  end
end
if flag
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 6992
n,m=gets.split.map &:to_i
min=[]
max=[]
m.times do
  x,y=gets.split.map &:to_i
  if x==1 || y==1
    min<< [x,y].max
  end
  if x==n || y==n
    max<< [x,y].min
  end
  
  
end
puts min & max == [] ? :IMPOSSIBLE : :POSSIBLE
  

Measured memory_bytes: 9844
#include <stdio.h>
int n;
char s[101], t[101];
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	scanf(" %s", t);
	for (int i = 0; i < n; i++) {
		printf("%c", s[i]);
		printf("%c", t[i]);
	}
	printf("\n");
}

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

int main(){
  int n,k,a=1,cnt=0;
  cin>>n>>k;
  while(a<k && cnt<n){
    a*=2;
    cnt++;
  }
  cnt=n-cnt;
  if(cnt<=0){ cout<<a; return 0; }
  for(int i=0;i<cnt;i++) a+=k;
  cout<<a;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  if(A>2*B){
    cout << A-2*B << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    string a;
    cin >> a;
    int ans = 0;
    int tmp = 0;
    bool flag = false;
    const string b = "ATGC";
    
    rep(i,a.size())
    {
        if(!flag)tmp = 0;
        flag = false;
        rep(j,b.size())
        {
            if(a[i] == b[j])
            {
                flag = true;
                tmp++;
                break;
            }
        }
        if(!flag) ans = max(ans, tmp);
    }
    ans = max(ans, tmp);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

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

	ll sum = a[0];
	for (ll i = 1; i < n; i++) sum = (sum ^ a[i]);
	for (ll i = 0; i < n - 1; i++) cout << (sum ^ a[i]) << " ";
	cout << (sum ^ a[n - 1]) << endl;
}

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

int main() {
    int d;
    cin>>d;
    if(d==25){
        cout << "Christmas" << endl;
    }
    else if(d==24){
        cout << "Christmas Eve" << endl;
    }
    else if(d==23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if(d==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
flag = 0

ans = 1

for i in range(N):
    ans *= A[i]
    if ans > 10 ** 18:
        flag = 1
        break

if 0 in A:
    print(0)
else:    
    if flag == 0:
        print(ans)
    else:
        print(-1)

Measured memory_bytes: 21528
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;

cc N, K, i, j, k, A[500000], B[500000], sub = 0, n = 0;
cc judge = 0, Ans, J[500000];

string S;


int main() {
	
	cin >> N;
	for (i = 0; i < N+1; i++) 
		cin >> A[i];
	for (i = 0; i < N; i++)
		cin >> B[i];
	
	for (i = 0; i < N; i++) {
		if ((A[i] - sub) < B[i]) {
			Ans += A[i];
			if ((A[i] - sub) > 0)
				sub = B[i] - (A[i] - sub);
			else
				sub = B[i];
		}
		else {
			Ans += B[i] + sub;
			sub = 0;
		}
	}
	if (sub < A[N])
		Ans += sub;
	else
		Ans += A[N];
	cout << Ans << endl;
		return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
ll gcd(ll x, ll y) {
    if (y == 0) return x;
    else return gcd(y, x % y);
}
class SEG {
public:
    const ll INF = -1;
    ll n;
    ll N; //葉の数を入れたい
    vector<ll> dat;
    SEG(ll n):n(n),dat(4 * n){
        for (int i = 0; i < 4 * n; i++) {
            dat[i] = INF;
        }
        N = 1;
        while (N < n) {
            N *= 2;
        }
    } //コンストラクタ

    void update(int i, ll x) {
        i += N - 1;    // i番目の値はindex  i + n - 1に相当
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            if (dat[i * 2 + 1] == -1) {
                dat[i] = dat[i * 2 + 2];
            }
            else if (dat[i * 2 + 2] == -1) {
                dat[i] = dat[i * 2 + 1];
            }
            else {
                dat[i] = gcd(dat[i * 2 + 1], dat[i * 2 + 2]);
            }
        }
    }

    //[a, b)の最小値を求めたい  [l, r):dat[k] の表す区間
    ll query_sub(int a, int b, int k, int l, int r) {
        if ((r <= a) || (b <= l)) return INF;
        else if ((a <= l) && (r <= b)) return dat[k];
        else {
            ll vl = query_sub(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query_sub(a, b, 2 * k + 2, (l + r) / 2, r);
            if (vl == -1) return vr;
            if (vr == -1) return vl;
            else return gcd(vl, vr);
        }
    }
    ll query(int a, int b) {
        return query_sub(a, b, 0, 0, N);
    }
};
int main() {
    int n;
    cin >> n;
    SEG tree(n);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        tree.update(i, a);
    }
    ll M = max(tree.query(1, n), tree.query(0, n - 1));
    for (int i = 1; i < n - 1; i++) {
        ll t = gcd(tree.query(0, i), tree.query(i + 1, n));
        if (t > M) M = t;
    }
    cout << M << endl;
    return 0;
}

Measured memory_bytes: 6388
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  std::vector<int> v = {a, b, c};

  // 並べ替える
  std::sort(v.begin(), v.end());
  cout << v[0] * v[1] / 2 ;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string s; cin >> s;
  reverse(s.begin(),s.end());
  
  vector<string> d = {"maerd", "remaerd", "esare", "resare"};
  ll p = 0; bool match;
  rep(i, s.size()){
    rep(j, 4){
      match = false;
      if(s.substr(p, d[j].size()) == d[j]){
        p += d[j].size();
        match = true;
        break;
      }
    }
    if(!match){
      cout << "NO" << endl;
      return 0;
    }
    if(p == s.size())
      break;
  }
  
  cout << "YES" << endl;
}


Measured memory_bytes: 3720
# Tree - Rooted Trees
class Node:
    def is_leaf(self):
        return self.depth > 0 and len(self.degree) == 0
    
    def __init__(self, id):
        self.id = id
        self.parent = None
        self.sibling = None
        self.degree = []
        self.depth = 0
        self.height = 0
    def __str__(self):
        p = self.parent.id if self.parent else -1
        s = self.sibling.id if self.sibling else -1
        d = len(self.degree)
        typ = 'root'
        if self.depth > 0: typ = 'internal node'
        if d == 0 and self.depth > 0: typ = 'leaf'
        h = self.height
        return 'node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(self.id, p, s, d, self.depth, h, typ)

def calc_cld_depth(nd):
    cs = nd.degree
    for c in cs:
        c.depth = nd.depth + 1
        calc_cld_depth(c)

n = int(input())
rbt = [Node(i) for i in range(n)]
for i in range(n):
    id,left,right = map(int, input().split())
    tgt = rbt[id]
    l,r = None,None
    if not left == -1:
        l = rbt[left]
        l.depth += tgt.depth + 1
        l.parent = tgt
        calc_cld_depth(l)
        tgt.degree.append(l)
    if not right == -1:
        r = rbt[right]
        r.depth += tgt.depth + 1
        r.parent = tgt
        calc_cld_depth(r)
        tgt.degree.append(r)
    if (not left == -1) and (not right == -1):
        l.sibling, r.sibling = r,l
    if left == -1 and right == -1:
        if tgt.parent: tgt.depth = tgt.parent.depth + 1
# calc height
for c in rbt:
    h = 0
    if c.is_leaf():
        c.height = h
        p = c.parent
        while p:
            h += 1
            if p.height < h: p.height = h
            p = p.parent
for t in rbt: print(t)


Measured memory_bytes: 7840
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
set<ll> Divisors(ll n){
    set<ll> s1;
    for (int i = 1; i*i<=n; ++i)
    {
        if(n%i==0){
            s1.insert(i);
            s1.insert(n/i);
        }
    }
    return s1;
}

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

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

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

    vector<ll> v;
    for (int i = 1; i < n+1; ++i)
    {
        if(b[i]==1){
            v.push_back(i);
        }
    }

    cout<<v.size()<<endl;
    for (int i = 0; i < v.size(); ++i)
    {
        cout<<v[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 7280
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back



vector< int > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  vector<int> res;
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  rep(i,n){
    if(prime[i])
      res.PB(i);
  }
  return res;
}


int n;

int main(){

  cin>>n;
  vector<int> res = prime_table(500000);

  int i=0,c=0;
  while(c<n){
    if(res[i]%10==1){
      cout<<res[i]<<endl;
      c++;
    }
    i++;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

long long dp[51][51][2510];

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

	int n, k;
	cin >> n >> k;

	if (k % 2) {
		cout << 0;
		return 0;
	}
	k /= 2;

	dp[1][0][0] = 1;
	dp[1][1][1] = 1;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k <= i * i; ++k) {
				if (dp[i][j][k]) {
					long long t = dp[i][j][k];
					(dp[i + 1][j][k + j] += t) %= MOD;;
					(dp[i + 1][j + 1][k + j + 1] += t) %= MOD;
					if (j) {
						(dp[i + 1][j][k + j] += t * 2 * j) %= MOD;
						(dp[i + 1][j - 1][k + j - 1] += t * j * j) %= MOD;
					}
				}
			}
		}
	}
	cout << dp[n][0][k];
}

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

struct StCoord
{
  StCoord() : m_nx(0), m_ny(0) { }

  int m_nx;
  int m_ny;
};

void fnInput(vector<StCoord>& rvoCoord)
{
  int nCrdSiz;
  cin >> nCrdSiz;
  rvoCoord.resize(nCrdSiz);

  for (StCoord& roCoord : rvoCoord)
    cin >> roCoord.m_nx >> roCoord.m_ny;
}

double fnAveDistGet(const vector<StCoord>& cnrvoCoord)
{
  vector<vector<double>> vvnDist(cnrvoCoord.size(), vector<double>(cnrvoCoord.size()));
  
  for (int i = 0; i < cnrvoCoord.size(); i++)
    for (int j = 0; j < cnrvoCoord.size(); j++)
      if (i != j)
      {
        int nDistx = cnrvoCoord[i].m_nx - cnrvoCoord[j].m_nx;
        int nDisty = cnrvoCoord[i].m_ny - cnrvoCoord[j].m_ny;
        vvnDist[i][j] = vvnDist[j][i] = sqrt(nDistx * nDistx + nDisty * nDisty);
      }

  double nTotalDist = 0.0;
  int nTotalCnt = 0;

  vector<int> vnCity(cnrvoCoord.size());
  iota(begin(vnCity), end(vnCity), 0);

  do {
    for (int i = 0; i < cnrvoCoord.size() - 1; i++)
      nTotalDist += vvnDist[ vnCity[i] ][ vnCity[i + 1] ];
      nTotalCnt++;
  }
  while ( next_permutation(begin(vnCity), end(vnCity)) );

  return nTotalDist / nTotalCnt;
}

int main()
{
  vector<StCoord> voCoord;

  fnInput(voCoord);
  cout << fixed << setprecision(10) << fnAveDistGet(voCoord) << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const long double PI = acos(-1.);
int N;
std::vector<int>x, y;

int main()
{
	in >> N;
	x.resize(N), y.resize(N);
	rep(i, N) in >> x[i] >> y[i];
	out << std::fixed << std::setprecision(20);
	rep(i, N)
	{
		std::vector<long double>res;
		long double ans = 0;
		rep(j, N)
		{
			if (i != j) res.push_back(atan2(y[j] - y[i], x[j] - x[i]));
		}
		std::sort(res.begin(), res.end());
		int size = res.size();
		rep(j, N - 1) res.push_back(res[j] + 2 * PI);
		rep(j, N - 1) ans = std::max(ans, PI - res[j + N - 2] + res[j]);
		out << ans / (2 * PI) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=2e5+5;
int deg[MN][2];
int n,m;
char ch[MN];
int to[MN<<1],nxt[MN<<1],h[MN],cnt;
inline void ins(int s,int t){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;
}
int que[MN],ta;
int main(){
	scanf("%d%d",&n,&m);scanf("%s",ch+1);
	for(reg int i=1,s,t;i<=m;i++){
		scanf("%d%d",&s,&t);ins(s,t);
		deg[s][ch[t]-'A']++;deg[t][ch[s]-'A']++;
	}
	for(reg int i=1;i<=n;i++)
		if(!deg[i][0]||!deg[i][1])que[++ta]=i;
	for(reg int i=1;i<=ta;i++)
		for(reg int j=h[que[i]];j;j=nxt[j])
			if(deg[to[j]][0]&&deg[to[j]][1]&&!(--deg[to[j]][ch[que[i]]-'A']))
				que[++ta]=to[j];
	puts(ta<n?"Yes":"No");
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int n;
bool vis[10];
int ans[10];

struct PP {
	double x, y;
} p[15];

int cnt;
double res;

void dfs(int x) {
	if(x == n + 1) {
		cnt++;
		/*for(int i = 1; i <= n; i++) {
			printf("%d", ans[i]);
			if(i == n) printf("\n");
			else printf(" ");
		}*/
		for(int i = 2; i <= n; i++) {
			int id = ans[i], id0 = ans[i - 1];
			double dx = p[id].x - p[id0].x;
			double dy = p[id].y - p[id0].y;
			res += sqrt(dx * dx + dy * dy);
		}
	}
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			vis[i] = 1;
			ans[x] = i;
			dfs(x + 1);
			vis[i] = 0;
		}
	}
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lf %lf", &p[i].x, &p[i].y);
	dfs(1);
	res /= cnt * 1.0;
	printf("%.10lf\n", res);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int i;
	if((b-a+1)<=(k*2-1)){
		for(i=a;i<=b;i++)cout<<i<<endl;
	}else{
		for(i=0;i<k;i++)cout<<a+i<<endl;
		for(i=b-k;i<b;i++){
			cout<<i+1<<endl;
		} 
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

#define MAXN 100000
#define INF (1ll<<50)
int N,M;
struct Edge{
    int v,w;
    Edge(){}
    Edge(int a,int b){
        v=a,w=b;
    }
};
vector<Edge> G[MAXN+5];
long long Lim[2][MAXN+5];
//S1 < Lim[0][i]
//S1 > Lim[1][i]

void dfs(int u,int f,int Sign,long long Sum){
    for(int i=0;i<int(G[u].size());i++){
        int v=G[u][i].v,w=G[u][i].w;
        if(v!=f){
            int id=Sign==1?0:1;
            long long tmp=Sum+Sign*w;
            if(Lim[id][v]!=INF){
                if(Lim[id][v]!=tmp){
                    puts("0");
                    exit(0);
                }
                else
                    continue;
            }
            Lim[id][v]=tmp;
            dfs(v,u,-Sign,tmp);
        }
    }
}

int main(){
    scanf("%d%d",&N,&M);
    for(int i=1;i<=M;i++){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        G[u].push_back(Edge(v,w));
        G[v].push_back(Edge(u,w));
    }
    fill(Lim[0]+1,Lim[0]+N+1,INF);
    fill(Lim[1]+1,Lim[1]+N+1,INF);
    dfs(1,-1,1,0ll);
    long long Left=0,Right=INF;
    for(int i=2;i<=N;i++){
        if(Lim[1][i]!=INF)
            Left=max(Left,Lim[1][i]);
        if(Lim[0][i]!=INF)
            Right=min(Right,Lim[0][i]);
    }
    long long Sure=-1,flag=INF;
    for(int i=2;i<=N;i++)
        if(Lim[0][i]!=INF&&Lim[1][i]!=INF){
            long long k=Lim[0][i]+Lim[1][i];
            if(k%2||k/2<0) flag=0;
            if(Sure==-1) Sure=k/2;
            else if(Sure!=k) flag=0;
        }
    if(Sure!=-1){
        if(Left<Sure&&Sure<Right) puts("1");
        else puts("0");
        return 0;
    }
    printf("%lld",min(flag,max(Right-Left-1,0ll)));
}


Measured memory_bytes: 19712
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,x=n1()
L=n1()
ans=1
c=0
for i in L:
    c+=i
    if c>x:
        break
    ans+=1
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}
func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

type Group struct {
	Depth int
	Value string
}

type Job struct {
	No     int
	S      int
	E      int
	Worker string
}

type Res struct {
	No int
}

func Abs(a int64, b int64) int64 {
	res := a - b
	if a-b < 0 {
		res = -res
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	n := nextInt64()
	k := nextInt64()
	res := n % k
	for {
		diff := Abs(res, k)
		if res > diff {
			res = diff
		} else {
			break
		}
	}
	fmt.Fprintln(out, fmt.Sprint(res))
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
ll N, K;
vector<vector<ll>> Adj;

ll count(ll v, ll par) {
  ll res = 1;
  ll choice = par == -1 ? K - 1 : K - 2;
  for (ll w : Adj[v]) {
    if (w == par) continue;
    (res *= max(0ll, choice) * count(w, v) % MOD) %= MOD;
    --choice;
  }
  return res;
}
int main() {
  cin >> N >> K;
  Adj.resize(N);
  for (ll i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    Adj[a].push_back(b);
    Adj[b].push_back(a);
  }
  cout << (K * count(0, -1) % MOD) << endl;
  return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int x,y;
    cin >> x >> y;
    for(int i =0; i<=x; i++) {
       int a = i * 2 +  (x -i)  * 4;
       if (a == y) {
           yes
           return 0;
       }
    }
    no
}

Measured memory_bytes: 3132
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int L = scan.nextInt();
        UnionFind road = new UnionFind(N);
        UnionFind train = new UnionFind(N);
        for (int i = 0; i < K; i++) {
            int p = scan.nextInt() - 1;
            int q = scan.nextInt() - 1;
            road.merge(p, q);
        }
        for (int i = 0; i < L; i++) {
            int p = scan.nextInt() - 1;
            int q = scan.nextInt() - 1;
            train.merge(p, q);
        }
        Map<Long, Integer> count = new HashMap<>();
        for (int i = 0; i < N; i++) {
            long r_p = road.parent(i);
            long t_p = train.parent(i);
            long key = r_p * 1000000 + t_p;
            count.merge(key, 1, Integer::sum);
        }
        int[] answers = new int[N];
        for (int i = 0; i < N; i++) {
            long r_p = road.parent(i);
            long t_p = train.parent(i);
            long key = r_p * 1000000 + t_p;
            answers[i] = count.get(key);
        }
        System.out.println(Arrays.stream(answers).mapToObj(i -> Integer.toString(i)).collect(Collectors.joining(" ")));
    }
    class UnionFind {
        private int[] par;
        private int[] size;
        UnionFind(int N) {
            this.par = new int[N];
            for (int i = 0; i < N; i++) {
                par[i] = i;
            }
            this.size = new int[N];
            for (int i = 0; i < N; i++) {
                this.size[i] = 1;
            }
        }
        int parent(int N) {
            if (this.par[N] == N) {
                return N;
            }
            return this.par[N] = parent(this.par[N]);
        }
        boolean same(int x, int y) {
            int parent_x = parent(x);
            int parent_y = parent(y);
            return parent_x == parent_y;
        }
        void merge(int x, int y) {
            int parent_x = parent(x);
            int parent_y = parent(y);
            if (parent_x == parent_y) {
                return;
            }
            int size_x = this.size[parent_x];
            int size_y = this.size[parent_y];
            if (size_x < size_y) {
                this.par[parent_x] = parent_y;
                this.size[parent_y] += this.size[parent_x];
                this.size[parent_x] = -1;
                return;
            }
            this.par[parent_y] = parent_x;
            this.size[parent_x] += this.size[parent_y];
            this.size[parent_y] = -1;
        }
    }
}


Measured memory_bytes: 116316
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  int h,w,n;
  cin >> h >> w >> n;
  
  cout << ((w*10+n)%4==0?"YES":"NO") << endl;
  return 0;
}

Measured memory_bytes: 256
// spnauT
//
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int _b=(b),i=(a);i<_b;++i)
#define ROF(i,b,a) for(int _a=(a),i=(b);i>_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(),(x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define nl '\n'
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long LL;typedef pair<int,int> PII;
typedef vector<int>VI;typedef vector<LL>VL;typedef vector<PII>VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}

#define MAXN (100004)

int A[MAXN];
int C[MAXN];

int main()
{
	IO();
	cint2(N,M);
	FOR(i,0,N) C[i] = 1;
	A[0] = 1;

	REP(M)
	{
		cint2(a,b);
		--a;
		--b;
		A[b] |= A[a];
		++C[b];
		--C[a];
		if(C[a] == 0) A[a] = 0;
	}

	int sol = 0;
	FOR(i,0,N) sol += A[i];
	cout << sol << nl;

	return 0;
}

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

static const int SIZE = 26;

int main()
{
    string s;
    cin >> s;
    int table[SIZE];
    for (int i = 0; i < SIZE; i++)
    {
        table[i] = 0;
    }
    for (int i = 0; i < s.size(); i++)
    {
        int x = s[i] - 'a';
        table[x]++;
    }
    for (int i = 0; i < SIZE; i++)
    {
        if (table[i] % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

ll h[100010];
ll dp[100100];
int main() {
    int n, k;
    cin >> n >> k;
    REP(i, n) {
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    FOR(i, 0, n) {
        for(int j = 1; j <= k; j++) {
            chmin(dp[i+j], dp[i]+abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
MOD = 10**9 + 7
n = int(input())
c = list(map(int, input().split()))
c.sort()

if n > 1:
    ans = 0
    x = (1 << (n - 1)) % MOD
    y = (1 << (n - 2)) % MOD
    for i in range(n):
        m = x + (y * (n - 1 - i)) % MOD
        m %= MOD
        ans += c[i] * m
        ans %= MOD

    for i in range(n):
        ans *= 2
        ans %= MOD
else:
    ans = c[0] * 2
    ans %= MOD
print(ans)


Measured memory_bytes: 87628
#include<iostream>

using namespace std;
int main(void){

	int a[5],c[3];

	while(1){
		cin>>a[0];
		if(a[0]==0) break;
		for(int i=1;i<5;i++){
			cin>>a[i];
		}
		for(int i=0;i<5;i++){
			c[0]=0,c[1]=0,c[2]=0;
			for(int j=0;j<5;j++){
				c[a[j]-1]++;
			}
			if(c[a[i]-1]==5) cout<<3<<endl;
			if(c[0]>0&&c[1]>0&&c[2]>0) cout<<3<<endl;
			if(a[i]==1&&c[1]>0&&c[2]==0) cout<<1<<endl;
			if(a[i]==1&&c[1]==0&&c[2]>0) cout<<2<<endl;
			if(a[i]==2&&c[2]>0&&c[0]==0) cout<<1<<endl;
			if(a[i]==2&&c[2]==0&&c[0]>0) cout<<2<<endl;
			if(a[i]==3&&c[0]>0&&c[1]==0) cout<<1<<endl;
			if(a[i]==3&&c[0]==0&&c[1]>0) cout<<2<<endl;
		}

	}
}

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

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

    if((a+b) % 2 == 0){
        cout << (a+b) /2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
a,b,theta = list(map(float,input().split()))
S = 0.5*a*b*math.sin(theta*math.pi/180)
c = math.sqrt(a*a+b*b-2*a*b*math.cos(theta*math.pi/180))
L = a+b+c
h = 2*S/a
print('{area:.5f}\n{length:.5f}\n{height:.5f}'.format(area = S,length=L,height=h))


Measured memory_bytes: 5696
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL A[111];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld", A+i);

    LL X = 1000;
    pair<LL, LL> cur(0, 0); // price, num;

    REP (i, N) {
	if (i) {
	    if (cur.first < A[i]) X += cur.second * A[i];
	    else X += cur.second * cur.first;
	}

	cur.first = A[i];
	cur.second = X / A[i];
	X %= A[i];
    }

    X += cur.first * cur.second;

    printf("%lld\n", X);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3812
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    S = list(map(int, input().split()))

    X = [[0] for _ in range(N)]
    Y = [[0] for _ in range(N)]
    for k in range(1, N):
        for i in range(1, N):
            if i*k >= N:
                break
            X[k].append(X[k][-1] + S[i*k])
    for k in range(1, N):
        for i in range(1, N):
            if i*k >= N:
                break
            Y[k].append(Y[k][-1] + S[-i*k-1])
    ans = 0
    for k in range(1, N):
        for i in range(N):
            if i*k == N-1-i*k:
                break
            if k*(i-1) == N-1-i*k:
                break
            if k*(i+1) >= N-1:
                break
            ans = max(ans, X[k][i] + Y[k][i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 99540
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using ULL = uint64_t;
using P = pair<LL, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
//#define DEBUG

//LL combination(const LL m, const LL n) {
//  LL prod = static_cast<LL>(1);
//  for (LL i = 0; i < n; ++i) {
//    prod *= (m - i);
//    prod /= (i + 1);
//  }
//  return prod;
//}

vector<LL> how_many_psum; // partial sum.

inline LL n_div_2(LL n) {
  LL count = 0;
  while (n != 0 && n % 2 != 1) {
    count++;
    n /= 2;
  }
  return count;
}

LL combination_mod_2(const LL m, const LL n) {
  if (how_many_psum.at(m) - how_many_psum.at(m - n) - how_many_psum.at(n) >= 1) {
    return 0;
  } else {
    return 1;
  }
}

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

  string s;
  cin >> s;

  bool contains_mid = false;
  rep (i, n) {
    switch (s[i]) {
    case '1':
      s[i] = '0';
      break;
    case '2':
      s[i] = '1';
      contains_mid = true;
      break;
    case '3':
      s[i] = '2';
      break;
    }
  }

  if (!contains_mid) {
    rep (i, n) {
      switch (s[i]) {
      case '2':
        s[i] = '1';
        break;
      }
    }
  }

  how_many_psum.assign(n, 0);
  how_many_psum.at(0) = n_div_2(0);
  rep (i, n - 1) {
    how_many_psum.at(i + 1) = how_many_psum.at(i) + n_div_2(i + 1);
  }

  LL sum = 0;
  rep (i, n) {
    if (s[i] == '1') {
      sum += combination_mod_2(n - 1, i);
    }
  }
  if (sum % 2 != 1) {
    // mid value
    cout << '0' << endl;
  } else {
    if (contains_mid) {
      cout << '1' << endl;
    } else {
      cout << '2' << endl;
    }
  }
  
  #ifdef DEBUG
  cout << n << endl;
  cout << s << endl;
  #endif
}



Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
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 % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(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;
    }
}
long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }
const ll INF = 1LL << 60;
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> as;
map<P, ll> number;
ll rmemo[101][300001];
ll memo[101][300001];
int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> as(n);
    memo[n][k] = 1;
    REP(i, n) { cin >> as[i]; }
    for (int i = n - 1; i >= 0; i--) {
        REP(j, 200001) { rmemo[i + 1][j + 1] = (memo[i + 1][j] + rmemo[i + 1][j])%mod; }
        REP(j, k + 1) {
            memo[i][j] = (rmemo[i + 1][j + as[i] + 1] - rmemo[i + 1][j])%mod;
            
        }
    }
    cout << (memo[0][0]+mod)%mod << endl;
}

Measured memory_bytes: 238792
# coding: utf-8


def solve(*args: str) -> str:
    a, v = map(int, args[0].split())
    b, w = map(int, args[1].split())
    t = int(args[2])
    ret = 'NO'
    if a == b:
        ret = 'YES'
    if w < v and abs(a-b)/(v-w) <= t:
        ret = 'YES'
    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, pin;
  cin >> n;
  vector<int> p(n + 1, 0);
  for(int i = 1; i <= n; ++i)
  {
    cin >> pin;
    p[i - 1] = (pin == i);
  }
  int ans = 0;
  for(int i = 0; i < n; ++i)
  {
    if (p[i]) p[i + 1] = 0;
    ans += p[i];
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3700
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = a-b;
		System.out.print(Math.max(c-d,0));
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MAX (int)(8000+5)
#define PB push_back
#define MP make_pair
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define sz(a) (int)a.size()
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d%d",&a,&b)
#define p1(a) cout<<"Check "<<a<<endl
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl
#define forn(i,n) for(int i=0;i<int(n);i++)
#define fore(i,l,n) for(int i=int(l);i<int(n);i++)
#define clr(a) memset(a,0,sizeof(a))
#define MOD (int)(1e7+7)
#define INF (long long)(1e18)

using namespace std;

int main()
{
    //freopen("tt.txt","r",stdin);
    //cout<<__gcd(865,365)<<endl;
    int test=1,i=0;
    //si(test);
    while(test--){
        string s,str;
        cin>>s>>str;
        int cnt=0;
        for(int i=0;i<sz(s);i++){
            if(s[i]==str[i]) cnt++;
        }
        if(cnt==sz(s)) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}




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

int main(void) {
    int N;
    cin >> N;
    int d[110];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d, d+N);
    int result = 0;
    int max = 0;
    for (int i = 0; i < N; i++) {
        if (d[i] != max) {
            max = d[i];
            result++;
        }
    }

    cout << result << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

    int n, k, q;
    cin >> n >> k >> q;

    vector<int> correct(n + 1, 0);
    int p;
    for (int i = 0; i < q; ++i) {
        cin >> p;
        ++correct[p];
    }

    for (int i = 1; i <= n; ++i) {
        int point = k - (q - correct[i]);
        if (point > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>

int main()
{
    while (true) {
        int l[10], v[2];
        char comma;
        for (int i = 0; i < 10; ++i) std::cin >> l[i] >> comma;
        std::cin >> v[0] >> comma >> v[1];
        if (std::cin.eof()) break;

        int ls = 0;
        for (int i = 0; i < 10; ++i) ls += l[i];
        double t = (double)ls / (v[0] + v[1]);
        double d = t * v[0];
        for (int i = 1; i <= 10; ++i) {
            d -= l[i - 1];
            if (d <= 0) {
                std::cout << i << std::endl;
                break;
            }
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll l, r;
	cin >> l >> r;
	if(r-l >=2019) cout << 0;
	else{
		int ans = 2018;
		REP(i, l, r+1){
			REP(j, i+1,r+1){
				ans = min(ans, (i%2019)*(j%2019) % 2019);
			}
		}
		cout << ans;
	}
}


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


int main(){
int n,m,k;
cin>>n>>m>>k;
vector<int> d(m);
vector<vector<int> > v(n,vector<int>(k));
vector<int> nogoal(n,-1);
for(int i=0;i<m;i++){
	cin>>d[i];
	d[i]--;
	nogoal[d[i]]=i;
}
for(int i=0;i<n;i++)for(int j=0;j<k;j++){
	cin>>v[i][j];
	v[i][j]--;
}
vector<int> dp(1<<m,-1);
queue<int> q;
q.push((1<<m)-1);
dp[(1<<m)-1]=0;

while(!q.empty()){
	int now=q.front();
	q.pop();
//	cout<<now<<dp[now]<<endl;
	if(now==0)break;
	for(int i=0;i<k;i++){
	int next=0;
		for(int j=0;j<m;j++){
			if(now&(1<<j))
			if(nogoal[v[d[j]][i]]>=0){
			next=next|(1<<nogoal[v[d[j]][i]]);
			}
		}	
	if(dp[next]<0){
		dp[next]=dp[now]+1;
		q.push(next);
	}
	
	else if(dp[next]>dp[now]+1){
	dp[next]=dp[now]+1;
		q.push(next);
	}
		

	}

}


cout<<dp[0]<<endl;
return 0;
}



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

int main(){
  int n;
  cin >> n;
  int n1,n2,n3,n4;
  n1 = n%10;
  n2 = (n/10)%10;
  n3 = (n/100)%10;
  n4 = (n/1000);
  if(n1 == n2 && n2 == n3){
    cout << "Yes" << endl;
  }else if (n2 == n3 && n3 == n4){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
struct edge{
	int t,next;
}g[400001];
ll ans,t1,t2;
int tmp,c[200001],i,j,k,n,m,tot,h[200001],flag,t3;
void addedge(int x,int y){
	g[++tot].t=y;g[tot].next=h[x];h[x]=tot;
	g[++tot].t=x;g[tot].next=h[y];h[y]=tot;
}
void dfs(int x){
	int i;
	tmp++;
	for (i=h[x];i;i=g[i].next)
	 if (!c[g[i].t]) c[g[i].t]=3-c[x],dfs(g[i].t);
	 else if (c[g[i].t]==c[x]) flag=0;
}
int main(){
	scanf("%d%d",&n,&m);memset(h,0,sizeof(h));memset(c,0,sizeof(c));tot=0;
	for (i=1;i<=m;i++) scanf("%d%d",&j,&k),addedge(j,k);
	for (i=1,t1=t2=t3=0;i<=n;i++)
	 if (!c[i]){
	 	c[i]=flag=1;tmp=0;dfs(i);
	 	if (tmp==1) t3++;
	 	else if (flag) t2++;else t1++;
	 }
	ans=t1*t1+2LL*t1*t2+2LL*t2*t2;
	ans+=(ll)n*(ll)n-(ll)(n-t3)*(ll)(n-t3);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6656
fn run() {
    proconio::input! {
        n: usize,
        t: u64,
        store: [(u32, u32); n],
    }
    let mut zero = vec![];
    let mut p = vec![];
    for (a, b) in store {
        if a == 0 {
            zero.push(b + 1);
        } else {
            p.push((a, a + b + 1));
        }
    }
    p.sort_by(|a, b| (a.1 as u64 * b.0 as u64).cmp(&(b.1 as u64 * a.0 as u64)));
    let w = 30;
    let mut dp = vec![t + 1; w];
    dp[0] = 0;
    for (a, b) in p {
        let a = a as u64;
        let b = b as u64;
        for i in (1..w).rev() {
            let x = dp[i - 1];
            let v = x + a * x + b;
            dp[i] = std::cmp::min(dp[i], v);
        }
    }
    zero.sort();
    zero.reverse();
    let mut ans = 0;
    let mut sum = 0;
    let mut cnt = 0;
    for (i, dp) in dp.into_iter().enumerate().rev() {
        while let Some(&b) = zero.last() {
            let b = b as u64;
            if dp + sum + b > t {
                break;
            } else {
                sum += b;
                cnt += 1;
                zero.pop();
            }
        }
        if sum + dp <= t {
            ans = std::cmp::max(ans, cnt + i);
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 9556
<?php
$numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
$n = intval($numbers[0]);
while ($n != 0){
    $m = intval($numbers[1]);
    // print $n;
    
    $money = [];
    $total = 0;
    $numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
    for ($i = 0; $i < $n; $i++) {
        $money[] = intval($numbers[$i]);
        if( ($m / $n) <= $numbers[$i]){
            $total += ($m / $n);
        } else {
            $total += $numbers[$i];
    
        }
    
    }
    
    // print_r($money);
    print $total;
    print "\n";
    $numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
    $n = intval($numbers[0]);
}


Measured memory_bytes: 9432
N = int(input())

B = list(map(int, input().split()))

A = [0]*N
A[0] = B[0]
A[N-1] = B[N-2]

for i in range(N):
    if i == 0 or i == (N-1):
        pass
    else:
        A[i] = min(B[i-1], B[i])

print (sum(A))

Measured memory_bytes: 3064
//Finite Disappointment and Infinite Hope
#include <bits/stdc++.h>
using namespace std;
#define help ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.first<<","<<v.second<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    for(auto &x:c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
const ll N=2e5+5,MOD=1e9+7;
int main(){
help
    ll w,h,n;cin>>w>>h>>n;
    ll opr = max(w,h);
    cout<< (n+opr-1)/opr;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M) vector<vector<L>> K(N, vector<L>(M))
#define mod 1000000007
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
  int A,B,C,D,E,F,N,M,K,sum=0,num=0;
  cin >> M >> K;
  rep(i,4,M+1)rep(j,1,K+1){
    A=j%10;B=j/10;
    if(A==1||B==1)continue;
    if(A*B==i)sum++;
  }
  Out(sum);
}

Measured memory_bytes: 256