akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <numeric>

const int MOD = (int)1e9 + 7;
int n, q, l[15], r[15];
int mask[15];
int dsu[15];

int inv(int x) {
  return x == 1 ? 1 : (MOD - MOD / x) * 1LL * inv(MOD % x) % MOD;
}

int find(int x) {
  return dsu[x] == x ? x : dsu[x] = find(dsu[x]);
}

int power(int a, int b) {
  int ret = 1;
  for ( ; b; b >>= 1, a = a * 1LL * a % MOD) if (b & 1) ret = ret * 1LL * a % MOD;
  return ret;
}

int main() {
  scanf("%d%d", &n, &q);
  std::vector<int> ss{0};
  for (int i = 0; i < q; ++ i) {
    scanf("%d%d", l + i, r + i);
    ss.emplace_back(l[i] - 1);
    ss.emplace_back(r[i]);
  }
  std::sort(ss.begin(), ss.end());
  ss.erase(std::unique(ss.begin(), ss.end()), ss.end());
  std::iota(dsu, dsu + q, 0);
  auto get = [&ss](int x) -> int {
    return std::lower_bound(ss.begin(), ss.end(), x) - ss.begin();
  };
  for (int i = 0; i < q; ++ i) {
    mask[i] = 1 << get(l[i] - 1) | 1 << get(r[i]);
  }
  for (int i = 0; i < q; ++ i) {
    for (int j = i + 1; j < q; ++ j) {
      int a = find(i), b = find(j);
      if (a != b && (mask[a] & mask[b])) {
        mask[a] |= mask[b];
        dsu[b] = a;
      }
    }
  }
  std::vector<int> groups;
  for (int i = 0; i < q; ++ i) if (dsu[i] == i) groups.emplace_back(mask[i]);
  int m = groups.size();
  const int inv9 = inv(9);
  auto calc = [&](int at, bool eq) {
    if (at == 0) return 1;
    int e = (power(10, ss[at] - ss[at - 1]) + MOD - 1) % MOD * 1LL * inv9 % MOD;
    if (eq) e = (e + 1) % MOD;
    return e;
  };

  std::vector<std::vector<int>> coef(2, std::vector<int>(1 << m));
  for (int w = 0; w < 1 << m; ++ w) {
    for (int o = 0; o < 2; ++ o) {
      int msk = o == 1;
      for (int i = 0; i < m; ++ i) if (w >> i & 1) msk |= groups[i];
      int ways = 1;
      for (int i = 0; msk >> i; ++ i) if (msk >> i & 1) {
        ways = ways * 1LL * calc(i, i && (msk >> i - 1 & 1)) % MOD;
      }
      coef[o][w] = ways;
    }
  }
  std::vector<std::vector<int>> dp(10, std::vector<int>(1 << m));
  dp[0][0] = 1;
  int p = -1;
  for (int i = 0; i < m; ++ i)
    if (groups[i] & 1)
      p = i;
  for (int i = 0; i < 9; ++ i) {
    for (int w = 0; w < 1 << m; ++ w) {
      for (int b = w; ; b = b - 1 & w) {
        if (i == 0 || p == -1 || (~b >> p & 1)) {
          dp[i + 1][w] = (dp[i + 1][w] + coef[i == 0][b] * 1LL * dp[i][w ^ b] % MOD) % MOD;
        }
        if (b == 0) break;
      }
    }
  }
  int result = dp[9][(1 << m) - 1] * 1LL * power(10, n - ss.back()) % MOD;
  printf("%d\n", result);
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

class UnionFind {
  std::vector<int> parent_;

 public:
  UnionFind(int size_num) : parent_(size_num, -1) {}
  int find(int x) {
    if (parent_[x] < 0) return x;
    return parent_[x] = find(parent_[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (parent_[x] > parent_[y]) std::swap(x, y);
    parent_[x] += parent_[y];
    parent_[y] = x;
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return -parent_[find(x)];
  }
};

int main(void) {
  int n, k, l;
  cin >> n >> k >> l;
  int s, g;
  UnionFind road(n), train(n);
  rep(i, k) {
    cin >> s >> g;
    road.unite(s - 1, g - 1);
  }
  rep(i, l) {
    cin >> s >> g;
    train.unite(s - 1, g - 1);
  }
  map<pair<int, int>, int> count;
  vector<pair<int, int>> vec(n);
  rep(i, n) {
    vec[i] = {road.find(i), train.find(i)};
    ++count[vec[i]];
  }
  rep(i, n) {
    cout << (i != 0 ? " " : "") << count[vec[i]];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define forr(i, n) for(int i = 0;i < n; ++i)
int main()
{
	cr7
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	string s, t;
	cin >> s >> t;
	if ((int)t.length() == (int)s.length() + 1) {
		bool flag = 0;
		forr(i, (int)t.length() - 1) {
			if (t[i] != s[i]) {
				flag = 1;
				break;
			}
		}
		if (flag)
			cout << "No\n";
		else
			cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll Abs(ll x,ll y){
    if(x>=y)return x-y;
    else return y-x;
}



int main(void){
    set<char>ans;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        char a;
        cin>>a;
        ans.insert(a);
    }
    if(ans.size()==3)cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,H,W;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int ret=0;
	cin>>N>>H>>W;
	FOR(i,N) {
		cin>>x>>y;
		if(x>=H && y>=W) ret++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())
a = [int(i) for i in input().split()]
s = [a[0]]
for i in range(1,n):s.append(s[i-1]+a[i])
c = collections.Counter(s)
d = [i*(i-1)//2 for i in c.values()]
print(sum(d)+c[0])


Measured memory_bytes: 41568
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;

int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

string alpha="abcdefghijklmnopqrstuvwxyz";

int N,K;
int l[100];



int main(){
	cin>>N>>K;
	Rep(i,N) cin>>l[i];
	sort(l,l+N);
	reverse(l,l+N);
	int ans=0;
	Rep(i,K){
		ans+=l[i];
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
         
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        for (h = 2; h < H; h++) {
            putchar('#');
            for (w = 2; w < W; w++) putchar('.');
            putchar('#');
            putchar('\n');
        }
 
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>

using namespace std;

int main() {
	int A, B;
	string str;
	cin >> A >> B >> str;

	for (int i = 0; i < str.size(); i++) {
		if (i != A && str[i] == '-') {
			cout << "No" << endl;
			return 0;
		}
	}

	if (str[A] == '-') {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
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 in = new BufferedReader(new InputStreamReader(System.in));
		String[] tokens = in.readLine().split(" ");
		int n = Integer.parseInt(tokens[0]);
		int x = Integer.parseInt(tokens[1]);
		int t = Integer.parseInt(tokens[2]);
		int ans;
		if (n%x == 0)
			ans = n/x*t;
		else
			ans = (n/x+1)*t;
		System.out.println(ans);
	}
}


Measured memory_bytes: 25348
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c;
    if((a-b) > 0){
        d = a;
        a = b;
        b = d;
    }
    if((a-c) > 0){
        d = a;
        a = c;
        c = d;
    }
    if((b-c) > 0){
        d = b;
        b = c;
        c = d;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


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

int main(){
	ll sum=0;
	int n;cin>>n;
	map<ll,ll>nums;
	for(int i=0;i<n;i++){
		ll a;cin>>a;
		nums[a]++;
		sum+=a;
	}
	int q;cin>>q;
	while(q--){
		ll b,c;
		cin>>b>>c;
		ll qtd=nums[b];nums[b]=0;
		nums[c]+=qtd;
		sum-=qtd*b;
		sum+=qtd*c;
		cout<<sum<<'\n';
	}


	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll A, B;
    cin >> A >> B;
    if(A==B) cout<<A<<endl;
    else{
        auto fa = ((A-1)%2==0? (A-1):0) ^ ((A-1-1)/2%2==0? 1:0);
        auto fb = ((B  )%2==0? (B  ):0) ^ ((B  -1)/2%2==0? 1:0);
        cout<<(fa^fb)<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}
 
fn main() {
  let nk: Vec<usize> = read_vec();
  let s: String = read();
 
  let mut cs: Vec<char> = s.chars().collect();
  cs[nk[1] - 1] = (cs[nk[1] - 1] as u8 + 0x20) as char;
 
  for c in cs {
    print!("{}", c);
  }
}

Measured memory_bytes: 4352
use std::io::prelude::*;

fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_to_string(&mut input_str).unwrap();

    let input_parts = input_str.split_whitespace().collect::<Vec<_>>();
    let mut input_parts_it = input_parts.iter().cloned();

    let n: usize = input_parts_it.next().unwrap().parse().unwrap();

    let p: Vec<usize> = (0..n)
        .map(|_| input_parts_it.next().unwrap().parse().unwrap())
        .collect();
    let mut p2 = p.clone();

    let is_sorted = p.windows(2).all(|w| w[0] < w[1]);
    if is_sorted {
        println!("YES");
        return;
    }

    for k1 in 0..n {
        for k2 in k1..n {
            p2.clear();
            p2.extend(p.iter().cloned());
            p2.swap(k1, k2);

            let is_sorted = p2.windows(2).all(|w| w[0] < w[1]);
            if is_sorted {
                println!("YES");
                return;
            }
        }
    }

    println!("NO");
}


Measured memory_bytes: 4352
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);
    Map<Integer, List<Evidence>> map;
    int n;

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        n = sc.nextInt();
        map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            List<Evidence> evidences = new ArrayList<>();
            for (int j = 0; j < a; j++) {
                int x = sc.nextInt()-1;
                int y = sc.nextInt();
                evidences.add(new Evidence(x, y));
            }
            map.put(i, evidences);
        }

        int ans = 0;
        for (int i = 0; i < 1 << n; i++) {
            int cnt = check(i);
            ans = Math.max(cnt, ans);
        }
        System.out.println(ans);
    }

    private int check(int i) {
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            // 正直者ではない人の証言は無視
            if (( 1 & i >> j) == 0) continue;

            cnt++;
            for (Evidence evidence : map.get(j)) {
                if ((1 & i >> evidence.x) != evidence.y) return -1;
            }
        }
        // 最後の人まで矛盾なくいければ正直者の人数を返す
        return cnt;
    }

    class Evidence {
        int x;
        int y;

        public Evidence(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}


Measured memory_bytes: 30292
# coding: utf-8


def main(N):
    for i in range(1, 10):
        if N % i == 0 and N / i<= 9:
            return "Yes"
    return "No"

if __name__ == "__main__":
    N = int(input())
    my_ans = main(N)
    print(my_ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstdlib> 
#include<cstring>
using namespace std;
int main()
{
	char s[100];
	cin>>s;
	int l=strlen(s),ans=0;
	for (int i=0; i<l; i++) if (s[i]=='1') ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000007

vector<int> a;
vector<vector<int>> to;
vector<int> ans;

vector<bool> done;

void dfs(int id,int length,vector<int>& dp)
{
	done[id]=true;
	bool plus=false;
	int bound_id;
	int befdp;
	if(id==0)
	{
		dp[0]=a[0];
		length=1;
	}
	else
	{
		if(dp[length-1]<a[id])
		{
			dp[length++]=a[id];
			plus=true;
		}
		else
		{
			auto itr=lower_bound(dp.begin(),dp.begin()+length,a[id]);
			bound_id=distance(dp.begin(), itr);
			//cerr << bound_id << endl;
			befdp=dp[bound_id];
			dp[bound_id]=a[id];
		}
	}
	/*
	cout << plus << " " << length << endl;
	cout << "id : " << id << " : ";
	for(int i=0;i<=dp.size();i++)
	{
		if(i==dp.size() or dp[i]==INF)
		{
			cout << endl;
			break;
		}
		cout << dp[i] << " ";
	}
	*/
	ans[id]=length;
	for(int i=0;i<to[id].size();i++)
	{
		int nx=to[id][i];
		if(done[nx])continue;
		dfs(nx,length,dp);
	}
	if(plus)
	{
		dp[length]=INF;
		length--;
	}
	else
	{
		dp[bound_id]=befdp;
	}
}

int main()
{
	int n;
	cin >> n;
	a=vector<int>(n);
	to=vector<vector<int>>(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		cin >> u >> v;
		u--;v--;
		to[u].push_back(v);
		to[v].push_back(u);
	}

	ans=vector<int>(n,0);
	done=vector<bool>(n,false);

	vector<int> dp(n,INF);

	dfs(0,0,dp);

	for(int i=0;i<n;i++)
		cout << ans[i] << endl;
		


}

Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
int n,K,x,y,c,a[2],sum[2005][2005];
char k[2];
inline int query(int l,int r,int u,int d) {
    if (l>r||u>d) return 0;
    int num=sum[r][d];
    if (l) num-=sum[l-1][d];
    if (u) num-=sum[r][u-1];
    if (l&&u) num+=sum[l-1][u-1];
    return num;
}
int main()
{
    scanf("%d%d",&n,&K);
    for (int i=1;i<=n;++i) {
        scanf("%d%d%s",&x,&y,k);
        if (k[0]=='W') y+=K;
        x%=2*K;
        y%=2*K;
        ++sum[x][y];
    }
    for (int i=0;i<2*K;++i)
        for (int j=0;j<2*K;++j) {
            if (i) sum[i][j]+=sum[i-1][j];
            if (j) sum[i][j]+=sum[i][j-1];
            if (i&&j) sum[i][j]-=sum[i-1][j-1];
        }
    int res=0;
    for (int i=0;i<K;++i)
        for (int j=0;j<K;++j) {
            int num1=query(0,i-1,0,j-1)+query(i,i+K-1,j,j+K-1)+query(i+K,2*K-1,j+K,2*K-1)+query(0,i-1,j+K,2*K-1)+query(i+K,2*K-1,0,j-1);
            int num2=n-num1;
            res=max(res,max(num1,num2));
        }
    printf("%d\n",res);
    return 0;
}


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

int main()
{
  long int Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  long int min;
  min = 4*Q;
  if (min>2*H) min = 2*H;
  if (min>S) min = S;
  long int min2 = 2*min;
  if(min2>D) min2 = D;

  if (N%2==1) cout << min2*(N/2) + min << endl;
  else cout << min2*(N/2) << endl;
  return 0;
}

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


  
int main(){

 
  int n;
  cin>>n;
  
  double answer=0;
  
  for (int i=0;i<n;i++){
    double number;
    string text;
    cin>>number>>text;
    
    if (text=="JPY"){
      answer+=number;}
    
    else {
      answer+=380000.0*number;
    }
    
  }
  
  cout<<answer<<endl;
  
      
      
      
  

  
}
  















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

using namespace std;

int main(){
	int size;
	cin >> size;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int h, w;
		cin >> h >> w;
		if(size%2 == 0){
			if(h > size/2) h = (size+1) - h;
			if(w > size/2) w = (size+1) - w;
		} else {
			if(h > size/2+1) h = (size+1) - h;
			if(w > size/2+1) w = (size+1) - w;
		}
		printf("%d\n", ( h-1 < w)? (h-1)%3+1: (w-1)%3+1);

	}
}

Measured memory_bytes: 1144
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int N;

int main() {
	ll least[2] = {1,1};
	cin >> N;
	rep(i, N) {
		ll ratio[2] = {};
		cin >> ratio[0] >> ratio[1];
		int min_id = ratio[0] < ratio[1] ? 0 : 1;

		ll tmp = least[min_id] / ratio[min_id]
			+ (least[min_id] % ratio[min_id] != 0);
		least[min_id] = tmp * ratio[min_id];
		dump(tmp);
		dump(least[min_id]);

		ll tmp2 = least[!min_id] / ratio[!min_id]
			+ (least[!min_id] % ratio[!min_id] != 0);
		dump(tmp2);

		least[!min_id] = max(
			tmp2 * ratio[!min_id]
			,tmp * ratio[!min_id]);
		dump(least[!min_id]);

		least[min_id] = least[!min_id] / ratio[!min_id] * ratio[min_id];
		dump(least[min_id]);

		dump(least[0]);
		dump(least[1]);
		cerr << endl;
	}
	cout << least[0] + least[1] << endl;
	return 0;
}

Measured memory_bytes: 256
//TaxRateChange???????????°????????????????????§???


import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int x,y,s,i,j,max;	
		Scanner in = new Scanner(System.in);
		
		x = in.nextInt(); //??§?¨????
		y = in.nextInt(); //??°?¨????5 8 105
		s = in.nextInt(); //??§????¨???????
	
		while(x != 0){
			max = 0;
			
			//i,j?????????????????¬?????????????????????????????¨??????
			for(i=1; i<s; i++){
			 
				for(j=1; j<s; j++){
					if(TotalPrice.calcTotalPrice(x, i, j) == s){	//??§?¨??????§???????¨?????????????????????????????¨????????????????????????????????????????
						max = Math.max(TotalPrice.calcTotalPrice(y, i, j), max);	
					}
				}
			}
			
			System.out.println(max);
			
			x = in.nextInt();
			y = in.nextInt();
			s = in.nextInt();
		}
		
		in.close();
	}
}


//2?????????????¨???????????¨???????????????????
class TotalPrice{
	//????????????????¨???????????¨??????????????????????
	public static int calcTotalPrice(int x, int i, int j){
		return i*(100+x)/100 + j*(100+x)/100;
	}
}

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


int main(){
	long long N,K;
	int answer;
	int input;
	
	vector<pair<int,int>> array;
	cin >> N >> K;
	
	int a,b;
	for(int i=0;i<N;i++){
		cin >> a;
		cin >> b;
		array.push_back(make_pair(a,b));
	}
	
	sort(array.begin(),array.end());
	
	for(int i=0;i<N;i++){
		answer = array[i].first;
		input = array[i].second;
		K-=input;
		if(K<=0){
			break;
		}
	}
	cout << answer << endl;
	
	
	return 0;
}


Measured memory_bytes: 1400
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define fst      first
#define snd      second
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};


int main()
{
    int N, M; cin >> N >> M;
    int a, b;
    vector<pii> bridge(M);
    rep(i, M) {
        cin >> a >> b;
        b--;
        bridge[i] = mp(b, a);
    }

    sort(bridge.begin(), bridge.end());
    int ans = 0;
    vb used(M, false);
    rep(i, M) {
        if(used[i])
            continue;

        for(int j = i+1; j < M; j++) {
            if(bridge[i].fst >= bridge[j].snd)
                used[j] = true;
        }
        used[i] = true;
        ans++;
    }

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



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> PPI;
typedef pair<LL, LL> PL;
typedef long long LL;
// LLONG_MIN, INT_MIN
#define xx first
#define yy second

// int seg[810000];
// void build(int id=1, int l=0, int r = n){
//   if(l==r-1){
//     seg[id] = da[l];
//   }
//   int mid = (l+r)/2;
//   build(id*2, l, mid);
//   build(id*2+1,mid, r);
//   s[id] = max(s[id*2],s[id*2+1]);
// }
// void mx(int x, int y, int id=1, int l=0, int r = n){
//   if(x>=r||y<=l) return -1;
//   if(l>=x&&r<=y)return seg[id];
//   int mid = (l+r)/2;
//   return max(mx(x,y,id*2,l,mid),mx(x,y,id*2+1,mid, r));
// }

LL n,k;
vector<LL> G[110000];
vector<LL> vi(110000, 0);
LL ans = 1;
void dfs(LL p, LL depth, LL bro){
  if(vi[p])return;
  // cout << p <<" " << depth <<" "<< bro << endl;
  ans *= k - min(depth, 2LL) - bro;
  ans %= 1000000007;
  int idx = 0;
  vi[p] = 1;
  for(auto adj:G[p]){
    if(vi[adj])continue;
    dfs(adj, depth+1, idx++);
  }
}
int main()
{
  // freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin>>n>>k;
  for(int i=0;i<n-1;i++){
    LL a,b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1, 0, 0);
  cout<<ans<<endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    string s;
    cin >> s;
    cout << s[0];
    cout << s[1];
    cout << s[2] << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int a[100+1];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		a[x]=1;
	}
	int s=0;
	for(int i=1;i<=100;i++){
		if(a[i]==1)s++;
	}
	cout<<s<<endl;
	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main (void){
int N,X,i,j,k=1;
scanf("%d",&N);
scanf("%d",&X);
int L[N+1];
for(i=0;i<N;i++){
scanf("%d",&L[i]);
}
int D[N+2];
D[0]=0;
for(j=1;j<N+1;j++){
D[j]=D[j-1]+L[j-1];
if(D[j]<=X){
k++;
}else{
break;
}
}
printf("%d",k);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
int main() {
    int N, M;
    cin >> N >> M;
    if(1 < abs(N - M)) {
        cout << 0 << endl;
        return 0;
    }
    long long int n = 1;
    long long int m = 1;
    for(int i = 1; i <= N; i++) {
        n *= i;
        n %= mod;
    }
    for(int i = 1; i <= M; i++) {
        m *= i;
        m %= mod;
    }
    long long int result = n * m % mod;
    if(N == M) {
        result *= 2;
        result %= mod;
    }
    cout << result << endl;
    return 0;
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int main(){
    double p = 3.14159265358979323846264338327950288419716939937510;
    double n;
    cin >> n;
    printf ("%.20f\n", 2 * n * p);
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll N, K, S;
    cin >> N >> K >> S;
    rep(i,N){
        if(i<K) cout << S << " ";
        else {
            if(S<1000000000) cout << S+1 << " ";
            else cout << 1 << " ";
        }
    }
    cout << endl;
    return 0;
}

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

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

	string s;
	cin >> s;
	if (s[0] == s[1] || s[2] == s[1] || s[3] == s[2]) {
		cout << "Bad";
	}
	else cout << "Good";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
const int N = 2e5 + 10;
ll a[N], n, res;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
struct cmp {
    bool operator()(const pii & a, const pii & b) const {
        int mina = min(a.first, a.second);
        int minb = min(b.first, b.second);
        if(minb > mina) {
            return true;
        } else if(mina > minb) {
            return false;
        } else {
            return max(b.first, b.second) > max(a.first, a.second);
        }
    }
};
void solve() {
    priority_queue<pii, vector<pii>, cmp> pq;
    res += a[n-1];
    pq.push({a[n-1], a[n-2]});
    pq.push({a[n-1], a[n-2]});
    for(int i = n - 3; i >= 0; i --) {
        auto curr = pq.top();
        pq.pop();
        res += min(curr.first, curr.second);
        pq.push({a[i], curr.first});
        pq.push({a[i], curr.second});
    }
}

int main() {
    quickread();
    cin >> n;
    for(int i = 0; i < n; i ++) cin >> a[i];
    sort(a, a+n);
    solve();
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6884
def create(month, days):
    day = 1
    while day <= days:
        calendar[(month, day)] = week[0]
        week.append(week[0])
        del week[0]
        day += 1
        
week = ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday']
calendar = {}
for i in range(12):
    month = i+1
    if month in (1,3,5,7,8,10,12):
        create(month, 31)
    elif month == 2:
        create(month, 29)
    else:
        create(month, 30)
    
while True:
        month, day = map(int, raw_input().split())
        if month == 0 and day == 0: break
        print calendar[(month, day)]

Measured memory_bytes: 4292
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	int Z = S.size();
	cout << S[0];
	cout << Z - 2;
	cout << S[Z - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	int n, m, k, ans = 0;
	cin >> n >> m >> k;		
	vector<vector<char>> grid(n, vector<char>(m));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			cin >> grid[i][j];
	for(int i = 0; i < (1 << n); ++i)
		for (int j = 0; j < (1 << m); ++j) {
			int cnt = 0;
			for (int i2 = 0; i2 < n; ++i2) {
				if (i >> i2 & 1)
					continue;
				for (int j2 = 0; j2 < m; ++j2) {
					if (j >> j2 & 1)
						continue;
					if (grid[i2][j2] == '#')
						++cnt;
				}
			}
			if (cnt == k)
				ans++;
		}
	cout << ans;
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <math.h>



#ifndef DEBUG 
#define fprintf (void)
#endif 

double absval(double x);

int main(void){
	int d[7];
	int c[7];
	
	int i,j,k,n;
	int rec=0;
	int top, front;
	char roll;
	char trash;
	
	for(i=1;i<7;i++){
		scanf("%d",&d[i]);
	}
	
	int turn[3][6]={{d[5],d[1],d[2],d[6],d[5],d[1]},
					{d[4],d[2],d[3],d[5],d[4],d[2]},
					{d[4],d[1],d[3],d[6],d[4],d[1]}};
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&top);
		scanf("%d",&front);
		
		for(j=0;j<3;j++){
			for(k=1;k<5;k++){
				if(top==turn[j][k]&&front==turn[j][k+1]){
					rec=1;
					break;
				}else if(top==turn[j][k]&&front==turn[j][k-1]){
					rec=-1;
					break;
				}
				fprintf(stdout,"%d:%d %d %d ,%d\n",j,turn[j][k],turn[j][k+1],turn[j][k-1],rec);
			}
			if(rec!=0){
				break;
			}
		}
		
		if(j==0){
			if(rec==1){
				printf("%d\n",d[3]);
			}else{
				printf("%d\n",d[4]);
			}
		}else if(j==1){
			if(rec==1){
				printf("%d\n",d[1]);
			}else{
				printf("%d\n",d[6]);
			}
		}else{
			if(rec==1){
				printf("%d\n",d[5]);
			}else{
				printf("%d\n",d[2]);
			}
		}
		rec=0;
	}
	
	return 0;
}

Measured memory_bytes: 2596
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
 
int main(){
	int n;
	cin >> n;
	int a[2][50001];
	for(int i=0;i<n;i++){
		cin >> a[i%2][i/2];
	}
	sort(a[0], a[0] + n/2 + n%2);
	sort(a[1], a[1] + n/2);
 
	map<int,int> mp;
	int d[100001];
	for(int i=0;i<n;i++){
		d[i] = a[i%2][i/2];
		mp[d[i]] = i;
	}
	sort(d,d + n);
	lli ans = 0;
	for(int i=0;i<n;i++){
		ans+=abs(mp[d[i]] - i)%2;
	}
	cout << ans/2 << endl;
 
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 raw_x) : x(raw_x) {
    if (x >= P || x < 0) { 
      x %= P;
      if (x < 0) x += P;
    }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};
ostream& operator<<(ostream& s, const FiniteField& x) { s << x.Value(); return s; }

FiniteField Combination(int a, int b) {
  FiniteField r = 1;
  for (int k = 0; k < b; k++) {
    r *= (a - k);
    r /= (1 + k);
  }
  return r;
}

FiniteField F(int n) {
  FiniteField r = 0;
  for (int x = 0; n - 5 - 2 * x >= 0; x++) {
    r += Combination(x + 4, 4) * Combination(n - 2 * x + 5, 10);
  }
  return r;
}

FiniteField LagrangeInterpolation(const vector<pair<int, FiniteField>>& ps, int x) {
  FiniteField r = 0;
  for (int i = 0; i < ps.size(); i++) {
    const auto [x_i, y_i] = ps[i];
    FiniteField t = 1;
    for (int k = 0; k < ps.size(); k++) {
      if (k == i) continue;
      const auto [x_k, y_k] = ps[k];
      t *= x - x_k;
      t /= x_i - x_k;
    }
    r += t * y_i;
  }
  return r;
}

FiniteField Solve() {
  int n;
  cin >> n;
  if (n <= 4) return 0;

  if (n % 2 == 1) {
    vector<pair<int, FiniteField>> ps;
    for (int x = 5; x < 5 + 2 * 16; x += 2) {
      ps.push_back({x, F(x)});
    }

    FiniteField r = LagrangeInterpolation(ps, n);
    return r;
  } else {
    vector<pair<int, FiniteField>> ps;
    for (int x = 6; x < 6 + 2 * 16; x += 2) {
      ps.push_back({x, F(x)});
    }

    FiniteField r = LagrangeInterpolation(ps, n);
    return r;
  }
}

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

  int num_cases;
  cin >> num_cases;
  for (int case_id = 0; case_id < num_cases; case_id++) {
    cout << Solve() << endl;
  }
}

Measured memory_bytes: 3620
#include<iostream>
#define MAX 3000000
using namespace std;
int prime[MAX];
int isPrime[MAX+1];

void seive(int n){
  for(int i=0;i<n;i++){
    prime[i]=i;
    isPrime[i+1]=true;
  }
  isPrime[0]=isPrime[1]=0;
  for(int i=2;i<n;i++){
    if(isPrime[i]==true)
      for(int j=2*i;j<n;j+=i)
	isPrime[j]=false;
  }
}

int main(){
  int a,b,n,count=0,c=0;
  seive(MAX);
  while(cin>>a>>b>>n,n){
    count=0;
    c=0;
    for(int i=0;count!=n;i++){
      if(isPrime[a+b*i]==true) count++;
      c++;
    }
    c--;
    cout<<a+b*c<<endl;
  }
  return 0;
}

Measured memory_bytes: 24596
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int n, start, goal, d;

bool check(const vector< vector<char> >& amida, int pos)
{
	for (int i = 0; i < d; ++i)
	{
		if (pos == 0)
		{
			if (amida[i][pos] == '1')
			{
				pos = 1;
			}
		}
		else if (pos == n - 1)
		{
			if (amida[i][pos - 1] == '1')
			{
				pos = n - 2;
			}
		}
		else
		{
			if (amida[i][pos - 1] == '1')
			{
				pos = pos - 1;
			}
			else if (amida[i][pos] == '1')
			{
				pos = pos + 1;
			}
		}
	}
	if (pos == goal)
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

void solve()
{
	while (cin >> n, n)
	{
		cin >> start >> goal >> d;
		--start; --goal;
		vector< vector<char> > amida(d, vector<char>(n - 1));
		for (int i = 0; i < d; ++i)
		{
			for (int j = 0; j < n - 1; ++j)
			{
				cin >> amida[i][j];
			}
		}
		int pos = start;
		if (check(amida, pos))
		{
			cout << 0 << endl;
			goto END;
		}
		for (int i = 0; i < d; ++i)
		{
			for (int j = 0; j < n - 1; ++j)
			{
				if (amida[i][j] == '1' || (j - 1 >= 0 && amida[i][j - 1] == '1') || (j + 1 < n - 1 && amida[i][j + 1] == '1'))
				{
					continue;
				}
				amida[i][j] = '1';
				pos = start;
				if (check(amida, pos))
				{
					cout << i + 1 << " " << j + 1 << endl;
					goto END;
				}
				amida[i][j] = '0';
			}
		}
		cout << 1 << endl;
	END:
		;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std ;
int main()
{
 int n;
  cin >> n;
  string str;
  cin >> str;
  int c = 0;
  for(int i = 0; i < n-2; i++)
  {
    if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C') c++;
  }
  cout<<c;
  return 0;
}


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

int main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }
  else{
    for(int i=0;i<k;i++){
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
}


Measured memory_bytes: 3628
n,m = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(m)]
l.sort(key=lambda x:x[1])
dec = 0
cur = 0
for i in l:
  if i[0] < cur <= i[1]:
    continue
  else:
    dec += 1
    cur = i[1]
print(dec)

Measured memory_bytes: 18172
using System;
using System.Linq;

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(inputs[0] < inputs[1] && inputs[1] < inputs[2] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 9304
a = input().split()
W,H = int(a[0]),int(a[1])
x,y = int(a[2]),int(a[3])
r = int(a[4])
if 0 <= x-r and x+r <= W:
    if 0 <= y-r and y+r <= H:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 5600
n,m=map(int,input().split())
edge=[list(map(int,input().split())) for _ in range(m)]
ans=[]

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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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

uf=UnionFind(n)
ans=[n*(n-1)//2]
while len(edge)>1:
    a,b=edge.pop()
    a-=1
    b-=1
    if uf.same(a,b):
        s=ans[-1]
    else:
        s=ans[-1]-uf.size(a)*uf.size(b)

    uf.union(a,b)
    ans.append(s)

while ans:
    print(ans.pop())


Measured memory_bytes: 100460
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, dp[N];
vector<int> gg[N];
int dfs(int v){
	if (gg[v].size() == 0 || dp[v] != 0){
		return dp[v];
	}
	for (int i=0; i<gg[v].size(); i++){
		int child = gg[v][i];
		dp[v] = max(dp[v], dfs(child) + 1);
	}
	return dp[v];
}
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	// cout << setprecision(10) << fixed;
	cin>>n>>m;
	for (int i=1; i<=m; i++){
		int from, to;
		cin>>from>>to;
		gg[from].push_back(to);
	}
	for (int i=1; i<=n; i++){
		dfs(i);
	}
	int ans = 0;
	for (int i=1; i<=n; i++){
		ans = max(ans, dp[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 8192
#! /usr/bin/env ruby

input = STDIN.read.split("\n").map{|l| l.split(" ").map{|i| i.to_i}}

N = input[0][0]
T = input[1][0]
A = input[1][1]
H = input[2]

def ondo(h)
  T - h * 0.006
end

def ondo_diff(h)
  (A - ondo(h)).abs
end

min = nil
min_pt = nil
pt = 0

while h = H.shift
  d = ondo_diff(h)
  pt = pt + 1
  if min == nil || d < min  then
    min = d
    min_pt = pt
  end
end

puts min_pt


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;


const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	if(_gcd!=1)cerr<<"WA";
	else return mpow(a,mod-2,mod);
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

//int dc[]={1,0,-1,0,1,1,-1,-1};
//int dr[]={0,-1,0,1,1,-1,-1,1};

/*void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}*/
vi a(105);
int main(){reduce200ms;
int n;cin>>n;
rep(i,0,n)cin>>a[i];
int ans=0;
rep(i,0,n-1){
	if(a[i]==a[i+1]){
		a[i+1]=10000;
		ans++;
	}
}
cout<<ans;
return 0;
}



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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;


#define rep(i,n) for(ll i=0;i<n;i++)



int main() {


  cout<<fixed<<setprecision(10);

  ll a,b,c;
  cin>>a>>b>>c;

  double S,L,h;

  S = 0.5*a*b*sin(acos(-1)*c/180.0);
  L = a + b + sqrt(a*a + b*b - 2*a*b*cos(acos(-1)*c/180.0));
  h = b*sin(acos(-1)*c/180.0);

  cout<<S<<endl;
  cout<<L<<endl;
  cout<<h<<endl;
}






//







Measured memory_bytes: 3524
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
	int r; 
	cin >> r;
	int D;
	cin >> D;
	int x;
	cin >> x;
	for (int i = 0; i < 10; i++) {
		 x = r * x - D;
		 cout << x << endl;
	 } 
 return 0;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi pair<int,int>

int main()
{
ll n;
cin>>n;
ll b[n-1];
for(int i=0;i<n-1;i++)
    cin>>b[i];
ll ans=0;
if(n==2)
ans=2*b[0];
else
{
ans+=b[0];
ans+=b[n-2];
for(int i=0;i<n-2;i++)
    ans+=min(b[i], b[i+1]);
}
cout<<ans;
}


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

int main() {
  int N;
  cin >> N;
  bool checker = true;
  int counter = 0;
  vector<int> vec(N);
  
  for(int i; i<N; i++){
    int temp = 0;
    int A;
    cin >> A;
    
    for(A; A%2==0;){
//      cout << A << endl;
      A /= 2;
      temp++;
    }
    
    if(i==0){
      counter = temp;
    }else{
      if(counter > temp){
        counter = temp;
      }
    }
    if(i==(N-1)){
      cout << counter << endl;
    }   
  }
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> a(n); rep(i,n) cin >> a[i];
  ll mx = 2, mn = 2;
  for(int i = n-1; 0 <= i; i--){
    mx = (mx/a[i])*a[i]+a[i]-1;
    mn = (mn+a[i]-1)/a[i]*a[i];
  }
  if(mn <= mx){
    cout << mn << " " << mx;
  }else{
    cout << -1;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3936
#include<stdio.h>
#include<string.h>
int main(){
int i,joi,ioi;
char cmpstr[4];
char str[10001];
while(scanf("%s",str)!=EOF){
joi=0;
ioi=0;
for(i=0;i<strlen(str)-2;i++){
cmpstr[0]=str[i];
cmpstr[1]=str[i+1];
cmpstr[2]=str[i+2];
if(strcmp(cmpstr,"JOI")==0) joi++;
if(strcmp(cmpstr,"IOI")==0) ioi++;
}
printf("%d\n%d\n",joi,ioi);
}
return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 
   string s;
   cin>>s;
   ll c=0;
   for( int i=0;i<s.size();i++)
   {
       if(s[s.size()-1]=='s')
       {
           c=1;
       }
   }
   if(c)
    cout<<s<<"es"<<endl;
   else
    cout<<s<<"s"<<endl;

}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// [start, end]
bool is_palindrome(const int start, const int end, const string &S) {
    const int len = end - start + 1;
    for (int i = 0; i < len; i++) {
        if (S[start + i] != S[end - i]) {
            return false;
        }
    }
    return true;
}

int main(void) {
    string S;
    cin >> S;
    const int slen = (int) S.size();

    if (is_palindrome(0, (slen - 3) / 2, S) &&
            is_palindrome((slen + 1) / 2, slen - 1, S) &&
            is_palindrome(0, slen - 1, S)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    ll s; cin >> s;
    ll base = 1000000000;
    ll a = (s + base - 1) / base;
    ll b = a * base - s;
    cout << "0 0 " << a << " " << b << " 1 1000000000" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll n;cin>>n;vl a(n);
    string ans="Yes";
    rep(i,n)cin>>a[i];
    for(ll i=n;i>0;i--)if(a[i-1]-1==a[i])a[i-1]-=1;
    rep(i,n-1){
        debug(a[i]);
        if(a[i]>a[i+1])ans="No";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024