akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

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


    int n,k;cin>>n>>k;
    vector<double> cumsum{0};
    for (size_t i = 0; i < n; i++)
    {
        int x;cin>>x;
        cumsum.push_back((x+1.)/2. + cumsum.back());
    }
    

    double max_exp = 0;
    for (size_t i = k; i < cumsum.size() ; i++)
    {
        chmax(max_exp,cumsum[i] - cumsum[i-k] );
    }
    cout <<setprecision(10)<< max_exp << "\n";
    
    
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main(void){
    int N,max=0,check=0;
    cin>>N;
    vector<double> H(N);
    rep(i,N){
        cin>>H[i];
    }
    rep(i,N-1){
        if(H[i]>max){
            max=H[i];
        }
        if(max-1>H[i])check++;
        if(H[i]-1>H[i+1]){
           cout<<"No"<<endl;
            return 0; 
        }
    }
    if(H[N-2]-1>H[N-1] || check>=1 ||max-1>H[N-1]){
        cout<<"No"<<endl;
        return 0; 
    }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int n; 
void dfs(string s, char mx){
    if(s.size()==n) cout<<s<<endl;
    else{
        for(char x='a';x<mx;x++)
            dfs(s+x,mx);
        char newmx = (char)mx+1;
        dfs(s+mx,newmx);
    }
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        cin>>n;
        dfs("",'a');
    }   
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<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; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int H, W, D;
    cin >> H >> W >> D;
    int A[H][W];
    map<int, P> mp;
    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
            mp[A[i][j]] = P(i,j); 
        }
    }
    int sum[H*W+1]{};
    for(int i=1;i<=H*W;i++){
        if(sum[i] != 0) continue;
        for(int j=i+D;j<=H*W;j+=D){
            sum[j] = sum[j-D] + abs(mp[j].first - mp[j-D].first) + abs(mp[j].second - mp[j-D].second);
        }
    }
    int Q;
    cin >> Q;
    rep(i,Q){
        int L, R;
        cin >> L >> R;
        cout << sum[R] - sum[L] << endl;
    }
}

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

using namespace std;
int v[100010];
int memo[100010];
int c;

int f(int i)
{

    if(memo[i]!=-1)
        return memo[i];

    if(i == 0)
        return memo[0] = 0;

    if(i == 1)
        return memo[1] = abs(v[0] - v[1]);

    return memo[i] = min(abs(v[i] - v[i-1]) + f(i-1), abs(v[i] - v[i-2]) + f(i-2));
}

int main()
{

    memset(memo, -1, sizeof(memo));
    cin>>c;

    for(int i = 0; i<c; i++)
    {
        cin>>v[i];
    }

    cout<<f(c-1)<<endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  if(a=="hi"){
    cout<<"Yes"<<endl;
  }
  else if (a=="hihi"){
    cout<<"Yes"<<endl;
  }
  else if (a=="hihihi"){
    cout<<"Yes"<<endl;
  }
  else if (a=="hihihihi"){
    cout<<"Yes"<<endl;
  }
  else if (a=="hihihihihi"){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
//ガウス
double sig(double a){
   return  (1+a)*a/2;
}
signed main(){
    int n,k;
    cin>>n>>k;
    vector<double> vec;

    rep(i,n){
        double a;
        cin>>a;
        vec.push_back(a);
    }

    double ans=0.0;
    double now_ans=0.0;
    //k<=n
    rep(j,k){
        now_ans+=sig(vec[j])/(double)vec[j];
    }

    rep(i,n-k+1){
        chmax(ans,now_ans);

        now_ans-=sig(vec[i])/(double)vec[i];
        now_ans+=sig(vec[i+k])/(double)vec[i+k];
    }
    cout<<setprecision(10)<<ans<<endl;
 
}

Measured memory_bytes: 2420
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n, m;

struct edge {
    int to, cost;

    edge(int to, int cost) : to(to), cost(cost) {}
};

vector<edge> G[half_inf];
vector<ll> L, R, D, ans;
vector<bool> searched;

bool dfs(int v) {
    searched[v] = true;
    rep(i, G[v].size()) {
        if (ans[G[v][i].to] == inf) {
            ans[G[v][i].to] = ans[v] + G[v][i].cost;
        }
        if (ans[G[v][i].to] != ans[v] + G[v][i].cost) {
            cout << "No" << endl;
            exit(0);
        }
        if (!searched[G[v][i].to]) dfs(G[v][i].to);
    }
}

void solve() {
    rep(i, n) {
        if (!searched[i]) {
            ans[i] = 0;
            dfs(i);
        }
    }
    cout << "Yes" << endl;
}

int main() {
    cin >> n >> m;
    L.resize(m), R.resize(m), D.resize(m);
    searched.resize(n);
    ans.resize(n);
    fill(ans.begin(), ans.end(), inf);
    for (int i = 0; i < m; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;
        L[i] = l, R[i] = r, D[i] = d;
        edge e1(r, d), e2(l, -d);
        G[l].emplace_back(e1);
        G[r].emplace_back(e2);
    }
    solve();
    return 0;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) ans++;
	}
	cout << (double)ans / N << endl;
}

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

int mata[17][17][17][17];

int main() {

  int data;
  cin >> data ;
  for(int i=0;i<data;i++) {
    //0で初期化
    memset(mata,0,sizeof(mata));

    int gx,gy;
    cin >> gx >> gy;
    gx++;
    gy++;

    int map[17][17];

    memset(map,0,sizeof(map));

    int n,a[2],b[2];


    cin >> n;


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

    map[1][1] = 1;

    for(int j=1;j<=gy;j++) {
      for(int i=1;i<=gx;i++) {

       
	if(mata[i-1][j][i][j] != 1) map[i][j] += map[i-1][j];

	if(mata[i][j-1][i][j] !=1) map[i][j] += map[i][j-1];
	  

      }
    }

    if(map[gx][gy] == 0) cout << "Miserable Hokusai!" << endl;
    else 
    cout << map[gx][gy] << endl;

  }

  return 0;

  
}

Measured memory_bytes: 1492
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
int main(){
    int save[5];
    scanf("%d%d%d", &save[1], &save[2], &save[3]);
    printf("%d %d %d\n", save[3], save[1], save[2]);
    
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    //旅行者の人数N人を定義
    int A;
    //電車を使う場合の一人当たりの料金A円を定義
    int B;
    //タクシーを使う場合の料金B円を定義
    cin >> N >> A >> B;
    if(N * A < B){
        cout << N * A << endl;
    } else if(N * A > B){
        cout << B << endl;
    } else if(N * A == B){
        cout << B << endl;
    }
}

Measured memory_bytes: 256
(let ((s (read-line))
      (m (make-array 13 :element-type 'integer
                        :initial-element 0
                        :adjustable t))
      (newm (make-array 13 :element-type 'integer
                        :initial-element 0
                        :adjustable t)))
     (setf (aref m 0) 1)
     (loop for x across s
           do (if (eq x #\?)
                  (dotimes (i 10)
                               (dotimes (j 13)
                                 (incf (aref newm (rem (+ (* j 10) i) 13)) (aref m j))))
                  (dotimes (j 13)
                    (incf (aref newm (rem (+ (* j 10) (- (char-code x) 48)) 13)) (aref m j))))
           (dotimes (i 13)
             (setf (aref m i) (rem (aref newm i) 1000000007))
             (setf (aref newm i) 0)))
     (princ (aref m 5)))

Measured memory_bytes: 16616
import java.util.Scanner;
public class Main{
	static long mod;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		long[] a=new long[s.length()+1];
		long[] c=new long[s.length()+1];
		long[] q=new long[s.length()+1];
		mod=1000000007;
		for(int i = 1; i<s.length()+1; i++){
			if(s.charAt(i-1)=='A'){
				a[i]++;
			}else if(s.charAt(i-1)=='C'){
				c[i]++;
			}else if(s.charAt(i-1)=='?'){
				q[i]++;
			}
			a[i]+=a[i-1];
			c[i]+=c[i-1];
			q[i]+=q[i-1];
		}
		long ans=0;
		for(int i=1; i<s.length()+1; i++){
			if(s.charAt(i-1)=='B' || s.charAt(i-1)=='?'){
				int bi=0;
				if(s.charAt(i-1)=='?'){
					bi=1;
				}
				ans+=((a[i]*(c[s.length()]-c[i]))%mod)*pow(3,q[s.length()]-bi);
				ans%=mod;
				ans+=((q[i-1]*(c[s.length()]-c[i]))%mod)*pow(3,q[s.length()]-1-bi);
				ans%=mod;
				ans+=((a[i]*(q[s.length()]-q[i]))%mod)*pow(3,q[s.length()]-1-bi);
				ans%=mod;
				ans+=((q[i-1]*(q[s.length()]-q[i]))%mod)*pow(3,q[s.length()]-2-bi);
				ans%=mod;
			}
		}
		System.out.println(ans);
	}
	static long pow(long t,long y){
		long ans=1;
		while(y>0){
			if((y & 1)==1){
				ans*=t;
			}
			ans%=mod;
			t*=t;
			t%=mod;
			y>>=1;
		}
		return ans;
	}
}

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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int main() {
  int v[50] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d", &k);
  printf("%d\n", v[k-1]);
	return 0;
}


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

int main(){
	int N,K,R,S,P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	
	int ans=0;
	
	for(int k=0;k<K;k++){
		int len=(N+K-1-k)/K;
		int dp[len+1][3];
		for(int i=0;i<len+1;i++)for(int j=0;j<3;j++)dp[i][j]=0;
		
		for(int i=0;i<len;i++){
			if(T[i*K+k]=='r'){
				dp[i+1][2]=max(dp[i][0]+P,dp[i][1]+P);
				dp[i+1][0]=max(dp[i][1],dp[i][2]);
				dp[i+1][1]=max(dp[i][0],dp[i][2]);
			}
			if(T[i*K+k]=='s'){
				dp[i+1][0]=max(dp[i][1]+R,dp[i][2]+R);
				dp[i+1][1]=max(dp[i][0],dp[i][2]);
				dp[i+1][2]=max(dp[i][1],dp[i][2]);
			}
			if(T[i*K+k]=='p'){
				dp[i+1][1]=max(dp[i][0]+S,dp[i][2]+S);
				dp[i+1][0]=max(dp[i][1],dp[i][2]);
				dp[i+1][2]=max(dp[i][0],dp[i][1]);
			}
		}
		ans+=max(max(dp[len][0],dp[len][1]),dp[len][2]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 214514
vector<int> G[MAX];
vector<double> L[MAX];
double ans[MAX];
double memo[MAX];
int n;
double dfs(int v,int p){
  double res=0;
  L[v].resize(G[v].size());
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i];
    if(u==p) continue;
    L[v][i]=dfs(u,v);
    //cout<<v<<":"<<u<<"/"<<k<<endl;
    res+=L[v][i];
  }
  if(G[v].size()==1) return memo[v]=1.0;
  //cout<<v<<"-"<<res<<endl;
  return memo[v]=(res/(G[v].size()-1))+1.0;
}


void dfs2(int v,int p,double x){
  ans[v]=x;
  //cout<<v<<" "<<x<<endl;
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i];
    if(u==p) continue;
    ans[v]+=memo[u];
    //cout<<v<<" "<<i<<":"<<((memo[v]-1.0)*(G[v].size()-1))<<" "<<L[v][i]<<" "<<x<<endl;
    dfs2(u,v,(G[v].size()>1?
	      (((memo[v]-1.0)*(G[v].size()-1)-L[v][i]+x)
	       /(double)(G[v].size()-1))
	       :x)+1.0);
	 
  }
  ans[v]/=G[v].size();
}

signed main(){
  cin>>n;
  int u[n-1],v[n-1];
  for(int i=0;i<n-1;i++) cin>>u[i]>>v[i];
  for(int i=0;i<n-1;i++){
    u[i]--;v[i]--;
    G[u[i]].push_back(v[i]);
    G[v[i]].push_back(u[i]);
  }
  dfs(0,-1);
  dfs2(0,-1,0);
  //for(int i=0;i<n;i++) printf("%.12f\n",memo[i]);puts("");
  for(int i=0;i<n;i++) printf("%.12f\n",ans[i]);
  return 0;
}


Measured memory_bytes: 34048
import math
s=input()
c=[]
c.append(1)
j=0
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        c[j]+=1
    else:
        c.append(1)
        j+=1
for i in range(len(c)//2):
    for s in range(c[2*i]-1):
        print(0,end=" ")
    print(math.ceil(c[2*i]/2)+math.floor(c[2*i+1]/2),end=" ")
    print(math.floor(c[2*i]/2)+math.ceil(c[2*i+1]/2),end=" ")
    for s in range(c[2*i+1]-1):
        print(0,end=" ")


Measured memory_bytes: 4856
info_n = int(input())

resident = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for _ in range(info_n):
    b, f, r, v = map(int, input().split())

    resident[b - 1][f - 1][r - 1] += v
    
for b in range(4):
    for f in range(3):
        for r in range(10):
            print(" " + str(resident[b][f][r]), end="")
        print()
    if b != 3:
        print("####################")


Measured memory_bytes: 5620
#include<stdio.h>

unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max);
unsigned short s_sarch_text(unsigned char * ring, unsigned short r_length, unsigned char * look, unsigned short l_length);

int main(){
	unsigned char ubW_D_ring_text[101];
	unsigned char ubW_D_look_text[101];
	unsigned short usW_D_ring_length;
	unsigned short usW_D_look_length;
	unsigned short usW_F_frg_main = 0;
	unsigned short usW_C_i;
	
	for(usW_C_i = 0;usW_C_i < 100;usW_C_i++){
		ubW_D_ring_text[usW_C_i] = 0;
		ubW_D_look_text[usW_C_i] = 0;
	}
	
	usW_D_ring_length = s_scan_sentence(ubW_D_ring_text, 101);
	usW_D_look_length = s_scan_sentence(ubW_D_look_text, 101);
	
	usW_F_frg_main = s_sarch_text(ubW_D_ring_text, usW_D_ring_length, ubW_D_look_text, usW_D_look_length);
	
	if(usW_F_frg_main == 0){
		printf("No\n");
	}
	else if(usW_F_frg_main == 1){
		printf("Yes\n");
	}
	
	return 0;
}


/* 関数名：文字列入力 */
/* 概要：文字列を入力する。その長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = 0;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = 0;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if(*(str + usW_C_i) == '\n'){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short s_sarch_text(unsigned char * ring, unsigned short r_length, unsigned char * look, unsigned short l_length)
{
	unsigned char twi_ring[100 * 2];
	unsigned short usW_F_frg_fanc = 0;
	unsigned short usW_C_i, usW_C_j;
	
	for(usW_C_i = 0;usW_C_i < 200;usW_C_i++){
		twi_ring[usW_C_i] = 0;
	}
	
	for(usW_C_i = 0;usW_C_i < r_length;usW_C_i++){
		twi_ring[usW_C_i] = *(ring + usW_C_i);
	}
	for(usW_C_i = 0;usW_C_i < l_length;usW_C_i++){
		twi_ring[r_length + usW_C_i] = *(ring + usW_C_i);
	}
	
	for(usW_C_i = 0;usW_C_i <= r_length;usW_C_i++){
		for(usW_C_j = 0;usW_C_j <= l_length;usW_C_j++){
			if(*(look + usW_C_j) == '\n'){
				usW_F_frg_fanc = 1;
			}
			if(twi_ring[usW_C_i + usW_C_j] != *(look + usW_C_j)){
				break;
			}
		}
	}
	
	return usW_F_frg_fanc;
}



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

int main(int argc, char const *argv[])
{
    int n,i,j;
    int a1[101]={};
    int a2[101]={};

    cin >> n;
    for(i=0;i<n;++i) cin >> a1[i];
    for(i=0;i<n;++i) cin >> a2[i];
    int tmp = 0;
    int max = 0;
    for (i=0;i<n;++i){
        for(j=0;j<=i;++j) tmp+=a1[j];
        for(--j;j<n;++j) tmp+=a2[j];
        if(tmp>max) max=tmp;
        tmp = 0;
    }
    cout << max;
    
    return 0;
}


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


const int M = 100 + 7, wei = 1e5 + 10, oo = -1e9;

int N, W, v[M], w[M];
ll dp[M][wei];

ll solve(int ind, int we) {
	if (ind == N)return (we <= W) ? 0 : oo;
	ll& re = dp[ind][we];
	if (re != -1)return re;
	re = max(re, solve(ind + 1, we));
	if(we+w[ind] <= W)
		re = max(re, v[ind] + solve(ind + 1, w[ind] + we));
	return re;
}

int main() {


	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> W;
	for (int i = 0; i < N; i++)
	{
		cin >> w[i] >> v[i];
	}
	memset(dp, -1, sizeof dp);
	cout << solve(0, 0) << endl;
	return 0;
}


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



int main(){
    int A,B;
    cin >> A >> B;
    if((A+B)%2 == 0) cout << (A+B)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [[int(i) for i in input().split(" ")] for j in range(n)]
a = sorted([i[0] for i in A])
b = sorted([i[1] for i in A], reverse=True)
if n%2 == 1:
    print(b[n//2]-a[n//2]+1)
else:
    l = (a[n//2-1] + a[n//2]) / 2
    r = (b[n//2-1] + b[n//2]) / 2
    print(int((r-l)*2)+1)

Measured memory_bytes: 47596
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

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

const int INF = 1e9 + 7;

vi G[20];
int p[20], s[20];

int main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		int k;
		cin >> k;
		for(int j=0;j<k;j++) {
			int s;
			cin >> s;
			s--;
			G[s].PB(i);
		}
	}
	for(int i=0;i<m;i++)
		cin >> p[i];
	int ans = 0;
	for(int i=0;i<(1<<n);i++) {
		for(int k=0;k<m;k++)
			s[k] = 0;
		bool ok = 1;
		for(int j=0;j<n;j++) {
			if(i>>j&1) {
				for(int k:G[j])
					s[k]++;
			}
		}
		for(int j=0;j<m;j++)
			if(s[j] % 2 != p[j])
				ok = 0;
		ans += ok;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int x;
        int z = 0;
        for (x = a; x <= b; x++) {
            if (c % x == 0) {
                z++;
            }
        }
        System.out.println(z);

    }

}


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

template <class T>
inline bool read(T &ret)
{
    char c;
    int sgn;
    if (c = getchar(), c == EOF)
    {
        return 0;
    }
    while (c != '-' && (c < '0' || c > '9'))
    {
        c = getchar();
    }
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9')
    {
        ret = ret * 10 + (c - '0');
    }
    ret *= sgn;
    return 1;
}

template <class T>
inline void write(T x)
{
    if (x > 9)
    {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}

int a,b;
int ans=1;

int main()
{
    cin>>a>>b;
    b-=a;
    a--;
    ans+=ceil(double(double(b)/double(a)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
   
int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    int n , m = 0 , x = 0;
    cin >> n;
    ll a[n];
    for( int i = 0 ; i < n ; i++ ) cin >> a[i];
    while( m == 0 ) {
        for( int i = 0 ; i < n ; i++ ) {
            if( a[i] % 2 ) m = 1;
        }
        if( m == 0 ) {
            for( int i = 0 ; i < n ; i++ ) {
                a[i] /= 2;
            }
        }
        x++;
    }
    cout << x - 1;
}

Measured memory_bytes: 3660
N = int(input())
Vlist = list(map(int,input().split()))

while len(Vlist) > 1:
	Vlist.sort()
	Vlist[0]=(Vlist[0]+Vlist[1])/2
	Vlist[1] = 0
	Vlist.remove(0)

print(Vlist[0])

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
using namespace std;
using lli = long long int;

lli ans(lli h){
  if(h <= 1)return h;
  h /= 2;
  return 2LL*ans(h) + 1LL;
}

int main(){
  lli h;
  std::cin >> h;
  std::cout << ans(h) << std::endl;
  return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t;

ll p[20];
vll choice[20];


// <------------- Implement Functions Here ----------> //

ll chk(vll select) {
	for(ll i=1;i<=m;i++) {
		ll cnt = 0;
		for(auto it : choice[i]) {
			cnt += select[it];
		}
		if(cnt%2 != p[i]) return 0;
	}
	return 1;
}

ll recur(vll select, ll i = 1) {
	if(i > n) {
		return chk(select);
	}

	ll sum = recur(select,i+1);
	select[i] = 1;
	sum += recur(select,i+1);

	return sum;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>m;
	for(ll i=1;i<=m;i++) {
		cin>>x;
		while(x--) {
			cin>>k;
			choice[i].pb(k);
		}
	}
	for(ll i=1;i<=m;i++) cin>>p[i];

	vll select(n+1,0);

	cout<<recur(select);
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 3005;
int n;
ll mod;
inline ll qpow(ll a, ll b, int c = mod)
{
	ll res = 1;
	for(; b; a = a*a%c, b >>= 1)
	    if(b&1)
	        res = res*a%c;
	return res;
}
ll f[MAXN][MAXN],c[MAXN][MAXN];

int main()
{
	cin >> n >> mod;
	ll ans = 0;
	f[0][0] = 1;
	for(int i = 1; i<=n+1; i++)
	    for(int j = 1; j<=i; j++)
	        f[i][j] = (f[i-1][j-1]+1ll*j*f[i-1][j]%mod)%mod;
	for(int i = 0; i<=n; i++)
	    c[i][0] = c[i][i] = 1;
	for(int i = 2; i<=n; i++)
	    for(int j = 1; j<i; j++)
	        c[i][j] = (c[i-1][j-1]+c[i-1][j])%mod;
    for(int i = 0; i<=n; i++)
	{
		ll s = qpow(2,n-i,mod-1);
	    ll t = c[n][i]*qpow(mod-1,i)%mod*qpow(2,s)%mod;
	    for(int j = 0; j<=i; j++)
	        ans = (ans+t*f[i+1][j+1]%mod*qpow(qpow(2,n-i),j)%mod)%mod;
    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 139648
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
	int ans;
	cin >> ans;
	cin.ignore();
	while (true) {
		char op;
		cin >> op;
		if (op == '=') {
			break;
		}
		int num;
		cin >> num;
		switch (op) {
			case '+':
				ans += num;
				break;
			case '-':
				ans -= num;
				break;
			case '*':
				ans *= num;
				break;
			case '/':
				ans /= num;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N, D;
    cin >> N >> D;
    int cnt = 0;
    rep(i, N){
        ll X, Y;
        cin >> X >> Y;
        ll ans = pow(X, 2)+pow(Y, 2);
        if(ans<=pow(D, 2)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] n =new int[3];
        for(int i = 0;i<3;i++){
            n[i] = sc.nextInt();
        }
        if((n[0]==n[1] && n[1] ==n[2] && n[0] == n[2])
           ||(n[0]!=n[1] && n[1] !=n[2] && n[0] != n[2]) ){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

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


ll n;

void dfs(ll value, ll chk, ll &cnt){
  if(n<value) return;
  if(chk==0b111) cnt += 1;
  dfs(10*value+3, chk | 0b100, cnt);
  dfs(10*value+5, chk | 0b001, cnt);
  dfs(10*value+7, chk | 0b010, cnt);
}


int main(){
  cin >> n;
  ll res=0;
  dfs(0, 0, res);
  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,m;
  int di,a,b,h[100000],f[100000]={0};
  int i=0,j=0;
  int count=0;
  
  if(scanf("%d %d",&n,&m)==1){}
  for(i=0;i<n;i++){
    f[i]=1;
    if(scanf("%d",&(h[i]))==1){}
  }

    for(j=0;j<m;j++){
      if(scanf("%d %d",&a,&b)==1){}
      if(h[a-1]>=h[b-1]){
	f[b-1]=0;
      }
      if(h[a-1]<=h[b-1]){
	f[a-1]=0;
      }
    }

    for(i=0;i<n;i++){
      if(f[i]==1){
	count++;
      }
    }
    for(i=0;i<n;i++){
      //printf("%d\n",h[i]);
    }
    printf("%d\n",count);
    return 0;
  }


Measured memory_bytes: 2512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

int main(void) {

  string str("abcdefghijklmnopqrstuvwxyz");
  string str2;

  cin >> str2;

  for(int i=0; i<str.length(); i++) {
      if(str2.find(str[i]) == string::npos) {
        cout << str[i] << endl;
        return 0;
      }
  }
  cout << "None" << endl;
  return 0;
}


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

namespace ABC146A
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            switch (S)
            {
                case ("SUN"): Console.WriteLine(7); break;
                case ("MON"): Console.WriteLine(6); break;
                case ("TUE"): Console.WriteLine(5); break;
                case ("WED"): Console.WriteLine(4); break;
                case ("THU"): Console.WriteLine(3); break;
                case ("FRI"): Console.WriteLine(2); break;
                case ("SAT"): Console.WriteLine(1); break;
            }
        }
    }
}


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

const int MOD = 1e9+7;
int add(int a, int b){return ((ll)a + (ll)b)%MOD;}
int sub(int a, int b){return add(a+MOD, -b);}
int mul(int a, int b){return ((ll)a * (ll)b)%MOD;}

void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<bool> g(n, true);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        g[a-1] = g[a-1] & (h[a-1] > h[b-1]);
        g[b-1] = g[b-1] & (h[b-1] > h[a-1]);
    }

    int cnt = 0;
    for(bool b : g){
        cnt += b;
    }
    cout << cnt << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        String[] s =sc.next().split("");

        System.out.println(s[2].equals(s[3]) && s[4].equals(s[5]) ? "Yes" : "No");
    }
}

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

#define d double

d coin(vector<d> p, int n){
    vector<vector<d>> dp(n+1, vector<d>(n+1, 0.0));
    dp[0][0]=1.0;
    for(int i=1; i<=n; i++){
        for(int j=0; j<=i; j++){
            if(j==0) dp[i][j] = dp[i-1][j]*(1-p[i-1]);
            else dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
        }
    }
    d ans = 0.0;
    for(int i=(n+1)/2; i<=n; i++) ans+=dp[n][i];
    return ans;
}

int main(){
    int n;
    cin>>n;
    vector<d> p(n);
    for(int i=0; i<n; i++) cin>>p[i];
    cout<<setprecision(10)<<coin(p, n);
    return 0;
}


Measured memory_bytes: 73812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String ans ="A";

		String str = "";
		while((str=br.readLine())!=null){

			String[] sp = str.split(",");

			if(ans.equals(sp[0])){
				ans = sp[1];
			} else if(ans.equals(sp[1])){
				ans = sp[0];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <queue>

using namespace std;

int main() {
  int n,m,k;
  string s;
  cin >> n >> m;
  cout << n+m/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

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

    if (n == k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
#define endl "\n";
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
    int n, t, x; cin >> n >> x>> t;
    cout << (ll)((n+x-1)/x * t) << endl;

}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, x, n) for(ll i=x; i<(ll)n; ++i)
#define rep(i, x) REP(i, 0, x)
#define all(v) v.gein(), v.end()

int main(){
    int N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    rep(i, N){
        cin >> p[i].first >> p[i].second;
    }
    map<pair<ll, ll>, ll> c;
    ll m = 0;
    rep(i, N){
        REP(j, i+1, N){
            ll dx = p[j].first - p[i].first;
            ll dy = p[j].second - p[i].second;
            if(dx<0){
                dx = -dx;
                dy = -dy;
            }
            else if(dx==0){
                if(dy<0) dy = -dy;
            }
            pair<ll, ll> d = {dx, dy};
            if(c.count(d)>0) ++c[d];
            else c.insert({d, 1});
            if(m<c[d]) m = c[d];
        }
    }
    cout << (N-m) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll fpow(ll a,ll b,ll mod){
    ll ans = 1;
    while(b > 0){
        if(b & 1){
            ans = ans * a % mod;
        }
        b >>= 1;
        a = a * a % mod;
    }
    return ans % mod;
}
int n;
int main(){
    cin >> n;
    ll ans = 1;
    ans = (fpow(10,n,mod) + fpow(8,n,mod) - fpow(9,n,mod) - fpow(9,n,mod) + mod + mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
inf = 10**9+7
mod = 10**9+7
n,x = map(int, input().split())
dp_s = [0 for i in range(n+1)]
dp_p = [0 for i in range(n+1)]
dp_s[0] = 1
dp_p[0] = 1
for i in range(n):
    dp_s[i+1] = dp_s[i]*2+3
for i in range(n):
    dp_p[i+1] = dp_p[i]*2+1

def getP(dim, rest):
    if dim == 0:
        if rest == 0:
            return 0
        elif rest == 1:
            return 1
    if rest == 1:
        return 0
    elif 1 < rest < dp_s[dim-1]+2:
        return getP(dim-1, rest-1)
    elif rest == dp_s[dim-1]+2:
        return dp_p[dim-1]+1
    elif dp_s[dim-1]+2 < rest < dp_s[dim]:
        return dp_p[dim-1]+1+getP(dim-1, rest-(dp_s[dim-1]+2))
    elif rest == dp_s[dim]:
        return dp_p[dim]

print(getP(n, x))

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  for(int i=0;i<n;i++){
    p[i].second=i+1;
    int number;
    cin >> number;
    p[i].first=number;
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n-1;i++){
    cout << p[i].second << " " ;
  }
  cout <<p[n-1].second << endl;
}

Measured memory_bytes: 1664
n = int(input())

for x in range(n//4, 3501):
    for y in range(x, 3501):
        A = n*x*y
        B = 4*x*y - n*x - n*y
        if B > 0 and A % B == 0:
            print(x, y, A//B)
            exit()


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

int main(){
    int N, Q; // N: 文字列長 Q: 問題数
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> l(Q);
    vector<int> r(Q);
    for(int i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
    }

    vector<int> sum(N+1, 0);
    for(int i = 1; i < N; i++){
        if(S[i-1] == 'A' && S[i] == 'C'){
            sum[i+1] = sum[i] + 1;
        }else{
            sum[i+1] = sum[i];
        }
    }

    int ans = 0;
    for(int i = 0; i < Q; i++){
        ans = sum[r[i]] - sum[l[i]];
        cout << ans << endl;
    }

    return 0;
}

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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int m = Integer.parseInt(s[1]);
    HashMap<Integer, ArrayList<Integer>> hm = new HashMap<>();
    for(int i=0;i<m;i++){
      String[] str = br.readLine().split(" ");
      int u = Integer.parseInt(str[0]);
      int v = Integer.parseInt(str[1]);
      if(hm.containsKey(u)){
        ArrayList<Integer> al = hm.get(u);
        al.add(v);
        hm.put(u,al);
      }
      else{
        ArrayList<Integer> al = new ArrayList<>();
        al.add(v);
        hm.put(u,al);
      }
    }
    long ans = 0;
    long[] dp = new long[1000005];
    Arrays.fill(dp,-1);
    for(int i=1;i<=n;i++){
      ans = Math.max(ans,getBestLength(i,dp,hm));
    }
    System.out.println(ans);
  }
  
  public static long getBestLength(int u,long[] dp,Map<Integer,ArrayList<Integer>> hm){
    if(dp[u]!=-1) return dp[u];
    else if(!hm.containsKey(u)){
      dp[u] = 0;
      return dp[u];
    }
      else{
        long bestLen = 0;
        for(int child : hm.get(u)){
          long currLen = getBestLength(child,dp,hm);
          bestLen = Math.max(bestLen,currLen);
        }
        dp[u] = bestLen+1;
        return dp[u];
      }
      
  }
}
      


Measured memory_bytes: 80608
#include<bits/stdc++.h>
using namespace std;
vector<int> d[100];
bool visited[100];
int dist, max_dist;
int V;
void dfs(int s){
	dist++;
	if(dist > max_dist) max_dist = dist;
	visited[s] = true;
	for(int i = 0; i < d[s].size(); i++){
		int t = d[s][i];
		if(visited[t] == false){
			dfs(t);
			dist--;
			visited[t] = false;
		}
	}
	visited[s] = false;
	return;
}
int main(){
	int N, a, b;
	for(;;){
		scanf("%d", &N);
		if(N == 0) break;
		max_dist = 0;
		V = 0;
		for(int i = 0; i < 100; i++) d[i].clear();
		for(int i = 0; i < N; i++){
			scanf("%d %d", &a, &b);
			if(a > V) V = a;
			if(b > V) V = b;
			a--; b--;
			d[a].push_back(b);
			d[b].push_back(a);
		}
		for(int i = 0; i < V; i++){
			fill(visited, visited + V, false);
			dist = 0;
			dfs(i);
		}
		printf("%d\n", max_dist);
	}
	return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>

#define DINF 1E+9
#define MIN(x,y) (((x)<(y))?(x):(y))

void solve(int n);

int main(void){
  int n;
  while(scanf("%d",&n) && n) solve(n);
  return 0;
}

void solve(int n){
  unsigned graph[11][11]={{0}};
  unsigned sum[11];
  int city=0,i,j,k,c1,c2,d,msum,mnum;

  for(i=0;i<11;i++) for(j=0;j<11;j++) graph[i][j]=(i==j)?0:DINF;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&c1,&c2,&d);
    graph[c1][c2]=graph[c2][c1]=d;
    if(city<c1) city=c1;
    if(city<c2) city=c2;
  }
  city++;

  for(k=0;k<city;k++)
    for(i=0;i<city;i++)
      for(j=0;j<city;j++)
	graph[i][j]=MIN(graph[i][j],graph[i][k]+graph[k][j]);

  msum=DINF;
  for(i=0;i<city;i++){
    sum[i]=0;
    for(j=0;j<city;j++) sum[i]+=graph[i][j];
    if(msum>sum[i]){
      msum=sum[i];
      mnum=i;
    }
  }
  printf("%d %d\n",mnum,msum);
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    ll N; cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    for(ll &a:A)
        cin >> a;
    for(ll &b:B)
        cin >> b;
    
    ll ans = 0;
    for(int i=0; i<N; i++){
        ans += min(A[i], B[i]);
        ans += min(A[i+1], B[i] - min(A[i], B[i]));
        A[i+1] = max(0LL, A[i+1] - (B[i] - min(A[i], B[i])));

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



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;


class Solve{
public:
  Solve()
  {
    cin>>n;
    res=0;
    for(int i=0;i<n;i++)
    {
      cin>>x>>u;
      if(u=="JPY")res+=x;
      else res+=x*380000;
    }
  }
  void print()
  {
    cout<<res<<endl;
  }
private:
  string u;
  double x;
  double res;
  int n;
};
int main()
{
  Solve test;
  test.print();
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;
ll n;
int len=0;
int a[50];
int b[50];

bool check(int loc)
{
    for (int i=loc+1; i<len; ++i)
        if (b[i]!=9)
            return 1;
    return 0;
}


int main()
{
    cin>>n;
    while (n)
    {
        a[len++]=n%10;
        n/=10;
    }
    for (int i=0; i<len; ++i)
    {
        b[i]=a[len-i-1];
    }
    for (int i=0; i<len; ++i)
    {
        if (check(i))
        {
            b[i]=b[i]-1;
            for (int j=i+1; j<len; ++j)
                b[j]=9;
            break;
        }
    }
    int ans=0;
    for (int i=0; i<len; ++i)
    {
        ans+=b[i];
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    cin>>n>>k;
    int s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    int ans=0;
    for(int i=0;i<n;i++){
        if(k==s[i]){cout<<ans+1<<endl;return 0;}
        else if(k<s[i]){cout<<ans<<endl;return 0;}
        else if(k>s[i]){k-=s[i];ans++;}
    }
    cout<<ans-1<<endl;
}


Measured memory_bytes: 256
n = list(input())

def check_list(li):
    count_big = 0
    count_small = 0
    for i in li:
        if i == '>':
            count_small += 1
        elif i == '<':
            count_big += 1
    a = list(range(max(count_small, count_big)+1))
    b = list(range(min(count_small, count_big)))
    return sum(a) + sum(b)

point_list = []
count = 0
for i in range(len(n)-1):
    if n[i] == '>' and n[i+1] == '<':
        point_list.append(i)

if point_list == []:
    print(check_list(n))
    exit()

point_list.insert(0,0)
point_list.insert(len(n), len(n)-1)

for i in range(len(point_list)-1):
    if i == 0:
        a = n[:point_list[i+1]+1]
    else:
        a = n[point_list[i]+1:point_list[i+1]+1]
    b = check_list(a)
    count += b

print(count)



Measured memory_bytes: 26800
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,c,x[100010],v[100010],x0[100010],v0[100010],ans=0,x1[10][100010],v1[10][100010],a[10]={},hara[100010];
  cin>>n>>c;
  fr(i,n){cin>>x[i]>>v[i];x0[n-1-i]=c-x[i];v0[n-1-i]=v[i];}
  hara[0]=v[0]-x[0];
  fr(i,n-1){
    hara[i+1]=hara[i]+v[i+1]+x[i]-x[i+1];
  }
  fr(i,n){
    if(a[0]<hara[i]) a[0]=hara[i];
    v1[0][i]=a[0];
  }
  fr(i,n){
    if(a[1]<hara[i]-x[i]) a[1]=hara[i]-x[i];
    v1[1][i]=a[1];
  }
  
  
  
  hara[0]=v0[0]-x0[0];
  fr(i,n-1){
    hara[i+1]=hara[i]+v0[i+1]+x0[i]-x0[i+1];
  }
  fr(i,n){
    if(a[2]<hara[i]) a[2]=hara[i];
    v1[2][n-1-i]=a[2];
  }
  fr(i,n){
    if(a[3]<hara[i]-x0[i]) a[3]=hara[i]-x0[i];
    v1[3][n-1-i]=a[3];
  }
  ans=max(max(ans,v1[0][n-1]),v1[2][0]);
  fr(i,n-1){
    ans=max(ans,v1[0][i]+v1[3][i+1]);
    ans=max(ans,v1[1][i]+v1[2][i+1]);
  }
  cout<<ans;
}

Measured memory_bytes: 9088
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func BinarySearch(arr []int, value int) int {
	r := len(arr)
	l := 0

	for r >= l {
		m := (l + r) / 2
		v := arr[m]

		switch {
		case v == value:
			return m
		case v < value:
			l = m + 1
		case v > value:
			r = m - 1
		}
	}

	return -1
}

func ScanArray(r io.Reader) *[]int {
	var n int
	fmt.Fscan(r, &n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &arr[i])
	}
	return &arr
}

func main() {
	r := bufio.NewReader(os.Stdin)
	s := *ScanArray(r)
	t := *ScanArray(r)

	var count int
	for _, v := range t {
		if BinarySearch(s, v) >= 0 {
			count++
		}
	}

	fmt.Println(count)
}



Measured memory_bytes: 3168
def main():
  N=input()
  A=sorted(map(int,input().split()))
  M=A[-1]+1
  B=[True]*M
  c=0
  x=0
  for i in A:
    if B[i]:
      if i!=c:
        for j in range(i*2,M,i):
          B[j]=False
        x+=1
        c=i
      else:
        B[i]=False
        x-=1
  print(x)
main()

Measured memory_bytes: 101412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t

const int MAXX = 510000;
const int MOD = 1000000007;
long long fac[MAXX], finv[MAXX], inv[MAXX];


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAXX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    ll N; cin >> N;
    vector<ll> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    vector<ll> D(N-1);
    ll ans = 0;
    for(int i = 0; i < N-1; i++){
        ll id = i+1; //idこ選ぶ
        D[i] = ((COM(N-1, id) * fac[N-1-id]%MOD) * fac[id-1])%MOD;
    }

    for(int i = 0; i < N-2; i++) D[i+1] = (D[i]+D[i+1])%MOD;
    for(int i = 0; i < N-1; i++){
        ll d = V[i+1]-V[i];
        ans += (d*D[i])%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13824
import math
a,b,C = map(int, input().split())
r = C*math.pi/180
h = b*math.sin(r)
print('{0:f}'.format(a*h/2))
print('{0:f}'.format(a+b+(math.sqrt(a**2+b**2-2*a*b*math.cos(r)))))
print('{0:f}'.format(h))

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

int main(){
	int S,h,m,s;
	
	cin >> S;
	h = S/3600;
	m = S/60 - h*60;
	s = S - m*60 - h*3600;
	
	cout <<  h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 3040