akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define intmx INT_MAX 
#define intmi INT_MIN
const int MOD=1e9+7;
int mod(int x){
    return ((x%MOD + MOD)%MOD);
}
int add(int a,int b){
    return mod(mod(a)+mod(b));
}
int mul(int a,int b){
    return mod(mod(a)*mod(b));
}
void solve(){
   int a[3][3];
   ff(i,0,3)
   ff(j,0,3)
   cin>>a[i][j];
   int n;
   cin>>n;
   while(n>0){
       n--;
       int x;
       cin>>x;
       ff(i,0,3){
           ff(j,0,3){
               if(a[i][j]==x)
               a[i][j]=0;
           }
       }
   }
   if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]&&a[0][0]==0)
   yes;
   else if(a[2][0]==a[1][1]&&a[1][1]==a[0][2]&&a[2][0]==0)
   yes;
   else{
       ff(i,0,3){
           if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]&&a[i][0]==0){
               yes;
               return;
           }
       }
       ff(i,0,3){
           if(a[0][i]==a[1][i]&&a[1][i]==a[2][i]&&a[0][i]==0){
               yes;
               return;
           }
       }
       no;
       
   }
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    int n = s.size();
    ll sum = 0;
    for(int bit = 0; bit < (1 << (n-1)); bit++){
        ll tmp = s[0] - '0';
        for(int i = 0; i < n-1; i++){
            if(bit & (1 << i)){
                sum += tmp;
                tmp = s[i+1] - '0';
            }else{
                tmp *= 10;
                tmp += s[i+1] - '0';
            }
        }
        sum += tmp;//最後には+はないので
    }
    cout << sum << endl;
}

Measured memory_bytes: 3604
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())


from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

# 入力
n = ni()

# グラフ作成
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a].append((c,b))
    graph[b].append((c,a))
    
q,k = li()
query = []
for _ in range(q):
    x,y = li()
    x -= 1
    y -= 1
    query.append((x,y))

# Kからダイクストラ
dist_k = dijkstra(graph, n, k-1)
    

# クエリ処理
for x,y in query:
    print(dist_k[x] + dist_k[y])

Measured memory_bytes: 59780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1);
    rep (i, m) {
        int l, r;
        cin >> l >> r;
        l--;
        a[l]++;
        a[r]--;
    }
    rep (i, n) a[i + 1] += a[i];
    int ans = 0;
    rep (i, n + 1) if (a[i] == m) ans++;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
N, K = gets.split.map(&:to_i)
ans = 0
zero_remain = 0
half_count = 0

if K % 2 == 0
    N.times{|x|
        zero_remain += 1 if (x + 1) % K == 0
        half_count += 1 if (x + 1) % K == K/2
    }
else
    N.times{|x|
        half_count += 1 if (x + 1) % K == 0
    }
end
ans = zero_remain ** 3 + half_count ** 3
puts ans


Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#define MAX 100

typedef struct node
{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
} Node;

Node *root, *NIL;

void insert(int);
Node *find(int, Node *);
void inorder(Node *);
void preorder(Node *);

int main()
{
    int m, i, k, j,con;
    char com[MAX],judge[MAX];
    char y='y',n='n';

    scanf("%d", &m);
    for (i = 0; i < m; i++)
    {
        scanf("%s", com);
        if(com[0] == 'f'){
            scanf("%d", &k);
            Node *u = find(k, root);
            if (u != NIL){
                printf("yes\n");
                // judge[con] = 'y';
                // con++;
            }
            else {
                printf("no\n");
                // judge[con] = 'n';
                // con++;
            }
        }
        else if (com[0] == 'i')
        {
            scanf("%d", &k);
            insert(k);
        }
        else if (com[0] == 'p')
        {
            //for(j=0;j<con;j++){
                // if(judge[j]==y) printf("yes\n");
                // else printf("no\n");
            // }
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node)); //ノードを作る
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
            x = x->right;
    }

    z->parent = y; //insertした値の親を設定する
    if (y == NIL)
    { //親がない場合insertした値がそのままroot
        root = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

Node *find(int k,Node *u){
   while(u!=NIL && k!=u->key){
       if(k<u->key) u=u->left;
       else u=u->right;
   }
   return u;
}

void inorder(Node *u)
{
    if (u == NIL)
        return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL)
        return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


Measured memory_bytes: 20448
#include <stdio.h>
int main(){
    while(1){
        int h,w;
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    int i,j;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if((i+j)%2==0){
                printf("#");
            }else{
                printf(".");
            }
        }
        printf("\n");
            }
        
        printf("\n");
    }
return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

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

	if (A[A.size()-1] == B[0] and B[B.size()-1] == C[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

class DisjointSet {
 public:
  DisjointSet(int size) : parent_(size), size_(size, 1) {
    for (int i = 0; i < size; ++i) {
      parent_[i] = i;
    }
  }
  int Find(int x) {
    int& p = parent_[x];
    if (p != x) p = Find(p);
    return p;
  }
  void Union(int x, int y) {
    x = Find(x), y = Find(y);
    if (x == y) return;
    if (Size(x) > Size(y)) std::swap(x, y);
    parent_[x] = parent_[y];
    size_[y] += size_[x];
  }
  int Size(int x) { return size_[Find(x)]; }
  bool Same(int x, int y) { return Find(x) == Find(y); }

 private:
  std::vector<int> parent_, size_;
};

struct Point {
  int x, y;
};

int main() {
  in(int, n);
  vector<Point> ps(n);
  rep(i, n) cin >> ps[i].x >> ps[i].y;
  const int kMax = 100001;
  vector<set<int>> xs(kMax), ys(kMax);
  for (const Point& p : ps) {
    xs[p.y].insert(p.x);
    ys[p.x].insert(p.y);
  }

  ll ans = 0;
  {
    DisjointSet dsx(kMax);
    for (const set<int>& s : xs)
      for (int x : s) dsx.Union(x, *s.begin());
    vector<int> y_count(kMax);
    vector<set<int>> y_unique(kMax);
    set<int> roots;
    for (const Point& p : ps) {
      int root = dsx.Find(p.x);
      ++y_count[root];
      y_unique[root].insert(p.y);
      roots.insert(root);
    }
    for (int r : roots) {
      ans += ll(dsx.Size(r)) * ll(y_unique[r].size()) - y_count[r];
    }
  }
  out(ans);
}


Measured memory_bytes: 30912
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    int d;
    cin >> d;

    bool first = true;
    while(--d >= 0){
        if(first)
            first = false;
        else
            cout << endl;

        int n;
        cin >> n;

        int len = n-1;
        int num = 3;
        int y = n-1;
        int x = 0;
        int i = 0;
        vector<string> s(n, string(n, ' '));
        s[y][x] = '#';

        for(;;){
            for(int j=0; j<len; ++j){
                y += dy[i];
                x += dx[i];
                s[y][x] = '#';
            }
            (++i) %= 4;
            if(--num == 0){
                num = 2;
                len -= 2;
            }
            if(n % 2 == 0 && num == 1 && len == 1)
                break;
            if(n % 2 == 1 && len == 0)
                break;
        }

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

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int MAXK=100000;
int k;
int f[MAXK+10];
void U(int p,int w){while(f[p]>w)f[p]=w,(p*=10)%=k;}
void update(int x){U(x%k,x);for(int i=0;i<k;++i)U((i*10+x)%k,f[i]+x);}
int main()
{
	scanf("%d",&k);while(k%10==0)k/=10;
	for(int i=0;i<k;++i)f[i]=520;
	for(int i=1;i<=32;++i)for(int j=1;j<=9;++j)update(j);
	printf("%d",f[0]);
	return 0;
}

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

#define MAX_LEN 400000
#define MAX_N 400000

using namespace std;

typedef long long lint;

const lint MOD = (lint)(1e9) + 7;


void euclid(lint a, lint b, lint &x, lint &y, lint &d)

{

    if(b == 0)

    {

        x = 1;

        y = 0;



        d = a;

        return;

    }



    lint xx, yy, q = a / b;

    euclid(b, a % b, xx, yy, d);

    x = yy;

    y = xx - yy * q;

}



void poz(lint &n)

{

    if(n < 0)

    {

        n = MOD + n % MOD;

    }

}



lint fact[MAX_LEN + 1];

lint inv[MAX_LEN + 1];
lint invf[MAX_LEN + 1];



void getInv()

{

    fact[0] = inv[0] = invf[0] = 1;

    for(lint i = 1; i <= MAX_LEN; i ++)

        fact[i] = 1LL * fact[i - 1] * i % MOD;



    lint x, y, d;

    euclid(fact[MAX_LEN], MOD, x, y, d);

    poz(x);

    inv[MAX_LEN] = x * fact[MAX_LEN - 1] % MOD;
    invf[MAX_LEN] = x;


    for(lint i = MAX_LEN - 1; i >= 1; i --)

    {

        invf[i] = invf[i + 1] * (i + 1) % MOD;

        x = x * (i + 1) % MOD;

        inv[i] = x * fact[i - 1] % MOD;

    }

}

lint getComb(lint n, lint k)
{
    if(k == 0 || k == n)
        return 1;

    lint rez = 1;
    rez = fact[n] * invf[k] % MOD * invf[n - k] % MOD;

    return rez;
}

lint put(lint a, lint b)
{
    lint cr = a;
    lint rez = 1;
    for(lint i = 0; (1 << i) <= b; i ++)
    {
        if(((1LL << i) & b) != 0)
        {
            rez = rez * cr % MOD;
        }

        cr = cr * cr % MOD;
    }

    return rez;
}

lint n, a, b;

lint rez = 0;
lint k;

lint getStars(lint n, lint k)
{
    return getComb(n + k - 1, n);
}

int main()
{
    getInv();

    cin >> n >> k;
    //for(lint i = k % 2; i < n && i <= k; i += 2)
    for(int i = 0; i < n && i <= k; i ++)
    {

        lint x = getComb(n, i);
        x = x * getStars(i, n - i) % MOD;
        rez += x;
/*
        rez += getComb(n + i - 1, i);
        cout << rez << "\n";
        cout << getComb(n + i - 1, i) << "\n\n";*/
        if(rez >= MOD)
            rez -= MOD;
    }

    cout << rez << "\n";

    return 0;
}


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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            
            int cnt = 0;
            for(int i = a ; i <= b ; i++)
            {
               if(Check(i)) cnt++;
            }
            
            Console.WriteLine(cnt);
        }
        public static bool Check(int target)
        {
            string s = target.ToString();
            //s = s.PadLeft(5,'-');
            if(s[0] == s[4] && s[1] == s[3])
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

  int a, b;

  cin >> a >> b;

  if (a * b % 2 != 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	long long k, a, b;
	cin >> k >> a >> b;
	long long ans = 1;
	if(b - a > 2 && a < k + 1){
		ans = a;
		k -= a - 1;
		if(k % 2 == 1){
			ans++; k--;
		}
		ans += k / 2 * (b - a); 
	}else{
		ans += k;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import *
from scipy.sparse.csgraph import *
import numpy as np
N,M,R = map(int,input().split())
T = list(map(int,input().split()))
E = [list(map(int,input().split())) for m in range(M)]
G = np.zeros((N,N))
A = []

for a,b,c in E:
  G[a-1][b-1] = c
  G[b-1][a-1] = c

F = floyd_warshall(G)

for P in permutations(T):
  A+=[sum(F[P[r]-1][P[r+1]-1] for r in range(R-1))]

print(int(min(A)))

Measured memory_bytes: 43056
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

const int maxn = 100003;

int n, a[maxn], ans;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi();
	for (int i = 1; i <= n; i+=1) if (a[a[i]] == i) ++ans;
	printf("%d\n", ans / 2);
	return 0;
}


Measured memory_bytes: 640
N = int(input())
dp = 100*[0]
ans = 0

for n in range(N+1):
  s = str(n)
  dp[10*int(s[0])+int(s[-1])]+=1

for i in range(1,10):
  for j in range(1,10):
    ans+=dp[10*i+j]*dp[10*j+i]

print(ans)

Measured memory_bytes: 9028
N = gets.to_i
T, A = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

diff = 1e9
ans = 0
N.times do |i|
    d = (T-hs[i]*0.006 - A).abs
    if diff > d
        diff = d
        ans = i+1
    end
end
puts ans


Measured memory_bytes: 1788
import Control.Applicative
main :: IO ()
main = do
    sigInput <-getLine
    let ans = editor sigInput []
    putStrLn $ ans
editor :: String -> String -> String
editor [] ys = ys
editor (x:xs) ys
    | x == 'B' = editor xs (if null ys then "" else init ys)
    | otherwise = editor xs (ys ++ [x])


Measured memory_bytes: 380
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int n, c1, c2, c4;

int main() {
	scanf("%d", &n);
	while (n--) {
		int a;
		scanf("%d", &a);
		if (a % 4 == 0) c4++;
		else if (a % 2 == 0) c2++;
		else c1++;
	}
	c1 += c2 % 2;
	if (c1 <= c4 + 1) printf("Yes\n");
	else printf("No\n");
#ifdef LOCAL_MSVC_DEBUG
	system("pause");
#endif
	return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int K, X;
  cin >> K >> X;
  if (500 * K >= X)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int n, m, bridges = 0, timer = 0;
vector < int > g[51];
bool used[51];
int tin[51], tup[51];

void dfs (int u, int p) {
    ++timer;
    tup[u] = tin[u] = timer;
    used[u] = 1;
    for (int v: g[u]) {
        if (used[v] && v != p) 
            tup[u] = min(tup[u], tin[v]);
        else if (!used[v]) {
            dfs(v, u);
            tup[u] = min(tup[u], tup[v]);
            if (tup[v] > tin[u]) 
                ++bridges;
        }
    }
}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, -1);
    cout << bridges << '\n';
}


Measured memory_bytes: 256
n, m = map(int, input().split())
t = [list(map(int, input().split())) for i in range(n)]

t = sorted(t, key=lambda v: v[0])

cost = 0
for i in range(n):
    if m-t[i][1] <= 0:
        cost += t[i][0]*m
        break
    cost += t[i][0]*t[i][1]
    m -= t[i][1]
print(cost)

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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N;
    vector<int> x(5);
    for (int i = 0; i < 5; ++i) {
        cin >> x[i];
        if (x[i] == 0) cout << i+1 << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3628
#????????§???????????????????????????????????????????????????????????¨???????????¨???????????????
#0????????£????????????????????????????????????
#?????????????????¨??¶???????°??????????
#????????????
#??????????????¢??°??????????????????????????????????????????????????????????????????????????\????????????????????????print??????????????????????????????????????????
#?????????????????????????????????????????????3????????°????¢???????????????£??????????????????????????????????????????????????????????????????
#?????????????????????
#?????????????????????????????????????????°???????????????????????????????????????????????¨?????????
#??????????????????????????¨??£????????????????????????????????????????¶??????????
x = int(input())

    
i = 1
y = i
n = []

#10??§?????£???3????????????3?????????????????????????????????????????????10??§???????¶???????1???????????§?¶???????
while i <= x:
    if y % 10 == 3 or y / 3 == 1:
        n.append(i)
        i += 1
        y = i
    else:
        y //= 10
        if y == 0:
            #?????????3????????°????????§??????????????????????????????
            if i % 3 == 0:
                n.append(i)
                i += 1
                y = i
            else:
                i += 1
                y = i
                
print("", end=" ")

i = 0
while i < int(len(n))-1:
    print(n[i], end=" ")
    i += 1
    
print(n[i])
#print("end")

Measured memory_bytes: 8236
use std::io::*;
use std::str::FromStr;
use std::f64::consts::PI;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let r: f64 = read();
    let s = r * r * PI;
    let l = 2.0 * r * PI;

   println!("{:.6} {:.6}", s, l);
}



Measured memory_bytes: 5068
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#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 <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int main()
{
	char ch;
	scanf("%c",&ch);
	cout<<(char)(ch+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val charSet = ('a' to 'z').toArray
    val keyword = Set("the", "this", "that")
    val sc = new Scanner(System.in)
    var line = ""

    (1 to 20).foreach { _ =>
      if (!sc.hasNext) return

      line = sc.nextLine

      (0 to 25).foreach { diff =>
        val result = line.map { ch =>
          val idx = charSet.indexOf(ch)

          if (idx < 0) {
            ch
          } else {
            if (idx - diff < 0) {
              (ch - diff + charSet.length).toChar
            } else {
              (ch - diff).toChar
            }
          }
        }.toString

        if (result.split(" ").exists(keyword.contains)) {
          println(result)
        }
      }
    }
  }
}

Measured memory_bytes: 47196
#include <iostream>
#include <string>
#include <algorithm>
char ToUpper (char cX) { return toupper(cX); } 
using namespace std;

int main() {
	string in;
	getline(cin, in);
	transform(in.begin(), in.end(), in.begin(), ToUpper);
	cout<<in<<endl;
	return 0;
}

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

int main(){
  long long x,k,d;
  long long plus;//,minus;
  long long minx;
  //long long minsoe;
  long long tempx;
  cin >> x >> k >> d;
  minx=abs(x);
  tempx=x;

  /*for(int i=0;i<k;i++){
    plus=x+d;
    minus=x-d;
    if(abs(plus)<abs(minus)){
      x=plus;
      if(abs(plus)<minx){
        minx=abs(plus);
        minsoe=i;
      }
    }else{
      x=minus;
      if(abs(minus)<minx){
        minx=abs(minus);
        minsoe=i;
      }
    }
  }*/
  long long syou=floor(abs(x)/d);
  if(syou>k){
    syou=k;
  }
  //cout << syou << endl;

  if(tempx<0){
    //if(d>0){
      plus=d;
      x=x+(plus*syou);
      minx=abs(x);
    //}else{
      //plus=(-1)*d;
    //}
  }else{
    //if(d>0){
      plus=(-1)*d;
      x=x+(plus*syou);
      minx=abs(x);
    //}/else{
      //plus=d;
    //}
  }

  if((k-syou)%2==0){
    minx=minx;
  }else{
    minx=abs(x-plus-plus);
  }

  for(int i=1;i<=(k-syou);i++){
    x=x+plus;
    //if(tempx<0){
      if(minx<abs(x)){
        if((k-syou-i)%2==1){
          minx=minx;
        }else{
          minx=abs(x-plus-plus);
          if(minx>abs(x)){
            minx=abs(x);
          }
        }
        break;
      }else{
        minx=abs(x);
      }
    /*}else{
      if(minx<abs(x)){
        if((k-syou-i)%2==1){
          minx=minx;
        }else{
          minx=abs(x-plus-plus);
        }
        break;
      }else{
        minx=abs(x);
      }
    }*/
  }

  cout << minx << endl;

  return(0);
}


Measured memory_bytes: 3580
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    s = ins()
    if s[-1] == "s":
        return s + "es"
    else:
        return s + "s"


print(solve())


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::pair<int, int> all[n];
	for (auto &i : all) {
		int s = ri(), t = ri();
		i.first = s - t;
		i.second = s + t;
	}
	std::sort(all, all + n);
	std::set<std::pair<int, int> > usable;
	for (int i = 0; i < n; i++) usable.insert({all[i].second, i});
	int head = 0;
	int res = 0;
	while (usable.size()) {
		auto min = *usable.begin();
		usable.erase(usable.begin());
		while (head < n && all[head].first < min.first) usable.erase({all[head].second, head}), head++;
		res++;
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char str[105];
    scanf("%s",str);
    int len=strlen(str);
    int i=0,j=len-1;
    int mid=len/2;
    int flag=0;
    int flagi=0;
    for(i=0,j=len-1; i<mid,j>mid; i++,j--)
    {
        if(str[i]!=str[j]) flag=1;
    }
    int ii,jj;
    if(flag==0)
    {

        for(ii=0,jj=mid+1; ii<mid,jj<len; ii++,jj++)
        {
            if(str[ii]!=str[jj]) flagi=1;
        }
        if(flagi==0)
            printf("Yes");
        else
        {
            printf("No");
        }
    }
    else
    {
         printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

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

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

const ll N = 1e7 + 1;
//vector<ll> adj[N];
//bool visited[N];

ll a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n;
	cin>>n;
	for (int i = 1; i <= n; i++) {
        for (int j = 1; j * i <= n; j++)
        	a[i * j]++;
    }
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=i*a[i];
	}

cout<<ans;

    return 0;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    ll N; cin >> N;
    ll t,a;
    ll x = 1,y = 1;
    rep(i,N){
        cin >> t >> a;
        ll n = max((x+t-1)/t,(y+a-1)/a);
        x = t * n; y = a * n;
    }
    cout << x + y << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
string s,t;
cin>>s>>t;
int n=s.length();
int m=t.length();
int ans=1001;
for(int i=0;i<n-m+1;i++){
  int tmp=0;
  for(int j=0;j<m;j++){
  	if(s[i+j]!=t[j])tmp++;
  }
  ans=min(ans,tmp);
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int n;
vector<int> mem;

int solve(int A, int B, int C)
{
    //printf("A=%d B=%d C=%d\n", A, B, C);
    int res;
    double p = (double)B / double(n);
    //printf("p=%lf\n", p);
    if(p == int(p)) res = n*p*p - 2*B*p + A;
    else {
        int p1 = int(p);
        int res1 = n*p1*p1 - 2*B*p1 + A;
        int p2 = p1+1;
        int res2 = n*p2*p2 - 2*B*p2 + A;
        res = min(res1,res2);
    }
    return res;
}

int main()
{
    cin >> n;
    mem.resize(n);
    rep(i,n){
        cin >> mem[i];
    }

    int A = 0;
    rep(i,n){
        A += mem[i]*mem[i];
    }

    int B = 0;
    rep(i,n){
        B += mem[i];
    }

    int C = n;
    cout << solve(A,B,C) << endl;     
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    char c;
    cin >> a >> c >> b;
    if(c=='+'){
        cout << a+b << endl;
    }else{
        cout << a-b << endl;
    }
    return 0;
}




Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
 
using namespace std;
 
int main() {
    int m, f, r;
    while (cin >> m >> f >> r) {
        if (m < 0 && f < 0 && r < 0)break;
        if (m < 0 || f < 0)cout << "F" << endl;
        else {
            if (m + f >= 80)cout << "A" << endl;
            else if (m + f >= 65)cout << "B" << endl;
            else if (m + f >= 50 || r >= 50)cout << "C" << endl;
            else if (m + f >= 30)cout << "D" << endl;
            else cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W, M = LI()
    hw = [LI() for _ in range(M)]
    hw_set = set([(h, w) for h, w in hw])

    cnt_h = collections.Counter([h for h, w in hw])
    cnt_w = collections.Counter([w for h, w in hw])

    # i行目にはどの列にあります
    # print(cnt_h)
    # print(cnt_w)
    max_h = max(cnt_h.values())
    max_w = max(cnt_w.values())
    max_h_k = [k for k, v in cnt_h.items() if v == max_h]
    max_w_k = [k for k, v in cnt_w.items() if v == max_w]
    is_on_target = True
    for i, j in itertools.product(max_h_k, max_w_k):
        if (i, j) not in hw_set:
            is_on_target = False
            break

    if is_on_target:
        ans = max_h + max_w - 1
    else:
        ans = max_h + max_w
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 120084
N=input()
A=int(N[0])
E=7-A
for i in range(8):
 F=["-","-","-"]
 B=int(N[1])
 C=int(N[2])
 D=int(N[3])
 for j in range(3):
  if ((i >> j) & 1):
   F[j]="+"
 if F[0]=="-":
  B*=-1
 if F[1]=="-":
  C*=-1
 if F[2]=="-":
  D*=-1
 if B+C+D==E:
  print(str(A)+str(F[0])+str(abs(B))+str(F[1])+str(abs(C))+str(F[2])+str(abs(D))+"=7")
  break

Measured memory_bytes: 38384
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = next()
    println("ABC$n")
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33668
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
  var sc = bufio.NewScanner(os.Stdin)
  sc.Scan()
  v, _ := strconv.Atoi(sc.Text())
  result := v*v*v
 fmt.Println(result)
}


Measured memory_bytes: 1092
import Control.Monad
import Data.List
main=do
    [a,b]<-map read.words<$>getLine :: IO [Int]
    let s = abs $ a-b
    let r = 16-(a+b)
    putStrLn $ case s of
        s | s<=1 -> "Yay!"
        s | s*2<=r -> "Yay!"
        _ | True -> ":("


Measured memory_bytes: 508
import sys
import math
from bisect import bisect_right
def main():
    N,M = map(int,input().split())
    Marray=[(0,0)] * M
    P={}
    for i in range(M):
        s = input().split()
        p=int(s[0])
        y=s[1]
        #print(s)
        if p in P.keys():
            P[p].append(int(y))
        else:
            P[p]=[]
            P[p].append(int(y))
        Marray[i]=(p,int(y))
        #print(P[p])
        
    for key in P:
        #string=P[key]
        
       # print(str)
        #sp=string.split(",")
        #de=len(sp)-1
        #del sp[de]
        #print(sp)
        tmp=sorted(P[key],key=int)
        #int_list=list(map(int,tmp))
        P[key]=tmp
        
        #print(P[key])
    
    for index,value in Marray:
        List=P[index]
        
        #print(list)
        result=bisect_right(List,value)
        result=str(result)
        index=str(index)
        index_zero = index.zfill(6)
        result_zero = result.zfill(6)
        print(index_zero,result_zero,sep='')



if __name__ == "__main__":
    main()







Measured memory_bytes: 40036
x, n = map(int,input().split())
p_list = list(map(int,input().split()))
p_list.sort()
ans_sa = abs(-1-x)
ans = -1
for i in range(0,200):
    if i in p_list:
        pass
    else:
        if ans_sa > abs(i-x):
            ans_sa = abs(i-x)
            ans = i
        elif ans_sa == abs(i-x):
            ans = min(ans,i)

print(ans)


Measured memory_bytes: 9224
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 333;

int a[N][N], n, m, cnt[N], bad[N], ptr[N];

bool check(int lim) {
    memset(bad, 0, sizeof bad);
    forn(i, 1, n) ptr[i] = 1;
    forn(i, 1, m) {
        memset(cnt, 0, sizeof cnt);
        forn(j, 1, n) cnt[a[j][ptr[j]]]++;
        int mx = 1;
        forn(j, 2, m) if (cnt[mx] < cnt[j]) mx = j;
        if (cnt[mx] <= lim) return 1;
        bad[mx] = 1;
        forn(j, 1, n) while (bad[a[j][ptr[j]]]) ++ptr[j];
    }
    return 0;
}

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

	cin >> n >> m;

    forn(i, 1, n) {
        forn(j, 1, m) {
            cin >> a[i][j];
        }
    }

	int l = 1, r = n;
	while (l < r) {
        int mid = (l + r) >> 1;
        if (check(mid)) r = mid;
        else l = mid + 1;
	}

	cout << l << "\n";

	return 0;
}


Measured memory_bytes: 640
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	int a[4];
	a[1]=ci();
	a[2]=ci();
	a[3]=ci();
	sort(a+1,a+4);
	bool ok = 0;
	if( a[1]==a[2] && a[2]!=a[3] ) ok =1 ;
	if( a[3]==a[2] && a[1]!=a[3] ) ok =1 ;
	puts(ok ? "Yes":"No");
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long long MOD = pow(10, 9) + 7;

typedef long long ll;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	string A, B;
	cin >> A >> B;

	if (A.length() > B.length()) {
		cout << "GREATER" << endl;
	}
	else if (A.length() < B.length()) {
		cout << "LESS" << endl;
	}
	else {
		if (A == B) {
			cout << "EQUAL" << endl;
		}
		else {
			for (int i = 0; i < A.length(); i++) {
				if (A[i] == B[i]) continue;
				else if (A[i] > B[i]) {
					cout << "GREATER" << endl; return 0;
				}
				else {
					cout << "LESS" << endl;
					return 0;
				}
			}
		}
	}


	return 0;
}



Measured memory_bytes: 256
from math import ceil
def solve(val):
	z = 0
	for i in range(n):
		if h[i] <= val*b:
			pass
		else:
			z += ((h[i]-val*b-1)/(a-b))+1
	if z <= val:
		return True
	else:
		return False
n,a,b = map(int,raw_input().split())
h = [input() for i in range(n)]
lo,hi = 1,10**9
while lo < hi:
	mid = lo+(hi-lo)//2
	if solve(mid):
		hi = mid
	else:
		lo = mid+1
print lo

Measured memory_bytes: 10996
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

bool prime[100010];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int x;
	
	cin >> x;
	
	for(int i = 2; i * i <= 100010; i++){
		if(!prime[i]){
			for(int j = i * i; j <= 100010; j += i){
				prime[j] = true;
			}
		}
	}
	
	for(int i = 2; i <= 100010; i++){
		//if(!prime[i])
		//	cout << i << endl;
		if(!prime[i] && i >= x){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
} 

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

template<typename T>
T get() { return 0; }
template<>
int get() { int x; scanf("%d", &x); return x; }
template<>
long get() { long x; scanf("%ld", &x); return x; }
template<>
std::string get() { std::string str; std::cin >> str; return str; }

template<typename T>
void put(T x) {}
template<>
void put(int x) { printf("%d\n", x); }
template<>
void put(long x) { printf("%ld\n", x); }
template<>
void put(std::string str) { printf("%s\n", str.c_str()); }
template<>
void put(const char* str) { printf("%s\n", str); }


std::string solve(long a, long b) {
  if( a <= 0 and 0 <= b ) return "Zero";
  if( 0 < a ) return "Positive";
  if( (b - a) % 2 == 0 ) return "Negative";
  else return "Positive";
}

int main() {
  int a = get<int>();
  int b = get<int>();

  put(solve(a, b));
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	int b[n];
	rep(i,n) {
		cin>>b[i];
		if(b[i]>i+1){
			//cout<<i<<"\n";
			cout<<-1<<"\n";
			return 0;
		}
	}

	int c[n]={};
	rep(i,n){
		int d=(i+1)-b[i];
		if(c[n-1-d]==0) c[n-1-d]=b[i];//まだそこまで到達しなければそのまま入れる
		else{
			for(int j=0;j<n-1-d;j++){//到達してればずらす
				c[j]=c[j+1];
			}
			c[n-1-d]=b[i];
		}
	}
	rep(i,n) cout<<c[i]<<"\n";
}

Measured memory_bytes: 256
cards = [False for i in range(52)]
patterns = {"S":0, "H":1, "C":2, "D":3}
n = int(input())
count = 0
while count < n:
    data = input().split()
    card = int(data[1]) - 1
    cards[card + 13 * patterns[data[0]]] = True
    count += 1
for i in range(52):
    if cards[i] == False:
        row = list(patterns.keys())[list(patterns.values()).index(i // 13)]
        col = i % 13 + 1
        print(row, col)



Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

int main() {
    string s;

    cin >> s;

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


Measured memory_bytes: 256