akhauriyash/Code-Regression huggingface dataset:
/*input
a
*/
/**
    Author: Kristopher Paul
    Date Created: 12-01-2020
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//Uncomment for File I/O
/*
#define cin fin
#define cout fout

ifstream fin("input.in");
ofstream fout("input.out");
*/

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    char c;
    cin >> c;
    cout << char(c+1) << endl;   
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
 
int main () {
    int N, K;
    cin >> N >> K;

    vector<int>A(N);
    rep(i,N) cin >> A[i];

    vector<int>baketto(N,0);
    rep(i,N){
        baketto[A[i]-1] +=1;
    }

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

    int kazu =0;
    for(auto b : baketto){
        if(!b == 0) kazu +=1; 
    }

    if (kazu <= K) {
        cout << 0 << endl;
        return 0;
    
    }else{
        int ans=0;
        for(int i = N-kazu; kazu > K ;i++){
            ans += baketto[i];
            kazu -=1;
        }
        cout  << ans << endl;

    }

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;

    int n = s.size();

    int ans = 0;

    for(int i=0; i<n ; i++){
        if(i >= (n+1)/2) break;
        if(s[i] != s[n-1-i]) ans ++;
    }

    dunk(ans);
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  double a ,b;
  while(scanf("%lf %lf",&a,&b) != EOF){
    if(a<35.5 && b<71){
      cout<< "AAA"<< endl;
    }
    else if(a<37.5 && b<77){
      cout<< "AA"<< endl;
    }
    else if(a<40 && b<83){
      cout<< "A"<< endl;
    }
    else if(a<43 && b<89){
      cout<< "B"<< endl;
    }
    else if(a<50 && b<105){
      cout<< "C"<< endl;
    }
    else if(a<55 && b<116){
      cout<< "D"<< endl;
    }
    else if(a<70 && b<148){
      cout<< "E"<< endl;
    }
    else cout<< "NA"<< endl;
  }
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

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

  cout << (a > b ? a - 1 : a) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  int su = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    su += A[i];
  }
  sort(A.begin(), A.end());
  int tmp = A[N - M];
  if(tmp * 4 * M < su){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


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

int main(){
    int k,n;
    long int temp;
    long int max=0;
    long int ansmax=0;
    int key=0;
    cin>>n>>k;
    vector<long int> v(n);
    vector<long int> u(n-1);
    for(int i=0;i<n;i++){
        cin>>v.at(i);
        if(max<v.at(i))
            max=v.at(i);
    }
    sort(v.begin(),v.end());

    for(int i=0;i<n-1;i++){
        u.at(i)=v.at(i+1)-v.at(i);
    }

    int i=0;
    while(i<n-k+1){
        temp=0;
        for(int j=i;j<i+k-1;j++){
            temp+=u.at(j);
        }
       if(i==0) max=temp;
       if(max>temp){
          max=temp;
          key=i;
       }
    i++;
    }
    cout<<v.at(key+k-1)-v.at(key)<<endl;

}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		int ao = (int)Math.ceil((double) a / (double) d);
		int taka = (int)Math.ceil((double) c / (double) b);
		
		if (ao < taka) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		sc.close();
	}
}


Measured memory_bytes: 35812
#include<stdio.h>

int main(){
  int k, i=0,gcd=1;
  long long int sum=0;
  scanf("%d",&k);
  
  for(int a = k; a>=2; a--){
    for(int b = a-1; b>= 1; b--){
      for(int c = b; c >=1;c--){
        for(i = 1; i<=c;i++){
          if(a % i == 0 && b % i == 0 && c % i == 0) gcd = i*6;
        }
        sum += gcd;
      }
    }
  }
  for(i = 1; i<=k; i++) sum += i;
  printf("%lld",sum);
}

Measured memory_bytes: 1732
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

val dx = arrayOf(0,1,0,-1)
val dy = arrayOf(1,0,-1,0)

fun abc000X() {
	val (h,w,m) = list()
	val a = mutableSetOf<Pair<Int,Int>>()
	for(i in 1..m) {
		val (y,x) = list()
		a.add(y-1 to x-1)
	}

	val r = IntArray(h) {0}
	val c = IntArray(w) {0}

	for((x,y) in a) {
		++r[x]
		++c[y]
	}

	val rm = r.max()!!
	val cm = c.max()!!

	val rc = (0 until h).count {r[it]==rm}
	val cc = (0 until w).count {c[it]==cm}

	val t = rc.toLong()*cc
	val u = a.count {(y,x)-> r[y]==rm&&c[x]==cm}.toLong()
	println(if(t==u) rm+cm-1 else rm+cm)
}


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

int main(){
  int n,i,j;
  cin >> n;
  for(i=1;i <= 9 ;i++){
    for(j=1; j <= 9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
 cout << "No" << endl;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int n, k;
long double p[100005], ans;

long double probability(int x) {
	if (x >= k)return 1.0;

	if (p[x])return p[x];

	return p[x] = probability(x * 2) / 2;
}

int main() {

	cin >> n >> k;

	REP(i, 1, n + 1) {
		ans += probability(i) / n;
	}

	cout  << fixed << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 10 ** 9 + 7
def main():
    n, m, *a = [int(x) for x in sys.stdin.read().split()]

    safe = sorted(set(range(1,n+1)) - set(a))
    dp = [0] * (n + 2) # dp[i+1]: i段目までいくパターン数
    dp[0] = 0  # -1段目にはいけない
    dp[1] = 1  # 初期条件(0段目にいる)
    for i in safe:
        dp[i+1] = (dp[i] + dp[i-1]) % mod

    print(dp[-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 20944
N,K = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N):
  P[i] = (P[i]+1)/2
R = sum(P[:K])
ans = R
for j in range(N-K):
  R = R - P[j] + P[j+K]
  ans = max(ans,R)
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	int64_t N;
	cin >> N;

	//calculation
	int64_t output = 0;
	for (int64_t i = 1; i <= N; i++) {
		if (i % 3 == 0) {
			continue;
		}
		if (i % 5 == 0) {
			continue;
		}
		output += i;
	}

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,pos,id[MAXN];
int64 l[MAXN],u[MAXN],b[MAXN],val[MAXN],X,all;
bool vis[MAXN];
void Solve() {
    read(N);read(X);
    for(int i = 1 ; i <= N ; ++i) {
	read(b[i]);read(l[i]);read(u[i]);
	all -= b[i] * l[i];
	val[i] = (X - b[i]) * u[i] + b[i] * l[i];
    }
    for(int i = 1 ; i <= N ; ++i) id[i] = i;
    sort(id + 1,id + N + 1,[](int a,int b){return val[a] > val[b];});
    int64 sum = 0;
    for(int i = 1 ; i <= N ; ++i) {
	sum += val[id[i]];
	if(sum + all >= 0) {pos = i - 1;sum -= val[id[i]];break;}
	vis[id[i]] = 1;
    }
    all += sum;
    int64 ans = (pos + 1) * X; 
    for(int i = 1 ; i <= N ; ++i) {
	int64 tmp = all;
	if(vis[i]) {tmp -= val[i];tmp += val[id[pos + 1]];}
	int64 L = 0,R = X + 1;
	while(L < R) {
	    int64 mid = (L + R) >> 1;
	    int64 sc = 0;
	    if(mid >= b[i]) sc = (mid - b[i]) * u[i];
	    else sc = (mid - b[i]) * l[i];
	    if(tmp + b[i] * l[i] + sc >= 0) R = mid;
	    else L = mid + 1;
	}
	if(R <= X) {
	    ans = min(ans,pos * X + R);
	}
    }
    out(ans);enter;
    
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}



Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    vector <int> test(n);
    int count=0;
    for(int i=n;i>=1;i--)
    {
        int sum=0;
        for(int j=2*i;j<=n;j+=i)
        {
            sum+=test[j-1];
        }
        if(sum%2==v[i-1])
            test[i-1]=0;
        else{
            test[i-1]=1;
            count++;
        }
    }
    cout<<count<<endl;
    for(int i=0;i<n;i++)
        if(test[i])
            cout<<i+1<<" ";
        cout<<endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100000;
static const int NIL=-1;

int n;
vector<int>G[MAX];

int color[MAX];

void dfs(int r,int c){
  stack<int>S;
  S.push(r);
  color[r]=c;
  while(!S.empty()){
    int u=S.top();
    S.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(color[v]==NIL){
	color[v]=c;
	S.push(v);
      }
    }
  }
}

int main(){
  int s,t,m,q;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  int id=1;
  for(int i=0;i<n;i++){
    color[i]=NIL;
  }
  
  for(int u=0;u<n;u++){
    if(color[u]==NIL) dfs(u,id++);
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>s>>t;
    if(color[s]==color[t]) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}
  
  



Measured memory_bytes: 9020
fn main() {
    let mut sc = Scanner::new();
    let w: usize = sc.read();
    let h: usize = sc.read();

    let mut edges = Vec::new();
    for _ in 0..w {
        let c: usize = sc.read();
        edges.push((c, true));
    }
    for _ in 0..h {
        let c: usize = sc.read();
        edges.push((c, false));
    }
    edges.sort();

    let h = h + 1;
    let w = w + 1;

    let mut ans = 0;
    let mut count_h = 0;
    let mut count_v = 0;
    for &(cost, horizontal) in &edges {
        if horizontal {
            if count_v >= h {
                continue;
            }
            ans += cost * (h - count_v);
            count_h += 1;
        } else {
            if count_h >= w {
                continue;
            }
            ans += cost * (w - count_h);
            count_v += 1;
        }
    }

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

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,h[22],count=1,max;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  max=h[0];
  for(int i=1;i<n;i++){
    if(max<=h[i]){
      count++;
      max=h[i];
    }
  }
  cout<<count<<"\n";
  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);
        String[] NK = sc.nextLine().split(" ");
        int N = Integer.parseInt(NK[0]);
        int K = Integer.parseInt(NK[1]);

        int pow = (int) Math.pow(K - 1, N - 1);
        System.out.println(K * pow);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define ll long long
#define fi first
#define se second
#define ii pair<int, int>
bool kt(int n){
    if(n<2) return false;
    rep(i,2,sqrt(n)) if(n%i==0) return false;
    return true;
}

int main(){
    int t;
    cin>>t;
    while(!kt(t)) t++;
    cout<<t;
	return 0;
}


Measured memory_bytes: 256
data = int(input())

def solve(nim,mike):
    if nim == mike:
        return 2*nim-2
    if mike < nim:
        return solve(mike, nim)

    lb, ub, ab = nim, 2*mike, nim*mike
    while ub-lb > 1:
        mid = (lb+ub)//2
        maxp = (mid+1)//2*(mid+1-(mid+1)//2)
        if maxp < ab:
            lb = mid
        else:
            ub = mid
    return lb-1

for _ in range(data):
    nim, mike = map(int, input().split())
    print(solve(nim,mike))



Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

int main() {
  string S;
  cin >> S;
  bool skip = false;
  int res = 1;
  for (int i = 1; i < S.size(); i++) {
    if (!skip && S[i] == S[i - 1]) {
      i++;
      skip = true;
    } else {
      skip = false;
    }
    if (i < S.size()) {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


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


struct NODE{
	int pos;
	int dist;
	int color;
	int pri;
};
bool operator < (const NODE &a,const NODE &b){
	return a.pri < b.pri;
};

void solve(long long N, long long M, vector<long long> a, vector<long long> b, long long Q_, vector<long long> v, vector<long long> d, vector<long long> c){
	int done[11][111111] = {};	
	priority_queue<NODE> Q;
	vector<int> g[111111];
	for(int i = 0 ; i < a.size() ; i++)
		a[i]--,b[i]--,
		g[a[i]].push_back(b[i]),
		g[b[i]].push_back(a[i]);
	
	for(int i = 0 ; i < v.size() ; i++){
		v[i]--;
		Q.push({v[i],d[i],c[i],i});
	}
	vector<int> mycolor(111111);
	while( Q.size() ){
		auto q = Q.top(); Q.pop();
		if( done[q.dist][q.pos]++ ) continue;
		if( mycolor[q.pos] == 0 ) mycolor[q.pos] = q.color;
		if( q.dist == 0 ) continue;
		for(int i = 0 ; i < g[q.pos].size() ; i++){
			Q.push({g[q.pos][i],q.dist-1,q.color,q.pri});
		}
	}
	for(int i = 0 ; i < N ; i++)
		cout << mycolor[i] << endl;
}

int main(){	
	long long Q;
	long long N;
	long long M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> a(M-1+1);
	vector<long long> b(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
	}
	scanf("%lld",&Q);
	vector<long long> d(Q-1+1);
	vector<long long> v(Q-1+1);
	vector<long long> c(Q-1+1);
	for(int i = 0 ; i <= Q-1 ; i++){
		scanf("%lld",&v[i]);
		scanf("%lld",&d[i]);
		scanf("%lld",&c[i]);
	}
	solve(N, M, a, b, Q, v, d, c);
	return 0;
}



Measured memory_bytes: 28780
x, a=map(int,input().split())
y, b=map(int,input().split())
z, c=map(int,input().split())
r, d=map(int,input().split())
p, e=map(int,input().split())
q, f=map(int,input().split())
s, g=map(int,input().split())
print(x-a)
print(y-b)
print(z-c)
print(r-d)
print(p-e)
print(q-f)
print(s-g)



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int l,r,d;
	cin>>l>>r>>d;
	int sum=0;
	for(int i=l;i<=r;i++)
	{
		if(i%d==0)
		{
			sum++;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 105;
char s[maxn], t[maxn];

int main()
{
    int n;
    int num;
    while(scanf("%d", &n)==1&&n)
    {
        scanf("%s", s);
        scanf("%s", t);
        if(strcmp(s,t) == 0)
            printf("%d\n", n);
        else
        {
            int i, j;
            int len1 = strlen(s);
            int len2 = strlen(t);
            num = 0;
            for(i = 0, j = 0; i < len1&&j < len2; )
            {
                if(s[i] == t[j])
                {
                    num++;
                    i++;
                    j++;
                }
                else
                {
                    i++;
                }
            }
            printf("%d\n", 2*n-num);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k,total=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&k);
		if(k>=m) total++;
	}
	cout<<total<<endl;
	return 0;
} 

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

int my_gcd(int n, int m){
    if(n < m) swap(n, m);
    if(m == 0) return n;
    return my_gcd(m, n%m);
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> a(n);
    int maxa = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        maxa = max(maxa, a[i]);
    }

    vector<int> primes;
    vector<bool> is_prime(maxa+1, true);
    
    primes.push_back(2);
    for(int j=4; j<=maxa; j+=2){
        is_prime[j] = false;
    }
    
    int i;
    for(i=3; i*i<=maxa; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=maxa; j+=i){
            is_prime[j] = false;
        }
    }
    
    for(; i<=maxa; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }

    int ggcd = a[0];
    for(int i=1; i<n; i++){
        ggcd = my_gcd(a[i], ggcd);
        if(ggcd == 1) break;
    }

    if(ggcd != 1){
        cout << "not coprime" << endl;
        return 0;
    }

    map<int, int> mp_prime;
    for(int j=0; j<primes.size(); j++){
        mp_prime[primes[j]] = j;
    }

    vector<bool> c(primes.size(), false);
    for(int i=0; i<n; i++){
        for(int j=0; j<primes.size() && a[i] >= primes[j]*primes[j]; j++){
            if(a[i] % primes[j] == 0){
                if(c[j] == true){
                    cout << "setwise coprime" << endl;
                    return 0;
                }
                c[j] = true;
                a[i] /= primes[j];
                while(a[i] % primes[j] == 0){
                    a[i] /= primes[j];
                }
            }
        }

        if(a[i] != 1){
            int jj = mp_prime[a[i]];
            if(c[jj] == true){
                cout << "setwise coprime" << endl;
                return 0;
            }
            c[jj] = true;
        }
    }
    cout << "pairwise coprime" << endl;

    return 0;
}

Measured memory_bytes: 16724
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


int main (){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    vector<int> p(m);
    Rep(i,m){
        int cnt;
        cin >> cnt;
        Rep(j,cnt){
            int tmp;
            cin >> tmp;
            s[i].pb(tmp);
        }
    }
    Rep(i,m){
        cin >> p[i];
    }
    int ans = 0;
    Rep(i,(1<<n)){
        int flag = 1;
        Rep(j,m){
            int cnt = 0;
            Rep(k,s[j].size()){
                if(i & (1 << s[j][k]-1)){
                    cnt++;
                }
            }
            if(cnt%2 != p[j]){
                flag = 0;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << "\n";
}

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

using namespace std;

#define int long long
#define PB push_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

int m, n, k, joi[3][1005][1005];

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

  cin >> m >> n >> k;

  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      char c;
      cin >> c;
      int typ;
      if (c == 'J')
	typ = 0;
      else if (c == 'O')
	typ = 1;
      else
	typ = 2;

      for (int i2 = 0; i2 < 3; ++i2) {
	joi[i2][j][i] += joi[i2][j - 1][i];
      }
      joi[typ][j][i]++;
    }
  }

  for (int j = 1; j <= n; ++j) {
    for (int i = 1; i <= m; ++i) {
      for (int k = 0; k < 3; ++k) {
	joi[k][j][i] += joi[k][j][i - 1];
      }
    }
  }

  for (int i = 0; i < k; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    for (int j = 0; j < 3; ++j) {
      int ans = joi[j][d][c] - joi[j][b - 1][c] - joi[j][d][a - 1] + joi[j][b - 1][a - 1];
      cout << ans;
      if (j != 2) cout << " ";
    }
    cout << endl;
  }
  
  return 0;
}

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

long long n, x;
long long memo[55][2] = {0};

long long solve(long long now, long long p);

int main() {
  cin >> n >> x;
  memo[0][0] = memo[0][1] = 1;
  for(int i = 1; i <= n; ++i) {
    memo[i][0] = memo[i - 1][0] * 2 + 1;
    memo[i][1] = memo[i - 1][1] * 2 + 3;
  }
  cout << solve(n, x) << endl;
  return 0;
}

long long solve(long long now, long long p) {
  if(now == 0) return p == 1;
  if(p < 2) return 0;
  if(memo[now][1] == p) return memo[now][0];
  if(memo[now][1] / 2 + 1 == p) return memo[now - 1][0] + 1;
  if(memo[now][1] / 2 + 1 < p)
    return solve(now - 1, p - (memo[now][1] / 2) - 1) +
           memo[now - 1][0] + 1;
  else
    return solve(now - 1, p - 1);
}


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

// a + b + c = N
// 10a + 5b + c = Y の連立方程式を解く。
// cを固定化したのち、下式を 2a = (Y - c) / 5 - (a + b) に変換し、bを消去して方程式を解く。
// 求めたa, b, cが非負ならそれを答えとする。なければcの値を変えて再度方程式を解く。

int main(void){
    int N, Y;
    cin >> N >> Y;
    int Y2 = Y / 1000;
    int mod5 = Y2 % 5;
    int div5 = Y2 / 5;
    int a, b, c;
    rep(c_div5,div5+1){
        c = c_div5 * 5 + mod5;
        a = div5 - c_div5 - (N - c);
        b = N - a - c;
        if(a >= 0 && b >= 0) break;
        if(c_div5 == div5){a = -1; b = -1; c = -1;}
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


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

using namespace std;

int main(){
    int x,y,s;
    while(cin >>x>>y>>s &&x){
        int maxvalue=0;
        for (int i=1;i<s;i++){
            for(int j=i;j<s;j++){
                int sum = floor((i+x*i/100.0))+floor((j+x*j/100.0));
                if(s==sum){
                    //cout << i<<j;
                    int sumafter = floor((i+y*i/100.0))+floor((j+y*j/100.0));
                    maxvalue=max(maxvalue,sumafter);
                    //cout<<endl;
                }
            }
        }
        cout << maxvalue <<endl;
    }
}

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

int n;
int col[100];

int main(void){
  cin >> n;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(a / 400 <= 7){
      col[a / 400]++;
    }
    else{
      col[8]++;
    }
  }
  int ans = 0;
  for(int i = 0; i <= 7; i++){
    if(col[i] > 0){
      ans++;
    }
  }
  if(ans > 0){
    cout << ans << " " << ans + col[8] << endl;
  }
  else{
    cout << 1 << " " << col[8] << endl;
  }
}


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

using namespace std;

int main()
{
    stack <char> st;
    string s;

    cin >> s;

    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '1' || s[i] == '0')
        {
            st.push(s[i]);
        }
        else
        {
            if (!st.empty())
            {
                st.pop();
            }
        }
    }

    string t = "";

    while (!st.empty())
    {
        t += st.top();
        st.pop();
    }

    reverse(t.begin(), t.end());

    cout << t << endl;

    return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int>& vec) {
    for (auto& e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

int func(long long N, long long K, std::vector<long long> h) {
    // cout << fixed << setprecision(8);

    return 0;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &h[i]);
    }

    int cnt = 0;
    rep(i, N) {
        if (h[i] >= K) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

// 代表的関数
vector<int> idv, p, q, pi, qi; // pi, qi は p, q の逆写像, idv は恒等写像

// 逆写像計算
vector<int> inv(const vector<int> &v) {
    int N = v.size();
    vector<int> res(N);
    for (int i = 0; i < N; ++i) res[v[i]] = i;
    return res;
}

// 合成写像計算
inline vector<int> operator +(const vector<int> &a, const vector<int> &b) {
    int N = a.size();
    vector<int> res(N);
    for (int i = 0; i < N; ++i) res[i] = a[b[i]];
    return res;
}

// r_k
vector<vector<int> > beki; // beki[i] := r[4×2^i], 前計算しておく
vector<int> calc(long long k) {
    int num = k / 4;
    int r = k % 4;
    vector<int> amari = idv;
    if (r == 0) amari = idv;
    else if (r == 1) amari = pi;
    else if (r == 2) amari = pi + qi;
    else if (r == 3) amari = pi + qi + p;
    auto syuki = idv;
    for (int i = 0; i < 35; ++i) if (num & (1LL<<i)) syuki = syuki + beki[i];
    return syuki + amari;
}

// 解く
vector<int> solve(long long K) {
    if (K == 1) return p;
    if (K == 2) return q;
    if (K == 3) return q + pi;
    if (K == 4) return q + pi + qi;
    if (K == 5) return q + pi + qi + p + qi;
    if (K == 6) return q + pi + qi + p + p + qi;
    long long a, b;
    long long k = K / 3;
    if (K % 3 == 0) a = k*2-1, b = k*2-3;
    else if (K % 3 == 1) a = k*2, b = k*2-3;
    else a = k*2, b = k*2-1;
    auto res = q + calc(a) + inv(calc(b)) + qi;
    return res;
}

int main() {
    // 入力, 恒等写像, 逆写像
    int N, K; cin >> N >> K;
    idv.resize(N); p.resize(N); q.resize(N);
    for (int i = 0; i < N; ++i) idv[i] = i;
    for (int i = 0; i < N; ++i) cin >> p[i], --p[i];
    for (int i = 0; i < N; ++i) cin >> q[i], --q[i];
    pi = inv(p);
    qi = inv(q);

    // 繰り返し構造のダブリング前処理
    auto pqpq = pi + qi + p + q;
    beki.resize(35);
    beki[0] = pqpq;
    for (int i = 0; i+1 < 35; ++i) beki[i+1] = beki[i] + beki[i];

    // 解く
    auto res = solve(K);
    for (auto v : res) cout << v + 1 << " ";
    cout << endl;
}


Measured memory_bytes: 19184
A = []
for i in range(3):
    A.append(list(input().split()))
N = int(input())
B = []
for i in range(N):
    B.append(input())
B=set(B)
if set(A[0]) <= B or set(A[1]) <= B or set(A[2]) <= B or {A[0][0], A[1][0], A[2][0]} <= B or\
{A[0][1], A[1][1], A[2][1]} <= B or {A[0][2], A[1][2], A[2][2]} <= B \
or {A[0][0], A[1][1], A[2][2]} <= B or {A[0][2], A[1][1], A[2][0]} <= B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(true){
    int n;
    cin>>n;
    if(!n) break;
    int maxl=0,maxn=0;
    for(int i=0;i<n;i++){
      int p,d1,d2;
      cin>>p>>d1>>d2;
      maxl=max(maxl,d1+d2);
      if(maxl==d1+d2) maxn=p;
    }
    cout<<maxn<<" "<<maxl<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 3e3+10;

priority_queue<int> pq;
vector<vector<pii> > graph;
vector<vector<pii> > rgraph;
queue<int> que;
vector<ll> upper;
int A[MAXN];
char S[MAXN];
bool reach_s[MAXM];
bool reach_d[MAXM];

ll bellman(int src,int target,int n)
{
    upper[src] = 0;

    int there,cost;

    for(int runs=0;runs<n;runs++){

        for(int here =1;here<=n;here++){
            for(int i=0;i<graph[here].size();i++){
                there = graph[here][i].f;
                cost = graph[here][i].s;
                upper[there] = min(upper[there],upper[here]+(ll)cost);
            }
        }
    }


    for(int here=1;here<=n;here++){
        for(int i=0;i<graph[here].size();i++){
                there = graph[here][i].f;
                cost = graph[here][i].s;

                if(upper[there]>upper[here]+(ll)cost){
                    if(reach_s[here]&&reach_d[there]){
                        return -LINF;
                    }
                }
        }
    }
    return upper[target];
}

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>m>>k;

    graph = vector<vector<pii> > (n+1);
    rgraph = vector<vector<pii> > (n+1);


    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>a;
        a-=k;
        a = -a;
        graph[x].push_back(pii(y,a));
        rgraph[y].push_back(pii(x,a));
    }

    upper = vector<ll> (n+1,LINF);

    que.push(1);

    reach_s[1] = true;

    while(!que.empty()){
        x = que.front(); que.pop();

        for(int i=0;i<graph[x].size();i++){
            cur = graph[x][i].f;
            if(reach_s[cur])continue;
            reach_s[cur] = true;
            que.push(cur);
        }
    }

    que.push(n);

    reach_d[n] = true;

    while(!que.empty()){
        x = que.front(); que.pop();

        for(int i=0;i<rgraph[x].size();i++){
            cur = rgraph[x][i].f;
            if(reach_d[cur])continue;
            reach_d[cur] = true;
            que.push(cur);
        }
    }

    ll res = bellman(1,n,n);

    res = -res;

    if(res==LINF)cout<<"-1\n";
    else cout<<max(res,0LL)<<"\n";

    return 0;
}


Measured memory_bytes: 512
/**
*    author:  y_takano
*    created: 23.06.2020 09:14:37
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

using namespace std;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    printf("%.8lf\n", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));

    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n), q(n), t(n);
	rep(i, n)
	{
		cin >> p[i];
		t[i] = i + 1;
	}
	rep(i, n)
	{
		cin >> q[i];
	}
	int p_count, q_count;
	p_count = q_count = 0;
	int count = 0;
	do
	{
		count++;
		bool p_find = true;
		bool q_find = true;
		rep(i, n)
		{
			if (p[i] != t[i])
				p_find = false;
			if (q[i] != t[i])
				q_find = false;
		}
		if (p_find)
			p_count = count;
		if (q_find)
			q_count = count;
	} while (next_permutation(t.begin(), t.end()));
	cout << abs(p_count - q_count) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#define in(n, m) for (ll i=n; i<m;i++)
#define inj(n, m)for (ll j=n; j<m;j++)
#define ink(n, m)for (ll k=n; k<m;k++)
using namespace std;
using ll=long long;
using P =pair<ll, ll>;
const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
	ll k, a, b;
	cin >> k;
	cin >> a >> b;
	bool can = false;
	in(1, 500) {
		ll K = i * k;
		if (K >= a && K <= b) can = true;
	}
	if (can) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define R cin>>
#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 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long unsigned int ll;
int main(){
    vector<int>a(4);
    rep(i, 4) R a[i];
    int ans = 0;
    ans = min(a[0], a[1]) + min(a[2], a[3]);
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;

void solve()
{
    int h,w,m;
    cin>>h>>w>>m;
    int x,y;
    vector<int>row(h,0);
    vector<int>col(w,0);
   map< pair<int,int>, int> mp;
    fr(i,m)
    {
        cin>>x>>y;
        x--,y--;
        row[x]++;
        col[y]++;
        mp[mp(x,y)]=1;

    }
   
    vector<pair<int,int> >mr;
    vector<pair<int,int> >mc;
    fr(i,h)
    {
        mr.pb(mp(row[i],i));
    }
    fr(i,w)
    {
        mc.pb(mp(col[i],i));
    }
   
    sort(mr.begin(),mr.end());
    sort(mc.begin(),mc.end());
    int rmax=mr[mr.size()-1].first;
    int cmax=mc[mc.size()-1].first;
   
    vector<pair<int,int> >rr;
    vector<pair<int,int> >cc;
    int k=mr.size()-1;
    while (k>=0 && mr[k].first==rmax)
    {
        rr.pb(mr[k]);
        k--;
        /* code */
    }
    k=mc.size()-1;
    while (k>=0 && mc[k].first==cmax)
    {
        cc.pb(mc[k]);
        k--;
        /* code */
    }
    int flag=1,ans=rmax+cmax;
    fr(i,rr.size())
    {
        fr(j,cc.size())
        {
            if(mp[mp(rr[i].second,cc[j].second)]==0)
            {
                flag=0;
                break;
            }
        }
        if(flag==0)break;
    }
    cout<<ans-flag;
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // int  k = 1;
    // cin >> t;
    t = 1;

    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


Measured memory_bytes: 53052
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <cstring>
#include <cctype>
#include <functional>
#include <climits>
 
using namespace std;
#define pr(...) do { _ost << #__VA_ARGS__ << " = "; ~(_ost,__VA_ARGS__); } while(0);
ostream & _ost = cout;
template <class T>
ostream &operator,(ostream& ost, const T& value) { return ost << value << ","; }
ostream &operator~(ostream& ost) { return ost << endl; }
template <class T>
string tos(const T& var){ ostringstream ss; ss << var; return ss.str(); }
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
 
typedef vector<int> vi;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;
 
const int mod = 1000000007;
const int INF = 1000000;
const double EPS = 1e-10;

int m,n;
int dp[1][1];

int main(){
    while(cin>>n,n){
        vi c(n);
        int ba=0;

        string h; cin>>h;
        FOR(i,0,100){
            if(h[i]=='S'){ // bozu
                ba+=c[i%n]+1;
                c[i%n]=0;
            } else if(h[i]=='L'){ // prin
                c[i%n]+=ba+1;
                ba=0;
            } else { // man
                c[i%n]++;
            }
        }
        sort(ALL(c));
        FOR(i,0,n)
            cout<<c[i]<<" ";
        cout<<ba<<endl;
    }
}

Measured memory_bytes: 1228
//
//AtCoder Beginner Contest 177
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int d,t,s;
    cin >> d >> t >> s;

    string ans = "Yes";
    if (d>t*s) ans = "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X, A = map(int, input().split())
if X < A:
    print(0)
else:
    print(10)


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

int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n, vector<int>(0));
	vector<int> h(n);
	vector<int> ans(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g.at(a).push_back(b);
		g.at(b).push_back(a);
	}
	queue<int> q;
	q.push(0);
	int hu = 1;
	h.at(0) = 1;
	while(!q.empty()){
		int k = q.front();
		hu++;
		rep(i, g.at(k).size()){
			if(h.at(g.at(k).at(i)) == 0){
				q.push(g.at(k).at(i));
				h.at(g.at(k).at(i)) = hu;
				ans.at(g.at(k).at(i)) = k+1;
			}
		}
		q.pop();
	}
	cout << "Yes" << endl;
	rep(i, n-1){
		cout << ans.at(i+1) << endl;
	}
	return 0;
}

Measured memory_bytes: 10724
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        String str = scanner.next();
        String order,change;
        int Q = scanner.nextInt();
        int a,b;
 
        for(int loop = 0; loop < Q; loop++){
            order = scanner.next();
 
            if(order.equals("print")){
 
                a = scanner.nextInt();
                b = scanner.nextInt();
 
                print(str,a,b);
 
            }else if(order.equals("reverse")){
 
                a = scanner.nextInt();
                b = scanner.nextInt();
 
                str = reverse(str,a,b);
 
            }else{
 
                a = scanner.nextInt();
                b = scanner.nextInt();
                change = scanner.next();
 
                str = replaceStr(str,a,b,change);
            }
        }
    }
 
    private static void print(String str,int a,int b){
        String output = str.substring(a, b+1);
        System.out.println(output);
    }
 
    private static String reverse(String str,int a,int b){
 
        char work[] = str.toCharArray();
 
        int num = b-a+1;
        char tmp;
 
        for(int i = 0; i < num/2; i++){
 
            tmp = work[a+i];
            work[a+i] = work[b-i];
            work[b-i] = tmp;
        }
 
        return String.valueOf(work).substring(0, str.length());
    }
 
    private static String replaceStr(String str,int a,int b,String change){
 
        char ch[] = change.toCharArray();
        char work[] = str.toCharArray();
 
        for(int i = a; i <= b; i++){
            work[i] = ch[i-a];
        }
 
        return String.valueOf(work).substring(0,str.length());
    }
}


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

int main() {
	int d,n;
	cin>>d>>n;
	
	
	if(n==100){
		if(d==0)cout<<101<<"\n";
		else if(d==1)cout<<10100<<"\n";
		else if(d==2)cout<<1010000<<"\n";
	}else if(d==0)cout<<n<<"\n";
	else if(d==1)cout<<n*100<<"\n";
	else if(d==2)cout<<n*10000<<"\n";
	return 0;
}

Measured memory_bytes: 256