akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;

constexpr int INF = 1001001001;

void Main() {
    string s;
    cin >> s;

    int ans = 0;
    string cur_str = { s[0] };
    rep(i, s.length()) {
        if (i == s.length() - 1) {
            ++ans;
            break;
        }
        string next_str = { s[i + 1] };
        /*DUMP(i);
        DUMP(cur_str);
        DUMP(next_str);*/
        if (cur_str == next_str) {
            cur_str = { s[i + 1], s[i + 2] };
            ++ans;
            ++i;
        }
        else {
            cur_str = s[i + 1];
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define int long long

signed main(void){
    string s,t; cin >> s >> t;
    int a,b ; cin  >>  a >> b;
    string u; cin >> u;
    if(u==s) a--;
    else if(u==t)b--;
    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  int n;
  n = s.size();
  
  bool flag = true;
  REP(i,n){
    if(i%2==0){
      if(s[i]=='L'){
        flag = false;
        break;
      }
    }else{
      if(s[i]=='R'){
        flag = false;
        break;
      }
    }
  }
  
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main() {
    int N; cin >> N;
    vector<pair<int, int>> v(N);
    for (int i = 0; i < N; i++){
        cin >> v[i].first;
        v[i].second = i;
    } 
    sort(v.begin(), v.end());
    int p = v.size()/2-1;
    int n = p+1;
    vector<int> result(N);
    for (int i = 0; i < N; i++)
    {
        if(i<=p) result[v[i].second] = v[n].first;
        else result[v[i].second] = v[p].first;
    }
    
    for(int i : result){
        cout << i << endl;
    }
}

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

using namespace std;

#define mem(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
typedef long long ll;

const int maxn=1e5+5;
priority_queue<int,vector<int>,greater<int> > q;
int n;

int main() {
    while(~scanf("%d",&n)) {
        while(!q.empty()) q.pop();
        rep(i,1,n) {
            int val;
            scanf("%d",&val);
            q.push(val);
        }
        while(q.size()>=2) {
            int x=q.top();
            q.pop();
            if(x==0) continue;
            int y=q.top();
            q.pop();
            q.push(x);
            q.push(y%x);
        }
        int ans=q.top();
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 892
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int m, k;
	cin >> m >> k;
	if (m == 0) {
		if (k != 0)cout << "-1" << endl;
		else cout << "0 0" << endl;
	}
	else if (m == 1) {
		if (k != 0)cout << "-1" << endl;
		else cout << "0 0 1 1" << endl;
	}
	else {
		if (k >= (1 << m)) {
			cout << "-1" << endl;
		}
		else {
			VI ans(1 << (m + 1));
			ans[(1 << m) - 1] = k;
			ans[(1 << (m + 1)) - 1] = k;
			REP(i, (1 << m) - 1) {
				ans[i] = i + (i >= k);
				ans[(1<<(m+1))-2-i] = i + (i >= k);
			}
			REP(i, 1 << (m + 1)) {
				printf("%d ", ans[i]);
			}
			printf("\n");
		}

	}
	
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll i,j,k,n,m,p=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++)
    {

        cin>>ara[i];
    }
    ll mn=INT_MAX;
    for(i=1;i<=100;i++)
    {

        for(j=0;j<n;j++)
        {
            p+=(ara[j]-i)*(ara[j]-i);


        }
        if(mn>p)
        {
            mn=p;
        }
        p=0;
    }
    cout<<mn<<endl;

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<float> x(n);
    vector<string> u(n);
    float ans=0;
    float btc=380000;
    for(int i=0;i<n;i++){
        cin>>x[i]>>u[i];
        if(u[i]=="JPY") ans+=x[i];
        else ans+=x[i]*btc;
    }
    cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

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 n;
ll w, weight[110], value[110];
ll dp[110][100010] = {0};

void solve() {
    cin >> n >> w;
    rep(i, 0, n) cin >> weight[i] >> value[i];
    // dp[i][sum_w] : i-1番目まで選んだとき…
    // dp loop
    rep(i, 0, n){
        Rep(sum_w, 0, w){
            if(sum_w - weight[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w-weight[i]]+value[i]);
            }
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[n][w] << endl;
}

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

    solve();
    return 0;
}


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

a = [-1]*N

for i in range(M):
  s,c = map(int,input().split())
  if a[s-1] == -1:
    a[s-1] = c
  else:
    if a[s-1] != c:
      print(-1)
      exit()
if a[0] == -1:
  if N ==1:
    a[0] = 0
  else:
    a[0] = 1
for i in range(N):
  if a[i] == -1:
    a[i] = 0
if N != 1 and a[0] == 0:
  print(-1)
  exit()
  
print("".join(map(str,a)))

Measured memory_bytes: 38256
# coding: utf-8
# Your code here!

import sys
n = int(input())

inf = float("inf")
u=d=l=r=0
umin = inf
umax = -inf
dmin = inf
dmax = -inf
lmin = inf
lmax = -inf
rmin = inf
rmax = -inf
xmin = inf
xmax = -inf
ymin = inf
ymax = -inf
xx=yy=0

for j in range(n):
    x,y,D = [i for i in input().split()]
    x=int(x); y=int(y)
    if D == "U":
        umin = min(umin,y)
        umax = max(umax,y)
        u=1
        xmin = min(xmin,x)
        xmax = max(xmax,x)
        xx=1
    if D == "D":
        dmin = min(dmin,y)
        dmax = max(dmax,y)
        d=1
        xmin = min(xmin,x)
        xmax = max(xmax,x)
        xx=1
    if D == "L":
        lmin = min(lmin,x)
        lmax = max(lmax,x)
        l=1
        ymin = min(ymin,y)
        ymax = max(ymax,y)
        yy=1
    if D == "R":
        rmin = min(rmin,x)
        rmax = max(rmax,x)
        r=1
        ymin = min(ymin,y)
        ymax = max(ymax,y)
        yy=1

def lpos(t):
    ans = inf
    if xx: ans = min(ans,xmin)
    if l: ans = min(ans,lmin-t)
    if r: ans = min(ans,rmin+t)
    return ans
def rpos(t):
    ans = -inf
    if xx: ans = max(ans,xmax)
    if l: ans = max(ans,lmax-t)
    if r: ans = max(ans,rmax+t)
    return ans

def dpos(t):
    ans = inf
    if yy: ans = min(ans,ymin)
    if u: ans = min(ans,umin+t)
    if d: ans = min(ans,dmin-t)
    return ans
def upos(t):
    ans = -inf
    if yy: ans = max(ans,ymax)
    if u: ans = max(ans,umax+t)
    if d: ans = max(ans,dmax-t)
    return ans

s = {0}
if xx and l:
    if lmin - xmin > 0: s.add(lmin - xmin)
    if lmax - xmax > 0: s.add(lmax - xmax)
if xx and r:
    if xmin - rmin > 0: s.add(xmin - rmin)
    if xmax - rmax > 0: s.add(xmax - rmax)
if l and r:
    if lmin-rmin > 0: s.add((lmin-rmin)/2)
    if lmax-rmax > 0: s.add((lmax-rmax)/2)

if yy and d:
    if dmin - ymin > 0: s.add(dmin - ymin)
    if dmax - ymax > 0: s.add(dmax - ymax)
if yy and u:
    if ymin - umin > 0: s.add(ymin - umin)
    if ymax - umax > 0: s.add(ymax - umax)
if d and u:
    if dmin-umin > 0: s.add((dmin-umin)/2)
    if dmax-umax > 0: s.add((dmax-umax)/2)
    
#print(rmax,xmax)

ans = 10**18
for t in s:
#    print(rpos(t),lpos(t),dpos(t),upos(t),xmin,ymin,xmax,ymax,xx,yy)
    area = (rpos(t)-lpos(t))*(upos(t)-dpos(t))
#    print(t,area)
    if area < ans:
        ans = area

print(ans)
    












Measured memory_bytes: 3320
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 203000;

    void solve() {
      ll n;
      cin >> n;
      ll a[n];
      rep(i, n) cin >> a[i], a[i]-=(i+1);
      sort(a, a+n);
      ll val1 = a[n/2 - 1], val2 = a[n/2], sum1 = 0, sum2 = 0;
      rep(i, n) sum1+=abs(a[i] - val1), sum2+=abs(a[i] - val2);
      cout << min(sum1, sum2) << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            exit(0);
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            exit(0);
        }
    }

    return 0;
}

Measured memory_bytes: 3652
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf8"));

function main(input) {
  const [hw, ...s] = input.trim().split("\n");
  const [h, w] = hw.split(" ").map(Number);
  const S = s.map(e => e.split(""));

  const bomb = "#";

  let ans = "";
  for(let i = 0; i < h; i++) {
    for(let j = 0; j < w; j++) {
      let cnt = 0;
      if(S[i][j] === bomb) {
        ans += bomb;
        continue;
      }
      if(S[i][j + 1] === bomb) { cnt++; }
      if(S[i][j - 1] === bomb) { cnt++; }
      if(S[i - 1] && S[i - 1][j - 1] === bomb) { cnt++; }
      if(S[i - 1] && S[i - 1][j] === bomb) { cnt++; }
      if(S[i - 1] && S[i - 1][j + 1] === bomb) { cnt++; }
      if(S[i + 1] && S[i + 1][j - 1] === bomb) { cnt++; }
      if(S[i + 1] && S[i + 1][j] === bomb) { cnt++; }
      if(S[i + 1] && S[i + 1][j + 1] === bomb) { cnt++; }
      ans += cnt;
    }
    ans += "\n";
  }

  console.log(ans);
}


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll m[100005]={0};
int main()
{
    #define int long long
    ios::sync_with_stdio(false);
    int n,q,temp,tot=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>temp;
        m[temp]++;
        tot+=temp;
    }

    cin>>q;
    int a,b;
    while(q--)
    {
        cin>>a>>b;
        tot+=m[a]*(b-a);
        m[b]+=m[a];
        m[a]=0;
        cout<<tot<<endl;
    }
    return 0;
}



Measured memory_bytes: 4440
k = int(input())
a = list(map(int, input().split()))

result = 1000
stock = 0

day = 0

dif = []
for i in range(len(a) - 1):
    dif.append(a[i+1]-a[i])

for i in range(len(dif)):
    if dif[i] > 0:
        stock += result // min(a[day:i+1])
        result -= (result // min(a[day:i+1]))*min(a[day:i+1])
        
        result += stock*a[i+1]
        stock = 0
        
        day = i+1
print(result)

Measured memory_bytes: 9216
#include <stdio.h>

int main(){
   char s[100001];
   long sum;
   int i,n,c[26];
    
   scanf("%d",&n);
   scanf("%s",s);
   for (i=0;i<26;i++) c[i]=0;
   for (i=0;i<n;i++) c[s[i]-'a']++;
   sum=0;
   for (i=0;i<26;i++) {
      if (c[i]==1) sum=(sum*2+1)%1000000007;
      else if (c[i]>1 && sum==0) sum=c[i];
      else if (c[i]>1) sum=(sum*(c[i]+1)+c[i])%1000000007;
   }
   printf("%ld\n",sum);
   return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    string n;
    cin >> n;
    char x = n[n.length() - 1];
    if(x=='3'){
        c("bon");
    }else if(x=='0'||x=='1'||x=='6'||x=='8'){
        c("pon");
    }else
        c("hon");
    return 0;
}


Measured memory_bytes: 3660
N = int(input())
S = input()[::-1]

BCS = [0]
for i in range(N):
    if S[i] == '#':
        BCS.append(BCS[-1] + 1)
    else:
        BCS.append(BCS[-1])

ans = N
for i in range(len(BCS)):
    wh_to_bk = i - BCS[i]
    bk_to_wh = BCS[-1] - BCS[i]
    ans = min(ans, wh_to_bk + bk_to_wh)

print(ans)


Measured memory_bytes: 11196
import java.util.*;
/*
import java.util.ArrayList;
import java.util.List;
*/

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    List<Integer> list = new ArrayList<Integer>();
    for(int i = 0; i < 3; i++) {
      int n = sc.nextInt();
      list.add(n);
    }

    int length = list.size();

    for(int i = 0; i < length - 1; i++) {
      for(int j = length - 1; j > i; j--) {
        if (list.get(j - 1) > list.get(j)) {
          int min = list.get(j - 1);
          list.set(j - 1,list.get(j));
          list.set(j, min);
        }
      }
    }
    String answer = "";
    for(int i = 0; i < length; i++) {

      if(i != 2) {
        answer += list.get(i) + " ";
      } else {
        answer += list.get(i);
      }
    }

    System.out.println(answer);

    sc.close();
  }
}


Measured memory_bytes: 26208
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int X, A;
	cin >> X >> A;
	if (X < A) cout << 0 << endl;
	else cout << 10 << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int counter[200010];
int rui[200010];
const int P=2019;
int ans;
int N;

signed main()
{
	string S; cin>>S;
	N=S.size();
	S = ' ' + S;
	counter[0]++;
	int ten = 1;
	for (int i = N; i >= 1; --i) {
		rui[i] += rui[i + 1];
		rui[i] += (S[i] - '0') * ten;
		rui[i] %= P;

		ans += counter[rui[i]];
		counter[rui[i]]++;

		ten *= 10;
		ten %= P;
	}

	cout<<ans<<endl;
}



Measured memory_bytes: 5332
n = int(input())
a = list(map(int, input().split()))
a_max = max(a)
lst = [0] * (a_max + 1)
cnt = 0
for i in a:
    if lst[i] > 1:  # 配列中のカウントが2以上なら以降の処理を省略
        continue
    for j in range(a_max // i + 1):  # Aiの倍数にインクリメント(配列の上限はa[-1])
        lst[i * j] += 1
    # lst[1::i] += 1
for i in a:
    if lst[i] == 1:
        cnt += 1
print(cnt)

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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("../input.txt","r",stdin);

    int K;
    cin >> K;

    ll num = 0;
    int ans = -1;
    for (int i = 1; i <=(int)1e6; ++i) {
        num = (num*10 + 7)%K;
        if(num%K == 0){
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
    
}

Measured memory_bytes: 3616
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    string s;
    rep(i,0,c-a) s+="R";
    rep(i,0,d-b) s+="U";
    rep(i,0,c-a) s+="L";
    rep(i,0,d-b) s+="D";
    s+="D";
    rep(i,0,c-a+1) s+="R";
    rep(i,0,d-b+1) s+="U";
    s+="L";
    s+="U";
    rep(i,0,c-a+1) s+="L";
    rep(i,0,d-b+1) s+="D";
    s+="R";
    cout << s;
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    ll A,B,K;
    cin >> A >> B >> K;

    if(K >= A){
        K -= A;
        A = 0;
        B -= K;
        B = max(B, 0ll);
    }else{
        A -= K;
    }

    cout << A << " " << B << endl;
}

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

// return the divisor of n
std::vector<int64_t> divisor(int64_t n) noexcept {
    std::vector<int64_t> ret;
    for (int64_t i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            if (i != 1) {
                ret.push_back(i);
            }

            if (i != n / i) {
                ret.push_back(n / i);
            }
        }
    }

    return ret;
}

int main() {
    int64_t N;
    std::cin >> N;

    int64_t ans = 0;
    const std::vector<int64_t> n1 = divisor(N - 1);
    ans += n1.size();

    const std::vector<int64_t> n = divisor(N);
    for (int64_t v : n) { 
        int64_t buf = N; 
        while (buf % v == 0) {
            buf /= v;
        }

        if (buf % v == 1) {
            ++ans;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3592
#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,val = 0,ans = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        if(a[i] >= a[i+1]){
            val++;
        } else {
            val = 0;
        }
        ans = max(ans, val);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    string s[N];
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }
    int M;
    cin >> M;
    string t[M];
    for(int i = 0; i < M; i++){
        cin >> t[i];
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        int max = 0;
        for(int j = 0; j < M; j++){
            if(s[i]==t[j]) max--;
        }
        for(int j = 0; j < N; j++){
            if(s[i]==s[j]) max++;
        }

        if(ans < max) ans = max;
    }

    if(ans >= 0) cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

judge_count = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0,
}
for judge in s:
    judge_count[judge] += 1

for judge, count in judge_count.items():
    print(f'{judge} x {count}')


Measured memory_bytes: 16152
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

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

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll N;
    vector<vector<ll>> A(3, vector<ll>(3, 0));
    REP(i, 3) {
        in >> A[i][0] >> A[i][1] >> A[i][2];
    }
    vector<vector<bool>> open(3, vector<bool>(3, false));
    in >> N;
    vector<ll> b(N);
    REP(x, N) {
        in >> b[x];
        REP(i, 3) {
            REP(j, 3) {
                if (A[i][j] == b[x]) {
                    open[i][j] = true;
                }
            }
        }
    }

    bool ret = [&]() {
        REP(i, 3) {
            if (open[i][0] && open[i][1] && open[i][2]) return true;
        }
        REP(j, 3) {
            if (open[0][j] && open[1][j] && open[2][j]) return true;
        }
        if (open[0][0] && open[1][1] && open[2][2]) return true;
        if (open[2][0] && open[1][1] && open[0][2]) return true;
        return false;
    }();
    string ans = ret ? "Yes": "No";

    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int k,n;
const ll MOD=1e9+7;
int f[2333][2333][2];
int main()
{
	cin>>n>>k;
	f[n+1][0][1]=1;
	for(int i=n+1;i>1;--i)
	{
		for(int j=n;~j;--j)
			(f[i][j][0]+=f[i][j+1][0])%=MOD;
		for(int j=0;j<=n;++j)
			for(int s=0;s<2;++s)
				(f[i-1][j+1][1]+=f[i][j][s])%=MOD,
				(f[i-1][j][0]+=f[i][j][s])%=MOD;
	}
	ll ans=f[1][n-k][0];
	for(int i=1;i<=n-k-1;++i) ans=ans*2%MOD;
	printf("%d\n",int(ans));
}


Measured memory_bytes: 37120
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		
		//テキスト入力クラス
		Scanner sc = new Scanner(System.in);
		DecimalFormat df2 = new DecimalFormat("##########.##########");
		
		//半径
		double radius = sc.nextDouble(); 
		//面積
		double area = radius*radius*Math.PI;
		//周の長さ
		double circuit = radius*2*Math.PI;
		
		System.out.print(df2.format(area)+" "+df2.format(circuit));
		
	}

}

Measured memory_bytes: 18420
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#include <queue>
#define Inf 10000000000ll
#define ll long long
using namespace std;


bool InBoundary(int x,int y,int H,int W) {
    if (x==0 || x==H-1 || y==0 || y==W-1)
        return true;
    else
        return false;
}

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

// K,K


pair<int,int> BFS[2][888*888];
bool done[888][888];
int main() {
    int H,W,K;
    cin>>H>>W>>K;
    
    for(int i=0;i<H;i++)
        cin>>G[i];
    
    int stx,sty;
    
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
        {
            done[i][j]=false;
            if (G[i][j]=='S') {
                stx=i;
                sty=j;
            }
        }
    
    
    vector<pair<int,int> > all_pts;
    
    BFS[0][0]=make_pair(stx,sty);
    all_pts.push_back(make_pair(stx,sty));
    done[stx][sty]=true;
    int sz=1;
    
    for(int iters=0;iters<K;iters++) {
        int nsz=0;
        
        for(int j=0;j<sz;j++) {
            int cx=BFS[iters&1][j].first;
            int cy=BFS[iters&1][j].second;
            
            if (InBoundary(cx,cy,H,W)) {
                break;
            }
            
            
            for(int d=0;d<4;d++) {
                int nx=cx+dx[d];
                int ny=cy+dy[d];
                
                if (done[nx][ny] || G[nx][ny]=='#')
                    continue;
                
                done[nx][ny]=true;
                
                BFS[(iters+1)&1][nsz++]=make_pair(nx,ny);
                all_pts.push_back(make_pair(nx,ny));

            }
        }
        sz=nsz;
    }
    
    ll ans=Inf;
    
    for(int j=0;j<all_pts.size();j++) {
        int x=all_pts[j].first;
        int y=all_pts[j].second;
        // ceil(x/K), ceil((H-1-x)/K)
        // ceil(y/K), ceil((W-1-y)/K)
        
        
        ans = min(ans, 1+(ll)(x+K-1)/K);
        ans = min(ans, 1+(ll)(H-1-x+K-1)/K);
        ans = min(ans, 1+(ll)(y+K-1)/K);
        ans = min(ans, 1+(ll)(W-1-y+K-1)/K);
    }
    
    
    cout << ans << endl;
    

    
    
}

Measured memory_bytes: 6008
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m, k = map(int, input().split())

uf = UnionFind(n)
n_friend = [0 for i in range(n)]

for i in range(m):
    ai, bi = map(int, input().split())
    uf.union(ai-1, bi-1)
    n_friend[ai-1] += 1
    n_friend[bi-1] += 1
for i in range(n):
    uf.find(i)

block = [[] for i in range(n)]
for i in range(k):
    ci, di = map(int, input().split())
    block[ci-1].append(di-1)
    block[di-1].append(ci-1)

lst = []
for i in range(n):
    num = uf.size(i) - n_friend[i] - 1
    for j in block[i]:
        if uf.find(i) == uf.find(j):
            num -= 1
    lst.append(num)

print(' '.join(map(str, lst)))

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

int main() {
    int n;cin>>n;
    string str;cin>>str;
    long ans=0;
    
    long r,g,b;
    r=count(str.begin(),str.end(),'R');
    g=count(str.begin(),str.end(),'G');
    b=count(str.begin(),str.end(),'B');

    ans=r*g*b;

    for(int i=0;i<n;++i){
        for(int j=1;i+2*j<n;++j){
        if(str[i]!=str[i+j] &&str[i]!=str[i + 2*j] &&str[i+j]!=str[i + 2*j])ans-=1;
        }
        }
    cout<<ans<<endl;

	return 0;
}

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

double pA[6];
double pB[6];
double wynn = 1.0;

void sprawdz(double p) {
	double res = 0.0;
	for(int i = 0; i < 6; ++i) {
		if(pA[i] + pB[i] < 1e-8) continue;
		double pom = pB[i] / (pA[i] + pB[i]);
		
		double ww;
		if(p > pom) ww = p * pA[i];
		else ww = (1.0 - p) * pB[i];
		res += ww;
	}
	wynn = min(wynn, res);
}

int main() {
	ios_base::sync_with_stdio(0);
	for(int i = 0; i < 6; ++i) cin >> pA[i];
	for(int i = 0; i < 6; ++i) cin >> pB[i];

	for(int i = 0; i < 6; ++i) {
		pA[i] /= 100.0;
		pB[i] /= 100.0;
	}
	
	for(int i = 0; i < 6; ++i) {
		if(pA[i] + pB[i] < 1e-8) continue;
		double pp = pB[i] / (pA[i] + pB[i]);
		sprawdz(pp);
	}
	
	cout.precision(12);
	cout << fixed;
	cout << wynn << endl;
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while (c >= 0 || a >= 0) {
    c -= b;
    a -= d;
    
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3600
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
template<class T> T read_val() { throw 1; }
template<> int read_val() { int tmp; scanf("%" PRId32, &tmp); return tmp; }
template<> long long read_val() { long long tmp; scanf("%" PRId64, &tmp); return tmp; }
auto read_int = read_val<int>; auto read_long = read_val<long long>;
template<class T> void scanf_vec(vector<T>& vec) { for (int i = 0; i < vec.size(); i++) vec[i] = read_val<T>(); }

#define MOD 1000000007
#define inf 2000000000
#define FWT_SIZE 2000000
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())


int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	int n;
	cin >> n;

	vector<pii> inp(n);
	int max_left = 0, min_right = 1e9 + 1, longest = 0;
	multiset<pii> ll; multiset<int> rr;
	for (int i = 0; i < n; i++)
	{
		cin >> inp[i].first >> inp[i].second;
		max_left = max(max_left, inp[i].first);
		min_right = min(min_right, inp[i].second);
		longest = max(longest, inp[i].second - inp[i].first + 1);
	}

	for (int i = 0; i < n; i++)
	{
		if (inp[i].first != max_left)
			ll.insert({ inp[i].first, inp[i].second });
		else
			rr.insert(inp[i].second);
	}

	int ans = longest;
	if (max_left <= min_right)
	{
		ans += min_right - max_left + 1;
	}

	while (ll.size() > 0)
	{
		ans = max(ans, min_right - ll.rbegin()->first + 1 + *rr.begin() - max_left + 1);
		auto x = *ll.rbegin();
		ll.erase(ll.find(x));
		rr.insert(x.second);
	}

	cout << ans;

	return 0;
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

vector<string> M;

int main(){

    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        
        vector<int> a(n);
        REP(i,n)cin>>a[i];
        sort(a.begin(),a.end());
        
        int ans=0;
        for(int i=1;i<n-1;i++){
            ans+=a[i];
        }
        
        cout<<ans/(n-2)<<endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 3076
from sys import stdin
n=int(input())
total=0
cartes=[0]*n
for i in range(n):
    nbCarte=int(stdin.readline())
    cartes[i]=nbCarte

for i in range(n-1):
    if cartes[i]%2==1 and cartes[i+1]!=0:
        cartes[i]-=1
        cartes[i+1]-=1
        total+=1
for i in range(n):
    total+=cartes[i]//2
print(total)

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

int w, h;
int c[26] = { 0 };

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char ch;
			cin >> ch;
			c[ch - 'a']++;
		}
	}
	int sum4 = 0, sum2 = 0, sum1 = 0;
	for (int i = 0; i < 26; i++) {
		if (c[i] % 2 == 1) {
			sum1++;
		}
		else if (c[i] % 4 != 0 && c[i] % 2 == 0) {
			sum2++;
		}
	}
	if (h % 2 == 0) {
		if (w % 2 == 1) {
			if (sum1 > 0) {
				cout << "No" << endl; return 0;
			}
			if (sum2 > h / 2) {
				cout << "No" << endl; return 0;
			}
			cout << "Yes" << endl; return 0;
		}
		else {
			if (sum1 > 0 || sum2 > 0) {
				cout << "No" << endl; return 0;
			}
			cout << "Yes" << endl;
		}
	}
	else {
		if (w % 2 == 1) {
			if (sum1 > 1) {
				cout << "No" << endl; return 0;
			} 
			if (sum2 > w / 2 + h / 2) {
				cout << "No" << endl; return 0;
			}
			cout << "Yes" << endl; return 0;
		}
		else {
			if (sum1 > 0) {
				cout << "No" << endl; return 0;
			}
			if (sum2 > w / 2) {
				cout << "No" << endl; return 0;
			}
			cout << "Yes" << endl; return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x;
    scanf("%d", &x);
    switch (x % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon");
        break;
    case 3:
        printf("bon");
        break;
    default:
        break;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int* a = new int[n];
    for(int i = 0; i < n; i++) 
        cin >> a[i];
    
    for(int i = n - 1; i > 0; i--)
        cout << a[i] << ' ';
    cout << a[0] << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> W(N);
  rep(i, N) cin >> W[i];

  vector<int> s(N + 1, 0);
  rep(i, N) s[i + 1] = s[i] + W[i];
  ll ans = INF;
  for (int t = 0; t < N; ++t){
    ll s1 = s[t + 1];
    ll s2 = s[N] - s[t + 1];
    chmin(ans, abs(s1 - s2));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
data = np.zeros((4, M))
 
for i in range(M):
    data[0, i] = i+1
    data[1:3, i] = list(map(int, input().split()))
 
city = [0 for i in range(N)]
data = data[:, np.argsort(data[2, :])]
for i in range(M):
    city[int(data[1, i]-1)] += 1
    data[3, i] = city[int(data[1, i]-1)]
 
data = data[:, np.argsort(data[0, :])]
for i in range(M):
    tmp = str(int(data[1, i])).zfill(6) + str(int(data[3, i])).zfill(6)
    print(tmp)

Measured memory_bytes: 20316
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

void Main() {
  ll n;
  R n;
  ll a[n],b[n],ans=0;
  rep(i,n) cin >> a[i] >> b[i];
  PP p[n];
  rep(i,n) p[i]=PP(a[i]+b[i],P(a[i],b[i]));
  sort(p,p+n,greater<PP>());
  rep(i,n) {
    if(i%2==0) ans+=p[i].S.F;
    else ans-=p[i].S.S;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main()
{
  int n;
  scanf("%d",&n);
  static char s[40];
  scanf("%s",s);
  long long ans=0ll;
  long long dp[40][40];
  for(int I=0;I<(1<<n);I++){
    char r[40],b[40];
    int nr=0,nb=0;
    for(int i=0;i<n;i++){
      if((I>>i)&1){
	r[nr++]=s[i];
      }
      else{
	b[nb++]=s[i];
      }
    }
    dp[0][0]=1ll;
    for(int i=0;i<=nr;i++){
      for(int j=(i==0?1:0);j<=nb;j++){
	int k=2*n-i-j;
	dp[i][j]=(i>0&&s[k]==r[i-1]?dp[i-1][j]:0)+(j>0&&s[k]==b[j-1]?dp[i][j-1]:0);
      }
    }
    ans+=dp[nr][nb];
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7

ans = 0
tmp = 0
tmp2 = 0
for i in range(N):
    for j in range(i):
        if A[i] < A[j]:
            tmp += 1
    for j in range(N):
        if A[i] > A[j]:
            tmp2 += 1

k = (K * (K-1) // 2) % mod
ans = ans + (tmp * K % mod) + (tmp2 * k % mod)
print(ans % mod)


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n;
  vector<string> v;
  cin >> n;
  int cnt = 0;
  rep(i,n) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  std::sort(v.begin(), v.end());
  decltype(v)::iterator result = std::unique(v.begin(), v.end());
  v.erase(result, v.end());
  cout << v.size() << endl;
  return 0;
}


Measured memory_bytes: 11600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;


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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),ans(n);
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n) cin>>b[i];
  vector<LP> c(n);//a-bの差,添字
  REP(i,n){
    c[i].first=a[i]-b[i];
    c[i].second=i;
    ans[i]=c[i].first;
  }
  VRSORT(c);
  //REP(i,n){
    //cout << c[i].first<<" "<<c[i].second<<endl;
  //}
  ll i=0,j=n;

  while(c[i].first>0){

    if(c[j].first>0)break;//もう足りる

    if(c[i].first>=abs(c[j].first)){//足りる
      c[i].first -= abs(c[j].first);
      a[c[i].second] += abs(c[j].first);
      c[j].first=0;
      j--;
    }
    else{//足りない
      a[c[i].second] += c[i].first;
      c[j].first += c[i].first;
      c[i].first=0;
      i++;
    }
  }
  ll diff=0;
  REP(i,n){
    if(c[i].first<0){
      cout << -1 << endl;
      return 0;
    }
    if(c[i].first!=ans[c[i].second]) diff++;
  }
  cout << diff << endl;
}

Measured memory_bytes: 4224