akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

double f(int L, int V, int T, int j) {
	return (double)L / V + j * T;
}

int main() {
	int N, M, L; cin >> N >> M >> L;
	vector<int> P(N), T(N), V(N);
	for (int i = 0; i < N; i++)
		cin >> P[i] >> T[i] >> V[i];
	vector< vector<double> > a(N);
	for (int i = 0; i < N; i++) {
		vector< vector<double> > dp(M + 1, vector<double>(M + 1));
		dp[0][0] = 1;
		for (int j = 0; j < M; j++)
			for (int k = 0; k <= j; k++) {
				dp[j + 1][k] += (1 - P[i] / 100.0) * dp[j][k];
				dp[j + 1][k + 1] += P[i] / 100.0 * dp[j][k];
			}
		a[i] = dp[M];
	}
	for (int i = 0; i < N; i++) {
		double ans = 0;
		for (int j = 0; j <= M; j++) {
			double pro = 1;
			for (int _i = 0; _i < N; _i++) {
				if (_i == i) continue;
				double sum = 0;
				for (int _j = 0; _j <= M; _j++)
					if (f(L, V[i], T[i], j) < f(L, V[_i], T[_i], _j) - EPS)
						sum += a[_i][_j];
				pro *= sum;
			}
			ans += a[i][j] * pro;
		}
		printf("%.10f\n", ans);
	}
}

Measured memory_bytes: 1300
# -*- coding: utf-8 -*-
INF=10**10

def main():
    
    n,m=list(map(int,input().split()))
    
    ans=0
    if n>=m//2:
        ans=m//2
        print(ans)
        return 0
    
    ans+=n #n使い切り
    m-=2*n
    ans+=m//4
    print(ans)
    
    
if __name__=="__main__":
    main()
    

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
    while(1){
      int n;
      cin >> n;
      if(n==0) break;
      int min = 1000000;
      int fee;
      for(int a=0;a<=n/200+1;a++){
	for(int b=0;b<=n/300+1;b++){
	  for(int c=0;c<=n/500+1;c++){
	    if(a*200+b*300+c*500==n){
	      fee=a*380+b*550+c*850;
	      if(a>=5) fee+=((a/5)*5*380)*0.8-((a/5)*5*380);
	      if(b>=4) fee+=((b/4)*4*550)*0.85-((b/4)*4*550);
	      if(c>=3) fee+=((c/3)*3*850)*0.88-((c/3)*3*850);
      if(min>fee) min=fee;
	    }
	  }
	}
      }	
      cout << min <<endl;
     } 
   return 0;
    }



Measured memory_bytes: 2996
n, a, b, c, d = map(int, raw_input().split())
MOD = 10**9+7
fact = [1]*(n+1)
frev = [1]*(n+1)

rcd = range(c, d+1)

dp = [0]*(n+1)
dp[0] = 1

for i in xrange(1, n+1):
    v = fact[i] = (fact[i-1] * i) % MOD
    frev[i] = pow(v, MOD-2, MOD)
Y = [None]*(n+1)
for g in xrange(a, min(n/c, b)+1):
    p = c*g; q = d*g
    y = frev[g]
    Y[p:min(q,n)+1:g] = (pow(y, j, MOD)*frev[j] for j in xrange(c, min(d, n/g)+1))
    dp[p:] = (dp[i] + frev[n-i]*sum(dp[i-j] * fact[n-i+j] * Y[j] for j in xrange(p, min(q, i)+1, g)) % MOD for i in xrange(p, n+1))
print dp[n]%MOD

Measured memory_bytes: 38300
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL M;
LL D[200000],C[200000];

LL ans = 0;

void solve(){
	LL digit = 0;
	LL sum_per_digit = 0;
	for(int i=0;i<M;i++){
		sum_per_digit += (D[i]*C[i]);
		digit += C[i];
	}
	ans = (sum_per_digit)/9LL - (sum_per_digit%9LL==0) + digit - 1LL;
}

int main(){
    cin >> M;
    for(int i=0;i<M;i++){
    	cin >> D[i] >> C[i];
    }

    solve();

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

Measured memory_bytes: 3328
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define endl "\n"
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

ll fac[1000001];

void pre(){
    fac[0]=fac[1]=1;
    for(int i=2;i<=1000001;i++)
{

    fac[i]=(fac[i-1]*1LL*i)%mod;
}
}

ll binpower(ll a,ll n){
    ll res=1;
    while(n){

    if(n%2)
        res = (res*1LL*a)%mod;

        n/=2;
        a=(a*1LL*a)%mod;

    }
    return res;

}

ll nCrmod(ll n,ll r){


ll res= fac[n];
res = (res*1LL*binpower(fac[r],mod-2))%mod;
res= (res*1LL*binpower(fac[n-r],mod-2))%mod;
return res;

}

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll modexp(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  modexp(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*modexp(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return modexp(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}

void SieveOfEratosthenes(ll n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (ll p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

vector<int> Centroid(vector<int>g[],int n) {

        vector<int> centroid;
        vector<int> sz(n+1);
        function<void (int, int)> dfs = [&](int u, int prev) {
                sz[u] = 1;
                bool is_centroid = true;
                for (auto v : g[u]) if (v != prev) {
                        dfs(v, u);
                        sz[u] += sz[v];
                        if (sz[v] > n / 2) is_centroid = false;
                }
                if (n - sz[u] > n / 2) is_centroid = false;
                if (is_centroid) centroid.push_back(u);
        };
        dfs(1, 0);
        return centroid;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    if(s[n-1]!='s')cout<<s+"s";
    else cout<<s+"es";


    return 0;
}


Measured memory_bytes: 3668
input= list( map(int,input().split()) )

n = int(input[0])

k=  input[1]

ln = len(str(n))
sum =0
i=0
while True :
    i+=1
    # print( k,i,k**i,"////",n % (k**i) )
    
    if n % (k**i)== n :
        break
    # print( k,"**",i,"=",k**i)
    
print(i)


Measured memory_bytes: 38384
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
    char s[6];
    for (int i = 0;i < 6;i++){
        cin >> s[i];
    }
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
s = input()
dic = {}
for i in s:
    if i not in dic.keys():
        dic[i]=1
    else:
        dic[i]+=1
ans = "Yes"
if len(dic) !=2:
    ans = "No"
else:
    for i in dic:
        if dic[i] != 2:
            ans = "No"
print(ans)

Measured memory_bytes: 2940
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut plan: [i64; n],
    }
    // println!("{:#?}", plan);

    // i64のマックスは以下
    // 9_223_372_036_854_775_807
    // 10の18乗は足りない
    // 1_000_000_000_000_000_0000

    // 0が含まれている場合は0を返す
    let contain_zero = plan.iter().any(|&e| e == 0);
    if contain_zero {
        println!("{}", 0);
        return; 
    }

    let mut res :i64 = 1;
    for e in plan {
        if 10i64.pow(18) / e < res as i64 {
            res = -1;
            break;
        } else {
            res = res * e;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define i(a) insert(a)
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7 ;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
    string s ;
    cin>>s ;
    ll n = s.length() ;
    if( s[n-1] == 's' ){

        cout<<s<<"es";
    }
    else{
        cout<<s<<"s";
    }
  }
 return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<endl;
    if(n>a+b)cout<<0;
    else cout<<a+b-n;



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RollerCoaster | diff RollerCoaster.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RollerCoaster.cpp && ./a.out

/*
 
 9/28/2019
 
 5:06-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N,K;

void solve() {
  int res=0;
  REP(i,N) res+=(A[i]>=K);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 1024
public class Main {
    public static void main(String[] args) {
        for (int i = 1; i < 10; i++)
            for (int j = 1; j < 10; j++)
                System.out.println(new StringBuilder()
                                   .append(i)
                                   .append('x')
                                   .append(j)
                                   .append('=')
                                   .append(i*j));
    }
}

Measured memory_bytes: 23972
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;//first=point second=num||first=time second=num
int N,r,l;
int d,t,x;
int n;
P team[100005];
P Seg[100005*2];
P Ttime[100005];
int top=0;
int btop=0;
int smin=-1000000;
int btime=0;
P Pmax(P a,P b);
void init(int n_);
void update(int k,int a);
P query(int a,int b,int k,int l,int r);
main(){
  cin>>N>>r>>l;
  for(int i=0;i<100005;i++){
    team[i].F=0;
    team[i].S=i+1;
    Ttime[i].F=0;
    Ttime[i].S=-(i+1);
  }
  init(N);
  for(int i=0;i<r;i++){
    cin>>d>>t>>x;
    Ttime[top].F+=t-btop;
    update(d-1,x);
    /*
    for(int i=n-1;i<2*n-1;i++){
      cout<<"|"<<Seg[i].F<<"|"<<Seg[i].S<<"| ";
    }
    */
    //cout<<endl;
    P tops;
    tops=query(0,n-1,0,0,n);
    top=tops.S;
    btop=t;
    int a=1;
  }
  Ttime[top].F+=l-btop;
  sort(Ttime,Ttime+N);
  /*
  for(int i=0;i<N;i++){
    cout<<Ttime[i].F<<"|"<<Ttime[i].S<<" ";
  }
  */
  //cout<<endl;
  cout<<-Ttime[N-1].second<<endl;
}
void init(int n_){
  n=1;
  while(n<n_){
    n*=2;
  }
  for(int i=0;i<2*n-1;i++){
    Seg[i]=P(0,0);
  }
  for(int i=n-1;i<2*n-1;i++){
    Seg[i].S=i-(n-1);
  }
  return;
}
void update(int k,int a){
  k+=n-1;
  Seg[k].F+=a;
  if(Seg[k].F<smin){
    smin=Seg[k].F;
  }
  while(k>0){
    k=(k-1)/2;
    Seg[k]=Pmax(Seg[k*2+1],Seg[k*2+2]);
  }

  return;
}
P Pmax(P a,P b){
  if(a.F>b.F||(a.F==b.F&&a.S<b.S)){
    return a;
  }
  else{
    return b;
  }
}
P query(int a,int b,int k,int l,int r){
  if(r<=a||b<=l){
    return P(smin,100010);
  }
  if(a<=l&&r<=b){
    return Seg[k];
  }
  else{
    P vl=query(a,b,k*2+1,l,(l+r)/2);
    P vr=query(a,b,k*2+2,(l+r)/2,r);
    return Pmax(vl,vr);
  }
}

Measured memory_bytes: 4288
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = (n - 1); i >= 0; i--)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

int to[6000000];

int main() {

	int k;

	cin >> k;

	int a = 7;
	ll cnt = 0;
	while (1) {
	int	x = a % k;

		
		if (to[x] != 0) {
			
			cout << "-1" << endl;
			return 0;
		}
		to[x]++;
		if (x == 0) {
			cout << cnt+1 << endl;
			return 0;
		}
		cnt++;
		a = x * 10 + 7;
	}

	return 0;
}

Measured memory_bytes: 7404
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define endl "\n"
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
  ll n;
  cin>>n;
  cout<<n*n*n;
return 0;
}


Measured memory_bytes: 256
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,a[100]={0},l;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,greater<int>());
    for(int i=1;a[i]!=0;i++){
        l=a[i-1];
        if(l==a[i]) --n;
    }
    cout<<n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int cntx[300010],cnty[300010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w,m;
    cin>>h>>w>>m;
    set<P>st;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        cntx[x]++,cnty[y]++;
        st.insert({x,y});
    }
    int xma=*max_element(cntx,cntx+h),yma=*max_element(cnty,cnty+w);
    int X=count(cntx,cntx+h,xma),Y=count(cnty,cnty+w,yma);
    int cnt=0;
    for(P p:st){
        int x=p.fi,y=p.se;
        if(cntx[x]==xma&&cnty[y]==yma)cnt++;
    }
    if(X*Y>cnt)cout<<xma+yma<<endl;
    else cout<<xma+yma-1<<endl;
    return 0;
}

Measured memory_bytes: 27060
use proconio::fastout;
use proconio::input;
use proconio::marker::Usize1;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        n: usize,
        abs: [(Usize1, Usize1)],
    }

    let graph = {
        let mut graph = vec![vec![]; n];
        for (a, b) in abs {
            graph[a].push(b);
            graph[b].push(a);
        }
        graph
    };

    let mut dists = vec![usize::max_value(); n];
    dists[0] = 0;

    let mut ans = vec![None; n];

    let mut queue = VecDeque::from(vec![(0, 0)]);
    while let Some((cur_node, cur_dist)) = queue.pop_front() {
        for &next_node in &graph[cur_node] {
            if cur_dist + 1 < dists[next_node] {
                dists[next_node] = cur_dist + 1;
                ans[next_node] = Some(cur_node);
                queue.push_back((next_node, cur_dist + 1));
            }
        }
    }

    println!("Yes");
    ans.remove(0);
    for ans in ans {
        println!("{}", ans.unwrap() + 1);
    }

    //let mut min_paths = vec![None; n];
    //let mut queue = VecDeque::from(vec![vec![0]]);
    //while let Some(path) = queue.pop_front() {
    //    for &next_node in &graph[path[path.len() - 1]] {
    //        if path.len() < dists[next_node] {
    //            let next_path = concat(&path, next_node);
    //            dists[next_node] = path.len();
    //            min_paths[next_node] = Some(next_path.clone());
    //            queue.push_back(next_path)
    //        }
    //    }
    //}
    //println!("Yes");
    //min_paths.remove(0);
    //for min_path in min_paths {
    //    let min_path = min_path.unwrap();
    //    println!("{}", min_path[min_path.len() - 2] + 1);
    //}
}


Measured memory_bytes: 16160
package main

import (
  "fmt"
  "math"
)

func main() {
  // var a,b,h,m float64
  var a,b,h,m int
  var angle, ans float64
  // fmt.Scanf("%f %f %f %f", &a, &b, &h, &m)
  fmt.Scanf("%d %d %d %d", &a, &b, &h, &m)

  angle = calcAngle(float64(h), float64(m))
  ans = calcAns(float64(a), float64(b), angle)
  fmt.Println(ans)
}

func calcAngle(h, m float64) (ans float64) {
  hAngle := h * 30 + 30 * m / 60
  mAngle := m * 6
  // hAngle := 360*(h/12)+30*(m/60)
  // mAngle := 360*(m/60)
  if hAngle > mAngle {
    ans = float64(hAngle - mAngle)
  } else {
    ans = float64(mAngle - hAngle)
  }
  return ans
}

func calcAns(a float64, b float64, angle float64) (ans float64) {
  cos := math.Cos(angle*math.Pi/180)
  ans = math.Sqrt(a*a+b*b-2*a*b*cos)
  return ans
}


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

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

    int now = 0;
    for (int i = 1; i <= X; i++)
    {
        now += i;
        if (now >= X)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
/**
*    created: 12.07.2020 02:41:24
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n-1) if (s[i] != s[i+1]) ans++;
    cout << ans << endl;
    return 0;
}

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

int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  if(a[0]==5&&a[1]==5&&a[2]==7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str1 = scan.next();
        String str2 = scan.next();
        int cnt1 = str1.length();
        String str3 = str2.substring(0, cnt1);
        if (str1.equals(str3)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
        scan.close();
    }
}

Measured memory_bytes: 35644
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N,M;cin >> N >> M;
    vector<int> A(N);
    vector<int> B(N);
    rep(i,N)cin >> A[i] >> B[i];
    map<int,int> m;
    rep(i,N){
        m[A[i]] += B[i];
    }
    LL ans = 0;
    int ct = 0;
    for(auto t : m){
        if(ct == M)break;
        rep(i,t.S){
            if(ct == M)break;
            ans += t.F;
            ct++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char keyword[15];
char str[15];
char check[30];
int main(){
	int num;
	int ans = 0;
	scanf("%s", keyword);
	scanf("%d", &num);
	for (int a = 0; a < num; a++){
		memset(str, '\0', sizeof(str));
		memset(check, '\0', sizeof(check));
		scanf("%s", str);
		sprintf(check, "%s%s", str, str);
		if (strstr(check, keyword) != NULL){
			ans++;
		}
	}
	printf("%d\n", ans);
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int dp[1<<21];

int main() {
    Int n;
    cin >> n;
    Int a[22][22] = {};
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    dp[0] = 1;
    for (Int bit = 0; bit < (1<<n); bit++) {
        Int cnt = 0;
        for (Int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                cnt++;
            }
        }
        for (Int i = 0; i < n; i++) {
            if (((bit & (1<<i)) == 0) and (a[cnt][i])) {
                dp[bit | (1<<i)] += dp[bit];
                dp[bit | (1<<i)] %= mod;
            }
        }
    }
    dump(dp[(1<<n) - 1]);
    return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;
  set<string> s;
  int n = S.length();
  if (n == 1) {
    cout << "1\n";
    return 0;
  }
  if (n == 2) {
    if (S[0] == S[1]) {
      cout << "1\n";
    } else {
      cout << "2\n";
    }
    return 0;
  }

  int dp[n + 1][2]{};
  dp[0][0] = 1;
  dp[0][1] = 1;
  if (S[0] == S[1]) {
    dp[1][0] = 1;
    dp[1][1] = 1;
  } else {
    dp[1][0] = 2;
    dp[1][1] = 1;
  }

  for (int i = 2; i < n; i++) {
    if(S[i] != S[i - 1]) {
      dp[i][0] = dp[i - 1][0] + 1; 
      dp[i][1] = dp[i - 2][0] + 1;
    } else {
      dp[i][0] = dp[i - 1][1] + 1;
      dp[i][1] = dp[i - 2][0] + 1;
    }
  }
  cout << max(dp[n -1][0], dp[n - 1][1]) << "\n";
  // for (int i = 0; i < n; i++) {
  //   cout << dp[i][0] << " " << dp[i][1] << "\n";
  // }
  return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define REP(i, n) for (ll i=0; i<(ll)n; ++i)
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll v(n);
  REP(i, n) cin >> v.at(i);
  cout << v.at(0);
  rep(i, 1, n) cout << ' ' << v.at(i);
  cout << endl;
  rep(i, 1, n) {
    ll k = v.at(i);
    ll j = i-1;
    while (j>=0 && v.at(j) > k) {
      v.at(j+1) = v.at(j);
      j--;
    }
    v.at(j+1) = k;
    cout << v.at(0);
    rep(j, 1, n) cout << ' ' << v.at(j);
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3108
def c_to_infinity(S, K):
    for k, s in enumerate(S,1):
        if s != '1':
            if k > K:
                return '1'
            else:
                return s
    # Sは1のみで構成されていた
    return 1

S = input().strip()
K = int(input())
print(c_to_infinity(S, K))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int aNum,bNum;
  cin >> aNum >> bNum; 
  
  int count = 0;  
  for(int i = aNum; i <= bNum; i++){
    string nowNum = to_string(i);
           
    if(nowNum.at(0) == nowNum.at(4) && nowNum.at(1) == nowNum.at(3)){
      count++;      
    }    
  }   
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N;
	cin >> N;

	map<string,int> m;

	rep(i, N) {
		string s;
		cin >> s;
		m[s]++;
	}

	for (auto p : m) {
		if (p.second > 0) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 19140
from sys import stdin, setrecursionlimit
from math import factorial

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N, M, K = map(int, input().split())
    MOD = 998244353
    fac = [0] * (N + 10)
    finv = [0] * (N + 10)
    inv = [0] * (N + 10)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, N + 2):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def COM(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    ans = 0
    for k in range(K + 1):
        ans += COM(N - 1, k) * ((M % MOD) * pow(M - 1, (N - k - 1), MOD)) % MOD

    print(ans % MOD)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32496
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pll;
const ll N = (ll) 1e5 + 77;

ll n,m,k,x,y,ans=LLONG_MAX;
ll a[N],pre[N];

int main(){
    fast;
    cin>>n;
    forn(i,n){
        cin>>a[i];
    }
    
    ll ct1=0;
    ll sum=a[0];
    ll ct=0;
    sum=min(-1LL, sum);
    ct+=abs(sum-a[0]);
    
    for(int i=1;i<n;i++){
        ll temp=a[i];
        temp=temp+sum;
        ll x=temp;
        if(sum<0){
            temp=max(temp,1LL);
            ct+=abs(temp-x);
            sum=temp;
        }
        else{
            temp=min(temp,-1LL);
            ct+=abs(temp-x);
            sum=temp;
        }
    }
    sum=a[0];
    sum=max(1LL, sum);
    ct1+=abs(sum-a[0]);
    for(int i=1;i<n;i++){
        ll temp=a[i];
        temp=temp+sum;
        ll x=temp;
        if(sum<0){
            temp=max(temp,1LL);
            ct1+=abs(temp-x);
            sum=temp;
        }
        else{
            temp=min(temp,-1LL);
            ct1+=abs(temp-x);
            sum=temp;
        }
    }
    ans = min(ct1, ct);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long double ld;
typedef unsigned long long ull;
const ld inf=1e18;
int main()
{
    int n;cin>>n;
    ld x,ans=1;//cin>>n;
    int flag=1;
    for(int i=1; i<=n; i++)
    {
        cin>>x;ans*=x;
        if(ans>inf){flag=0;ans=1;}
        //if(ans>inf){flag=0;ans=1;}
    }
    if(!flag&&(int)ans)cout<<-1<<endl;
    else cout<<(ull)(ans+0.5)<<endl;
    return 0;
}


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

int main() {
  int n, m; cin >> n >> m;
  vector<int> ac(n), wa(n);
  int num; 
  string s;
  rep(i,m) {
    cin >> num >> s;    
    num--;
    if (ac[num]) continue;
    if (s=="AC") {
      ac[num] = 1;
    } else {
      wa[num]++;
    }
  }
  int AC=0, WA=0;
  rep(i,n) {
    AC += ac[i];
    if (ac[i]) WA += wa[i];
  }
  printf("%d %d\n", AC, WA);
  return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N,M;
int ans=0;
int a[1000001];
void input(){
    cin>>N;
    rep(i,N){
        int t;
        cin>>t;
        a[t]++;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    REP(i,1,1000001){
        if(a[i]==0)continue;
        if(a[i]==1)ans++;
        for(int j = i; j<1000001;j+=i){
            a[j]=0;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
     int n; cin>>n;
     int A[n];
     for(int i=0;i<n;i++)cin>>A[i];

     int curr=1;
     int cnt=0;
     for(int i=0;i<n;i++){
          if(A[i]==curr){
               curr++;
          }
          else cnt++;
     }
     if(cnt==n)cout<<-1;
     else cout<<cnt;
}

Measured memory_bytes: 1024
use proconio::input;

fn main() {
    input!(n: usize, s: proconio::marker::Chars, k: usize);
    let sk = s[k - 1];
    println!(
        "{}",
        s.iter()
            .map(|&c| if c == sk { c } else { '*' })
            .collect::<String>()
    );
}


Measured memory_bytes: 2188
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

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

  int n;
  while (cin >>n && n > 0){
    string move;

    int lpos[200];
    int rpos[200];
    int res = 0;
    

    lpos[0] = 0;
    rpos[0] = 0;
    
    REP(i, n){
      cin >> move;
      lpos[i + 1] = lpos[i];
      rpos[i + 1] = rpos[i];

      (move[0] == 'l' ? lpos[i + 1]  : rpos[i + 1]) = (move[1] == 'u');

      if (i > 0 && lpos[i + 1] == rpos[i + 1] && lpos[i - 1] == rpos[i - 1] && lpos[i + 1] != lpos[i - 1]){
        res++;
      }
    }
    cout << res << endl;

    
  }
  return 0;
}

Measured memory_bytes: 1208
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

    vector<int> AB;
    for (int i = 0; i < N; i++) AB.push_back(A[i]), AB.push_back(B[i]);
    sort(AB.begin(), AB.end());
    AB.erase(unique(AB.begin(), AB.end()), AB.end());

    map<int, int> M;
    for (int i = 0; i < AB.size(); i++) M[AB[i]] = i + 1;

    for (int i = 0; i < N; i++) A[i] = M[A[i]];
    for (int i = 0; i < N; i++) B[i] = M[B[i]];

    vector<int> imos(200100, 0);
    for (int i = 0; i < N; i++) {
        imos[A[i]]++;
        imos[B[i] + 1]--;
    }
    for (int i = 0; i < imos.size() - 2; i++) imos[i + 1] += imos[i];

    int ans = *max_element(imos.begin(), imos.end());
    cout << ans << endl;

}












Measured memory_bytes: 14740
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define ll long long
#define rr register

#define inf 1e9
#define MAXN 100010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

char c;

signed main() {
	cin >> c;
	if (c >= 'A' && c <= 'Z') puts("A");
	if (c >= 'a' && c <= 'z') puts("a");
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main()
{
	int x, y;

	for (int n = 1; n <= 10000; n++)
	{

		cin >> x >> y;
		if (x == 0 && y == 0)
		{
			break;
		}
		if (x > y)
		{
			cout << y << " " << x << endl;
		}
		else
		{
			cout << x << " " << y << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3112
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())

    MOD = int(1e9) + 7

    tmp = abs(N - M)
    if tmp >= 2:
        print(0)
    else:
        ans = 2
        if tmp == 1:
            ans = 1
        for i in range(2, N+1):
            ans *= i
            ans = ans % MOD
        for i in range(2, M+1):
            ans *= i
            ans = ans % MOD
        print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/modint.hpp"



#include <iostream>

// Modint
struct Mint {
    static const long long mod = (long long)1e9 + 7;
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, long long b) {
    return a.pow(b);
}


int main() {
    std::string s; std::cin >> s;
    int n = s.size();
    std::vector<std::vector<Mint>> dp(n + 2, std::vector<Mint>(13));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == '?') {
            for (int d = 0; d < 10; d++) {
                for (int j = 0; j < 13; j++) {
                    dp[i + 1][(10 * j + d) % 13] += dp[i][j];
                }
            }
        }
        else {
            for (int j = 0; j < 13; j++) {
                dp[i + 1][(10 * j + (s[i] - '0')) % 13] += dp[i][j];
            }
        }
    }
    std::cout << dp[n][5] << std::endl;
    return 0;
}

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

int main() {
  int x;
  cin >> x;
  
  int x0 = x / 500;

  int x1 = x - 500 * x0;

  int x2 = x1 / 5;

  cout << 1000 * x0 + 5 * x2 << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""

S=input()
N=len(S)

ans="Yes"

for i in range(int((N-1)/2)):
    if S[i]!=S[N-i-1]: ans="No"

for i in range(int((N-1)/2/2)):  
    if S[i]!=S[int((N-1)/2)-i-1]: ans="No"

for i in range(int(N-(N+3)/2)):
    #print(S[int((N+3)/2)+i],S[N-i-1])
    if S[int((N+3)/2)+i-1]!=S[N-i-1]: ans="No" 

print(ans)


Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var (
		n int
	)

	fmt.Scan(&n)
	mochis := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&mochis[i])
	}

	count := make(map[int]int, n)
	for _, mochi := range mochis {
		count[mochi]++
	}

	fmt.Println(len(count))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
int level[100005]={0},parent[100005]={0},coin[100005]={0},visited[100005]={0};
int main()
{
    ll a[200001]={0};
    int n,k;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    ll min1=1e15,curr=0;
    for(int i=0;i<n-1;i++)
    {
        curr+=a[i];
        sum-=a[i];
        if(abs(curr-sum)<=min1)
            min1=abs(curr-sum);
    }
    cout<<min1;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    map<string, int> judge;
    vector<string> S(N);
    for(int i = 0; i < N; i++) {
        cin >> S[i];
        if(!judge.count(S[i])) judge[S[i]] = 1;
        else judge[S[i]]++;
    }
    cout << "AC x " << judge["AC"] << endl;
    cout << "WA x " << judge["WA"] << endl;
    cout << "TLE x " << judge["TLE"] << endl;
    cout << "RE x " << judge["RE"] << endl;
    return 0;
}

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

int main() {
    int n, q;
    long long k;
    cin >> n >> k >> q;

    vector<long long> p(n, k - q);

    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        p.at(--a)++;
    }

    for (int i = 0; i < n; i++)
        cout << (p.at(i) > 0 ? "Yes" : "No") << endl;
}

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

int gcd(int y, int x){
	if(y<x)swap(y,x);

	if(x==0)return y;
	return gcd(x,y%x);
}

int main(){
	int n,k;	cin>>n>>k;
	string ans="IMPOSSIBLE";

	vector<int> a(n);	for(int i=0;i<n;i++) cin>>a[i];

	int x=a[0];
	int m=1;
	for(int i=0;i<n;i++){
		m=max(m,a[i]);
		x=gcd(x,a[i]);
	}

	if(k<=m && k%x==0)ans="POSSIBLE";

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
#include<set>
struct da
{
	int x;
	long long f;
};
bool operator <(const da &x,const da &y){return x.x<y.x;}
std::multiset<da> s;

int a[555555],b[555555];
int t[555555];
long long add;
int k;
void print()
{
	for(std::multiset<da>::iterator it=s.begin();it!=s.end();++it)
			printf("%lld %lld\n",(it->x+add)%k,it->f);
		puts("");
}
int main()
{	
	int n=io::F();
	k=io::F();
	long long sum=0;
	for(register int i=1;i<=n;++i)a[i]=io::F()*2,b[i]=io::F(),sum+=a[i];
	for(register int i=1;i<=n;++i)
		if(a[i]>k&&b[i]==1)puts("-1"),exit(0);
	for(register int i=1;i<=n;++i)t[i]=(t[i-1]+a[i])%k;
	for(register int i=1;i<=n;++i)s.insert((da){(k-t[i])%k,0});
	for(register int i=1;i<=n;++i)
	{
		//print();
		if(b[i]==1)
		{
			int l=(k-a[i]+1-add+k)%k;
			int r=(k-1-add+k)%k;
			long long min=0x3f3f3f3f3f3f3f3fll;
			if(l<=r)
			{
				std::multiset<da>::iterator it=s.lower_bound((da){l,0}),tmp;
				while(it!=s.end()&&it->x<=r)cmin(min,it->f+r+1-it->x),tmp=it,++it,s.erase(tmp);
			}
			else
			{
				std::multiset<da>::iterator it=s.begin(),tmp;
				while(it!=s.end()&&it->x<=r)cmin(min,it->f+r+1-it->x),tmp=it,++it,s.erase(tmp);
				it=s.lower_bound((da){l,0});
				while(it!=s.end())cmin(min,it->f+r+1+k-it->x),tmp=it,++it,s.erase(tmp);
			}
			if(min!=0x3f3f3f3f3f3f3f3fll)s.insert((da){(k-add)%k,min});
		}
		//print();
		add=(add+a[i])%k;
	}
	//print();
	long long min=0x3f3f3f3f3f3f3f3fll;
	for(std::multiset<da>::iterator i=s.begin();i!=s.end();++i)cmin(min,i->f);
	printf("%lld\n",sum+min);
	return 0;
}

Measured memory_bytes: 11008