akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  if(n>=30)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
vector<int>perm,inv;
void init_perm(){
	int x=1e6+1;perm.resize(x);inv.resize(x);
	perm[0]=1;
	REP(i,x+1)perm[i]=perm[i-1]*i%mod;
	inv[x]=mod_pow(perm[x],mod-2);
	for(int i=x-1;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}
signed main() {
	cin.tie(0);ios::sync_with_stdio(false);
	init_perm();
	int N,M,K;
	cin>>N>>M>>K;
	int ans=0;
	rep(i,K+1){
		int j=M*mod_pow(M-1,N-i-1)%mod*nCk(N-1,i)%mod;
		ans=(ans+j)%mod;
	}
	cout<<ans<<endl;
}


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

using namespace std;

class Fenwick {
public:
	Fenwick(int _N) : N(_N), v(N+1, 0) {}
private:
	int N;
	vector<int> v;
public:
	void add(int val, int p){
		for(int i=p;i<=N;i+=i&-i) v[i] += val;
	}
	int sum(int p){
		int res = 0;
		for(int i=p;i>0;i-=i&-i) res += v[i];
		return res;
	}
};

int main(){
	int N, M;
	while(cin >> N >> M){
		Fenwick f(M+1);
		vector< vector<pair<int,int>> > range(M+1);
		for(int i=0;i<N;i++){
			int l, r; cin >> l >> r;
			range[r-l+1].push_back(make_pair(l, r));
		}
		cout << N << endl;
		int all = N;
		for(int i=2;i<=M;i++){
			all -= range[i-1].size();
			for(const pair<int,int>& p : range[i-1]){
				f.add(1, p.first);
				f.add(-1, p.second+1);
			}
			int res = all;
			for(int j=i;j<=M;j+=i) res += f.sum(j);
			cout << res << endl;
		}
	}
}


Measured memory_bytes: 7936
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    vector<LLONG> As(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> As[i];
    }
    LLONG sum = accumulate(As.begin(), As.end(), 0LL) / 2;
    LLONG x1 = sum;
    for (int i = 1; i < N - 1; i += 2)
    {
        x1 -= As[i];
    }
    cout << x1 * 2 << ' ';
    LLONG prevXi = x1;
    for (int i = 2; i <= N; ++i)
    {
        LLONG xi = As[i - 2] - prevXi;
        cout << xi * 2;
        prevXi = xi;
        if (i < N)
        {
            cout << ' ';
        }
        else
        {
            cout << endl;
        }
    }
}


Measured memory_bytes: 2048
H, W = map(int, input().split())
 
res = min(H, W)
for h in range(H // 3, H // 3 + 3):
    w = W // 2
    s1 = h*W
    s2 = (H-h)*w
    s3 = (H-h)*(W-w)
    res = min(res, max(s1,s2,s3) - min(s1,s2,s3))
for w in range(W // 3, W // 3 + 3):
    h = H // 2
    s1 = w*H
    s2 = (W-w)*h
    s3 = (W-w)*(H-h)
    res = min(res, max(s1,s2,s3) - min(s1,s2,s3))
if H % 3 == 0 or W % 3 == 0:
    res = 0
print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  VI a(n); for (int i = 0; i < n; i++) cin >> a[i];
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += __builtin_ctz(a[i]);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
t[99999];main(T,W,N,w,c,i,j,m){
for(;scanf("%d%d",&W,&N)>1;printf("Case %d:\n%d\n%d\n",T++,m-1,i)){
	for(memset(t,0,sizeof(t)),t[0]=1,i=0;i<N;i++)
		for(scanf("%d,%d",&c,&w),j=W;j>=0;j--)if(t[j])if(t[j+w]<t[j]+c)t[j+w]=t[j]+c;
	for(m=j=0;j<=W;j++)if(m<t[j])m=t[j],i=j;
}exit(0);}

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

int main() {
    int n;
    while (true) {
        cin >> n;
        if (!n) break;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 1e9;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                ans = min(ans, abs(a[i] - a[j]));
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3084
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/




#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1, 0);
    int ans = 0;
    for(int i = 1; i <= n; i++) cin >> a[i]; // 1-origin
    for(int i = n; i > 0; i--) {
        int cnt = 0;
        for(int j = i; j <= n; j += i) cnt += b[j];
        if(cnt % 2 != a[i]) {
            b[i]++;
            ans++;
        }
    }
    cout << ans << endl;
    for(int i = 1; i <= n; i++) {
        if(b[i]) cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2560
enum MOD = 10uL^^9+7;

void main() {
	auto ip = readAs!(long[]), N = ip[0], M = ip[1];
	auto c = abs(N-M);
	switch(c) {
		case 0:
			writeln((fact(N)*fact(M) % MOD)*2 % MOD);
			break;
		case 1:
			writeln((fact(N)*fact(M)) % MOD);
			break;
		default:
			writeln(0);
			break;
	}
}

ulong fact(ulong n) {
	ulong p = 1;
	while(n>1) {
		p *= n;
		p %= MOD;
		n--;
	}
	return p;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>

using namespace std;

int N;
int ans;
bool f[1000];
bool wait[1000];
int A[1000][1000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> A[i][j];
		}
	}

	int game = N*(N - 1) / 2;
	vector<int> now(N, 0);
	int e;
	while (game > 0) {
		bool flag = false;
		memset(f, false, sizeof(f));
		for (int i = 0; i < N; i++) {
			if (wait[i] || f[i] || now[i] >= N - 1)continue;
			e = A[i][now[i]] - 1;
			if (A[e][now[e]] == i + 1 && !f[e]) {
				flag = true;
				game--;
				now[e]++;
				now[i]++;
				f[e] = f[i] = true;
				wait[e] = false;
			}
			else { wait[i] = true; }
		}
		if (!flag) {
			cout << -1 << endl; return 0;
		}
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
#define MAXN 330000
int prime[MAXN];
bool is_prime[MAXN];

int sieve(int n){
  int i,j;
  int p=0;
  is_prime[0]=is_prime[1]=false;
  for(i=2;i<n;i++){
    if(i%7==1||i%7==6) is_prime[i]=true;
    else is_prime[i]=false;
  }
  for(i=2;i<n;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(j=2*i;j<n;j+=i) is_prime[j]=false;
    }
  }
  return p;
}

int main(void){
  int n,i,j;
  sieve(MAXN);
  while(cin>>n){
    if(n==1) break;


    cout<<n<<":";
    i=0;
    while(1){
      if(prime[i]>n) break;
      if(n%prime[i]==0) cout<<" "<<prime[i];
      i++;
    }
    cout<<endl;

  }

  return 0;
}

Measured memory_bytes: 3552
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var road = new int[num];
        for(var i = 0; i < num; i++)
        {
            road[i] = ToInt32(ReadLine());
        }
        var button = 1;
        var isClear = false;
        for(var i = 0; i < num; i++)
        {
            button = road[button-1];
            if (button == 2)
            {
                isClear = true;WriteLine(i+1);break;
            }
        }
        if (!isClear) WriteLine(-1);
    }
}


Measured memory_bytes: 15300
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#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 gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y,z,n,m=0,k,h,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> s;
    n = s.size();
    int l=0, r = n-1;
    while(s.size() > 0){
        if(s[l] == s[r]){
            if(s.size()>0)
                s.pop_back();
            if(s.size()>0)
                s.erase(s.begin());
            l = 0;
            r = s.size()-1;
        }
        else{
            if(s[l]=='x'){
                s=s+'x';
                ans++;
                l = 0;
                r = s.size()-1;
            }
            else if(s[r]=='x'){
                s='x'+s;  
                ans++;
                l = 0; 
                r = s.size()-1;
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 788
#include <iostream>
 
int main() {
    int a, b;   std::cin >> a >> b;
    int ret = 0;
    for (int i = a; i <= b; i++) {
        int l = i / 1000;
        int r = i % 100;
 
        int ll = l / 10;
        int lr = l % 10;
        
        int rl = r / 10;
        int rr = r % 10;
 
        if (lr == rl && ll == rr)   ret++;
    }
 
    std::cout << ret << std::endl;
 
    return 0;
}

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

from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def strong(x,y):
    if y == 1 : return False
    return (x == 1) or (x > y)

a = readln()
if a[0] == a[1]:
    print("Draw")
elif strong(a[0],a[1]):
    print("Alice")
else:
    print("Bob")


Measured memory_bytes: 5716
# AGC008A

def func(x, y):
    if y >= x:
        if x >= 0:
            return y - x
        else:
            if y > 0:
                if abs(x) > abs(y):
                    return 1 - x - y
                else:
                    return 1 + x + y
            elif y <= 0:
                return y - x
    else:
        if x >= 0:
            if y < 0:
                if abs(x) > abs(y):
                    return 1 + x + y
                else:
                    return 1 - x - y
            elif y == 0 or y == 1:
                return x + 1
            else:
                if abs(x) > abs(y):
                    return 1 + x + y
                else:
                    return 1 + y - x
        else:
            return 2 + x - y

x, y = map(int, input().split())
print(func(x, y))


Measured memory_bytes: 9204
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut sushi = vec![vec![]; n];
    for _ in 0..n {
        let t = sc.read::<usize>() - 1;
        let d: usize = sc.read();
        sushi[t].push(d);
    }

    let mut tops = vec![];
    let mut garbage = vec![];
    for sushi in sushi.iter_mut() {
        if sushi.is_empty() {
            continue;
        }
        sushi.sort();
        let len = sushi.len();
        for i in 0..(len - 1) {
            garbage.push(sushi[i]);
        }
        tops.push(sushi[len - 1]);
    }
    garbage.sort();
    garbage.reverse();
    tops.sort();
    tops.reverse();

    let mut tops_sum = vec![0; tops.len() + 1];
    let mut garbage_sum = vec![0; garbage.len() + 1];
    for i in 0..tops.len() {
        tops_sum[i + 1] = tops_sum[i] + tops[i];
    }
    for i in 0..garbage.len() {
        garbage_sum[i + 1] = garbage_sum[i] + garbage[i];
    }

    let mut ans = 0;
    for i in 1..(k + 1) {
        if tops_sum.len() <= i || garbage_sum.len() <= k - i {
            continue;
        }
        let sum = tops_sum[i] + garbage_sum[k - i] + i * i;
        ans = cmp::max(ans, sum);
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x;
    cin >> x;
    string ans;
    if(x == 7 || x == 5 || x == 3){
        ans = "YES";
    }else{
        ans = "NO";
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
  int N;cin>>N;
  vector<string> S;
  string tmp;
  for(int i=0;i<N;i++)
  {
    cin>>tmp;
    S.push_back(tmp);
  }

  map<string,int> m;
  for(int i=0;i<N;i++)
  {
    if(m.count(S[i])>0)
    {
      m[S[i]]+=1;
    }
    else
    {
      m[S[i]]=1;
    }
  }

  vector<string> ret;
  int n=1;

  for( auto it = m.begin(); it != m.end() ; ++it )
  {
     int num=it->second;
     if(num>n)
     {
       n=num;
       ret.clear();
       ret.push_back(it->first);
     }
     else if(num==n)
     {
       ret.push_back(it->first);
     }
  }

  for(int i=0;i<ret.size();i++)
  {
    cout<<ret[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 32108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

vector<P> segmi;
ll N=1;

void update(ll i,ll x){
    i=N+i-1;
    segmi[i].first=x;
    while(i>0){
        i=(i-1)/2;
        if(segmi[i*2+1].first<segmi[i*2+2].first){
            segmi[i].first=segmi[i*2+1].first;
            segmi[i].second=segmi[i*2+1].second;
        }
        else{
            segmi[i].first=segmi[i*2+2].first;
            segmi[i].second=segmi[i*2+2].second;
        }
    }
}

P mi(ll a,ll b,ll k,ll l,ll r){
    if(r<=a||b<=l)return P(inf,-1);
    if(a<=l&&r<=b)return segmi[k];
    P c1=mi(a,b,k*2+1,l,(l+r)/2);
    P c2=mi(a,b,k*2+2,(l+r)/2,r);
    return min(c1,c2);
}


    


int main(){
    int n,m;cin>>n>>m;
    while(N<n)N*=2;
    segmi=vector<P>(N*2-1,P(inf,-1));
    vector<PP> v(m);
    vi dp(n,inf);
  
    rep(i,2*N-1)segmi[i]=P(inf,i);
  dp[0]=0;
  update(0,0);
    rep(i,m){
        int a,b,c;cin>>a>>b>>c;a--;b--;
        v[i]=PP(a,b,c);
    }
    sort(all(v));
  
    rep(i,m){
      
        ll a=get<0>(v[i]),b=get<1>(v[i]),c=get<2>(v[i]);
        chmin(dp[b],mi(a,n,0,0,N).first+c);
      update(b,dp[b]);
    }
    if(dp[n-1]!=inf)cout<<dp[n-1]<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 7424
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
aij = []

for i in range(H):
    aij.append( list(input()) )

# print(aij)

ans = []
for i in range(H):
    if aij[i] == ['.']*W:
        continue
    else:
        ans.append(aij[i])

pop_num = []
for j in range(W):
    tmp = []
    for i in range(len(ans)):
        tmp.append(ans[i][j])
    if tmp == ['.']*len(ans):
        for i in range(len(ans)):
            pop_num.append(j)

ans2 = []
for i in range(len(ans)):
    tmp = []
    for j in range(W):
        if j not in pop_num:
            tmp.append(ans[i][j])
    ans2.append(tmp)

for i in range(len(ans2)):
    print( ''.join(ans2[i]) )


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

int main(){
  string s;
  cin >>s;
  string s1 = "CODEFESTIVAL2016";
  int cnt = 0;
  rep(i,16){
    if(s[i]!=s1[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
// A - +-x
#include <stdio.h>

int main(void){
    int a, b;
    scanf("%d%d", &a, &b);
    int ans=a+b;
    if(ans<a-b)ans=a-b;
    if(ans<a*b)ans=a*b;
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 128
<?php
$tmp = [];
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}

$N = (int)$tmp[0];

function training(int $power = 1, int $count = 1)
{
    global $N;
    
    $power %= (pow(10, 9) + 7);

    if ($count > $N)
        return $power;

    return training($power * $count, $count + 1);
}

echo training();

Measured memory_bytes: 31224
S = input()
if int(S[:4]) <= 2019:
  if int(S[5:7]) <= 4:
    if int(S[8:10]) <= 30:
      print("Heisei")
    else:
      print("TBD")
  else:
    print("TBD")
else:
  print("TBD")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<long long> X(N);
    vector<long long> S(N);
    REP(i, N) { cin >> X[i]; }
    S = X;
    sort(S.begin(), S.end());
    long long tmp = S[((N - 1) / 2)];
    REP(i, N) {
        if(X[i] <= tmp) {
            cout << S[((N - 1) / 2) + 1] << endl;
        } else {
            cout << tmp << endl;
        }
    }
    return 0;
}

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

using namespace std;

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

  int time[100010];
  memset(time, 0, sizeof(time));
  vector<vector<pair<int, int>>> vec(C, vector<pair<int, int>>());
  for (int i = 0; i < N; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    vec[c].push_back({s, t});
  }

  for (int i = 0; i < C; i++) {
    sort(vec[i].begin(), vec[i].end());
    for (int j = 0; j < vec[i].size(); j++) {
      int s = vec[i][j].first;
      int t = vec[i][j].second;

      while(j < vec[i].size() -1 && vec[i][j].second == vec[i][j + 1].first) {
        t = vec[i][j+1].second;
        j++;
      }
      time[s-1]++;
      time[t]--;
    }
  }

  int maxv = 0;
  for(int i = 1; i < 100000; i++) {
    time[i] += time[i -1];
    maxv = max(maxv, time[i]);
  }

  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 1920
import math

def combinations_count(count, r):
    if count <= 1:
        return 0

    return math.factorial(count) // (math.factorial(count - r) * math.factorial(r))

if __name__ == "__main__":
    n, m = map(int, input().split(' '))
    print(combinations_count(n, 2) + combinations_count(m, 2))

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		if(R < 1200) {
			System.out.println("ABC");
		}else if(R < 2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}

	}

}


Measured memory_bytes: 23764
c=Array.new(8)
cnt=0
N=gets.to_i
a=gets.split
N.times{|i|
  t=a[i].to_i/400
  if t>=8
    cnt+=1
  else
    c[t]=true
  end
}
t2=c.compact.size
if t2==0 && cnt>0
  print 1," ",cnt,"\n"
else
  min=c.compact.size
  print min," ",min+cnt,"\n"
end


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

long long cnt[100010]={0};

int main(){
    int n;
    scanf("%d",&n);
    long long sum=0;
    for(int i=0;i<n;i++){
        long long s;
        scanf("%lld",&s);
        sum+=s;
        cnt[s]++;
    }
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        long long b,c;
        scanf("%lld%lld",&b,&c);
        long long cntb=cnt[b];
        sum-=cntb*b;
        cnt[b]=0;
        long long cntc=cnt[c];
        sum+=cntb*c;
        cnt[c]=cnt[c]+cntb;
        printf("%lld\n",sum);
    }
    return 0;
}


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

int ar[100001][4], dp[100001][4];

int go(int day, int activity) {
    if(day == 1) return ar[day][activity];
    
    if(dp[day][activity]) return dp[day][activity];

    int curr = -1;
    for(int i=1; i<=3; ++i) {
        if(activity != i) curr = max(curr, go(day-1, i));
    }
    return dp[day][activity] = curr + ar[day][activity];
}

int main() {
    int n; cin >> n;

    for(int i=1; i<=n; ++i) {
        for(int j=1; j<=3; ++j) {
            cin >> ar[i][j];
        }
    }

    int ans = -1;

    for(int i= 1; i<=3; ++i) {
        ans = max(ans, go(n, i));
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

int find_lower(int *a, int n, int v){
    int l = -1, r = n;

    while (r-l > 1){
        int m = (l+r)/2;
        if (a[m] <= v) l = m;
        else r = m;
    }
    return l;
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}



void solve(){
    int n;
    cin >> n;
    vi a(n), b(n), c(n-1);
    forn cin >> a[i];
    forn cin >> b[i];
    for (int i = 0; i < n-1; i++) cin >> c[i];
    int ans = b[a[0]-1];
    for (int i = 1; i < n; i++){
        ans += b[a[i]-1];
        if (a[i] == a[i-1] + 1) ans += c[a[i-1]-1];
    }
    cout << ans << '\n';
}

int main(){
    //init();

    ios::sync_with_stdio(false);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> hight(N);

	for (int i = 0; i < N; i++)
		cin >> hight.at(i);

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (hight.at(i) >= K)
			count++;
	}

	cout << count << endl;
}

Measured memory_bytes: 640
N,M=list(map(int,input().split()))

checklist=[True for i in range(M)]

for i in range(N):
    A=list(map(int,input().split()))
    minicheck = [False for i in range(M)]
    for a in A[1:]:
        minicheck[a-1]=True
    for i in range(M):
        checklist[i] = checklist[i] and minicheck[i]
count=0
for i in range(M):
    if checklist[i]:
        count+=1
        
print(count)

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

typedef long long ll;

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

    int s = 0;
    ll n = 0;
    for(int i=0;i<N.size();i++){
        int c = N[i]-'0';
        s += c;
        n = n*10+c;
    }
    //cout << s << endl;
    //cout << n << endl;
    if(n%s==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int r, s, n;
	cin >> r >> s >> n;
	vector<int> a;
	for(int i = 0; i < n; ++i){
		int y, x;
		cin >> y >> x;
		--y; --x;
		int d = r - y;
		if(x < s){
			d += s - 1 - x;
		}else{
			d += x - s;
		}
		a.emplace_back(d);
	}
	sort(a.begin(), a.end());
	int answer = 0;
	for(int i = 0; i < n; ++i){
		answer = max(a[i], answer + 1);
	}
	cout << answer + 1 << endl;
	return 0;
}




Measured memory_bytes: 5000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, m, l[114514], r[114514];
int ta[114514];
int ans;

signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> l[i] >> r[i];
		ta[l[i]]++;
		ta[r[i] + 1]--;
	}
	rep(i, n) {
		ta[i + 1] = ta[i] + ta[i + 1];
	}
	for (int i = 1; i <= n; i++) {
		if (ta[i] == m)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<numeric>
#include<queue>
#include<string>
#include<sstream>

using namespace std;

int main(void) {

  int d, e;
  while(cin >> d >> e){
    if( d == 0 && e == 0 ) break;

    double ans = 1000000000;
    for(int i=0; i<=d; i++){

      int x = i;
      int y = d-i;

      ans = min(ans, abs(e-sqrt(x*x + y*y)));
    }
    printf("%.10lf\n", ans);
  }


  return 0;
}










//

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

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

	
	int base;
	if(N!=100){
		base=N;
	}else{
		base= N+1;
	}
	for(int i=0;i<D;i++) base*=100;

	cout << base << endl;
	return 0;
}



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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int NN = N;
		int SN = 0;

		while(NN > 0) {
			SN += NN%10;
			NN = NN/10;
		}
		//System.out.println(SN);

		if(N%SN == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23252
#C_Repsept
K = int(input())
if K % 7 == 0 :
    L = int( 9 * K / 7 )
else:
    L = 9 * K
X = 0
kekka = 1
total = -1
if L % 2 == 1:
    if L % 5 != 0:
        for i in range(L): 
            kekka = kekka * 10 % L
            if kekka == 1:
                total = i+1
                break
# 出力
print(total)

Measured memory_bytes: 9136
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();

		int p[] = new int[101];
		for(int i=1; i<=N; i++) {
			int x = i;
			for(int j=2; j*j<=x; j++) {
				if(x%j==0) {
					while(x%j==0) {
						p[j]++;
						x/=j;
					}
				}
			}
			if(x>1) {
				p[x]++;
			}
		}

		int dp[][] = new int[102][76]; //使う素数/約数の個数
		dp[1][1]=1;
		for(int i=1; i<=N; i++) {
			for(int j=1; j<=75; j++) {
				for(int k=0; k<=p[i]; k++) {
					if(j*(k+1)<=75) {
						dp[i+1][j*(k+1)] += dp[i][j];
					}
				}
			}
		}
		System.out.println(dp[N][75]);
		sc.close();
	}


}


Measured memory_bytes: 23508
import bisect

abq = input().split()
a = int(abq[0])
b = int(abq[1])
q = int(abq[2])
slist = [int(input()) for i in range(a)]
tlist = [int(input()) for i in range(b)]
xlist = [int(input()) for i in range(q)]


def get_nears(list_search, idx, val):
    if idx == 0:
        return (None, list_search[idx])

    try:
        list_search[idx]
    except IndexError:
        return (list_search[idx - 1], None)

    return (list_search[idx - 1], list_search[idx])


def get_min_distance(x, anear, bnear, mindis):
    if anear is None or bnear is None:
        return mindis

    dis = abs(x - anear)
    dis += abs(anear - bnear)

    if mindis is None:
        return dis
    return min(dis, mindis)


for x in xlist:
    sidx = bisect.bisect_left(slist, x)
    tidx = bisect.bisect_left(tlist, x)

    snear1, snear2 = get_nears(slist, sidx, x)
    tnear1, tnear2 = get_nears(tlist, tidx, x)

    mindis = None
    mindis = get_min_distance(x, snear1, tnear1, mindis)
    mindis = get_min_distance(x, snear1, tnear2, mindis)
    mindis = get_min_distance(x, snear2, tnear1, mindis)
    mindis = get_min_distance(x, snear2, tnear2, mindis)
    mindis = get_min_distance(x, tnear1, snear1, mindis)
    mindis = get_min_distance(x, tnear1, snear2, mindis)
    mindis = get_min_distance(x, tnear2, snear1, mindis)
    mindis = get_min_distance(x, tnear2, snear2, mindis)

    print(mindis)


Measured memory_bytes: 16168
#include<iostream>
int main(){
int a,b,c,t;
std::cin>>a>>b>>c;

if(a>b){t=b;b=a;a=t;}
if(b>c){t=c;c=b;b=t;}
if(a>b){t=b;b=a;a=t;}

std::cout<<a<<" "<<b<<" "<<c<<std::endl;
return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        String S = nextStr(r);
        String T = nextStr(r);

        String ans = "";
        for (int i = 0; i < N; i++) {
            ans += S.charAt(i);
            ans += T.charAt(i);
        }
        System.out.println(ans);
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }

    public static String nextStr(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return str;
    }
}


Measured memory_bytes: 21204
#include<iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{      
    int n;
    cin >> n;
    char a[n];
    cin >> a;
    if(n%2!=0){
        cout << "No";
    }else{
        int b = 1;
        for (int i = 0;i<n/2;i++){
            if(a[i]==a[i+n/2]){
            }else
            {
                b=0;
            }
            
        }
        if(b){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }
    


}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  set<char>st;
  for(int i=0;i<s.size();i++)
    st.insert(s[i]);
    if(st.size()==2)
      cout<<"Yes";
  else
    cout<<"No";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c,k,cnt=0;
    cin>>a>>b>>c>>k;
    bool reshenie=true;
    if(a>=b){
        while(a>=b){
            b*=2;
            cnt++;
            if(cnt>k){
                reshenie=false;
                break;
            }
            
        }
    }
    //cout<<"b"<<b;
    //cout<<"k"<<k;
    k=k-cnt;
    cnt=0;
  // cout<<"k"<<k;
    if(b>=c){
        while(b>=c){
            c*=2;
            cnt++;
            if(cnt>k){
            reshenie=false;
            break;
            }
        }
    }
    //cout<<"c"<<c;
    if(reshenie==true){
        cout<<"Yes";
    }
    else 
    cout<<"No";
    
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
struct activity
{
    int A,B,C;
};
int solve(vector<activity>arr,int n)
{
    int dp[n+1][3];
    dp[1][0]=arr[1].A;
    dp[1][1]=arr[1].B;
    dp[1][2]=arr[1].C;
    for(int i=2;i<=n;++i)
    {
        dp[i][0]=arr[i].A+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i].B+max(dp[i-1][2],dp[i-1][0]);
        dp[i][2]=arr[i].C+max(dp[i-1][0],dp[i-1][1]);

    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));

    
}
int main()
{
    int n;
    cin>>n;
    vector<activity>arr(n+1);
    for(int i=1;i<=n;++i)
    {
        cin>>arr[i].A;
        cin>>arr[i].B;
        cin>>arr[i].C;
    }
    cout<<solve(arr, n)<<endl;
    return 0;
}


Measured memory_bytes: 6668
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int ans=0;
  string a, b;
  cin >> a >> b;
  rep(i, 3) if(a[i] == b[i])ans++;
  cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

ll solve() {
    ll res = 0;
    ll cnt = 0;
    int idx = (int)s.size() - 1;
    while (idx >= 0) {
        if (s[idx] == 'A') {
            res += cnt;
            idx--;
        } else if (idx > 0 && s[idx-1] == 'B' && s[idx] == 'C') {
            cnt++;
            idx -= 2;
        } else {
            cnt = 0;
            idx--;
        }
    }
    return res;
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 720
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b
N = a_int()
XY = read_tuple(N)
if N == 1:
    print(1)
    exit()
# q,pは何通りありえる？N**2//2通りぐらい
# p,qを決定したらあとは直線に乗っているか確かめれば良い
# 点に当たるたびにO(N)かけて調べれば良い
# 以下のO(n**4)のプログラムが可能
# for q,p全通り
#     while ある点を選択
#        その点の+p+qを見てボールを消す
#     コストをmin
# と思ったけど、ただ単純にp,qで拾えるボールの個数を数えればいいかも

PQcandi = []
for po1, po2 in combinations(XY, r=2):
    dx = po1[0] - po2[0]
    dy = po1[1] - po2[1]
    if dx < 0:
        dx *= -1
        dy *= -1
    elif dx == 0:
        dy = abs(dy)

    PQcandi.append((dx, dy))

print(N - max(Counter(PQcandi).values()))


# def del_ball(p, q, XYtmp):
#     ret = []
#     # x軸にソートしてあるので左から拾っていく
#     x, y = XYtmp[0]
#     for xxyy in XYtmp[1:]:
#         if xxyy == (x + p, y + q):
#             x += p
#             y += q
#         else:
#             ret.append(xxyy)

#     return ret


# from copy import deepcopy
# ans = INF
# for p, q in PQcandi:
#     XYtmp = deepcopy(XY)
#     anstmp = 0
#     while XYtmp:
#         anstmp += 1
#         XYtmp = del_ball(p, q, XYtmp)
#     # print(p, q, anstmp)
#     ans = min(ans, anstmp)
# print(ans)


Measured memory_bytes: 74560
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;
struct xy{
	long long int x, y;
};
bool cmp(xy a, xy b) {
	if (a.x != b.x) { return a.x < b.x; }
	else { return a.y < b.y; }
 }

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	//cout << fixed << setprecision(10);
	xy num[200];
	long long int n, m, res = 0, mi = 9999999999999,sa_x,sa_y, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
			cin >> num[i].x >> num[i].y;
		
	}
	sort(num, num + n, cmp);
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			sa_x = num[j].x - num[i].x;
			sa_y = num[j].y - num[i].y;
			res = 0;
			for (int p = 0; p < n; p++) {
				res++;
				for (int q = 0; q < p; q++) {
					if (num[p].x == num[q].x + sa_x && num[p].y == num[q].y + sa_y) {
						res--;
						break;
					}
					
				}
			}
			mi = min(mi, res);
		}
	}
	if (n == 1) { mi = 1; }
	cout << mi << endl;
}


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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long

int main(int argc, char const *argv[]){
	int n,l;
	char str[107][107],temp[107];
	scanf("%d%d\n",&n,&l);

	scanf(" %s",str[0]);
	for(int i = 1; i < n; ++i)
	{
		scanf(" %s",str[i]);
		for(int j = 0; j < i; ++j)
		{
			if(strcmp(str[i],str[j]) < 0)
			{
				strcpy(temp,str[i]);
				strcpy(str[i],str[j]);
				strcpy(str[j],temp);
			}
		}
	}
	for(int i = 0; i < n; ++i)	printf("%s",str[i]);
	return 0;
}


Measured memory_bytes: 128
from sys import stdin
input = stdin.readline
def BFS(K,path,N):
  """リストのリスト道順path,頂点の個数Nが与えられたとき, 頂点Kから各頂点までの距離をlistで返す"""
  from collections import deque
  dist=[-1]*N
  dist[K]=0
  que=deque()
  que.append(K)
  while que:
    label=que.popleft()
    for i,c in path[label]:
      if dist[i]==-1:
        dist[i]=dist[label]+c
        que+=[i]
  return dist
 
N=int(input())
path=[ [] for i in range(N)]
for i in range(N-1):
  a,b,c=map(int,input().split())
  path[a-1]+=[(b-1,c)]
  path[b-1]+=[(a-1,c)]
Q,K=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(Q)]
distance=BFS(K-1,path,N)
for i in range(Q):
  print(distance[xy[i][0]-1]+distance[xy[i][1]-1])

Measured memory_bytes: 69296
from collections import defaultdict

H,W,M = map(int,input().split())
hw = defaultdict(int)

h = [0]*H
w = [0]*W

for _ in range(M):
    hh,ww = map(int,input().split())
    h[hh-1] += 1
    w[ww-1] += 1
    hw[(hh-1,ww-1)] = 1

def returnMaxs(a):
    m = max(a)
    ind = []
    for i in range(len(a)):
        if a[i] == m:
            ind.append(i)
    return ind

ind_h = returnMaxs(h)
ind_w = returnMaxs(w)

m = h[ind_h[0]]+w[ind_w[0]]

if len(ind_h)*len(ind_w) > M:
    print(m)
else:
    flag = False
    for i in ind_h:
        for j in ind_w:
            if hw[(i,j)] == 0:
                flag = True
    
    if flag:
        print(m)
    else:
        print(m-1)

Measured memory_bytes: 85824
// AtCoder Beginner Contest - Problem D: 756 (https://atcoder.jp/contests/abc114/tasks/abc114_d)
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const vector<int> primes { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };

const int MAX { 2000010 };
const int oo { 2000000010 };
const int MOD { 1000000007 };

vector<ii> factorization(int n)
{
    vector<ii> f;

    for (const auto& p : primes)
    {
        if (p > n)
            break;

        int k = 0, base = p;

        while (n / base)
        {
            k += (n / base);
            base *= p;
        }

        f.push_back(ii(p, k));
    }

    return f; 
}

const int MAXP { 30 };
const int MAXD { 80 };

int st[MAXP][MAXD];
int as[MAXP];

int ans = 0;

void backtracking(const vector<ii>& f, size_t idx, size_t D)
{
    if (f.size() == idx)
    {
        if (D == 1)
        {
            ans += 1;

    //        for (size_t i = 0; i < idx; ++i)
     //           cout << f[i].first << ": " << as[i] << " (" << f[i].second << ")\n";
        }
    } else
    {
        const vector<int> ds { 1, 3, 5, 15, 25, 75 };
        int p, k;
        tie(p, k) = f[idx];

        for (const auto& d : ds)
        {
            if (d - 1 <= k and D % d == 0)
            {
                as[idx] = d - 1;
                backtracking(f, idx + 1, D / d);
            }
        }
    }
}

int dp(const vector<ii>& f, size_t idx, int D)
{
    const vector<int> ds { 1, 3, 5, 15, 25, 75 };
    int p, k;

    tie(p, k) = f[idx];

    if (idx == f.size())
        return D == 1 ? 1 : 0;

    if (st[idx][D] != -1)
        return st[idx][D];

    int res = 0;

    for (const auto& d : ds)
        if (k >= d - 1 and D % d == 0)
            res += dp(f, idx + 1, D / d);

    st[idx][D] = res;    

    return res;
}
   
void solve(int N)
{
    memset(st, -1, sizeof st);

    auto f = factorization(N);
//    LOGV(f, '\n');

//    backtracking(f, 0, 75);
//    cout << ans << endl;

    cout << dp(f, 0, 75) << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    solve(N);

    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<list>
#include<queue>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<vector>
#include<cmath>
#include<algorithm>

#define ull unsigned long long
#define ll long long
#define mp make_pair
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

unordered_map<int, int> m;

int main(int argc, char *argv[])
{
    int n, q;
    ll sum = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        m[v]++;
        sum += v;
    }

    cin >> q;
    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a>>b;
        
        ll change = (b-a)*m[a];
        m[b] += m[a];
        m[a] = 0;
        sum += change;
        cout << sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 7032