akhauriyash/Code-Regression huggingface dataset:
from typing import Union


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
print(uf.group_count()-1)


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

using namespace std;

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

int main()
{
  long long int k=0,value=0;
  cin>>k;
  
  for(int a=1;a < k+1;a++)
  {
      for(int b=1;b < k+1;b++)
      {
          for(int c=1;c < k+1;c++)
          {
              value = value + gcd(gcd(a,b),c);
          }
      }
  }
  cout<<value<<endl;

  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;

int s[N], t[N];

bool solve() {
  int h, w, n; scanf("%d%d%d", &h, &w, &n);
  int sr, sc; scanf("%d%d", &sr, &sc);
  for (int i = 0; i < n; ++i) {
    scanf(" %c", s+i);
    if (s[i] == 'L') s[i] = 0;
    else if (s[i] == 'R') s[i] = 1;
    else if (s[i] == 'U') s[i] = 2;
    else s[i] = 3;
  }
  for (int i = 0; i < n; ++i) {
    scanf(" %c", t+i);
    if (t[i] == 'L') t[i] = 0;
    else if (t[i] == 'R') t[i] = 1;
    else if (t[i] == 'U') t[i] = 2;
    else t[i] = 3;
  }
  int z[4] = {0, 0, 0, 0};
  ++z[s[n-1]];
  --sc; --sr;
  for (int i = n-2; i >= 0; --i) {
    int other = t[i]+1;
    if (t[i]%2) other = t[i]-1;
    z[other] = max(z[other]-1, 0);
    ++z[s[i]];
    if (z[0] >= w-z[1] || z[2] >= h-z[3]) return true;
  }
  debug(z[0]);
  debug(w-z[1]);
  debug(z[2]);
  debug(h-z[3]);
  debug(sc);
  debug(sr);
  debug(sc);
  debug(sr);
  return z[0] > sc || w-z[1] <= sc || z[2] > sr || h-z[3] <= sr;
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    puts(!solve()?"YES":"NO");
  }
  return 0;
}


Measured memory_bytes: 5180
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function(chunk){
var a = chunk.split(' ');
var b = parseInt(a[0],10);
var c = parseInt(a[1],10);
var menseki = b*c;
var nagasa = b*2+c*2;
console.log(menseki+' '+nagasa);
});

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int calc(ll n) {
    ll c = 0;
    for (k = 1; k <= n; k++) {
        if (n % k == 0) c++;
    }
    return c;
}

int main() {
    cin >> n >> x;
    MSG(n - x + 1)
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int H, N;
  cin >> H >> N;
  vi A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    H -= A[i];
  }
  string ans = "No";
  if (H <= 0) ans = "Yes";
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		boolean[] red = new boolean[n];
		Arrays.fill(a, 1);
		red[0] = true;
		for(int i = 1; i < n; i++) {
			red[i] = false;
		}
		for(int i = 0; i < m; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			x--;
			y--;
			if(red[x] && !red[y]) {
				red[y] = true;
//				if(a[x] == 1) {
//					red[x] = false;
//				}
//				a[x]--;
//				red[y] = true;
//				a[y]++;
			}
			if(a[x] == 1 && red[x]) {
				red[x] = false;
			}
			a[x]--;
			a[y]++;
		}
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(red[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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


int main() {
  
  
  int a[9];
  for (int i=0; i < 9; i++) cin >> a[i];

  int N;
  cin >> N;
  int b[N];
for (int i=0; i < N; i++) cin >> b[i];

int num[9]={0};
for (int i=0; i < N; i++){
  for (int j=0; j < 9; j++){
    if (b[i]==a[j])
      {
        num[j]+= 1;
      }
  }
}

string result;
if ((num[0]&&num[1]&&num[2] >= 1)|
(num[3]&&num[4]&&num[5] >=1 )|
(num[6]&&num[7]&&num[8] >=1 )|
(num[0]&&num[3]&&num[6] >=1 )|
(num[1]&&num[4]&&num[7] >=1 )|
(num[2]&&num[5]&&num[8] >=1 )|
(num[0]&&num[4]&&num[8] >=1 )|
(num[2]&&num[4]&&num[6] >=1 ))
  {
    result = "Yes";
  }

else
{
  result = "No";
}
cout << result << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
class Main{
  public static void main(String args[]){
    long n;
    String str="";
    n = readLong();
    while(n>0){
      long k=n%26;
      if(k==0){k=26;}
      k--;
      str=(char)('a'+k)+str;
      n=(n-1)/26;
    }
    pl(str);
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

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

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

using namespace std;

int main(){
    int N, W;
    while(cin >> N >> W){
        vector<int> v(N), w(N);
        for(int i=0;i<N;i++) cin >> v[i] >> w[i];
        vector<int> dp(W+1, 0);
        for(int i=0;i<N;i++){
            for(int j=W;j>=w[i];j--) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
        }
        cout << dp.back() << endl;
    }
}


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

int N;
string c;

int main(){
	while(cin >> N, N != 0){
		cin >> c;
		vector<int> v = vector<int>(N);
		for(int i = 0; i < N; i++){
			v[i] = 0;
		}
		int b = 0;
	
		int t = 0;
		for(int i = 0; i < 100; i++){
			if(c[i] == 'M'){
				v[t]++;
			}
			else if(c[i] == 'S'){
				b += v[t] + 1;
				v[t] = 0;
			}
			else{ // L
				v[t] += b + 1;
				b = 0;
			}
			t = (t+1)%N;
		}
		sort(v.begin(),v.end());
		for(int i = 0; i < N; i++){
			cout << v[i] << " ";
		}
		cout << b << endl;
	}
	return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int main(){
  ll h,w;cin>>h>>w;
  string a[h];
  for(ll i=0;i<h;i++)cin>>a[i];
  ll dp[h][w];
  for(ll i=0;i<h;i++)for(ll j=0;j<w;j++)dp[i][j]=0;
  dp[0][0]=1;
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      if(a[i][j]=='#')continue;
      if(i+1<h&&a[i+1][j]=='.'){
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]%=mod;
      }
      if(j+1<w&&a[i][j+1]=='.'){
        dp[i][j+1]+=dp[i][j];
        dp[i][j+1]%=mod;
      }
    }
  }
  cout<<dp[h-1][w-1]%mod<<endl;
}

Measured memory_bytes: 9088
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

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

    vector<pair<long long, int>> v;
    for (long long i = 2; i * i < n; i++) {
        int cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        pair<long long, int> p(i, cnt);
        v.emplace_back(p);
    }
    if (n != 1) {
        pair<long long, int> p(n, 1);
        v.emplace_back(p);
    }

    int ans = 0;
    for (auto p : v) {
        int a = p.second;
        int i = 1;
        while (i <= a) {
            a -= i;
            i++;
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 19748
#include <iostream>
#include<vector>
#define RP(i,n) for(int i;i<n;i++)
using namespace std;
// 5
// 1 5 7 10 21
// 4
// 2 4 17 8


int n;

vector<int> A(50);

bool solve(int i,int m){
    if (m==0) return 1;
    if (i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A.at(i));
    return res;
}


int main() {
    int q,M,i;
    cin>>n;
    // for(int i=0;i<n;i++){
    RP(i,n) 
        cin>>A.at(i);
    // }
    cin>>q;
    RP (i,q){
        cin>>M;
        if (solve(0,M)) cout<<"yes\n";
        else cout<<"no\n";
    }
        return 0;
 }



Measured memory_bytes: 3096
f=lambda:map(int,input().split())
n,m=f()
# Union Find
p=[-1]*n
def root(x):
  while p[x]>=0: x=p[x]
  return x
def unite(x,y):
  x,y=root(x),root(y)
  if x==y: return
  if x>y: x,y=y,x
  p[x]+=p[y]
  p[y]=x
def same(x,y):
  return root(x)==root(y)
def size(x):
  return -p[root(x)]

for i in range(m):
  a,b=f()
  unite(a-1,b-1)
print(-min(p))

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

int main(){
  int A,B;
  cin >> A >> B;
  int num = 0;
  int n1,n2,n4,n5;
  for(int i=A;i<B+1;i++){
    n5=i%10;
    n4=(i/10)%10;
    n2=(i/1000)%10;
    n1=i/10000;
    if(n1==n5 && n2==n4){
      num++;
    }
  }
  cout << num << endl;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int jColor(int i) {
	return (i+1) % 3;
}

int kColor(int i) {
	return (i+2) % 3;
}

int color(char c) {
	return c == 'R' ? 0 : c == 'B' ? 1 : 2;
}

ll findAllJK(int cur, vector<int> v1, vector<int> v2) {
	ll c = 0;

	auto it1 = upper_bound(v1.begin(), v1.end(), cur);

	for (auto it = it1; it != v1.end(); it++) {

		auto it2 = upper_bound(v2.begin(), v2.end(), *(it));
		int c2 = distance(it2, v2.end());

		if (c2 > 0) {
			if (binary_search(v2.begin(), v2.end(), *(it) + *(it) - cur))
				c2--;

			c += c2;	
		}
	}

	return c;
}

void printV(vector<int> v) {
	for (auto x: v)
		cout << x << " ";
	cout << endl;
}

int main() {

	IOS

	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<vector<int>> v;
	v.resize(3);

	int red = 0, blue = 1, green = 2;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')
			v[red].push_back(i);

		else if (s[i] == 'G')
			v[green].push_back(i);

		else if (s[i] == 'B')
			v[blue].push_back(i);
	}

	// printV(v[red]);
	// printV(v[blue]);
	// printV(v[green]);

	int color_i, color_j, color_k;
	ll c = 0;

	for (int i = 0; i < n-2; i++) {
		color_i = color(s[i]);
		color_j = jColor(color_i);
		color_k = kColor(color_i);

		// deb(color_i);
		// deb(color_j);
		// deb(color_k);

		c += findAllJK(i, v[color_j], v[color_k]);
		c += findAllJK(i, v[color_k], v[color_j]);
	}

	cout << c << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

ll mod;

ll powimod(ll x,ll n,ll mod){
    ll res=1;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

ll func(ll n)
{
if(n==0) return 0;
ll op=0;
while(n)
{
n=n%(__builtin_popcount(n));
op++;
}
return op;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a[200001];
    for(ll i=0;i<=200000;i++)
    {
    a[i]=func(i);
    }
    ll n;
    cin>>n;
    string s;
    cin>>s;
    int pop=0;
    for(ll i=0;i<n;i++)
    {
    if(s[i]=='1') pop++;
    }
    ll rem1=0;
    for(ll i=n-1;i>=0;i--)
    {
    if(s[i]=='1') rem1=(rem1+powimod(2,n-1-i,pop+1))%(pop+1);
    }
    ll rem2=0;
    if(pop>1)
    {
    for(ll i=n-1;i>=0;i--)
    {
    if(s[i]=='1') rem2=(rem2+powimod(2,n-1-i,pop-1))%(pop-1);
    }
    }
    ll temp;
    for(ll i=0;i<n;i++)
    {
    if(s[i]=='0')
    {
    temp=rem1;
    temp=(temp+powimod(2,n-1-i,pop+1))%(pop+1);
    cout<<a[temp]+1<<"\n";
    }
    else
    {
    if(pop==1)
    {
    cout<<0<<"\n";
    }
    else
    {
    temp=((pop-1)-powimod(2,n-1-i,pop-1))%(pop-1);
    temp=(temp+rem2)%(pop-1);
    cout<<a[temp]+1<<"\n";
    }
    }
    }
}


Measured memory_bytes: 5308
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M; cin>>N>>M;
    vector<ll> X(N+1,0); //数
    vector<bool> R(N+1,0); //赤
    rep1(i,N) X[i]=1;
    R[1]=true;
    
    rep(i,M){
        ll x,y; cin>>x>>y;
        if(!R[x]){
        }
        else{
            if(X[x]==1){
                R[x]=false;
                R[y]=true;
            }
            else R[y]=true;
        }
        X[x]--;
        X[y]++;
    }
    ll ans=0;
    rep1(i,N){
        if(R[i]) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3996
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int n;
  cin >> n;
  int ans=n;
  string s[n];
  for(int i=0;i<n;i++){cin >> s[i];}
  sort(s,s+n);
  for(int i=0;i<n-1;i++){if(s[i]==s[i+1])ans--;}
  cout << ans << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  double H, W, X, Y;
  cin >> H >> W >> X >> Y;
  cout << fixed << setprecision(10) << (H*W)/2 << " " << (H == X*2 && W == Y*2) << endl;
}


Measured memory_bytes: 256
using System;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());

        string s = Console.ReadLine();
        string[] t = s.Split(' ');
        //数字の割り当て
        float T = float.Parse(t[0]);
        float A = float.Parse(t[1]);

        string h = Console.ReadLine();
        string[] h_split = h.Split(' ');
        //数字の割り当て
        float[] H = new float[N];
        for (int i = 0; i < N; i++) {
            H[i] = float.Parse(h_split[i]);
        }

        //その高さの温度
        float[] temp = new float[N];
        //差となる温度（絶対値）
        float[] diff = new float[N];
        //最小値を保存する用の変数
        float min_temp = 999.0f;
        int a = 0;

        //各地点において温度を求める
        for (int i = 0; i < N; i++) {
            temp[i] = T - H[i] * 0.006f;
            diff[i] = Math.Abs(A - temp[i]);
            if (i == 0) {
                min_temp = diff[0];
                a = 0;
            } else {
                //min_temp = Math.Min(diff[i], diff[i - 1]);
                //if (diff[i] < diff[i - 1]) {
                //    a = i;
                //} else {
                //    break;
                //}
                if (diff[i] == 0) {
                    a = i;
                    break;
                } else if (diff[i] < min_temp) {
                    min_temp = diff[i];
                    a = i;
                }
            }
        }

        //出力
        Console.WriteLine(a + 1);
    }
}

Measured memory_bytes: 13204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

Int IntLCM(Int a, Int b, Int MAX) {
    Int c = a / __gcd(a,b) * b;
    if (c > MAX) return -1;
    else return c;
}


int main(){ 
  
  Int N, M;
  cin >> N >> M;
  vector<Int> a(N);
  rep(i,N) {
      cin >> a[i];
      a[i] /= 2;
  }

  Int LCM = a[0];

  rep1(i,N-1) {
      Int n = IntLCM(LCM,a[i],M);
      if (n == -1) {
          cout << 0 << endl;
          return 0;
      }
      else LCM = n;
  }

  bool flag = true;

  rep(i,N) {
      if ((LCM / a[i]) % 2 == 0) flag = false;
  }

  if (!flag) {
      cout << 0 << endl;
      return 0;
  }

  cout << (M / LCM) - (M / (2 * LCM)) << endl;





}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0){
            return 0;
        }
        for(int i=0;i<9;++i){
            int a;
            cin>>a;
            n-=a;
        }
        cout<<n<<endl;
    }
}


Measured memory_bytes: 2980
N,A,B,C,D = map(int,input().split())
S = input()
X = max(C,D)
rock = 0
check = 0
for i in S[A:X]:
    if i == '#':
        rock += 1
    else:
        rock = 0
    if rock == 2:
        check = 1
        break
if check == 0 and C > D:
    plane = 0
    pcheck = 0
    for i in S[B-2:D+1]:
        if i == '.':
            plane += 1
            if plane == 3:
                pcheck = 1
                break
        else:
            plane = 0
    if pcheck == 0:
        check = 1
if check == 0:
    print('Yes')
else:
    print('No')

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

int main(){
    
    long long int N;
    cin>>N;
    long long int ans=0;
    ans+=N/11*2;
    N-=N/11*11;
    if(1<=N&&N<=6) ans++;
    else if(7<=N)ans+=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N,M;
    cin>>N>>M;
    vector<vector<ll>> G(N);
    rep(i,M){
        ll a,b;
        cin>>a>>b;
        G.at(a-1).push_back(b-1);
        G.at(b-1).push_back(a-1);
    }
    vector<ll> dist(N,-1);
    queue<ll> que;

    dist.at(0)=0;
    que.push(0);

    while(!que.empty()){
        ll v=que.front();
        que.pop();

        for(ll nv:G.at(v)){
            if(dist.at(nv)!=-1)continue;
            dist.at(nv)=dist.at(v)+1;
            que.push(nv);
        }
    }
    cout<<"Yes"<<endl;
    rep(i,N){
        if(i>=1){
            for(ll v:G.at(i)){
                if(dist.at(i)==dist.at(v)+1){
                    cout<<v+1<<endl;
                    break;
                }
                
            }
        }
    }
}

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

int answer[10500];

void add_gyakusu(int x){
  int t = 1;
  for(int i = 0;i < 10200;i++){
    answer[i] += t / x;
    t %= x;
    t *= 10;
  }
}

void kuriagari(){
  for(int i = 10199;i >= 0;i--){
    answer[i - 1] += answer[i] / 10;
    answer[i] %= 10;
  }
}

int main(){
  int n, k, m, r;
  while(true){
    cin >> n >> k >> m >> r;
    fill(answer, answer + 10500, 0);
    if(n + k + m + r == 0)return 0;
    add_gyakusu(n);
    if(m == 1){
      for(int i = 1;i < n;i++){
	add_gyakusu(i * n);	
      }
    }
    kuriagari();
    cout << answer[0]  <<'.';
    for(int i = 1;i <= r;i++){
      cout << answer[i];
    }
    cout << endl;
  }
}

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

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string st;
vector<int> a[10];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n >> st;
    for (int i = 0; i < n; i++) {
        a[st[i] - '0'].push_back(i);
    }
    ll ans = 0;
    for (int i = 0; i < 10; i++) {
        if (a[i].empty()) {
            continue;
        }
        int idOne = a[i][0];
        for (int j = 0; j < 10; j++) {
            if ((i == j && a[j].size() == 1) || a[j].empty()) {
                continue;
            }
            int idTwo = -1, L = 0, R = a[j].size() - 1;
            while (L <= R) {
                int M = L + R >> 1;
                if (a[j][M] > idOne) {
                    idTwo = a[j][M];
                    R = M - 1;
                } else {
                    L = M + 1;
                }
            }
            if (idTwo == -1) {
                continue;
            }
            for (int k = 0; k < 10; k++) {
                if ((i == j && j == k && a[k].size() < 3) || a[k].empty()) {
                    continue;
                }
                int idThree = -1;
                L = 0, R = a[k].size() - 1;
                while (L <= R) {
                    int M = L + R >> 1;
                    if (a[k][M] > idTwo) {
                        idThree = a[k][M];
                        R = M - 1;
                    } else {
                        L = M + 1;
                    }
                }
                if (idThree != -1) {
                    ans++;
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


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


int main() {
    string s[] = {"Sunny", "Cloudy", "Rainy"},inp;
    cin >>inp;
    rep(i,3){
        if(inp==s[i])cout << s[(i+1)%3] <<endl;
    }
}

Measured memory_bytes: 256
package main

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

func main() {
	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	for b := 0; b < 60; b++ {
		t := 0
		bs := (A[N-1] >> uint(b)) & 1
		for i := N - 2; i > -1; i-- {
			a := (A[i] >> uint(b)) & 1
			if a == 0 {
				t += bs
			} else {
				t += (N - (i + 1)) - bs
			}
			bs += a
		}
		t %= 1000000007
		B := (1 << uint(b)) % 1000000007
		result += (t * B) % 1000000007
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 9088
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe (fromJust)

type Dice = [Int]

rot :: Dice -> Char -> Dice
rot d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]
rot d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
rot d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
rot d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
rot _ _ = undefined

solve :: [[Int]] -> [String]
solve (dice:qCnt:qs) =
    map solve' $ take (head qCnt) qs
    where
    solve' [upSide,foreSide] =
        let cmdSet = [(upSide, ["", "N", "W", "E", "S", "NN"]),
                        (foreSide, ["S", "", "NWS", "NES", "NEES", "N"])] in
        let d = foldl' f dice cmdSet in
        show $ d!!2
    f :: Dice -> (Int,[String]) -> Dice
    f dice (side,cmds) =
        let cmd = fromJust . lookup side $ zip dice cmds in
        foldl' rot dice cmd

main =
    mapM_ putStrLn =<< solve . map (map read . words) . lines <$> getContents

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())
const double PI = 3.14159265359;
using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

int main(){
	int i,j,k,l,a,b,c,d;
	scanf("%d",&i);
    printf("%lf",2*PI*i);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 3832
#[allow(unused_imports)]
use proconio::{fastout, input};
 
#[fastout]
fn main() {
  input!(n: isize);
  let mut optional = Some(n);
  let mut count = 0;
  let mut iter_cnt = 0;
  let mut multiplyer = 10;
  while let Some(i) = optional {
    if i >= 10 {
      if iter_cnt % 2 == 0 {
        count += multiplyer - multiplyer / 10;
      }
      multiplyer *= 10;
      optional = Some(i / 10);
      iter_cnt += 1;
    } else if i > 0 {
      if iter_cnt % 2 == 0 {
        count += n - multiplyer / 10 + 1;
      }
      multiplyer *= 10;
      optional = Some(i / 10);
      iter_cnt += 1;
    } else {
      break;
    }
  }
  println!("{}", count);
}

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

namespace B_ABC126
{
    class MainClass
    {

        static int[] s;


        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int mae = s[0]/100;
            int ushiro = s[0]%100;
            string ans="";
            if(mae>=1&&12>=mae){
                if(ushiro>=1&&ushiro<=12){
                    ans = "AMBIGUOUS";

                }else{
                    ans = "MMYY";
                }
            }else{
                if(ushiro>=1&&ushiro<=12){
                    ans = "YYMM";
                }else{
                    ans = "NA";
                }
            }

            WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13268
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
#define inf 1e18
const int mod=1e9+7;
const int N=2e5+9;
const long double pi=3.14159265358979323846;
void raushan_kumar(){

    /////////////////variables///////////////
    int d=0,e=0,f=0,g=0;
    double f1=0.0,f2=0.0,f3=0.0;
    int flag=0,ans=0,res=0,cnt=0,sum=0;
    /////////////////////////////////////////
    ld n;cin>>n;
    ld k=2*pi*n;
    cout<<k;    
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fast;int t=1;
    //cin>>t;
    while(t--){
        raushan_kumar();
    }

}

Measured memory_bytes: 3796
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for _ in range(N):
    s = input()
    d[s] += 1
print('AC x '+str(d['AC']))
print('WA x '+str(d['WA']))
print('TLE x '+str(d['TLE']))
print('RE x '+str(d['RE']))


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


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	int N, K; cin >> N >> K;
	vector<int> p(N); cin >> p;

	sort(p.begin(), p.end());
	int ans = 0;
	for(int i=0; i<K; i++) ans += p[i];
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n; cin >> n;
    vector<long long> cnt(60, 0);
    for (int i = 0; i < n; i++) {
        long long a; cin >> a;
        for (int j = 0; j < 60; j++) {
            if (a & (1LL << j)) cnt[j]++;
        }
    }
    long long ans = 0;
    long long pow2 = 1;
    for (int i = 0; i < 60; i++) {
        ans = (ans + cnt[i] * (n - cnt[i]) % mod * pow2 % mod) % mod;
        pow2 = pow2 * 2 % mod;
    }
    cout << ans << endl;
    return 0;
}

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

namespace ITP1_4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            int d = a / b;
            int r = a % b;
            double f = (double)a / b;

            Console.WriteLine("{0} {1} {2}", d, r, f.ToString("f5"));

            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 18000
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int N, K;

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

    cin >> N >> K;

    int64 result = 0;

    if (!K) {
        for (int b = 1; b <= N; b++) {
            for (int a = b; a <= N; a += b) {
                result++;
            }
        }
        K++;
    }

    for (int b = K + 1; b <= N; b++) {
        // a = K, K + b, K + 2 * b
        int cur = 0;
        int a = 0;
        for (a = K; a <= N; a += b) {
            //debug() << a << " " << b;
            cur++;
        }
        if (a > N)
            a -= b;

        if (b - K <= N - a + 1) {
            result += (int64)cur * (b - K);
        } else {
            result += (int64)cur * (N - a + 1);
            int dif = (b - K) - (N - a + 1);
            cur--;
            result += (int64)dif * cur;
        }
    }

    cout << result << "\n";

    return 0;
}


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

const int MAX = 200001;
const int mod = 998244353;

long long fac[MAX], fac_inv_mod[MAX],inv_mod[MAX];

void comb_init(){
    fac[0] = fac[1] = 1;
    fac_inv_mod[0] = fac_inv_mod[1] = 1;
    inv_mod[1]=1;
    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv_mod[i] = mod - inv_mod[mod%i] * (mod / i) % mod;
        fac_inv_mod[i] = fac_inv_mod[i-1] * inv_mod[i] % mod;
    }
}

long long comb(int n, int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n] * (fac_inv_mod[k] * fac_inv_mod[n-k] % mod) % mod;
}

int main(){
    int n,p; cin>>n>>p;
    int even=0,odd=0;
    for(int i=0;i<n;i++){
        int c;cin>>c;
        if(c%2==0) even++;
        else odd ++;
    }
    long long ans = pow(2,even);
    comb_init();
    long long odds=0;
    if(p==1){
        for(int j=0; j<(odd+1)/1;j++){
            odds+=comb(odd,2*j+1);
        }
    }
    else{
        for(int j=0; j<=odd/2;j++){
            odds+=comb(odd,2*j);
        }
    }
    cout << ans*odds << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    pairs p(N);
    REP(i, N){
        cin >> p[i].s >> p[i].f;
    }
    Sort(p); Reverse(p);
    int t = INF;
    REP(i, N){
        Min(t, p[i].f);
        t -= p[i].s;
    }
    Ans(t >= 0, "Yes", "No");

    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
  {
    cin >> p.at(i);
  }

  int ans = 0;
  for (int i = 1; i < n - 1; i++)
  {
    if ((p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1))
        || p.at(i - 1) > p.at(i) && p.at(i) > p.at(i + 1))
        ans++;
  }
  
  cout << ans << endl;
}

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

int main()
{
  int A, B;
  int a[5000], b[5000];

  cin >> A >> B;
  for(int i = 0; i < A; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < B; i++) {
    cin >> b[i];
  }
  
  int ret = 0;

  for(int i = 0; i < B; i++) {
    int ana = 0, blue = i;
    while(blue < B && ana < A) {
      while(ana < A && a[ana] != b[blue]) {
        ana++;
      }
      if(a[ana] != b[blue]) break;
      ana++;
      blue++;
    }
    ret = max(ret, blue - i);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <algorithm>

using namespace std;

char s[200'009];

int main() {
  int n;
  scanf("%d%s", &n, s);
  int w = 0;
  for (int i = 0; i < n; ++i) {
    w += s[i] == '.';
  }
  int ans = 1'000'000'000;
  int b = 0;
  for (int i = 0; i < n; ++i) {
    ans = min(ans, b + w);
    b += s[i] == '#';
    w -= s[i] == '.';
  }
  ans = min(ans, b);
  printf("%d\n", ans);
}


Measured memory_bytes: 384
using System;
using static System.Console;

namespace abc168
{
    class Program
    {
        static void Main()
        {
            var k = int.Parse(ReadLine());
            var s = ReadLine();
            if (s.Length > k)
            {
                WriteLine(s.Substring(0, k) + "...");
            }
            else
            {
                WriteLine(s);
            }
        }
    }
}


Measured memory_bytes: 27504
s = list(input())
a = s[:4]
b = s[5:7]
c = s[8:10]

year = ''.join(a)
year = int(year)

month = ''.join(b)
month = int(month)

day = ''.join(c)
day = int(day)

if year > 2018:
    if month > 4:
        print('TBD')
    else:
        print('Heisei')
else:
    print('Heisei')

Measured memory_bytes: 3064
#A
N,K = (int(x) for x in input().split())

S = input()

x = S[K-1]
#print(x)
if x=="A":
    XX=S[:K-1]+"a"+S[K:]
elif x=="B":
    XX=S[:K-1]+"b"+S[K:]
else:
    XX=S[:K-1]+"c"+S[K:]

print(XX)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n,x;
    cin>>n>>x;
    if(n==2){
        if(x==2){
            printf("Yes\n1\n2\n3\n");
        }else{
            printf("No\n");
        }
        return 0;
    }
    if(x==1||x==2*n-1){
        printf("No\n");
    }else{
        printf("Yes\n");
        int out[2*n]={};
        set<int> st;
        st.insert(x);
        out[n] = x;
        if(x==2){
            out[n-1]=x-1;
            st.insert(x-1);
        }else{
            out[n-1]=x+1;
            st.insert(x+1);
            out[n-2]=x-1;
            st.insert(x-1);
            out[n+1]=x-2;
            st.insert(x-2);
        }
        int cnt = 1;
        int val = 1;
        while(cnt<=2*n-1){
            while(st.find(val)!=st.end()){
                val++;
            }
            while(cnt<2*n&&out[cnt]!=0){
                cnt++;
            }
            if(cnt==2*n){break;}
            out[cnt]=val;
            st.insert(val);
            val++;
            cnt++;
        }
        for(int i=1;i<=2*n-1;i++){
            printf("%d\n",out[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 11648
X,N = map(int,input().split())
P = list(map(int,input().split()))
if N==0:print(X); exit()
diff = float('inf')
ans = X
A = {}
for p in P:
    A[p] = 1
s = X
while True:
    if s not in A:
        diff = s-X
        ans = s
        break
    else:
        s += 1
s = X
while True:
    if s not in A:
        if X-s<=diff:
            ans = s
        break
    else:
        s -= 1 
print(ans)

Measured memory_bytes: 61808