akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let (n,r) = read!(i64,i64);
	let mut ans = 0;
	let mut res = n;
	let mut p = r;
	loop {
		ans += 1;
		if res/p==0 {
			break;
		}
		p *= r;
	}
	println!("{}", ans);
}

fn run() {
    solve();
}


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

int main(){
    ll h,w,m,a,b,k;
    cin>>h>>w;
    if(h%3==0||w%3==0){
        cout<<0;
        return 0;
    }
    if(h>w){
        m=w;
    }else{
        m=h;
    }
    a=(h+1)/3;
    b=w/2;
    k=max({a*w,(h-a)*b,(h-a)*(w-b)})-min(a*w,(h-a)*b);
    if(m>k){
        m=k;
    }
    a=(w+1)/3;
    b=h/2;
    k=max({a*h,(w-a)*b,(w-a)*(h-b)})-min(a*h,(w-a)*b);
    if(m>k){
        m=k;
    }
    cout<<m;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int a,b,t;
	cin>>a>>b>>t;
	cout<<t/a*b<<endl;


	return 0;

}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0];
    const H = arg[1].split(" ").map(n=>~~n);
    
    let answer = 1;
    let heighest = H[0];
    
    for(let i=1; i<N; i++) {
        if(H[i] >= heighest) {
            answer++;
        }
        
        if(H[i] > heighest) {
            heighest = H[i];
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

const int N = 660;
const ld inf = (ll)1e14;
ld dp[N][N];

vector<int> T[N];
bitset<N> can[N];
vector<int> L[N];
bool memo[N];

void dfs1(int u){
  if(memo[u]) return;
  memo[u] = true;
  can[u][u] = 1;
  for(auto x : T[u]){
    dfs1(x);
    can[u] |= can[x];
  }
}

int n;

void dfs2(int u){
  if(memo[u]) return;
  memo[u] = true;
  for(auto x : T[u]) dfs2(x);
  for(auto x : T[u]){
    dp[u][0] += dp[x][0];
  }
  ld m = (ld)T[u].size();
  dp[u][0] = (dp[u][0] / m) + 1.0;
  for(int y = 1; y <= n; y ++ ){
    if(!can[u][y]) continue;
    if(y == u){
      if(T[u].size() <= 1) dp[u][y] = inf;
      else{
        vector<ld> R;
        for(auto x : T[u]){
          R.push_back(dp[x][0]);
        }
        sort(R.begin(), R.end());
        R.pop_back();
        for(auto x : R) dp[u][y] += x;
        dp[u][y] = (dp[u][y] / (m - 1.0)) + 1.0;
      }
    }
    else{
      for(auto x : T[u]){
        if(can[x][y]) dp[u][y] += dp[x][y];
        else dp[u][y] += dp[x][0];
      }
      dp[u][y] = (dp[u][y] / m) + 1.0;
    }
  }
}

int main(){
  fastIO;
  int m;
  cin >> n >> m;
  int u, v;
  for(int i = 0 ; i < m ; i ++ ){
    cin >> u >> v;
    T[u].push_back(v);
  }
  dfs1(1);
  for(int i = 1; i <= n; i ++ ){
    memo[i] = false;
  }
  memo[n] = true;
  dfs2(1);
  ld ans = dp[1][0];
  for(int x = 1; x <= n; x ++ ) if(can[1][x]) ans = min(ans, dp[1][x]);
  cout << fixed << setprecision(10) << ans << "\n";
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  int h, w;
  cin >> h >> w;

  vvi mat(h, vi(w));

  rep(i,0,h) rep(j,0,w) {
    char c;
    cin >> c;
    if (c=='#') mat[i][j] = 1;
    else mat[i][j] = 0;
  }

  const ll inf = 1e18;
  vvi dp(h, vi(w, inf));
  dp[0][0] = 0;
  rep(i,0,h) {
    rep(j,0,w) {
      if (i+1<h) ckmin(dp[i+1][j], dp[i][j]+(mat[i][j] == 1 and mat[i+1][j] == 0));
      if (j+1<w) ckmin(dp[i][j+1], dp[i][j]+(mat[i][j] == 1 and mat[i][j+1] == 0));
    }
  }

  if (mat[h-1][w-1] == 1) ++ dp[h-1][w-1];
  cout << dp[h-1][w-1] << endl;

}

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

int main(){
	string s;
	cin>>s;
	if(s[0] == s[1] && s[3] == s[2] && s[1]!=s[3])
		cout<<"Yes";
	else if(s[0] == s[2] && s[1] == s[3] && s[0]!=s[1])
		cout<<"Yes";
	else if(s[0] == s[3] && s[1] == s[2] && s[0]!=s[1])
		cout<<"Yes";
	else 
		cout<<"No";
	
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int n, m;
    cin >> n >> m;
    
    cout << (n + m - 1) / m << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;

int n1;
const int nx =  1e5+5;
int ac[nx][3];


int dp[3][nx];


int go(int a, int i)
{
	if(i==n1) return 0;
	
	if(dp[a][i] != -1) return dp[a][i];
	
	int& ans = dp[a][i];
	
	if(a==0)
	{
	ans=max(ans, go(1, i+1)+ac[i][0]);
	ans=max(ans, go(2, i+1)+ac[i][0]);
	}
	if(a==1)
	{
	ans=max(ans, go(0, i+1)+ac[i][1]);
	ans=max(ans, go(2, i+1)+ac[i][1]);
	}
	if(a==2)
	{
	ans=max(ans, go(0, i+1)+ac[i][2]);
	ans=max(ans, go(1, i+1)+ac[i][2]);
	}
	
	return ans;
	
}
int main()
{
    cin>>n1;

    for(int i=0; i<n1; i++) cin>>ac[i][0]>>ac[i][1]>>ac[i][2];
   
    memset(dp, -1, sizeof dp);
    cout<<max(go(0,0), max(go(1,0),go(2,0)))<<"\n";
    return 0;
}

Measured memory_bytes: 7296
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
VPII e;
VI ev;
void go(int x,int L,int mul){
    if(L&1){
        if(x<20){e.PB(MP(x,20));
            ev.PB((L-1)*mul);
        }
        L--;
    }
    if(!L){
        return;
    }
    e.PB(MP(x,x+1));
    ev.PB(0);
    e.PB(MP(x,x+1));
    ev.PB(mul);
    go(x+1,L/2,mul*2);
}
int main(){
    int L;
    R(L);
    go(1,L,1);
    W(20,SZ(e));
    REP(i,SZ(e))W(e[i],ev[i]);
    return 0;
}


Measured memory_bytes: 256
N = STDIN.gets.to_i
As = STDIN.gets.split(' ').map(&:to_i).sort
Bs = STDIN.gets.split(' ').map(&:to_i).sort
Cs = STDIN.gets.split(' ').map(&:to_i).sort

result = 0

Bs.each do |b|

  # count candidates from A based on selected B
  a_ng_min_index = As.bsearch_index { |a| a >= b }
  a_candidates = a_ng_min_index ? a_ng_min_index : As.length

  # count candidates from C based on selected B
  c_ok_min_index = Cs.bsearch_index { |c| c > b }
  c_candidates = c_ok_min_index ? Cs.length - c_ok_min_index : 0

  result += a_candidates * c_candidates

end

puts result


Measured memory_bytes: 24688
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#h,w,k = [int(i) for i in read().split()]


s = input()
u = ""
t = ""
q = int(input())
num = 0

for _ in range(q):
    a = readline().split()
    if len(a)==1:
        u,t = t,u    
        num ^= 1
    else:
        f = int(a[1])
        c = a[2]
        if f==1:
            t += c
        else:
            u += c

if num:
    print(t[::-1]+s[::-1]+u)
else:
    print(t[::-1]+s+u)
    



Measured memory_bytes: 4340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		char[] input = sc.next().toCharArray();

//		int g[] = new int[input.length];
//		int p[] = new int[input.length];
//
//		for(int i = 1; i < input.length; i++){
//			if(input[i - 1] == 'g'){
//				g[i] = g[i - 1] + 1;
//				p[i] = p[i - 1];
//			}
//			else {
//				g[i] = g[i - 1];
//				p[i] = p[i - 1] + 1;
//			}
//
//			System.out.println(g[i] + " " + p[i]);
//		}

		int result = 0;
		int p = 0;
		int g = 1;
		for(int i = 1; i < input.length; i++){
//			if(input[i] == 'g' && p[i] + 1 <= g[i]){
			if(input[i] == 'g'){
//				System.out.println("i = "+i);
				if(p + 1 <= g){
					result++;
					p++;
				}
				else {
					g++;
				}
			}
			else {
				if(p + 1 <= g){
					p++;
				}
				else {
					g++;
					result--;
				}
			}

//			System.out.println("g "+g+" p "+p);
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 27880
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;


int main(void) {

    int N;
    cin >> N;
    vector<pair<string, int>> pl;
    rep(i, N) {
        string s;
        int t;
        cin >> s >> t;
        pl.push_back(make_pair(s, t));
    }
    string X;
    cin >> X;

    bool flg = false;
    int ans = 0;
    for(vector<pair<string, int>>::iterator it=pl.begin(); it!=pl.end(); it++) {
        if(flg) ans += it->second;
        else if(X.compare(it->first) == 0) flg = true;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int h,w,k;
  scanf("%d%d%d",&h,&w,&k);


  char s[h][w];
  for(int i=0;i<h;i++){
    scanf("%s",s[i]);
  }

  int ans=0;

  for(int bit1=0;bit1<(1<<h);bit1++){//行
    for(int bit2=0;bit2<(1<<w);bit2++){//列
      int cnt=0;//今決めたbitの状態で，黒いマスが何マスあるか
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if((bit1 & (1<<i)) || (bit2 & (1<<j))){//bitとかぶってるならば，その行or列は塗る
            continue;
          }

          if(s[i][j]=='#'){
            cnt++;
          }

        }
      }

      if(cnt==k){
        ans++;
      }
    }
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1712
import sys
n = int(sys.stdin.readline().strip())

eroot_n = int(pow(n, 0.5))
res = 0
for num_a in range(1, eroot_n + 1):
    limit_b = int(n / num_a) + 1
    for num_b in range(num_a, limit_b):
        """
        print(num_a)
        print(num_b)
        print('\n')
        """
        if num_a * num_b >= n:
            continue
        if num_a == num_b:
            res = res + 1
        else:
            res = res + 2
print(res)

Measured memory_bytes: 9448
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');
let input = '';

process.stdin.on('data', function(chunk) {
  input += chunk;
}).on('end', function() {
  let tmp = "";
  let result = "Good";
  for (let v of input) {
    if (v === tmp)
      result = "Bad";
    else
      tmp = v;
  }
  console.log(result);
});

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

int main(void){
	string s,txt="";
	cin >> s;
	for(char i:s){
		switch(i){
			case '0':
			case '1':
				txt.push_back(i);
				break;
			case 'B':
				if(txt!="")
					txt.pop_back();
				break;
		} 
	}
	cout << txt << endl;
}


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

struct teaminfo {
    int team_id;
    int AC_num;
    int WA_num[11];
    int elapsed_time;

    teaminfo(int id) {
        this->team_id = id;
        this->AC_num = 0;
        for (int i = 0; i <= 10; i++) this->WA_num[i] = 0;
        this->elapsed_time = 0;
    }

    bool operator< (const teaminfo& another) const {
        if (this->AC_num == another.AC_num) {
            if (this->elapsed_time == another.elapsed_time) {
                return this->team_id > another.team_id;
            }
            return this->elapsed_time < another.elapsed_time;
        }
        return this->AC_num > another.AC_num;
    }
};

int main(void) {

    int M, T, P, R;
    while (cin >> M >> T >> P >> R, M||T||P||R) {
        vector<teaminfo> teams;
        for (int i = 1; i <= T; i++) {
            teams.emplace_back(i);
        }
        for (int i = 0; i < R; i++) {
            int m, t, p, j; cin >> m >> t >> p >> j; t--;
            if (j) {
                teams[t].WA_num[p]++;
            } else {
                teams[t].AC_num++;
                teams[t].elapsed_time += m + (teams[t].WA_num[p]*20);
            }
        }

        sort(teams.begin(), teams.end());
        cout << teams[0].team_id;
        for (auto i = 1; i < teams.size(); i++) {
            if (teams[i-1].AC_num == teams[i].AC_num && \
                teams[i-1].elapsed_time == teams[i].elapsed_time) {
                cout << '=' << teams[i].team_id;
            } else {
                cout << ',' << teams[i].team_id;
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int n, h, w;
	cin >> n >> h >> w;
	int ans = 0;
	for (int i = 0; i < n; ++i){
		int a, b;
		cin >> a >> b;
		if (a>=h&&b>=w) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int bubbleSort(int A[],int N){
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag=1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void){
	int A[100],N,sw;
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	
	sw=bubbleSort(A,N);
	
	for(int i=0;i<N;i++){
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	cout<<sw<<endl;
	
	return 0;
}


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

ll pow(ll x, ll p)
{
    // base case
    if (p == 0)
    {
        return 1;
    }

    if (p & 1)
    {
        return x * pow(x, p - 1);
    }
    else
    {
        ll half = pow(x, p / 2);
        return half * half;
    }
}

void dfs(string &s, ll cur, ll power, ll to_add, ll &ans)
{
    ll c = s.at(cur) - '0';
    to_add += c * pow(10, power);
    // base case
    if (cur == 0)
    {
        // cout << ans << " -> ";
        ans += to_add;
        // cout << ans << endl;
        return;
    }
    dfs(s, cur - 1, power + 1, to_add, ans);
    dfs(s, cur - 1, 0, to_add, ans);
    return;
}

int main()
{
    string s;
    cin >> s;
    ll ans = 0;
    dfs(s, s.size() - 1, 0, 0, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 3e4 + 10;
char s[N];
char f[2][11][11][11];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n >> (s + 1);
	for (int i = 1; i <= n; ++i)
	{
		int cur = i % 2, lst = 1 - cur;
		int num = s[i] - '0';
		memset(f[cur], 0, sizeof(f[cur]));
		f[cur][num][10][10] = 1;
		for (int j = 0; j <= 10; ++j)
			f[cur][j][num][10] |= f[lst][j][10][10];
		for (int j = 0; j <= 10; ++j)
			for (int k = 0; k <= 10; ++k)
				f[cur][j][k][num] |= f[lst][j][k][10];
		for (int j = 0; j <= 10; ++j)
			for (int k = 0; k <= 10; ++k)
				for (int l = 0; l <= 10; ++l)
					f[cur][j][k][l] |= f[lst][j][k][l];
	}
	int ans = 0;
	for (int i = 0; i < 10; ++i)
		for (int j = 0; j < 10; ++j)
			for (int k = 0; k < 10; ++k)
			{
				ans += f[n % 2][i][j][k];
				/*
				if (f[n % 2][i][j][k])
				{
					cout << i << j << k << endl;
				}
				*/
			}
	cout << ans;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long N = Long.parseLong(br.readLine());
        int[] cnt = new int[11];
        for (int i = 1; i < cnt.length; ++i) {
            cnt[i] += i + cnt[i - 1];
        }
        List<Integer> list = new ArrayList<>();
        while (N != 1) {
            long choosen = N;
            for (long i = 2; i * i <= N; ++i) {
                if (N % i == 0) {
                    choosen = i;
                    break;
                }
            }
            int cntdiv = 0;
            while (N % choosen == 0) {
                cntdiv++;
                N /= choosen;
            }
            list.add(cntdiv);
            // 2 2 2 2 3 3
        }
        int res = 0;
        for (int i = 0; i < list.size(); ++i) {
            int val = list.get(i);
            int lo = 0;
            int hi = cnt.length - 1;
            int idx = -1;
            while (lo <= hi) {
                int mid = lo + (hi - lo) / 2;
                if (cnt[mid] <= val) {
                    idx = mid;
                    lo = mid + 1;
                } else {
                    hi = mid - 1;
                }
            }
            res += idx;
        }
        System.out.println(res);
    }
}

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

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    int x = 0;
    for(int i = 0; i < N - 1; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[minj] > A[j]) minj = j;
        }
        int tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        if(minj != i) x++;
    }
    
    for(int i = 0; i < N; i++){
        cout << A[i] << ((i == N -1) ? "\n" : " " );
    }
    cout << x << endl;
}


Measured memory_bytes: 3112
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let nk: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nk[0];
    let k = nk[1];
    let xs: Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mid:Option<usize> = xs.iter().position(|&x| x >= 0);

    if mid.is_none() {
        println!("{}", -xs[n-k]);
    } else {
        let mid = mid.unwrap();

        let mut ans = xs[0].abs()*2 + xs[n-1].abs()*2;

        for i in 0..mid {
            if mid-i > k {
                ans = cmp::min(ans, xs[i].abs());
            } else if i+k-1 < n {
                ans = cmp::min(ans, xs[i].abs() + xs[i+k-1]*2);
                ans = cmp::min(ans, xs[i].abs()*2 + xs[i+k-1]);
            }
        }
        if mid+k-1 < n {
            ans = cmp::min(ans, xs[mid + k - 1]);
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void){
	int W=0,H=0,N=0,i=0,j=0,a=0,b=0,c=0,d=0,all=0;
	cin>>W>>H>>N;
	cin>>i>>j;
	for(int k=1;k<=N-1;k++){
		cin>>a>>b;
		c=i-a;d=j-b;
		while(c>0&&d>0)
		{
			c--;d--;all++;
		}
		while(c<0&&d<0)
		{
			c++;d++;all++;
		}
		all+=abs(c);
		all+=abs(d);
		i=a;j=b;
	}
	cout<<all<<endl;
	return 0;
}


Measured memory_bytes: 3084
import java.util.*;
 class Main{
   public static void main (String[] args){
 	Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     int C = sc.nextInt();
     
     if(A == B && A != C){
     	System.out.println("Yes");  
     }
     else if(A == C && A != B){
     	System.out.println("Yes");  
     }
     else if(B == C && A != B){
     	System.out.println("Yes");  
     }
     else{
     	System.out.println("No");
     }
   }
 }


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

vector< vector<int> > g;
vector<bool> visited;
int f1, f2;

bool dfs(int v, int prev){
    if(v == f2){
        return false;
    }

    visited[v] = true;

    bool res = false;
    for(auto x : g[v]){
        if(prev != f1 && x == f1){
            return true;
        }
        if(!visited[x]){
            res |= dfs(x, v);
        }
    }

    return res;
}

bool solve(void){
    int n, m;
    cin >> n >> m;

    if(m <= 2){
        return false;
    }

    g.resize(n);
    vector< P > deg(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        ++deg[a].first;
        ++deg[b].first;
    }

    rep(i, n){
        if(deg[i].first % 2 == 1){
            return false;
        }
        deg[i].second = i;
    }

    SORT_INV(deg);
    if(deg[0].first >= 6 || deg[2].first >= 4){
        return true;
    }else if(deg[1].first < 4){
        return false;
    }

    f1 = deg[0].second;
    f2 = deg[1].second;
    visited.resize(n, false);

    return dfs(f1, -1);
}

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

    if(solve()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main()
{
    long long int sum = 0;
    long long int prev_length = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        long long int a;
        cin >> a;
        long long int table_height = 0;
        if (prev_length - a > 0) {
            sum += table_height =(prev_length - a);
        }
        prev_length = a + table_height;
    }
    cout << sum;
    
}

Measured memory_bytes: 3552
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())

    if n % 2 == 0:
        print(min(8 * q, 4 * h, 2 * s, d) * (n // 2))
    else:
        print(min(8 * q, 4 * h, 2 * s, d) * (n // 2) + min(4 * q, 2 * h, s))


if __name__ == "__main__":
    main()


Measured memory_bytes: 61828
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, A, B;
  std::cin >> N >> A >> B;
  std::cout << min(N*A,B) << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <sstream>

std::string to_string(int i) {
  std::stringstream ss;
  ss << i;
  return ss.str();
}

bool palindrome(std::string s) {
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) {
      return false;
    }
  }

  return true;
}

int main() {
  int A, B;
  std::cin >> A >> B;

  int answer = 0;

  for (int i = A; i <= B; i++) {
    if (palindrome(to_string(i))) {
      answer++;
    }
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
//using oset = tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 17*7*(1<<23) + 1;
ll n, f[400400];
string s;
ll get(ll k) {
	ll ans = 0;
	for(int i = 0; i < k; i++) {
		ans = ((ans<<1)+(s[i]=='1'))%mod;
	}
	int i = 0;
	while(i+k<s.size()&&s[i]!=s[i+k])i++;
	if(i+k>=s.size()||s[i+k]=='1')ans++;
	return ans%mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> s;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		if(n%i||(n/i)%2==0) continue;
		f[i] += get(i);
		for(int j = i+i; j <= 2*n; j+=i)
			f[j]-=f[i];
		ans = (ans + 2ll*i*f[i])%mod;
	}
	if(ans < 0)
		ans %= mod, ans += mod;
	cout << ans << "\n";
}


Measured memory_bytes: 3732
#include <iostream>
using namespace std;
		int main(){
			int a,b;
			cin >> a >> b;
			if ( a < b )
				cout << "a < b" << endl;
			else if ( a > b ) 
				cout << "a > b" << endl; 
			else if ( a == b )
				cout << "a == b" << endl;
		}

Measured memory_bytes: 1156
import math
from functools import reduce
def gcd_list(numbers):
  return reduce(math.gcd, numbers)

K = int(input())
gcd = 0

for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      gcd += (gcd_list([a, b, c]))

print(gcd)

Measured memory_bytes: 74824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for (auto c : s) {
        ans += (c == 'R');
    }
    if (s[1] == 'S' && ans == 2)
        ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 3620
A, B = map(int, input().split())

ans = 0
for i in range(40):
    T = 2 ** i
    cnt = 0

    loop = (B + 1) // (2 * T)
    rest = (B + 1) % (2 * T)
    cnt += T * loop
    cnt += max(0, rest - T)

    loop = A // (2 * T)
    rest = A % (2 * T)
    cnt -= T * loop
    cnt -= max(0, rest - T)

    if cnt % 2 == 1:
        ans += T

print(ans)


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

int main() {
    int a, b, c, temp, ans;
    cin >> a >> b >> c;
    temp = max(a, max(b, c));
    if(3 * temp % 2 != (a + b + c) % 2) temp++;
    ans = (3 * temp - (a + b + c)) / 2;
    cout << ans << endl;
}

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int N;
int X;
ll S[100010];
ll dp[100010];
ll mod = 1000000007;

int main()
{
    cin >> N >> X;
    for(int i = 0; i < N; i++)cin >> S[i];

    sort(S, S + N);

    for(int i = 0; i <= 100000; i++)dp[i] = i % S[0];

    for(int i = 1; i < N; i++)
    {
        ll mem[100010] = {0};
        for(int j = 0; j < S[i]; j++)
        {
            for(int k = 0; k * S[i] + j <= 100000; k++)
            {
                mem[k * S[i] + j] += dp[j];
                mem[k * S[i] + j] %= mod;
            }
        }
        for(int j = 0; j <= 100000; j++)
        {
            mem[j] += dp[j] * i % mod;
            mem[j] %= mod;
        }
        for(int j = 0; j <= 100000; j++)dp[j] = mem[j];
    }

    cout << dp[X] << endl;
    return 0;
}


Measured memory_bytes: 1792
#
# abc068 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """32"""
        output = """32"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """100"""
        output = """64"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    ans = 1
    while ans * 2 <= N:
        ans = ans * 2
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  vector<ll> vl(3);
  cin >> n;
  REP(i,3) cin >> vl[i];
  vector<pair<int, int>> cmd(n);
  REP(i,n){
    string s;
    cin >> s;
    cmd[i].first = s[0] - 'A';
    cmd[i].second = s[1] - 'A';
  }

  vector<char> ch(n);
  REP(i,n){
    int x = cmd[i].first;
    int y = cmd[i].second;
    if(vl[x]==0 && vl[y]==0){
      cout << "No\n";
      return 0;
    }

    if(i<n-1 && vl[x]==vl[y]){
      int nx = cmd[i+1].first;
      int ny = cmd[i+1].second;
      if(x==nx || x==ny){
        vl[x]++;
        vl[y]--;
        ch[i] = 'A' + x;
      }else{
        vl[x]--;
        vl[y]++;
        ch[i] = 'A' + y;
      }
    }else if(vl[x] < vl[y]){
      vl[x]++;
      vl[y]--;
      ch[i] = 'A' + x;
    }else{
      vl[x]--;
      vl[y]++;
      ch[i] = 'A' + y;
    }
  }
  cout << "Yes\n";
  REP(i,n) cout << ch[i] << '\n';
  return 0;
}


Measured memory_bytes: 4316
n,x=map(int,input().split())
l=[int(i) for i in input().split()]
ans=0
for i in range(1,n):
    if l[i]+l[i-1]>x:
        tmp=l[i]+l[i-1]-x
        ans+=tmp
        l[i]=max(0,l[i]-tmp)
print(ans)


Measured memory_bytes: 14068
import sys
input = sys.stdin.readline
from bisect import *

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(N):
    for j in range(i+1, N):
        k = bisect_left(L, L[i]+L[j])
        ans += k-j-1

print(ans)

Measured memory_bytes: 42844
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  int N, a, m = 0, nm = 0, mi = 0;
  cin >> N;
  cin >> m;
  for (int i = 1; i < N; i++) {
    cin >> a;
    if (a > m) {
      nm = m;
      m = a;
      mi = i;
    } else if (a > nm) {
      nm = a;
    }
  }
  for (int i = 0; i < N; i++) {
    if (i == mi) cout << nm << endl;
    if (i != mi) cout << m << endl;
  }
}


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

int main(){
	int a,b;
	cin >> a >> b;
	cout << "a ";
	if(a<b) cout << "< ";
	if(a==b) cout << "== ";
	if(a>b) cout << "> ";
	cout << "b" << endl;
	
	
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a%2 == b%2) {
    cout << (a+b)/2 << endl;
  } else {
    cout << (a+b)/2 + 1<< endl;
  } 
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
s1 = [input() for i in range(N)]
c1 = Counter(s1)
M = int(input())
s2 = [input() for i in range(M)]
c2 = Counter(s2)

ans = 0
for k,v in c1.items():
    ans = max(ans, v-c2[k])
print(ans)

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main(void) {
    int A, B, K;
    cin >> A >> B >> K;
    int divisor = min(A, B);
    while(K) {
        if(A%divisor == 0 && B%divisor == 0) {
            K--;
        }
        divisor--;
    }
    cout << divisor+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int h,w,i,j,flag=0;
    scanf("%d%d",&h,&w);
    char a[h][w];
    int H[h],W[w];
    for(i=0;i<h;i++){
        scanf("%s",a[i]);
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(a[i][j]=='#'){
                H[i]=1;
                break;
            }
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(a[i][j]=='#'){
                W[j]=1;
            }
        }
    }
    for(i=0;i<h;i++){
        flag=0;
        for(j=0;j<w;j++){
            if(H[i]==1&&W[j]==1){
                printf("%c",a[i][j]);
                flag=1;
            }
        }
        if(flag==1){
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: isize = 1000000007;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut a: [isize; n],
    }

    let mut a_plus = vec![];
    let mut a_minus = vec![];
    for i in 0..n {
        let ai = a[i];
        if ai > 0 {
            a_plus.push(ai);
        } else if ai < 0 {
            a_minus.push(ai);
        }
    }

    let np = a_plus.len();
    let nm = a_minus.len();

    if np + nm < k {
        eprintln!("zero");
        println!("0");
        return;
    }
    if (np == 0 && k % 2 == 1) || (np + nm == k && nm % 2 == 1) {
        eprintln!("minus");
        a.sort_by_key(|&ai| ai.abs());
        let mut result = 1;
        for i in 0..k {
            result = result * a[i].abs() % M;
        }
        println!("{}", (M - result) % M);
        return;
    }

    a_plus.sort();
    a_plus.reverse();
    a_minus.sort();
    a_plus.push(0);
    a_plus.push(0);
    a_minus.push(0);
    a_minus.push(0);

    let mut result = vec![];
    let mut i = 0;
    let mut j = 0;
    while result.len() < k {
        let x = a_minus[j] * a_minus[j + 1];
        let y = a_plus[i] * a_plus[i + 1];
        if y > x || k - result.len() == 1 {
            result.push(a_plus[i]);
            i += 1;
        } else {
            result.push(a_minus[j]);
            result.push(a_minus[j + 1]);
            j += 2;
        }
    }

    let mut s = 1;
    for &ai in &result {
        s = s * ai.abs() % M;
    }
    println!("{}", s);
}


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

using namespace std;

int main(int argc, char* argv[])
{
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    ios::sync_with_stdio(false);
    int n, a;
    long long mx, mx1;
    map <int, int> m;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        m[a]++;
    }
    mx = -1, mx1 = -1;
    for (__typeof(m.begin()) it = m.begin(); it != m.end(); ++it) {
        if (it->second > 3) {
            mx1 = it->first;
            mx = it->first;
        }
        else if (it->second > 1) {
            mx1 = mx;
            mx = it->first;
        }
    }
    if (mx != -1 and mx1 != -1) {
        cout << mx*mx1 << endl;
    }
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,s,g;
vector<pair<int,string> >edge[45];
string dp[45];
struct S{
	int v; string s;
	bool operator <(const S &a)const{
		return s > a.s;
	}
	S(int a,string b){
		v = a; s = b;
	}
};
int a[3005],b[3005]; string c[3005];
int main(){
	while(1){
		scanf("%d%d%d%d",&n,&m,&s,&g);
		if(n==0) return 0;
		for(int i=0;i<n;i++){
			edge[i].clear();
			dp[i] = "1";
		}
		for(int i=0;i<m;i++){
			cin >> a[i] >> b[i] >> c[i];
		//	edge[b[i]].pb(mp(a[i],c[i]));
		}
		dp[g] = "";
		while(1){
			bool upd = 0;
			for(int i=0;i<m;i++){
				if(dp[b[i]] != "1" && (dp[a[i]]=="1" || dp[a[i]] > c[i]+dp[b[i]]) && (c[i]+dp[b[i]]).size()<500){
					dp[a[i]] = c[i]+dp[b[i]];
					upd = 1;
				}
			}
			if(!upd) break;
		}
		
		/*priority_queue<S>que;
		que.push(S(g,"")); dp[g] = "";
		while(!que.empty()){
			S t = que.top(); que.pop();//cout << t.s << endl;
			if(dp[t.v] != "1" && dp[t.v] < t.s) continue;
			if(t.s.size() > 500) continue;
			for(int i=0;i<edge[t.v].size();i++){
				string nex = edge[t.v][i].sc;
				nex += t.s;
				if(dp[edge[t.v][i].fi] == "1" || dp[edge[t.v][i].fi] > nex){
					dp[edge[t.v][i].fi] = nex;
					que.push(S(edge[t.v][i].fi,nex));
				}
			}
		}*/
		if(dp[s].size() >= 250 || dp[s] == "1") puts("NO");
		else cout << dp[s] << endl;
	}
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int,int>>;
using vpsi = vector<pair<string,int>>;
using vpis = vector<pair<int,string>>;

int main(){
    int n; cin>>n;
    vs blue(n);
    rep(0,i,n) cin>>blue[i];

    int m; cin>>m;
    vs red(m);
    rep(0,i,m) cin>>red[i];

    int ans = 0;

    auto calc = [&](string s){
        int buf = 0;
        for(string t: blue){
            if(t==s) buf++;
        }
        for(string t: red){
            if(t==s) buf--;
        }
        return buf;
    };

    for(string t: blue){
        ans = max(ans,calc(t));
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
vector<int> v[200005];
long long pw[200005];
int n,sz[200005],ans;
void dfs(int node,int p)
{
	sz[node]=1;
	int pr=pw[1];
	for (int u:v[node])
	{
		if (u!=p)
		{
			dfs(u,node);
			sz[node]+=sz[u];
			pr=(pr-pw[n-sz[u]]+mod)%mod;
		}
	}
	if (node!=1)
	pr=(pr-pw[sz[node]]+mod)%mod;
	pr=(pr+(v[node].size()-1)*pw[n]%mod+mod)%mod;
	ans=(ans+pr)%mod;
}
int main()
{
	scanf("%d",&n);
	pw[0]=1;
	pw[1]=(mod+1)/2;
	for (int i=1;i<n;i++)
	{
		pw[i+1]=(pw[1]*pw[i])%mod;
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 30304
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\2010-input.txt"));

		while (scan.hasNext()) {
			int n = scan.nextInt();
			int q = scan.nextInt();

			Qu qu = new Qu(n);
			for (int i = 0; i < n; i++) {
				qu.add(scan.next(), scan.nextInt());
			}
			while (qu.process(q))
				;
		}

		scan.close();
		System.exit(0);
	}
}

class Qu {
	class Proc {
		public Proc(String _name, int _time) {
			name = new String(_name);
			time = _time;
		}

		String name;
		int time;
	}

	List<Proc> proc = new ArrayList<Proc>();
	int pt = 0;
	int total = 0;

	public Qu(int n) {
	}

	public boolean process(int q) {
		if (proc.get(pt).time <= q) {
			total += proc.get(pt).time;
			System.out.println(proc.get(pt).name + " " + total);
			proc.remove(pt);
			if (proc.size() == 0)
				return false;
		} else {
			total += q;
			proc.get(pt).time -= q;
			pt++;
		}
		if (pt == proc.size())
			pt = 0;
		return true;
	}

	public void add(String _name, int _time) {
		proc.add(new Proc(_name, _time));
	}

}

Measured memory_bytes: 72304