akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

bool judge(vector<int> &per, vector<pair<int, int>> &edge) {
    int N = per.size() + 1;
    int M = edge.size();
    bool flag = 1;
    
    vector<int> junretu(N);
    junretu[0] = 1;
    for (int i = 0; i < N - 1; i++)
        junretu[i + 1] = per[i];
    //cout << endl;
    /*
    for (int i = 0; i < N; i++)
        cout << junretu[i] << " ";
    //cout << endl;
    */
    for (int i = 0; i < N-1; i++) {
        for (int j = 0; j < M; j++) {
            //cout << "  j=" << j ;
            if (junretu[i] == edge[j].first && junretu[i + 1] == edge[j].second) {
                //cout << "jo";
                break;
            }
            if (junretu[i + 1] == edge[j].first && junretu[i] == edge[j].second) {
                //cout << "ge";
                break;
            }
            if (j == M - 1) {
                flag = 0;
                //cout << "finish";
            }
        }
        if (!flag) break;
    }
    
    if (flag) {
        //cout << "  flag=" << flag;
        return true;
    }
    else {
        //cout << "  flag=" << flag;
        return false;
    }
}

int main() {
    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> edge(M);
    for (int i = 0; i < M; i++)
        cin >> edge[i].first >> edge[i].second;

    vector<int> per(N-1);
    for (int i = 0; i < N - 1; i++)
        per[i] = i + 2;

    int ans = 0;
    do {
        if (judge(per, edge) == true) {
            ans++;
        }
    } while (next_permutation(per.begin(), per.end()));

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int A[100000];
    for(int i=0;i<n;i++) cin>>A[i];
    
    sort(A,A+n);
    int ptr=0,res=0;
    while(ptr<n){
        int cc=A[ptr],f=0;
        while(ptr<n&&A[ptr]==cc)f++,ptr++; 
        res+=f%2;
    }
    cout<<res;
}

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

int flag[52][52];
int c[52][52];
std::vector<std::vector<int> > land;
std::vector<int> v(2);
int island;
int w, h;

bool search(int x, int y){
  flag[x][y] = 1;
  for(int dx = -1; dx < 2; dx++){
    for(int dy = -1; dy < 2; dy++){
      if(c[x + dx][y + dy] == 1 && flag[x + dx][y + dy] == 0){
        v[0] = x + dx;
        v[1] = y + dy;
        land.push_back(v);
        flag[x + dx][y + dy] = 1;
      }
    }
  }
  land.erase(land.begin());
  return land.empty();
}

int main(){
  while(true){
    std::cin >> w >> h;
    if(w == 0 && h == 0){
      break;
    }
    else{
      island = 0;
      for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
          std::cin >> c[j][i];
          flag[j][i] = 0;
        }
      }

      for(int i = 1; i <= w; i++){
        for(int j = 1; j <= h; j++){
          if(c[i][j] == 1 && flag[i][j] == 0){
            v[0] = i;
            v[1] = j;
            land.push_back(v);
            while(true){
              if(search(land[0][0], land[0][1])) break;
            }
            island++;
          }
        }
      }
      std::cout << island << std::endl;
    }
  }
  return 0;
}



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

#define rep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll MOD = 1e9+7;

int main(){


    int a,b,c;
    cin >> a >> b >> c;

    if ((a == b) && (b == c)){
         cout << 1 << endl;
    }else if ((a == b) || (b == c) || (c == a) ){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
}

Measured memory_bytes: 256
import bisect

def solve():
  n,a,b,c = (int(i) for i in input().split())
  l = [int(input()) for _ in range(n)]
  ans = 10**15
  for bita in range(2**n):
    for bitb in range(2**n):
      if bita&bitb: continue
      for bitc in range(2**n):
        if bitc&bitb:continue
        if bitc&bita:continue
        if bita == 0 or bitb == 0 or bitc == 0: continue
        lenkado = [0]*3
        stime = [0]*3
        for k in range(n):
            if 1&(bita>>k): 
              lenkado[0] += l[k]
              stime[0] += 1
            elif 1&(bitb>>k): 
              lenkado[1] += l[k]
              stime[1] += 1
            elif 1&(bitc>>k): 
              lenkado[2] += l[k]
              stime[2] += 1
        tmp = abs(a-lenkado[0])+abs(b-lenkado[1]) + abs(c-lenkado[2])
        for i in range(3):
          tmp += max(0,stime[i]-1)*10
        ans = min(ans,tmp)
  print(ans)     
solve()

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int a, b;
    char op;
    cin >> a >> op >> b;
    if(op == '+')
    {
        cout << a + b << endl;
    }
    else if (op == '-')
    {
        cout << a-b << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

int n,m;

scanf("%d",&n);

m = n % 10;

if(m == 3){
  printf("bon\n");
}else if(m == 0 || m == 1 || m == 6 || m == 8){
  printf("pon\n");
}else{
  printf("hon\n");
}

return 0;

}


Measured memory_bytes: 1648
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX = 1e6;
const int INF = 2e9;
typedef long long ll;



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

    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String b = sc.next();
        if(a >= 3200){
            System.out.println(b);
        }else{
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 21844
use proconio::input;
use proconio::derive_readable;
use std::ops::Sub;

#[derive_readable]
#[derive(Debug, PartialEq)]
struct Point {
    x: isize,
    y: isize,
}

impl Sub for Point {
    type Output = Point;
    fn sub(self, other: Point) -> Point {
        Point {
            x: self.x - other.x,
            y: self.y - other.y,
        }
    }
}

fn main() {
    input! {
        s: Point,
        t: Point,
    }

    let sub = t - s;

    let mut ans = String::new();
    for _ in 0..sub.x {
        ans.push('R');
    }
    for _ in 0..sub.y {
        ans.push('U');
    }
    for _ in 0..sub.x {
        ans.push('L');
    }
    for _ in 0..sub.y {
        ans.push('D');
    }

    ans.push('D');
    for _ in 0..sub.x + 1 {
        ans.push('R');
    }
    for _ in 0..sub.y + 1{
        ans.push('U');
    }
    ans.push('L');
    ans.push('U');
    for _ in 0..sub.x + 1{
        ans.push('L');
    }
    for _ in 0..sub.y + 1{
        ans.push('D');
    }
    ans.push('R');

    println!("{}", ans);
}


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x;
  cin>>n>>x;int l[n];int c=0;
  for(int i=0;i<n;i++)
  {
  cin>>l[i];
  }
  int d[n];
  d[0]=0;
   for(int i=1;i<n+1;i++)
     d[i]=d[i-1]+l[i-1];
   for(int i=0;i<n+1;i++)
     if(d[i]<=x)
       c++;
  cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

template<ll mod> struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

    Mod_Int &operator += (const Mod_Int &p) {
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p) {
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p) {
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p) {
        *this *= p.inverse();
        return *this;
    }

    Mod_Int operator -() const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int pow(ll n) const{
        Mod_Int now = *this, ret = 1;
        while(n > 0){
            if(n & 1) ret *= now;
            now *= now, n >>= 1;
        }
        return ret;
    }

    Mod_Int inverse() const{
        return pow(mod-2);
    }
};

using mint = Mod_Int<MOD>;
const int MAX_N = 1e5;
mint fac[MAX_N+1];

void init(){
    fac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = fac[i-1]*mint(i);
    }
}

mint comb(mint n, mint k){
    return fac[n.x]/(fac[n.x-k.x]*fac[k.x]);
}

mint perm(mint n, mint k){
    return fac[n.x]/fac[n.x-k.x];
}

const int MAX_V = 2e5;
vector<int> es[MAX_V];
//E[i]:=iが穴開きとなる確率
mint E[MAX_V], tw = 2;
int N;

int dfs(int now, int pre){
    int size = 1;
    mint al = 1;
    for(auto &e: es[now]){
        if(e == pre) continue;
        int s = dfs(e, now);
        size += s;
        al += tw.pow(s)-1;
    }
    al += tw.pow(N-size)-1;
    al /= tw.pow(N-1);
    al = (mint)1-al;
    E[now] = al/tw;
    return size;
}

int main(){
    cin >> N;
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    dfs(0, -1);
    mint ans = 0;
    rep(i, N) ans += E[i];
    cout << ans.x << endl;
}

Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, count=0, tap=1;
    cin >> a >> b;
    
    while(true){
      if (tap < b) {
          tap += a-1;
          count++;
      } else {
          break;
      }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){
    int a,b,n;
    cin >> n >> a >> b;
    ll count=0;
    
    for(int i=1;i<=n;i++){
        int c=0,t=i;
        for(int j=1;j<=5;j++){
            c += t%10;
            t /= 10;
        }
        if(a<=c and c<=b){
            count += i;
        }
    }

    cout << count << endl;

}




Measured memory_bytes: 256
// abc170_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int X, Y;
    cin >> X >> Y;

    REP(i, 100) REP(j, 100){

        int x = i + j;
        int y = 2 * i + 4 * j;
        if (X == x && Y == y){
            print("Yes");
            return 0;
        }
    }

    print("No");


    return 0;
}


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


int main() {

  string s;
  cin>>s;

  for(int i=0;i<3;i++){
    if(s.at(i)=='9')
      s.at(i)='1';
    else if(s.at(i)=='1')
      s.at(i)='9';
  }

  cout<<s<<endl;

  return 0;
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int a[3];

int main()
{
    REP(i,3){
        cin >>a[i];
    }
    sort(a,a+3);
    printf("%d %d %d\n",a[0],a[1],a[2]);
}


Measured memory_bytes: 3256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		double ang = Math.toRadians(scanner.nextInt());
		
		double c = Math.sqrt(a*a+b*b - 2*a*b*Math.cos(ang));
		double l = a+b+c;
		
		double h =  b * Math.sin(ang);
		
		double s = 0.5 * a* h;
		
		System.out.printf("%1$.8f %2$.8f %3$.8f", s, l, h);
	}
}

Measured memory_bytes: 26360
from collections import defaultdict

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

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

    if x == y:
        return

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

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

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

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

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

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

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

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

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

n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
  
uf = UnionFind(n)
for a, b in AB:
  a -= 1
  b -= 1
  uf.union(a, b)

ans = 0
for v in uf.roots():
  ans = max(ans, uf.size(v))
  
print(ans)


Measured memory_bytes: 107564
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
	
  char a[n][100];
  char b[n][100];
  int c[n];
  char d[100];
  int sum1=0;
  int sum2=0;
  for (int i=0; i<n; i++){
    scanf("%s%s",a[i],b[i]);
    c[i] = atoi(b[i]);
    sum1+=c[i];
  }
  scanf("%s",d);
  int e=0;
  while(1){
    sum2+=c[e];
    if (strcmp(d,a[e])==0){
      break;
    }
    e++;
  }
  printf("%d",sum1-sum2);
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  rep(i, m)  {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  
  if (m == 0) {
    if (n == 1) {
      cout << 0 << endl;
    } else if (n == 2) {
      cout << 10 << endl;
    } else {
      cout << 100 << endl;
    }
    return 0;
  }
  
  if (n == 1) {
    int ans = 10;
    rep(i, m) {
      if (s[i] > 0) {
        cout << -1 << endl;
        return 0;
      } else {
        if (ans == 10) {
          ans = c[i];
        } else if (ans != c[i]){
          cout << -1 << endl;
          return 0;
        }
      }
    }
    cout << ans << endl;
    return 0;
  }
  
  else if (n == 2) {
    rep(i, m) {
      if (s[i] > 1 || (s[i] == 0 && c[i] == 0)) {
        cout << -1 << endl;
        return 0;
      }
    }
    
    string ans = "aa";
    rep(i, m) {
      if (ans[s[i]] == 'a') {
        ans[s[i]] = c[i] + '0';
      } else if (ans[s[i]] != c[i] + '0') {
        cout << -1 << endl;
        return 0;
      }
    }
    if (ans[0] == 'a') {
      cout << 1;
    } else {
      cout << ans[0];
    }
    if (ans[1] == 'a') {
      cout << 0;
    } else {
      cout << ans[1];
    }
    cout << endl;
    return 0;
  }
  
  else if (n == 3) {
    rep(i, m) {
      if (s[i] > 2 || (s[i] == 0 && c[i] == 0)) {
        cout << -1 << endl;
        return 0;
      }
    }
    string ans = "aaa";
    rep(i, m) {
      if (ans[s[i]] == 'a') {
        ans[s[i]] = c[i] + '0';
      } else if (ans[s[i]] != c[i] + '0') {
        cout << -1 << endl;
        return 0;
      }
    }
    if (ans[0] == 'a') {
      cout << 1;
    } else {
      cout << ans[0];
    }
    if (ans[1] == 'a') {
      cout << 0;
    } else {
      cout << ans[1];
    }
    if (ans[2] == 'a') {
      cout << 0;
    } else {
      cout << ans[2];
    }
    cout << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(long long N, long long M, long long X, std::vector<long long> A){
    ll cnt = 0;
    rep(i, M){
        if(A[i] < X)
            cnt ++;
    }
    cout << min(cnt, M-cnt) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, X, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
//#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll ans = 1LL<<60;
    ll n;
    cin >> n;
    for(ll i=1; i*i<=n; i++)
    {
        if(n%i==0) ans = min(ans, i+n/i);
    }
    cout << ans-2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
	int dp[1005][1005];
int LCS(string A,string B){
	memset(dp,0,sizeof dp);
	int n=A.size();
	int m=B.size();
	A=' '+A;
	B=' '+B; 
	int max1=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(A[i]==B[j])	dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			max1=max(max1,dp[i][j]);
		}
	}
	return dp[n][m];
}
int main(){
	int q;
	cin>>q;
	while(q--){
		string A,B;
		cin>>A>>B;
		cout<<LCS(A,B)<<endl;
	}
	return 0;
}


Measured memory_bytes: 7112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

vector<long long> enum_div(long long n) {
    vector<long long> res;
    for (long long i = 1; i*i <= n; i++) {
        if (n%i) continue;
        res.push_back(i);
        if (i*i != n) res.push_back(n/i);
    }
    sort(res.begin(), res.end());
    return res;
}

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

    int n, m;
    cin >> n >> m;
    auto d = enum_div(m);

    rrep(i, d.size()) {
        if (m / d[i] >= n) {
            cout << d[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3668
fn main() {
    ioset! { inp, buf }
    macro_rules! scan {
        ($($r:tt)*) => {
            input! { inp, $($r)* }
        }
    }
    macro_rules! print {
        ($($t:expr),*) => {
            write!(buf, $($t),*).unwrap();
        } 
    }

    scan! {
        n: usize,
        x: usize,
        t: usize,
    }
    print!("{}\n", ((n + x - 1) / x) * t);
}

use std::io::{ stdout, BufWriter, Write };

#[macro_export]
macro_rules! ioset {
    ($inp:ident, $buf:ident) => {
        inset!($inp);
        outset!($buf);
    }
}

#[macro_export]
macro_rules! inset {
    (source = $s:expr, $iter:ident) => {
        let mut $iter = $s.split_whitespace();
    };
    ($iter:ident) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut $iter = s.split_whitespace();
    }
}

#[macro_export]
macro_rules! input {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt, $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, mut $var:ident : $t:tt, $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, ($var:expr) : $t:tt, $($r:tt)*) => {
        $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
}

#[macro_export]
macro_rules! read_value {

    // tuple
    ($iter:expr, ( $($t:tt), * )) => {
        ( $(read_value!($iter, $t)), * )
    };
    
    // array
    ($iter:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    
    // string
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    
    // any other
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[macro_export]
macro_rules! outset {
    ($buf:ident) => {
        let sout = stdout();
        let mut $buf = BufWriter::new(sout.lock());
    }
}

#[macro_export]
macro_rules! output {
    ($buf:expr, $($t:expr),*) => {
        write!($buf, $($t),*).unwrap();
    }
}

struct Chars<'a>(&'a Vec<char>);

impl<'a> std::fmt::Display for Chars<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        write!(f, "{}", self.0.iter().collect::<String>())
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M; cin >> N >> M;
    vector<vector<int>> graph(N);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int Q; cin >> Q;
    vector<int> V(Q), D(Q), C(Q);
    for (int i = 0; i < Q; i++) cin >> V[i] >> D[i] >> C[i], V[i]--;
    vector<int> painted(N, -1), result(N);
    function<void(int, int, int)> recur;
    recur = [&](int v, int d, int c) {
        if (d < 0 || painted[v] >= d) return;
        if (painted[v] == -1) result[v] = c;
        painted[v] = d;
        if (d > 0) for (int t : graph[v]) recur(t, d-1, c);
    };
    for (int i = Q-1; i >= 0; i--) {
        recur(V[i], D[i], C[i]);
    }
    for (int r : result) cout << r << '\n';
    return 0;
}


Measured memory_bytes: 8440
import bisect

def solve():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    cnt = 0
    for i in range(2,N):
        for j in range(i):
            shortest_len = L[i] - L[j] + 1
            index = bisect.bisect_left(L, shortest_len)
            if index < j:
                cnt += j - index
    
    print(cnt)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 42716
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int N = S.size();

    vector<vector<ll>> dp(N+1, vector<ll>(4));
    dp[0][0] = 1;

    for(int i = 1; i <= N; i++){
        for(int j = 3; j >= 0; --j){
            dp[i][j] = dp[i-1][j] * (S[i-1] == '?' ? 3LL : 1LL);
            if(0 < j && (S[i-1] == '?' || S[i-1] == "ABC"[j-1])){
                dp[i][j] += dp[i-1][j-1];
            }
            dp[i][j] %= mod;
        }
    }
    cout << dp[N][3] << endl;
}


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



  
int main(){
  

  int n;
  cin>>n;
  
  vector<int> data(n);
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  sort(data.begin(),data.end());
  
  
  vector<int> count(n);
  
  count.at(0)=1;
  
  for (int i=1;i<n;i++){ 
    if (data.at(i)==data.at(i-1)){
      count.at(i)=count.at(i-1)+1;
    }
    else {
      count.at(i)=1;
    }
  }
  
  int answer=0;
  
  for (int i=0;i<n;i++){
    if (count.at(i)%2==1){
      answer++;
    }
    else {
      answer--;
    }
  }
  
  cout<<answer<<endl;
  
    
  
}

    











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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int U=1e9+7;
unordered_map<s64,int>mp;
int ans[10];

int main()
{
//	freopen("1.in","r",stdin);
	int h,w,n;
	cin>>h>>w>>n;
	rep(i,1,n)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		rep(x1,max(1,x-2),min(x,h-2))
		rep(y1,max(1,y-2),min(y,w-2))++mp[(s64)x1*U+y1];
	}
	for(auto pr:mp)++ans[pr.second];
	printf("%lld\n",(s64)(h-2)*(w-2)-mp.size());
	rep(i,1,9)printf("%d\n",ans[i]);
}

Measured memory_bytes: 36624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(void){
    int n;
    int ans = 0;
    scanf("%d",&n);
    int a[n],b[n],c[n - 1];
    for(int i = 0;i < n;i++)scanf("%d",&a[i]);
    for(int i = 0;i < n;i++)scanf("%d",&b[i]);
    for(int i = 0;i < n - 1;i++)scanf("%d",&c[i]);
    for(int i = 0;i < n - 1;i++){
        ans += b[a[i] - 1];
        if(a[i+1] == a[i] + 1){
            ans += c[a[i] - 1];
        }
    }
    ans += b[a[n-1] - 1];
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

int dp[310];
int coin[32];

int main(){
	int n;
	
	rep(i,17){
		coin[i] = (i+1)*(i+1);
	}
#if DEB
	rep(i,17){
		printf("%d:%d\n",i,coin[i]);
	}
#endif	

	dp[0] = 1;
	rep(i,17){
		for(int j=coin[i]; j<=300; j++){
			dp[j] += dp[j-coin[i]];
		}
	}
	
	while(scanf("%d",&n),n){
		printf("%d\n",dp[n]);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
N,M,L = map(int,input().split())
ABC = [tuple(map(int,input().split())) for i in range(M)]
Q = int(input())
ST = [tuple(map(int,input().split())) for i in range(Q)]

INF = float('inf')
dist1 = [[INF]*N for i in range(N)]
dist2 = [[INF]*N for i in range(N)]
for a,b,c in ABC:
    if c > L: continue
    a,b = a-1,b-1
    dist1[a][b] = dist1[b][a] = c
for i in range(N):
    dist1[i][i] = 0
    dist2[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            d = dist1[i][k] + dist1[k][j]
            if dist1[i][j] <= d: continue
            dist1[i][j] = d
for i in range(N):
    for j in range(N):
        if i==j: continue
        if dist1[i][j] <= L:
            dist2[i][j] = 1
for k in range(N):
    for i in range(N):
        for j in range(N):
            d = dist2[i][k] + dist2[k][j]
            if dist2[i][j] <= d: continue
            dist2[i][j] = d
ans = []
for s,t in ST:
    d = dist2[s-1][t-1]
    if d == INF:
        ans.append(-1)
    else:
        ans.append(d-1)
print(*ans, sep='\n')

Measured memory_bytes: 90716
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }



int
main(void){  
  string s;
  cin >> s;
  
  int l = 0;
  int r = 1;
  bool f = false;

  if(s.size()>2){
  
    REP(l, s.size()-2){
      map<char, int> mp;
      set<char> st;
      f = false;
      
      //cout << "l " << l << " r " << r << endl;
      
      FOR(i, l, r+2){
	mp[s[i]]++;
	st.insert(s[i]);      
      }
      for(auto itr = st.begin(); itr != st.end(); ++itr) {
	if(mp[*itr] > 1){
	  f=true;
	}
	//cout << *itr << ":" << mp[*itr] << endl;
      }        
      if(f){
	cout << l+1 << " " << r+2 << endl;
	break;
      }
      else{
	r++;
      }    
    }
    
    if(!f) cout << "-1 -1" << endl;
  }
  else{
    if(s[0] != s[1]) cout <<  "-1 -1" << endl;
    else cout<< "1 2" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

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

void solve() {
    string s, t;
    cin >> s >> t;
    int a = 0;
    for (int i = 0; i < sz(s); ++i) {
        a += (s[i] != t[i]);
    }
    cout << a << en;
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


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

int main() {
  int n,k,cnt=0;
  cin >> n >> k;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0; i<k; i++) {
    cnt+=v[i];
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=100005,M=400005,Node=M;

int v[M],nxt[M];
vector<pii> node[N];
bool used[N];
int head[Node],dist[Node],pos[Node];
int x[M],y[M],c[M];
int n,m,cnt;
int q[Node*2],st,ed;

il void addedge(int p,int x,int y){
	v[p]=y,nxt[p]=head[x],head[x]=p;
}

il int find(int u,int c){
	return lower_bound(node[u].begin(),node[u].end(),mp(c,0))->Y;
}

int main(){
//	fileio("test");
	scanf("%d%d",&n,&m);
	rep(i,1,m){
		scanf("%d%d%d",x+i,y+i,c+i);
		node[x[i]].pb(mp(c[i],0));
		node[y[i]].pb(mp(c[i],0));
	} 
	node[1].pb(mp(-1,0));
	rep(i,1,n){
		sort(node[i].begin(),node[i].end());
		node[i].resize(unique(node[i].begin(),node[i].end())-node[i].begin());
		rep0(j,node[i].size()){
			node[i][j].Y=++cnt;
			pos[cnt]=i;
		}
	}
	rep(i,1,m){
		int p=find(x[i],c[i]),q=find(y[i],c[i]);
		addedge(lch(i),p,q);
		addedge(rch(i),q,p);
	}
//	cerr<<"cnt="<<cnt<<endl;
	rep(i,2,cnt) dist[i]=inf;
	dist[1]=0;
	st=0,ed=1,q[ed]=1;
	while(st!=ed){
		int u=q[st+1==Node?0:st+1];
//		cerr<<st<<" "<<u<<endl;
		if(pos[u]==n) return printf("%d\n",dist[u]),0;
		bool flag=true;
		for(int e=head[u];e;e=nxt[e]){
			if(dist[v[e]]<=dist[u]) continue;
			dist[v[e]]=dist[u];
			flag=false;
			q[st]=v[e];
			st=(!st?Node-1:st-1);
		}
		if(!flag) continue;
		if(++st==Node) st=0;
		int id=pos[u];
		if(used[id]) continue;
		used[id]=true;
		rep0(i,node[id].size()){
			int v=node[id][i].Y;
			if(dist[v]<=dist[u]+1) continue;
			dist[v]=dist[u]+1;
			if(++ed==Node) ed=0;
			q[ed]=v;
		}
	}
	puts("-1");
	return 0;
}

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

struct gr{
		int fr;
		int to;
		long long co;
};

int compare_int(const void *a,const void *b){
		struct gr A=*(struct gr*)a,B=*(struct gr*)b;
		return A.fr-B.fr;
}

int n,list[100001]={0},ans[100000];
struct gr abc[200000];

void dfs(int now,long long cost){
		if(cost%2==0)ans[now]=0;
		else ans[now]=1;
		int i;
		for(i=0;abc[i+list[now]].fr==now;i++){
				if(ans[abc[i+list[now]].to]<0){
						dfs(abc[i+list[now]].to,cost+abc[i+list[now]].co);
				}
		}
}

int main(){
		int i,j;
		scanf("%d",&n);
		for(i=0;i<n-1;i++){
				int a,b;
				long long c;
				scanf("%d%d%lld",&a,&b,&c);
				a--,b--;
				abc[i*2].fr=a;
				abc[i*2].to=b;
				abc[i*2].co=c;
				abc[i*2+1].fr=b;
				abc[i*2+1].to=a;
				abc[i*2+1].co=c;
		}
		qsort(abc,2*n-2,sizeof(struct gr),compare_int);
		for(i=1;i<2*n-2;i++){
				if(abc[i-1].fr!=abc[i].fr){
						list[abc[i].fr]=i;
				}
		}
		for(i=0;i<n;i++)ans[i]=-1;
		dfs(0,0);
		for(i=0;i<n;i++)printf("%d\n",ans[i]);
		return 0;
}



Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  int n,k;
  cin >>n >>k;
  if(n%k==0){cout << 0 << endl;}else{cout << 1 << endl;}

}


Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
using ll = long long;

int main(){
	int x, y;
	cin >> x >> y;

		if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8|| y == 10 || y == 12)) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)) {
				cout << "Yes" << endl;
				return 0;
			}
			else {
				if (x == 2 && y == 2) {
					cout << "Yes" << endl;
					return 0;
				}
				else {
					cout << "No" << endl;
					return 0;
				}
			}

		}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int N,D,cnt = 0;
    cin >> N >> D;
    vector<double> x(N);
    vector<double> y(N);
    for(int i = 0; i<N; i++) cin >> x[i] >> y[i];
    for(int i = 0; i<N; i++) {
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=D) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }
  else {
    long double T, A;
    cin >> T >> A;
    long double H;
    cin >> H;
    long double t = T - H * 0.006;
    long double min;
    if(t > A) {
      min = t - A;
    }
    else {
      min = A - t;
    }
    int ans = 1;
    for(int i = 1; i < N; i++) {
      cin >> H;
      long double t = T - H * 0.006;
      long double d;
      if(t > A) {
        d = t - A;
      }
      else {
        d = A - t;
      }
      if(min > d) {
        min = d;
        ans = i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }
}

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

using namespace std;
using ll = long long;

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

const int maxn = 2e5 + 10;

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

int ans = 0;

int vis[maxn];
set<int>graph[maxn];

int cnt = 0;
void dfs(int u)
{
	vis[u] = 1;
	cnt++;
	ans = max(ans, cnt);
	for(const auto &v : graph[u])
	{
		if(!vis[v])
		{
			dfs(v);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	int test = 1;
	while(test--)
	{
		int n,m;
		cin >> n >> m;
		while(m--)
		{
			int u,v;
			cin >> u >> v;
			graph[u].insert(v);
			graph[v].insert(u);
		}
		for(int i = 1; i <= n ; i++)
		{
			if(!vis[i])
			{
				cnt = 0;
				dfs(i);
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A, B;
ll i, j, k;
int main(){
    scanf("%lld%lld", &A, &B);
    if(A<=8&&B<=8){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    return 0;
}

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

int main()
{
    int n, m, q, a, d[101];

    while( cin >> n >> q )
    {

        if( n + q == 0 )
            break;

        for( int i = 0; i < 101; i++ )
            d[i] = 0;

        for( int i = 0; i < n; i++ )
        {
            cin >> m;
            for( int j = 0; j < m; j++ )
            {
                cin >> a;
                d[a]++;
            }
        }

        int res = 0, max = 0;
        for( int i = 0; i < 101; i++ )
            if( d[i] > max )
            {
                max = d[i];
                res = i;
            }
        if( q > max )
            cout << 0 << endl;
        else
            cout << res << endl;
    }
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  map<int, int> mp;
  rep(i,n)
  {
    int a;
    cin >> a;
    mp[a]++;
  }
  
  int res = 0;
  for(auto x : mp)
  {
    if(x.second < x.first) res += x.second;
    else res += x.second - x.first;
  }
  cout << res << endl;
  
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;

int main() {
  string s;
  cin >> s;
  vector<P> v;
  vector<int> t,z;
  t.push_back(1);
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='+'||s[i]=='-') {
      if(s[i]=='+') t.push_back(1);
      else t.push_back(-1);
      s[i]=' ';
    }
  }
  stringstream ss;
  ss << s;
  int k=0;
  while(ss >> s) {
    int x=0;
    P p=P(-1,0);
    for(int i=0; i<s.size(); i++) {
      if(isdigit(s[i])) {
        x*=10;
        x+=s[i]-'0';
      } else if(p.F==-1) {
        if(!x) x=1;
        p.F=x;
        x=0;
      }
    }
    if(p.F==-1) {
      if(!x) x=1;
      p.F=x;
    } else {
      if(!x) x=1;
      p.S=x;
    }
    p.F*=t[k++];
    v.push_back(p);
  }
  for(int x=-2000; x<=2000; x++) {
    int sum=0;
    for(int i=0; i<v.size(); i++) sum+=v[i].F*pow(x,v[i].S);
    if(!sum) z.push_back(-x);
  }
  sort(z.begin(),z.end());
  for(int i=0; i<z.size(); i++) cout << "(x" << (z[i]>0?"+":"") << z[i] << ")";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3492
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
int main(){
    unsigned long long N,K;
    unsigned long long ans = 0;
    cin >> N >> K;
    if(K%2 == 0 && 2*N >= K){
        K /= 2;
        unsigned long long even = N/K/2,odd = (N/K+1)/2;
        ans = even*even*even+odd*odd*odd;
    }
    else ans = (N/K)*(N/K)*(N/K);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
N, K, Q = map(int, input().split())  # 参加人数、初期ポイント、正解回数
L = [K-Q] * N
for i in range(Q):
    L[int(input()) - 1] += 1
for i in range(N):
    print('Yes') if L[i] > 0 else print('No')


Measured memory_bytes: 6664
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
int dp[5010][5010];
pair<int, int> p[5010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int h, x;
		scanf("%d%d", &h, &x);
		p[i] = make_pair(h + x, x);
	}
	sort(p, p + n);
	for (int i = 0; i < 5010; i++) {
		for (int j = 0; j < 5010; j++) {
			dp[i][j] = 2001001001;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		int h = p[i].first, x = p[i].second;
		h -= x;
		for (int j = 0; j <= i; j++) {
			dp[i+1][j] = dp[i][j];
		}
		for (int j = 0; j <= i; j++) {
			if (dp[i][j] <= h && dp[i+1][j+1] > dp[i][j] + x) {
				dp[i+1][j+1] = dp[i][j] + x;
			}
		}
	}
	for (int i = n; i >= 0; i--) {
		if (dp[n][i] < 2001001001) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 98304
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
/*int main(){
int a,i=0,sum=0,b;
printf("回数入力 : ");
scanf("%d",&b);
REs:
printf("%d回目　数字(int型)を入力 : ",i+1);
scanf("%d",&a);
sum+=a;
i++;
if(i<b){
goto REs;
}
printf("%d\n",sum);
return 0;
}
*/
int t[10][10000];
int main(){
int r,c,i,j,l,sum,cnt;
while(1){
cin>>r>>c;
if(r==0&&c==0)goto RICE;
int mx=0;
for(i=0;i<r;i++){
for(j=0;j<c;j++){
cin>>t[i][j];
}
}
for(l=0;l<(1<<r);l++){
sum=0;
for(i=0;i<c;i++){
cnt=0;
for(j=0;j<r;j++){
cnt+=(t[j][i]!=((l>>j)&0x01));
}
sum+=max(r-cnt,cnt);
}
mx=max(mx,sum);
}
printf("%d\n",mx);
}
RICE:
return 0;
}



Measured memory_bytes: 3560