akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

const int N=1e5+1;

vi adj[N];
// aaaaaaaaaaaaaaaa
void solve() {
  int n,m; cin>>n>>m;
  int u,v;
  rep(i,0,m){
    cin>>u>>v;
    --u,--v;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  int ptr=0;
  vi sgn(n,-1),q;
  sgn[0]=0;
  q.pb(0);

  while(ptr<sz(q)){
    int x=q[ptr++];
    trav(y,adj[x]){
      if(sgn[y]!=-1) continue;
      sgn[y]=x+1;
      q.pb(y);
    }
  }
  bool w=1;
  rep(i,0,n)
    w&=sgn[i]!=-1;
  if (!w) cout<<"No\n";
  else {
    cout<<"Yes\n";
    rep(i,1,n)
      cout<<sgn[i]<<'\n';
  }
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}


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


int main(){
	char buf[10]; 
	if(scanf("%s", buf)==EOF){return 0;}
	if(buf[1]=='R'){buf[1]='B';}
	else{buf[1]='R';}
	printf("%s\n", buf);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main()
{
	int a,b,c,d,x,y;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a+b;
	y=c+d;
	if(x==y)
	{
		printf("Balanced");
	};
	if(x>y)
	{
		printf("Left");
	};
	if(x<y)
	{
		printf("Right");
	};
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	
		try{
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    String input = buf.readLine();
//	String[] strAry = input.split(" ");
//    int H = Integer.parseInt(strAry[0]);
//    int W = Integer.parseInt(strAry[1]);
	
int max = Integer.parseInt(input);
int x;

for(int i =3; i <= max; i++){
    x = i;
	if(i%3 == 0){
		System.out.printf(" " + i);
	}else{
	while(x > 1){
		if(x%10 == 3){
		System.out.printf(" " + i);
		break;
	}
		x = x / 10;
	}
	
	}
}
System.out.printf("\n");

} catch (Exception e) {

	System.out.println("????????????");
	
}
		 }
    }

Measured memory_bytes: 29596
#include <stdio.h>
typedef long long ll;

void seq(ll num,ll a[],ll b[]){
  for(int i=0;i<num-1;i++){
    b[a[i]-1]++;
  }
  return ;
}

int main(void){
  ll num;
  scanf("%lld",&num);
  ll a[num-1];
  ll b[num];
  for(int i=0;i<num;i++){
    b[i]=0;
  }
  for(int i=0;i<num-1;i++){
  scanf("%lld",&a[i]);
  }
  seq(num,a,b);
  for(int i=0;i<num;i++){
  printf("%lld\n",b[i]);
  }
  return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(Math.Min(NAB[0]*NAB[1], NAB[2]));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define P 1000000007
#define inf 1e18
vector<ll> adj[100005];
ll d[200005];
bool used[200005];
queue<ll> q;
void bfs(ll s)
{
    for (ll i = 0; i <= 100005; i++)
    {
        d[i] = inf;
        used[i] = false;
    }
    d[s] = 0;
    used[s] = true;

    q.push(s);
    while (!q.empty())
    {
        ll v = q.front();
        q.pop();
        for (ll i = 0; i < adj[v].size(); i++)
        {
            if (!used[adj[v][i]])
            {
                d[adj[v][i]] = d[v] + 1;
                used[adj[v][i]] = true;
                q.push(adj[v][i]);
            }
        }
    }
}
int main()
{
    ll n, i;
    cin >> n;
    ll a[n + 1];
    for (i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        adj[i + 1].push_back(x);
        //adj[x].push_back(i + 1);
    }
    bfs(1);
    if(d[2] == inf)
    cout<<"-1\n";
    else
    cout << d[2] << "\n";

    return (0);
}


Measured memory_bytes: 9988
#include <cstdio>
using namespace std;

int main(){
    int h,w;
    while(1){
        scanf("%d %d", &h , &w);
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0; i < h; i++){
            for(int i = 0; i < w; i++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2604
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  priority_queue<pll,vector<pll>,greater<pll>> pq;
  ll N,M;
  cin>>N>>M;
  string s;
  cin>>s;
  pq.push({0,0});
  vector<int> dp(N+1,-1);
  for(int i=1;i<=N;i++){
    if(s[i]=='1'){continue;}
    while(!pq.empty() && pq.top().S<i-M){pq.pop();}
    if(pq.empty()){continue;}
    pll tp=pq.top();
    dp[i]=tp.S;
    pq.push({dp[i],i});
  }
  if(dp.back()==-1){cout<<-1<<endl; return 0;}
  vector<ll> ans;
  ll w=N;
  while(dp[w]!=-1){
    ans.push_back(w);
    w=dp[w];
  }
  reverse(ans.begin(),ans.end());
  int ls=0;
  for(auto &I:ans){
    ll uku=I;
    I-=ls;
    ls=uku;
  }
  cout<<ans<<endl;


  return 0;
}


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


int main() 
{
   
   int a[3];
   cin >> a[0] >> a[1] >> a[2];
   sort(a, a+3);
   if(a[0]==a[1] && a[0]!=a[2]){
       cout << "Yes";
       return 0;
   }else if(a[1]==a[2] && a[0]!=a[1]) cout << "Yes";
   else cout <<  "No";
}

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

using namespace std;

class Dice
{
public:
	Dice(unsigned int in[6])
	{
		for (int i = 0; i < 6; i++)
			label[i] = in[i];
		
		Reset();
	}
	~Dice()
	{
	}
	void Reset()
	{
		N = 5;
		E = 3;
		S = 2;
		W = 4;
		F = 1;
		B = 6;
	}
	void Run(string &cmd)
	{
		for (int i = 0; i < cmd.size(); i++)
		{
			char c = cmd[i];
			if (c == 'S')
			{
				int tmpF = F;
				F = N;
				N = B;
				B = S;
				S = tmpF;
			}
			else if (c == 'N')
			{
				int tmpN = N;
				N = F;
				F = S;
				S = B;
				B = tmpN;
			}
			else if (c == 'E')
			{
				int tmpB = B;
				B = E;
				E = F;
				F = W;
				W = tmpB;
			}
			else if (c == 'W')
			{
				int tmpW = W;
				W = F;
				F = E;
				E = B;
				B = tmpW;
			}
		}
	}
	int GetFront()
	{
		return F;
	}
	int GetLabel()
	{
		return label[F-1];
	}
	int GetSouthLabel()
	{
		return label[S-1];
	}
	int GetEastLabel()
	{
		return label[E-1];
	}
	int GetWestLabel()
	{
		return label[W-1];
	}
	
	int IsSameDice(Dice &d)
	{
		if((d.GetLabel() == this->GetLabel())
			&& (d.GetSouthLabel() == this->GetSouthLabel())
			&& (d.GetEastLabel() == this->GetEastLabel())
			&& (d.GetWestLabel() == this->GetWestLabel())
		)
		{
			return 1;
		}
		return 0;
	}
	int ThrowTo(Dice &d)
	{
		for (int x = 0; x < 4; x++)
		{
			Reset();
			if (x == 0)
			{
			}
			else if (x == 1)
			{
				string cmd1 = "WSE";
				Run(cmd1);
			}
			else if (x == 2)
			{
				string cmd2 = "WSSE";
				Run(cmd2);
			}
			else if (x == 3)
			{
				string cmd3 = "WSSSE";
				Run(cmd3);
			}
			for (int w = 0; w < 4; w++)
			{
				for (int n = 0; n < 4; n++)
				{
					string nnnn = "N";
					Run(nnnn);
					if (IsSameDice(d))
						return 1;
				}
				string wwww = "W";
				Run(wwww);
			}
		}
		return 0;
	}
	int ThrowTo(int argF, int argS)
	{
		for (int x = 0; x < 4; x++)
		{
			Reset();
			if (x == 0)
			{
			}
			else if (x == 1)
			{
				string cmd1 = "WSE";
				Run(cmd1);
			}
			else if (x == 2)
			{
				string cmd2 = "WSSE";
				Run(cmd2);
			}
			else if (x == 3)
			{
				string cmd3 = "WSSSE";
				Run(cmd3);
			}
			for (int w = 0; w < 4; w++)
			{
				for (int n = 0; n < 4; n++)
				{
					string nnnn = "N";
					Run(nnnn);
					if (GetLabel() == argF && GetSouthLabel() == argS)
					{
						return label[E-1];
					}
				}
				string wwww = "W";
				Run(wwww);
			}
		}
		return 1;
	}
private:
	unsigned int label[6];
	int N;
	int E;
	int S;
	int W;
	int F;
	int B;
};

int main()
{
	unsigned int in1[6] = {0};
	for (int i = 0; i < 6; i++)
	{
		cin >> in1[i];
	}
	Dice firstDice(in1);
	
	unsigned int in2[6] = {0};
	for (int i = 0; i < 6; i++)
	{
		cin >> in2[i];
	}
	Dice secondDice(in2);
	
	cout << (secondDice.ThrowTo(firstDice) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

int N, K;
vector<int> x;

int input(){
  int tmp;
  cin >> N >> K;
  for( int i = 0; i < N; i++ ){
	cin >> tmp;
	x.push_back(tmp);
  }
  return 0;
}

int min(int a, int b){ return (a<b ? a : b); }

int main(){
  input();

  int ans = 0;
  for( int i = 0; i < N; i++ ){
	ans += 2 * min(x[i], K-x[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# coding = utf-8
n=input("")
a=input("")
a=a.split(" ")
a=[int(s) for s in a]
a.sort()
base=100000
n=1
for num in a:
    while num%2**n==0:
        n=n+1
    n=n-1
    if n < base:
        base=n
print(base)

Measured memory_bytes: 9128
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let k: usize = sc.next();
    if k < 2 {
        println!("2");
        println!("0 {}", k * 2);
    } else if k < 50 {
        println!("{}", k);
        print!("{}", k);
        for i in 1..k {
            print!(" {}", k);
        }
        print!("\n");
    } else {
        let mut v = vec![k / 50 + 49; 50];
        for i in 0..k % 50 {
            v[i] += 50 - k % 50 + 1;
        }
        for i in k % 50..50 {
            v[i] -= k % 50;
        }
        println!("50");
        print!("{}", v[0]);
        for i in 1..50 {
            print!(" {}", v[i]);
        }
        print!("\n");
    }
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> ab;
    for(ll i=0; i< n; i++){
    	ll a,b;
        cin >> a >> b;
        ab.push_back(MP(a,b));
    }
    sort(ab.begin(),ab.end());
    ll tmp=0;
    while(true){
      	k-=ab.at(tmp).S;
        if(k<=0){
        	cout << ab.at(tmp).F << endl;
            break;
        }
        tmp++;
    }
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,W;cin>>n>>W;
  long dp[121][100010],w[110],v[110];
  for(int i=0;i<n;i++) cin>>w[i]>>v[i];
  for(int j=0;j<100001;j++) dp[0][j]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<W+2;j++){
      if(j>=w[i]) dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[n][W]<<endl;
}


Measured memory_bytes: 80768
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
int main()
{
    ll int n,m;
    cin >> n >> m;
    ll int total=0;
    total = min(n,m/2);
    n -=total;
    m -=total*2;
    // what_is(total);
    // what_is(m);
    if(m>0)
    {
        total += (m/4);
    }
    cout << total;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define MN 200005
using namespace std;
char s[MN];
long long cnt[30],ans,len;
int main()
{
    scanf("%s",&s); len=strlen(s);
    for(int i=0;i<len;i++) cnt[s[i]-'a']++;
    for(int i=0;i<=26;i++) ans+=cnt[i]*(cnt[i]-1)/2;
    printf("%lld",len*(len-1)/2-ans+1);
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      if ((j / 10) * (j % 10) == i && 2 <= (j / 10) && 2 <= (j % 10)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#N = int(input())
M,D = map(int,input().split())
cnt = 0
for m in range(2,M+1):
    for i in range(2,10):
        if m%i == 0:
            day = m//i
            if day < 10:
                if day > 1:
#                    print(m,i,day)
                    if (i + 10*day) <= D:
#                        print(i + 10*day)
                        cnt += 1
#                    if (day + 10*i) <= D:
#                        print(day + 10*i)
#                        cnt += 1
print(cnt)

    


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll h,w;
    cin >> h >> w;
    char s[h][w];
    ll cnt = 0;
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            if(s[i][j] == '#'){
                cnt++;
            }
        }
    }
    if(cnt == h+w-1) puts("Possible");
    else puts("Impossible");
}


Measured memory_bytes: 256
/**********************************************************
* @Author: 			   .Sunbeam
* @Date:   			   2020-03-22 20:26:46
* @Last Modified by:   .Sunbeam
* @Last Modified time: 2020-03-22 20:33:13
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

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

const int maxn=2e5+100;
ll arry[maxn],num[maxn];

int main()
{
	FAST;
	int n;
	cin>>n;
	CSE(num,0);
	for(int i=1;i<=n;i++){
		cin>>arry[i];
		num[arry[i]]++;
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=(num[i]-1)*num[i]/2;
	}
	for(int i=1;i<=n;i++){
		ll x=(num[arry[i]]-1)*num[arry[i]]/2-(num[arry[i]]-2)*(num[arry[i]]-1)/2;
		cout<<ans-x<<endl;
	}
	return 0;
}

Measured memory_bytes: 5760
import math

N, D = map(int, input().split())
poses = []
for i in range(N):
    pos = [num for num in map(int, input().split())]
    poses.append(pos)
count = 0
for pos in poses:
    kyori = math.sqrt(pos[0]**2 + pos[1]**2)
    if kyori <= D:
        count += 1

print(count)

Measured memory_bytes: 42400
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main() 
{
    fastio
    int s, w;
    cin>>s>>w;
    if(w>=s) {
        cout<<"unsafe"<<endl;
    }
    else {
        cout<<"safe"<<endl;
    }
}   

Measured memory_bytes: 3652
#include<iostream>

#define     MAX_N_NUMBER     200

using namespace std;

int main(){
	int *pointx, *pointy;
	int n, ni, d, i;

	// ループ
	cin >> n;
	while(n > 0){
		int ue = 0, shita = 0, migi = 0, hidari = 0;
		// メモリの確保
		pointx = new int[n];
		pointy = new int[n];
		// メモリ領域が正常に確保されたかチェック
		if((pointx == NULL) || (pointy == NULL)){
			cerr << "メモリ確保エラー" << endl;
			return -1;
		}
		// 初期化
		pointx[0] = 0;
		pointy[0] = 0;
		// ループ
		for(i=1;i<n;i++){
			// ni と d の入力
			cin >> ni >> d;
			// チェック
			if((ni < 0) || (ni >= n)){
				cerr << "指定された正方形は存在しません" << endl;
				i--;
				continue;
			}else if((d < 0) || (d > 3)){
				cerr << "方向の指定が間違っています" << endl;
				i--;
				continue;
			}
			// 座標の代入・端の計算
			switch(d){
				case 0:
					// 座標の代入
					pointx[i] = pointx[ni] - 1;
					pointy[i] = pointy[ni];
					// 左端かどうかをチェック
					if(pointx[i] < hidari){
						// 左端を更新
						hidari = pointx[i];
					}
					break;
				case 1:
					// 座標の代入
					pointx[i] = pointx[ni];
					pointy[i] = pointy[ni] - 1;
					// 下端かどうかをチェック
					if(pointy[i] < shita){
						// 下端を更新
						shita = pointy[i];
					}
					break;
				case 2:
					// 座標の代入
					pointx[i] = pointx[ni] + 1;
					pointy[i] = pointy[ni];
					// 右端かどうかをチェック
					if(pointx[i] > migi){
						// 右端を更新
						migi = pointx[i];
					}
					break;
				case 3:
					// 座標の代入
					pointx[i] = pointx[ni];
					pointy[i] = pointy[ni] + 1;
					// 上端かどうかをチェック
					if(pointy[i] > ue){
						// 上端を更新
						ue = pointy[i];
					}
					break;
			}
		}
		// 結果の表示
		cout << (migi - hidari + 1) << " " << (ue - shita +1) << endl;
		// メモリの解放
		delete [] pointx;
		delete [] pointy;
		// n の入力
		cin >> n;
	}


	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <string.h>

int main(void){
    //文字列SとTに値を代入する
    char S[200001];
    char T[200001];
    memset(&S,'\0',sizeof(S));
    memset(&T,'\0',sizeof(T));
    scanf("%s",S);
    scanf("%s",T);
    
    //文字列Sの長さをsizeに代入する
    int size = strlen(S);

    //アルファベットの箱を用意し、初期化する
    char alpha[26];
    memset(&alpha,'\0',sizeof(alpha));

    //重複チェックのフラグを用意する
    int flag = 0;

    //
    for(int i = 0;i<size;i++){

        if(alpha[T[i] - 'a'] == '\0'){
            alpha[T[i] - 'a'] = S[i];
        }else if(alpha[T[i] - 'a'] != S[i]){
            printf("No\n");
            return 0;
        }
    }
    for(int i = 0;i<26;i++){
        for(int j = 0;j<26;j++){
            if(alpha[j] == 'z' - i){
                flag++;
            }
            if(flag > 1){
                printf("No\n");
                return 0;
            }
        }
        flag = 0;
    }
    // printf("S %s\n",S);
    // printf("T %s\n",T);
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 512
N = list(map(int,input().split()))
q = int(input())
S = []
S += [42,23,35,54],
S += [14,46,63,31],
S += [12,26,65,51],
S += [21,15,56,62],
S += [13,36,64,41],
S += [24,45,53,32],
for i in range(q):
    a,b = map(int,input().split())
    c = [str(N.index(a)+1)]
    c += str(N.index(b)+1),
    c = "".join(c)
    for j in range(6):
        if int(c) in S[j]:
            print(N[j])


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		String check = "abcdefghijklmnopqrstuvwxyz";

		if(check.contains(S)) {
			System.out.println("a");
		}else {
			System.out.println("A");
		}
	}


}

Measured memory_bytes: 35764
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
namespace Fast_Read {
	inline void read(int &res) {
		res = 0;int tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
	inline void read(long long &res) {
		res = 0;long long tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
}
using namespace Fast_Read;
int H,A,ans;
int main() {
	read(H);read(A);
	while (H > 0) ans++,H -= A;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define       M                        1000000007
#define       ll                       long long
#define	      FIO		                   ios_base::sync_with_stdio(false);cin.tie(NULL)
#define        ifor(st,lim)             for(int i=st;i<lim;i++)
#define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
#define       eifor(st,lim)            for(int i=st;i<=lim;i++)
#define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
#define       blank		                 cout<<'\n';

void solve()
{
	ll x,k,d; cin>>x>>k>>d;
	x = abs(x);

	ll mn = min(k,x/d);
	k -=mn;
	x = x-mn*d;

	if(k%2) {cout<<d-x;}
	else cout<<x;
}

int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
int t=1;
  while(t--){
    solve();
   } 
}


Measured memory_bytes: 3656
import sys


def resolve(in_):
    N = int(next(sys.stdin.buffer))
    P = map(int, next(sys.stdin.buffer).split())

    min_ = 200001
    ans = 0
    for p in P:
        if p <= min_:
            ans += 1
            min_ = p
    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21188
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     return p.first>q.first;//descending by first
//     return p.first<q.first;//ascending by first
//     return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }
    return 0;
}
int clue() {

    int x;
    cin>>x;
    if(x>=1800) {cout<<1<<endl;}
    elif(x>=1600){cout<<2<<endl;}
    elif(x>=1400){cout<<3<<endl;}
    elif(x>=1200){cout<<4<<endl;}
    elif(x>=1000){cout<<5<<endl;}
    elif(x>=800){cout<<6<<endl;}
    elif(x>=600){cout<<7<<endl;}
    elif(x>=400){cout<<8<<endl;}
    return 0;
}

Measured memory_bytes: 3536
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N;
	cin >> N;
	vector<string> s(N);
	REP(i, N)
	{
		string str;
		cin >> str;
		ALL(sort, str);
		s[i] = str;
	}

	sort(s.begin(), s.end());

	vector<i64> ren;
	i64 cnt = 0;
	string cur = s[0];
	REP(i, N)
	{
		if (cur == s[i])
		{
			cnt++;
		}
		else
		{
			if (1 < cnt)
			{
				ren.push_back(cnt);
			}
			cnt = 1;
			cur = s[i];
		}
	}
	if (1 < cnt)
	{
		ren.push_back(cnt);
	}

	i64 ans = 0;
	REP(i, SIZE(ren))
	{
		i64 a = 0;
		FOR(j, 1, ren[i])
		{
			a += j;
		}
		ans += a;
	}

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


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, sz[N];
vector<int> G[N];
int dep[N], have[N];

void dfs(int u, int pre) {
    sz[u] = 1;
    dep[u] = dep[pre] + 1;
    have[u] = (u == n);
    for(int v : G[u]) {
        if(v == pre) continue;
        dfs(v, u);
        have[u] |= have[v];
        sz[u] += sz[v];
    }
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 0);
    int d = dep[n]&1 ? dep[n]/2 + 2 : dep[n]/2 + 1, x = n;
    for(int i = 1; i <= n; i++) {
        if(have[i] && dep[i] == d) {
            x = i;
            break;
        }
    }
    //cout << x << endl;
    //cout << sz[1] << ' ' << sz[x] << endl;
    puts(sz[1] - sz[x] > sz[x] ? "Fennec" : "Snuke");
    return 0;
}


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

int main(){
  int N;
  int M;
  cin >> N >> M ;
  vector<int> l(M);
  vector<int> r(M);

  rep(i,M){
    cin >> l.at(i) >> r.at(i);
  }

  sort(all(l));
  sort(all(r));

  int ans;
  if(r.at(0)-l.at(M-1)<0) ans =0;
  else ans = r.at(0)-l.at(M-1)+1;
  cout << ans << endl;
}

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

const int N = 100005;
int n, p[N], q[N], kp, kq, cp[N], cq[N];
bool vis[N];

namespace flow {
	const int M = 2 * N;
	int S, T, tot = 1, nxt[M], fst[M], to[M], f[M], cur[M], d[M];
	void addedge(int u, int v, int w1, int w2) {
		nxt[++tot] = fst[u]; fst[u] = tot; to[tot] = v; f[tot] = w1;
		nxt[++tot] = fst[v]; fst[v] = tot; to[tot] = u; f[tot] = w2;
	}
	bool bfs() {
		static int q[M];
		int st = 0, ed = 0;
		q[ed++] = S;
		for (int i = 1; i <= T; i++) d[i] = -1, cur[i] = fst[i];
		d[S] = 0;
		while (st < ed) {
			int u = q[st++];
			for (int i = fst[u]; i; i = nxt[i])
				if (f[i] && d[to[i]] == -1) {
					d[to[i]] = d[u] + 1;
					if (to[i] == T) return true;
					q[ed++] = to[i];
				}
		}
		return false;
	}
	int aug(int u, int flow) {
		if (u == T || !flow) return flow;
		int used = 0;
		for (int &i = cur[u], w; i; i = nxt[i])
			if (d[to[i]] == d[u] + 1 && (w = aug(to[i], min(f[i], flow - used)))) {
				f[i] -= w, f[i ^ 1] += w;
				if ((used += w) == flow) break;
			}
		return used;
	}
	int dinic() {
		int ans = 0;
		while (bfs()) ans += aug(S, 1 << 30);
		return ans;
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", p + i), ++p[i];
	for (int i = 1; i <= n; ++i) scanf("%d", q + i), ++q[i];
	for (int i = 1; i <= n; ++i)
		if (!vis[i]) {
			cp[i] = ++kp;
			vis[i] = true;
			for (int j = p[i]; j != i; j = p[j]) cp[j] = kp, vis[j] = true;
		}
	fill(vis + 1, vis + 1 + n, false);
	for (int i = 1; i <= n; ++i)
		if (!vis[i]) {
			cq[i] = ++kq;
			vis[i] = true;
			for (int j = q[i]; j != i; j = q[j]) cq[j] = kq, vis[j] = true;
		}
	flow::S = kp + kq + 1, flow::T = kp + kq + 2;
	int ans = n;
	for (int i = 1; i <= n; ++i)
		if (p[i] == q[i] && p[i] == i) --ans;
		else if (p[i] == i) flow::addedge(kp + cq[i], flow::T, 1, 0);
		else if (q[i] == i) flow::addedge(flow::S, cp[i], 1, 0);
		else if (p[i] != q[i]) flow::addedge(kp + cq[i], cp[i], 1, 0);
		else flow::addedge(cp[i], kp + cq[i], 1, 1);
	ans -= flow::dinic();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 7936
#include <cstdio>

long long sum = 0;
char temp;

int main() {
	while((temp = getchar()) != '\n') {
		sum += temp - '0';
	}
	if (sum % 9) {
		printf("No");
	}
	else {
		printf("Yes");
	}
	return 0;
}

Measured memory_bytes: 1600
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

int main(void) {
  int n;
  string s;
  cin>>n>>s;
  int r=0;
  int b=0;
  for(auto i=s.begin(); i!=s.end(); i++) {
    if(*i == 'R')
      r++;
    else
      b++;
  }
  if(r>b)
    cout<<"Yes";
  else
    cout<<"No";
  cout<<endl;
  return 0;
}



Measured memory_bytes: 256
while(n,m=gets.split.map(&:to_i))!=[0,0]do
r,p,a=[],[],[]
n.times{r.unshift(gets.gsub("?",".").split)}
m.times{p<<gets.split}
p.each{|p|r.each{|r|if/#{r[1]}/=~p[0]&&p[1]=~/#{r[2]}/
a<<p*" "if/p/=~r[0]
break
end}}
puts a.size,a
end

Measured memory_bytes: 9420
#include <stdio.h>

int n, m, d, p, r[11];

int main()
{
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &m);
        
        if(n == 0 && m == 0) { break; }
        
        for(int i = 0; i < 11; i++)
        {
            r[i] = 0;
        }
        
        while(n--)
        {
            scanf("%d", &d);
            scanf("%d", &p);
            
            r[p] += d;
        }
        
        for(int i = 10; i >= 0; i--)
        {
            if(m >= r[i])
            {
                m -= r[i];
                
                r[i] = 0;
            }
            else
            {
                r[i] -= m;
                
                break;
            }
        }
        
        int sum = 0;
        
        for(int i = 0; i <= 10; i++)
        {
            sum += i * r[i];
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}

Measured memory_bytes: 2724
n = int(input())
h = list(map(int, input().split()))
for i in range(n):
    id = i + 1
    k = h[i]
    p = id // 2
    pk = h[p-1] if p > 0 else 0
    left = id * 2
    lk = h[left-1] if left <= n else 0
    right = id * 2 + 1
    rk = h[right-1] if right <= n else 0
    print('node {0}: key = {1}, '.format(id, k), end='')
    if p > 0:
        print('parent key = {0}, '.format(pk), end='')
    if left <= n:
        print('left key = {0}, '.format(lk), end='')
    if right <= n:
        print('right key = {0}, '.format(rk), end='')
    print()



Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>

#define INF (1e+9)

#define MAX_N 100
#define MAX_C 10

using namespace std;

typedef struct edge{
	int to;
	int cost;
	int used;
	edge(){}
	edge(int _to,int _cost,int _used){
		to = _to;
		cost = _cost;
		used = _used;
	}
	bool operator<(const edge &a)const{
		if(cost == a.cost) return to > a.to;
		return cost > a.cost;	//for ASC
	}
}edge;


int cost[MAX_N + 1][MAX_N + 1];
int sum[MAX_N + 1][MAX_C + 1];
priority_queue<edge > pque;

int C;
int N,M;
int S,D;

void init(){
	for(int i = 0;i <= MAX_N;i++){
		for(int j = 0;j <= MAX_N;j++){
			cost[i][j] = INF;
		}
	}
	for(int i = 0;i <= MAX_N;i++){
		for(int j = 0;j <= MAX_C;j++){
			sum[i][j] = INF;
		}
	}
	return ;
}

int solve(){
	int res;

	pque.push(edge(S,0,0));

	while(!pque.empty()){
		edge e = pque.top();pque.pop();
		if(sum[e.to][e.used] != INF) continue;
		sum[e.to][e.used] = e.cost;
		for(int i = 1;i <= N;i++){
			if(cost[e.to][i] != INF){
				int _cost = e.cost + cost[e.to][i];
				pque.push(edge(i,_cost,e.used));
				if(e.used < C){
					_cost = e.cost + cost[e.to][i] / 2;
					pque.push(edge(i,_cost,e.used + 1));
				}
			}
		}
	}

	res = INF;
	for(int i = 0;i <= 10;i++){
		res = min(res,sum[D][i]);
	}

	return res;
}

int main(){

	while(true){
		init();
		scanf("%d%d%d%d%d",&C,&N,&M,&S,&D);
		if(C == 0) break;
		int _u,_v,_cost;
		for(int i = 0;i < M;i++){
			scanf("%d%d%d",&_u,&_v,&_cost);
			cost[_u][_v] = _cost;
			cost[_v][_u] = _cost;
		}
		
		int ans = solve();

		/*for(int i = 1;i <= N;i++){
			printf("###");
			for(int j = 0;j <= C;j++){
				printf(" %d",sum[i][j]);
			}
			puts("");
		}*/
		printf("%d\n",ans);

	}

	return 0;
}

Measured memory_bytes: 1364
N, K = gets.split.map(&:to_i)
ans = (1 .. N).inject(0.to_f) do |s, n|
  r = (0 .. 20).bsearch{|c| n * (1 << c) >= K }
  s + (1.to_f / N) * (1.to_f / (1 << r))
end
puts ans



Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const int MAXN = 110;
const int MAXK = 100010;
int arr[MAXN];
int N, K;
bool dp[MAXK];
int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> arr[i];
    }

    for (int k = 0; k <= K; k++) {
        bool win = false;
        for (int i = 1; i <= N; i++) {
            if (k - arr[i] < 0) continue;
            if (dp[k - arr[i]] == false) win = true; 
        }
        dp[k] = win;
    }

    // for (int i = 0; i <= K; i++) {
    //     cout << i << " -- " << dp[i] << endl; 
    // }
    if (dp[K]) cout<< "First";
    else cout<< "Second";

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  int N,co=0;
  cin >> N;
  string s,t;
  cin >> s >> t;
  for(int i=1; i<=N; i++){
    if(s.substr(N-i)==t.substr(0,i)) co=i;
  }
  cout << 2*N-co << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
int c,e,d;
double a,b,result=0;
cin>>a>>b;
c=a/b;
d=fmod(a,b);
result=a/b;
cout<<c<<" "<<d<<" ";
printf("%0.5f\n",result);
}




Measured memory_bytes: 3344
def main():
    a, b = (int(i) for i in input().split())
    if a*b <= 0:
        print("Zero")
    elif 0 < a:
        print("Positive")
    else:
        if (b-a+1) % 2 == 0:
            print("Positive")
        else:
            print("Negative")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
program Homework;
var
	sum, i, N, M, a : integer;
begin
	sum := 0;
	readln(N, M);
	for i := 1 to m do begin
		read(a);
		sum := sum + a;
	end;
	if N >= sum
		then writeln(N - sum)
		else writeln('-1');
end.

Measured memory_bytes: 1388
#include <iostream>
#include <vector>
#define int long long
using namespace std;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,ret=0;
	cin >> n;
	vector<int> v(n);
	for (int i=0; i<n; ++i){
		cin >> v[i];
		ret += v[i];
	}
	int crt=0,idx=1,j=0,ans=ret;
	for (auto& i:v){
		crt += i;
		if (abs((ret-crt)-crt) < ans){
			ans=abs((ret-crt)-crt);
			idx=j+1;
		}
		j++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int A, B;
  std::cin >> A >> B;

  int sum = A + B;
  bool flag = false;
  if ( sum % 3 == 0 ) flag = true;
  else if ( A % 3 == 0 ) flag = true;
  else if ( B % 3 == 0 ) flag = true;

  if ( flag ) {
    std::cout << "Possible" << std::endl;
  } else {
    std::cout << "Impossible" << std::endl;
  }

  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<ll> node;
};

Vertex V[100005];
ll T[100005];
ll A[100005];

int main() {
    ll N, u, v;
    cin >> N >> u >> v;
    u--;
    v--;
    REP(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(b);
        V[b].node.push_back(a);
    }

    {
        memset(A, -1, sizeof(A));
        A[v] = 0;
        queue<pll> q;
        q.push(pll(v, 0));
        while (!q.empty()) {
            pll t = q.front();
            q.pop();
            REP(i, V[t.first].node.size()) {
                ll n = V[t.first].node[i];
                if (A[n] >= 0)
                    continue;
                A[n] = t.second + 1;
                q.push(pll(n, t.second + 1));
            }
        }
    }

    ll max = 0;
    {
        memset(T, -1, sizeof(T));
        T[u] = 0;
        queue<pll> q;
        q.push(pll(u, 0));
        while (!q.empty()) {
            pll t = q.front();
            q.pop();
            if (V[t.first].node.size() > 1) {
                max = std::max(max, A[t.first]);
            }
            REP(i, V[t.first].node.size()) {
                ll n = V[t.first].node[i];
                if (T[n] >= 0)
                    continue;
                T[n] = t.second + 1;
                if (T[n] <= A[n])
                    q.push(pll(n, t.second + 1));
            }
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 8544
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

signed main()
{
  int n,k;
  cin>>n>>k;
  int ma=(n-1)*(n-2)/2;
  if(ma<k){
    cout<<-1<<endl;
    return 0;
  }
  int diff=ma-k;
  int rem=0;
  cout<<n-1+diff<<endl;
  reps(i,(n-1+diff)){
    if(i>2*(n-1)){
      rem=n-1+diff-2*(n-1);
      break;
    }
    else if(i>(n-1)) {
      if(i==2*(n-1)) cout<<i-(n-1)<<" "<<1<<endl;
      else cout<<i-(n-1)<<" "<<1+i-(n-1)<<endl;
    }
    else cout<<n<<" "<<i<<endl;
  }
  int dist=2;
  reps(i,rem){
    if(i!=1) if((i-1)%(n-1)==0) dist++;
    int p=i%(n-1);
    if(p==0)p=(n-1);
    int c=(p+dist)%(n-1);
    if(c==0)c=(n-1);
    cout<<p<<" "<<c<<endl;
  }
}



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

using namespace std;

bool check(int *p, int *k, int *s, int m, int n,int l)
{
  bool check = true;
  for(int i = 0 ; i < m; i++){
    int sum = 0;
    int tmp = s[i] & l;
    for(int j = 0 ; j < n; j++){
      if((tmp >> j) % 2)
        sum++;
    }
    if(sum % 2 != p[i]){
      check = false;
      break;
    }
  }
  return check;
}
int main(void)
{
  	int n, m;
  	cin >> n >> m;
  	int k[m];
  	int p[m];
  	int s[m];
  	for(int i = 0 ; i < m ;i++){
      cin >> k[i];
      s[i] = 0;
      for(int j = 0 ; j < k[i];j++){
        int tmp;
        cin >> tmp;
        s[i] |= 1 << tmp - 1;
      }
    }
    for(int i = 0 ; i < m ;i++){
      cin >> p[i];
    }
    int sum = 0;
  	for(int i = 0 ; i < (1 << n) ;i++){     
      if(check(p, k, s, m,n, i))
      	sum++;    
    }
  	cout << sum;
  return 0;	
}

Measured memory_bytes: 256
N,K=map(int,input().split())
dset=set(map(int,input().split()))

def contain(n):
  ns=list(str(n))
  for c in ns:
    if int(c) in dset:
      return True
  return False

for i in range(N,100000):
  if not contain(i):
    print(i)
    break
else:
  print(-1) 

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    long double A[N];
    long double prod=1;
    for(int i=0;i<N;i++){
        cin >> A[i];
        prod *= A[i];
    }
    if(N==1){
        cout << A[0];
        return 0;
    }
    long double sum=0;
    long double prod2=1;
    for(int i=0;i<N;i++){
        for(int k=0;k<N;k++){
            if(i!=k){
                prod2*=A[k];
            }
        }
        sum += prod2;
        prod2=1;
    }
    cout<< prod/sum;
}

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

using namespace std ;

int a[ 100001 ] , n , k , dp[ 100001 ] ;

void solve()
{
    dp[ 1 ] = 0 ;

    for( int i = 2 ; i <= n ; i++ )
    {
        int ans = 1e9 ;
        for( int j = 1 ; j <= k ; j++ )
            if( i - j >= 1 )
                ans = min( dp[ i - j ] + abs( a[ i - j ] - a[ i ] ) , ans ) ;
        dp[ i ] = ans ;
    }


    cout << dp[ n ] << endl ;
}

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

    for( int i = 1 ; i <= n ; i++ )
    {
        cin >> a[ i ] ;
        dp[ i ] = -1 ;
    }

    solve() ;
}



Measured memory_bytes: 4376
l, r = map(int, input().split())

MOD = 2019

if r - l > 2019:
    print(0)
    exit()
else:
    mi = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            mi = min(mi, (i * j) % MOD)
    print(mi)

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

int main() {

    string s;
    cin >> s;

    bool flag = false;
    rep(i, s.length()){
        if(s[i] == 'C'){
            flag = true;
        }
        if(flag && s[i] == 'F'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    
    bool judge = false;
    rep(i, S.size()) for (int j = i - 1; j < S.size(); ++j) {
        string str = "";
        for (int k = 0; k < i; ++k) str += S[k];
        for (int k = j + 1; k < S.size(); ++k) str += S[k];
        if (str == "keyence") judge = true;
    }
    if (judge) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
try:
    while True:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==0:
            x=0
        if y==0:
            y=0
        print("{0:.3f}".format(round(x,3)), "{0:.3f}".format(round(y,3)))
except EOFError:
    pass

Measured memory_bytes: 7448
N, A, B = map(int, input().split())

count = 0

for i in range(1, N+1):
  str_i = str(i)
  tmp = 0
  for j in range(len(str_i)):
    tmp += int(str_i[j])
  if A <= tmp <= B:
    count += i
    
print(count)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  map<string, int64_t> mp;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  int64_t res = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    res += it->second * (it->second - 1) / 2;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#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__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
#define ll long long
    

void test_case(){
    string s;
    cin >> s;
    if(s.back() == 's'){
        //s.pop_back();
        s += 'e';
        s += 's';
    }else if(s.back() != 's'){
        s += 's';
    }
    cout << s << endl;
} 


int main(){
    
    int t = 1;
    //cin >> t;
    for(int i = 0; i < t; i++)
        test_case();
    
    return 0;
} 


 


Measured memory_bytes: 3628