akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>

int gcd(int a,int b){
    if(a<b){
        int now=a;
        a=b;
        b=a;
    }

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

    return b;
}



/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

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

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}



int main(void){
    char c;
    scanf("%c",&c);
    int d=c-'A';
    if(d<=26){
        printf("A\n");
    }
    else{
        printf("a\n");
    }
}

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

long long a, b, x, cnt = 0;

int main() {
  cin >> a >> b >> x;
  if(a == 0) ++cnt;
  cout << b / x - max(0LL, (a - 1)) / x + cnt << endl;
  return 0;
}

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

int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> vec;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin >> a[i];
        vec.push_back(make_pair(a[i],1));
    }
    for(ll i=0;i<m;i++){
        ll b,c;
        cin >> b >> c;
        vec.push_back(make_pair(c,b));
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    ll res=0;
    ll count=0;
    for(ll i=0;i<vec.size();i++){
        if(count+vec[i].second<n){
            res+=vec[i].first*vec[i].second;
            count+=vec[i].second;
        }
        else{
            res+=vec[i].first*(n-count);
            break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 8208
#include <iostream>
#include <cstdlib>
#include <map>

using namespace std;

const int MAXN = 1e5 + 10;
int ar[MAXN];

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

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


int main()
{
    // freopen("tmp.txt", "r", stdin);

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

    // if all zero than n doesn't matter
    bool nz = false;
    for (int i = 0; i < n and not nz; ++i)
        if (ar[i] != 0)
            nz = true;
    if (not nz)
    {
        yes();
    }

    if (n % 3 != 0)
    {
        no();
    }

    map<int, int> unique;
    for (int i = 0; i < n; ++i)
    {
        auto iter = unique.find(ar[i]);
        if (iter != unique.end())
        {
            int count = iter->second + 1;
            unique.erase(iter);
            unique.emplace(ar[i], count);
        }
        else
            unique.emplace(ar[i], 1);
        if (unique.size() > 3)
        {
            break;
        }
    }

    if (unique.size() > 3 or unique.size() == 1)
    {
        no();
    }

    if (unique.size() == 2)
    {
        auto iter = unique.begin();
        int i1 = iter->first, c1 = iter->second;
        ++iter;
        int i2 = iter->first, c2 = iter->second;
        if (c1 > c2)
        {
            swap(c1, c2);
            swap(i1, i2);
        }
        if (c1 == n / 3 and c2 == c1 * 2)
        {
            if ((i1 ^ i2 ^ i2) == 0)
                yes();
            else
                no();
        }
        else
            no();
    }
    else
    {
        auto iter = unique.begin();
        int i1 = iter->first, c1 = iter->second;
        ++iter;
        int i2 = iter->first, c2 = iter->second;
        ++iter;
        int i3 = iter->first, c3 = iter->second;
        if (not (c1 == c2 and c1 == c3 and c1 == n / 3))
            no();
        else if (not ((i1 ^ i2 ^ i3) == 0))
            no();
        else
            yes();
    }

}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N, Q;
int s[1000000], ss[1000000];
std::vector<int> leaders;

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

    REP(i, N){
        std::cin >> s[i];
        ss[i] = s[i];
    }

    std::sort(ss, ss+N);

    REP(i, Q){
        std::string query;
        std::cin >> query;

        if(query == "ADD"){
            int a;
            std::cin >> a;
            a -= 1;

            leaders.push_back(a);
        }else if(query == "REMOVE"){
            int a;
            std::cin >> a;
            a -= 1;

            leaders.erase(std::find(leaders.begin(), leaders.end(), a));
        }else{
            int x;
            std::cin >> x;

            int lb = -1, ub = INF;
            while(ub - lb > 1){
                int mid = (lb+ub) / 2;
                std::vector<P> bs;
                
                for(auto l : leaders){
                    bs.push_back(mp(s[l]-mid, s[l]));
                }

                std::sort(bs.begin(), bs.end(),
                          [](const P& lhs, const P& rhs){if(lhs.first != rhs.first){return lhs.first < rhs.first;} return lhs.second < rhs.second;});

                for(int i=0;i+1<(int)bs.size();){
                    if(bs[i].first <= bs[i+1].first && bs[i+1].first <= bs[i].second){
                        bs[i].second = bs[i+1].second;
                        bs.erase(bs.begin()+i+1);
                    }else{
                        i += 1;
                    }
                }

                int res = 0;
                for(auto b : bs){
                    res += std::upper_bound(ss, ss+N, b.second) - std::lower_bound(ss, ss+N, b.first);
                }

                if(N-res <= x){
                    ub = mid;
                }else{
                    lb = mid;
                }
            }

            if(ub != INF){
                std::cout << ub << std::endl;
            }else{
                std::cout << "NA" << std::endl;
            }
        }
    }
}

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7, INF = 1e18 + 7;
int x, y, z, a[N][3], per[N], pref[N], post[N];
bool comp(int i, int j) {
    return a[i][2] - a[i][1] < a[j][2] - a[j][1];
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> x >> y >> z;
    int n = x + y + z;
    for (int i = 0; i < n; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
    int add = 0;
    for (int i = 0; i < n; ++i) {
        a[i][1] -= a[i][0]; a[i][2] -= a[i][0];
        add += a[i][0];
    }   
    for (int i = 0; i < n; ++i) per[i] = i;
    sort(per, per + n, comp);
 
    for (int i = 0; i < N; ++i) pref[i] = post[i] = -INF;
 
    multiset <int> ms; int sum = 0;
    for (int i = 0; i < y; ++i) {
        int v = a[per[i]][1];
        ms.insert(v); sum += v;
    }   
    pref[y] = sum;
    for (int i = y; i < n; ++i) {
        int v = a[per[i]][1];
        if (*ms.begin() < v) {
            sum += v - *ms.begin();
            ms.erase(ms.begin());
            ms.insert(v);
        }   
        pref[i + 1] = sum;
    }   
 
    ms.clear(); sum = 0;
    for (int i = n - 1; i >= n - z; --i) {
        int v = a[per[i]][2];
        ms.insert(v); sum += v;
    }   
    post[n - z] = sum;
    for (int i = n - z - 1; i >= 0; --i) {
        int v = a[per[i]][2];
        if (*ms.begin() < v) {
            sum += v - *ms.begin();
            ms.erase(ms.begin());
            ms.insert(v);
        }   
        post[i] = sum;
    }       
 
    int ans = -INF;
    for (int i = 0; i <= n; ++i) ans = max(ans, pref[i] + post[i]);
    cout << ans + add << '\n';
}   

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n - 1; i++){
        int counter = 0;
        for (char c='a'; c <= 'z';c++){
            bool left = false, right = false;
            for (int j = 0; j < i; j++){
                if (s[j] == c){
                    left = true;
                }
            }
            for (int j = i; j < n; j++){
                if (s[j] == c){
                    right = true;
                }
            }
            if (left && right){
                counter++;
            }
        }
        ans = max(ans,counter);
    }
    cout << ans << endl;
}

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

typedef unsigned long long ULL;
typedef long long LL;

const int PI = 3.1415926535;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 100007;


int main() {
	
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int n, x, t; cin >> n >> x >> t;
	LL ans = (n + x - 1) / x;
	cout << ans * 1LL * t << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
  int h,w;
  cin>>h; cin>>w;
  vector<string> a(h);
  for(int i=0;i<h;i++){
    cin>>a[i];
  }
  vector<bool> row(h,false);
  vector<bool> col(w,false);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(row[i]){
      for(int j=0;j<w;j++){
        if(col[j]) cout<<a[i][j];
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,i,c=0;
    string s="ABC",t;
    cin>>n>>t;
    for(i=0;i<n-2;i++)
        if(t.substr(i,3)==s)
        c++;
    cout<<c<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class RangeAdd
{
private:
    vector<vector<long long> > data;
public:
    RangeAdd(int h, int w){
        data.assign(h+1, vector<long long>(w+1, 0));
    }
    void add(int y1, int x1, int y2, int x2, long long val){
        data[y1][x1] += val;
        data[y1][x2+1] -= val;
        data[y2+1][x1] -= val;
        data[y2+1][x2+1] += val;
    }
    void get(vector<vector<long long> >& ans){
        int h = data.size() - 1;
        int w = data[0].size() - 1;
        for(int y=0; y<h; ++y){
            for(int x=1; x<w; ++x)
                data[y][x] += data[y][x-1];
        }
        for(int y=1; y<h; ++y){
            for(int x=0; x<w; ++x){
                data[y][x] += data[y-1][x];
            }
        }
        ans.swap(data);
        data.clear();
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n-1);
    for(int i=0; i<n-1; ++i)
        cin >> a[i];
    vector<vector<int> > b(m, vector<int>(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            cin >> b[j][i];
        }
    }

    RangeAdd ra(n, n);
    for(int i=0; i<m; ++i){
        vector<pair<int, int> > v(n);
        for(int j=0; j<n; ++j)
            v[j] = make_pair(b[i][j], j);
        sort(v.rbegin(), v.rend());

        set<int> s;
        s.insert(-1);
        s.insert(n);
        for(const auto& p : v){
            int val = p.first;
            int k = p.second;
            auto it = s.lower_bound(k);
            int b = *it;
            int a = *--it;

            ra.add(a+1, k, k, b-1, val);
            s.insert(k);
        }
    }

    vector<vector<long long> > v;
    ra.get(v);
    long long ans = 0;
    for(int i=0; i<n; ++i){
        ans = max(ans, v[i][i]);
        long long d = 0;
        for(int j=i+1; j<n; ++j){
            d += a[j-1];
            ans = max(ans, v[i][j] - d);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 200064
#include <stdio.h>
int main(int argc, char *argv[])
{
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		if((a+b)%3==0||a%3==0||b%3==0)printf("Possible\n");
		else printf("Impossible\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,k;

int main(){
    long long a, b, n, shor;
    cin >> a >> b >> n;
    if(b - 1 > n) shor = n;
    else shor = b-1;
    cout << (a*shor)/b - a*(shor/b) << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<stdbool.h>
int row[8],col[8],dpos[15],dneg[15];
bool x[8][8];
void func1(){
  int i;
  for(i=0;i<8;i++){
    row[i]=-1;
    col[i]=-1;
  }
  for(i=0;i<15;i++){
    dpos[i]=-1;
    dneg[i]=-1;
  }
}
void print(){
  int i,j;
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(x[i][j]){
	if(row[i]!=j)
	  return;
      }
    }
  }
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(row[i]==j)
	printf("Q");
      else
	printf(".");
    }
    printf("\n");
  }
}
void func(int i){
  int j;
  if(i==8){
    print();
    return ;
  }
  for(j=0;j<8;j++){
    if(col[j]==1||dpos[i+j]==1||dneg[i-j+7]==1)
      continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+7]=1;
    func(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+7]=-1;
  }
}
int main(){
  int i,j,k,a,b;
  func1();
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      x[i][j]=false;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&a,&b);
    x[a][b]=true;
  }
  func(0);
  return 0;
}
    
  



Measured memory_bytes: 2108
import java.util.Scanner;

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

		if (a < b) {
			if (b < c) {
				System.out.printf("%d %d %d\n", a, b, c);
			} else if (a < c) {
				System.out.printf("%d %d %d\n", a, c, b);
			} else {
				System.out.printf("%d %d %d\n", c, a, b);
			}
		} else {
			if (b > c) {
				System.out.printf("%d %d %d\n", c, b, a);
			} else if (a > c) {
				System.out.printf("%d %d %d\n", b, c, a);
			} else {
				System.out.printf("%d %d %d\n", b, a, c);
			}
		}
	}

}



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

int main(){

  int a,b;

  cin >> a >> b;
  
  if(a < b){
  for(int i=0; i<b; i++)
    cout << a;
    return 0;
  }
  for(int i=0; i<a; i++)
    cout << b;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<int> a(n+1, 0);
  rep(i, n) cin >> a[i+1];

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1 && a[i] % 2 == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

struct State {
	int l, r, x, y;
	State(int _l, int _r, int _x, int _y) : l(_l), r(_r), x(_x), y(_y) {}
	
};

int a, b, d;

void solve() {
	int sum = iINF;
	int x = 50000, y = 50000;
	
	for_(i,-50000,50001) {
		int val = d - i * a;
		if (val % b != 0) continue;
		
		int _x = abs(i), _y = abs(val / b);
		
		if (_x + _y < x + y || (_x + _y == x + y && _x * a + _y * b < sum)) {
			sum = _x * a + _y * b;
			x = _x; y = _y;
		}
	}
	
	cout << x << " " << y << endl;
}

int main() {
	while (cin >> a >> b >> d, a) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC083BSomeSums solver = new ABC083BSomeSums();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC083BSomeSums {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = Integer.parseInt(in.next());
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int ans = 0;

            for (int i = 1; i <= n; i++) {
                int sum = someDigits(i);
                if (sum >= a && sum <= b) {
                    ans += i;
                }
            }
            System.out.println(String.valueOf(ans));
        }

        private int someDigits(int i) {
            int sum = 0;
            while (i > 0) {
                sum += i % 10;
                i /= 10;
            }
            return sum;
        }

    }
}



Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int price = 700;
  for(int i=0;i<3;i++){
    if( s.at(i) == 'o' ){
      price += 100;
    }
  }
  cout << price << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int ans=0;
  int n,z,w;cin>>n>>z>>w;
  int a[2010];
  rep(i,n)cin>>a[i];
  if(n==1)ans=abs(a[n-1]-w);
  else ans=max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin


def find_palindromic(s):
    TF = False
    for i in range(len(s)//2):
        if s[i] != s[-i-1]:
            break
    else:
        TF = True
    return TF


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for i in range(A,B+1):
        if find_palindromic(str(i)):
            cnt += 1
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

from collections import defaultdict

N = int(input())
s1 = input()
s2 = input()

def make_appears(s):
    chars = list(map(ord, s))
    hist = defaultdict(int)
    for ch in chars:
        hist[ch] += 1
    appears = list(hist.values())
    appears.sort()
    appears.reverse()
    return appears
    
appears1 = make_appears(s1)
appears2 = make_appears(s2)

ans = 0
for i, j in zip(appears1, appears2):
    ans += abs(i - j)

shorter = min(len(appears1), len(appears2))
ans += sum(appears1[shorter:]) + sum(appears2[shorter:])

print(ans//2)

Measured memory_bytes: 9068
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

vector<vector<Weight>> shortest_distance(Graph g) {
    /* Johnson */
    size_t V=g.size();
    vector<Weight> h(V);
    for (size_t k=0; k<V; ++k)
        for (size_t i=0; i<V; ++i)
            for (const Edge &e: g[i])
                if (h[e.dst] > h[e.src] + e.weight) {
                    h[e.dst] = h[e.src] + e.weight;
                    if (k == V-1)
                        return vector<vector<Weight>>();
                }

    for (size_t i=0; i<V; ++i)
        for (Edge &e: g[i])
            e.weight += h[e.src] - h[e.dst];

    vector<vector<Weight>> d(V, vector<Weight>(V, INF<<1));
    vector<vector<size_t>> prev(V, vector<size_t>(V, -1));
    for (size_t s=0; s<V; ++s) {
        gp_queue<Edge> q; q.push(Edge(s, s, 0));
        d[s][s] = 0;
        while (!q.empty()) {
            Edge e=q.top(); q.pop();
            if (~prev[s][e.dst]) continue;

            prev[s][e.dst] = e.src;
            for (const Edge &f: g[e.dst]) {
                if (d[s][f.dst] > e.weight + f.weight) {
                    d[s][f.dst] = e.weight + f.weight;
                    q.push(Edge(f.src, f.dst, e.weight+f.weight));
                }
            }
        }
        for (size_t u=0; u<V; ++u)
            if (d[s][u] < INF)
                d[s][u] += h[u] - h[s];
    }

    return d;
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %lld", &s, &t, &d);

        connect(g, s, t, d);
    }

    vector<vector<Weight>> d=shortest_distance(g);
    if (d.empty())
        return !printf("NEGATIVE CYCLE\n");

    for (vector<Weight> w: d)
        for (size_t i=0; i<V; ++i)
            if (w[i] < INF) {
                printf("%lld%c", w[i], i<V-1? ' ':'\n');
            } else {
                printf("INF%c", i<V-1? ' ':'\n');
            }

    return 0;
}

Measured memory_bytes: 3200
/**
 *	author:   fractal
 *	timus:    288481RF
 *	created: 08/22/20 18:05:41
**/

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e6 + 2;
const int M = 1e5;
const int mod = 0;
const int inf = 2e9 + 3;
const ll INF = 1e16;

int n;
ll mx, x, sum;

int main() {
	scanf("%d", &n);
	n--;
	scanf("%lld", &x);
	mx = x;
	while (n--) {
		scanf("%lld", &x);
		sum += max(0LL, mx - x);
		mx = max(x, mx);
	}
	printf("%lld", sum);
}


Measured memory_bytes: 3820
n = int(input())
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))

money = [10**7+9]*(n+1)
money[0] = 0
for price,num in zip(lis1,lis2):
    i = 0
    while(i<n+1):
        if i-num < 0:
            money[i] = min(price,money[i])
        else:
            money[i] = min(money[i],price+money[i-num])
        i += 1
print(money[n])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  string a;
  cin>>a;
  int n=a.size();
  int x=0;
  rep(i,(n-1)/2){
    if(a.at(i)!=a.at(n-i-1)) {
      cout<<"No";
      break;
    }
    else if(i==(n-1)/2-1) {
      x=1;
    }
    else{
      continue;
    }   
 }
  int b=(n-1)/2;
  if(x==1&&n==3){cout<<"Yes";}
  else if(x==1){
    for(int j=0;j<b/2;j++){
      if(a.at(j)!=a.at(b-j-1)) {
      cout<<"No";
      break;
    }
    else if(j==b/2-1) {
      cout<<"Yes";
    }
    else{
      continue;
    }   
   }  
}
}

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


void solve(long long N, std::vector<std::string> S){
    set<string> kinds;
    for(auto s: S){
        kinds.insert(s);
    }

    cout << kinds.size() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];

    int cnt = 1;
    FOR(i, 1, n) {
        bool see = true;
        rep(j, i) {
            if (h[i] < h[j]) see = false;
        }
        if (see) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int a[n + 1], ans = 0;
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	for (int i = 1; i <= n; ++i) {
		if (a[a[i]] == i)
			++ans;
	}
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  
  int ans = a*x+b*y;
  rep(i,200001){
    int tot = i*c;
    int n = i/2;
    if(x-n>0) tot += a*(x-n);
    if(y-n>0) tot += b*(y-n);
    ans = min(ans,tot);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> p(s.size(), 0);
	int ct = 0;
	ff(i, 0, s.size()) {
		if (s[i] == 'R')ct++;
		else {
			p[i] += ct/2;
			p[i - 1] += (ct+1)/2;
			ct = 0;
		}
	}
	ct = 0;
	ff(i, 0, s.size()) {
		if (s[s.size()-1-i] == 'L')ct++;
		else {
			p[s.size() - 1 - i] += ct / 2;
			p[s.size() - i] += (ct + 1) / 2;
			ct = 0;
		}
	}
	ff(i, 0, s.size()) {
		cout << p[i];
		(i + 1 == s.size() ? cout << endl : cout << " ");
	}
	return 0;
}

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

int main() {
 	string s, t;
  	cin >> s >> t;
 	int ans = 0;
  	for(int i = 0; i < 3; i++) {
     	ans = (s[i] == t[i]) ? (ans + 1) : (ans); 
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int dp[111][111],n,L[111],R[111];

int dfs(int l,int r){
	if(dp[l][r]!=-1)return dp[l][r];
	if(l==r)return dp[l][r]=0;
	int res=1e17;
	for(int i=l;i<r;i++){
		res=min(res,dfs(l,i)+dfs(i+1,r)+L[l]*R[i]*R[r]);
	}
	return dp[l][r]=res;
}

signed main(){
	memset(dp,-1,sizeof(dp));
	cin>>n;
	r(i,n)cin>>L[i]>>R[i];
	dfs(0,n-1);
	cout<<dp[0][n-1]<<endl;
}


Measured memory_bytes: 3188
n, nQueries = map(int,input().split())
inString = input()
queries = [ [int(x)-1 for x in input().split()] for i in range(nQueries)]
occurance_list = [0]*n
idx = 0
while(idx < n):
    if(idx<n-1 and inString[idx] == "A" and inString[idx+1] == "C"):
        occurance_list[idx] = occurance_list[idx-1]
        occurance_list[idx+1] += occurance_list[idx-1] + 1
        idx += 2
    else:
        occurance_list[idx] = occurance_list[idx-1]
        idx+=1



for (i,j) in queries:
    print(occurance_list[j] - occurance_list[i])
    
            


Measured memory_bytes: 24452
let N = stdin.ReadLine() |> int

let rec firstDigit num =
    match num with
    | n when n < 10 -> n
    | n -> firstDigit (n / 10)

let table = Array2D.init 10 10 (fun _ _ -> 0)

for i in [ 1..N ] do
    table.[firstDigit i, i % 10] <- table.[firstDigit i, i % 10] + 1

let mutable result = 0

for i in [ 1..N ] do
    result <- result + table.[i % 10, firstDigit i]
result |> stdout.WriteLine


Measured memory_bytes: 32200
/*
https://beta.atcoder.jp/contests/abc085/tasks
*/
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n,k;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>k;  vec[i]=k;
  }
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());

  cout<<vec.size()<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main(){
    int n,k,q; cin>>n>>k>>q;
    map<int, int> cnt;
    for(int i=0; i<q; i++){
        int a; cin>>a;
        cnt[a]++;
    }
    for(int i=0; i<n; i++){
        if(q-cnt[i+1] >= k) OUT("No");
        else OUT("Yes");
    }
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

struct edge {
  int to;
  int cost;
};

int n, m;
vector<vector<edge>> vec;
vector<bool> visited;
vector<i64> dist;

bool dfs(int v) {
  visited[v] = true;
  
  for(auto e : vec[v]) {
    if(!visited[e.to]) {
      dist[e.to] = dist[v] + e.cost;
      if(!dfs(e.to)) return false;
    }
    else if(dist[e.to] != dist[v] + e.cost) return false;
  }
  return true;
}

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

  cin >> n >> m;
  vec.resize(n + 1);
  visited.resize(n + 1, false);
  dist.resize(n + 1);
  rep(i, 0, m) {
    int l, r, d;
    cin >> l >> r >> d;
    vec[l].push_back({r, d});
    vec[r].push_back({l, -d});
  }

  erep(i, 1, n) {
    if(!visited[i]) {
      dist[i] = 0;
      if(!dfs(i)) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 12416
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
if s[0]!="A":
    print("WA")
    quit()

ccnt=0
for i in range(len(s)):
    if i==0:
        if s[i]!="A":
            print("WA")
            break
        else:
            continue

    elif 2<=i<=len(s)-2 and s[i]=="C":
        ccnt+=1
    elif not s[i] in al:
        print("WA")
        break
else:
    if ccnt==1:
        print("AC")
    else:
        print("WA")

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int pos = 0;
  int H;
  for (int i = 0; i < N; i++) {
    int e;
    cin >> e;
    if (i > 0 && H >= e) {
      count += 1;
    }
    if (H < e || i == N-1) {
      pos = max(pos, count);
      count = 0;
    }
    H = e;
  }
  
  cout << pos << endl;
}

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

  int n; cin>>n;
  int ans =0;
  vector<int>a(n);
  
  for (int i=1; i<=n; i++) {
    cin >> a[i];
    if (i%2 != 0 && a[i] %2 != 0) ans++;
  }
  cout<<ans<<endl;
}


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

bool leap(int y){
    if( y%400==0 ) return true;
    if( y%100==0 ) return false;
    if( y%4==0 ) return true;
    return false;
}

int main(){
    int a, b;
    bool first = true;
    while( cin >> a >> b, a||b ){
        if( !first ) cout << '\n';
        bool exist = false;
        for(int i = a; i <= b; i++){
            if( leap(i) ){
                cout << i << endl;
                exist = true;
            }
        }
        if( !exist ) cout << "NA" << endl;
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main() {
  long long int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if ((a + b) <= 2 * c) {
    cout << a * x + b * y;
  } else {
    if (x > y) {
      if (a > 2 * c) {
        cout << 2 * c * x << endl;
      } else {
        cout << 2 * c * y + a * (x - y) << endl;
      }
    } else {
      if (b > 2 * c) {
        cout << 2 * c * y << endl;
      } else {
        cout << 2 * c * x + b * (y - x) << endl;
      }
    }
  }
  return 0;
}

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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]),i;
        ArrayList<Integer> g[]=new ArrayList[n];
        for(i=0;i<n;i++)
        g[i]=new ArrayList<>();

        for(i=0;i<m;i++)
        {
            s=bu.readLine().split(" ");
            int u=Integer.parseInt(s[0])-1,v=Integer.parseInt(s[1])-1;
            g[u].add(v);
            g[v].add(u);
        }

        boolean vis[]=new boolean[n]; int gr=0;
        for(i=0;i<n;i++)
        if(!vis[i])
        {
            gr++;
            Queue<Integer> q=new LinkedList<>();
            q.add(i);
            vis[i]=true;
            while(!q.isEmpty())
            {
                int p=q.poll();
                for(int x:g[p])
                if(!vis[x])
                {
                    vis[x]=true;
                    q.add(x);
                }
            }
        }
        System.out.print(gr-1);
    }
}


Measured memory_bytes: 65420
#include<bits/stdc++.h>
using namespace std;
string s;
int step[300000];
int a[300000];
int main(){
	cin>>s;
	int lx=-1,rx=-1;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='L')
		{
			step[i]=lx;
		}
		else lx=i;
	}
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='R')
		{
			step[i]=rx;
		}
		else rx=i;
	}
	
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			if((step[i]-i)%2==1)
			{
				a[step[i]-1]++;
			}
			else a[step[i]]++;
		}
		else {
			if((i-step[i])%2==1)
			{
				a[step[i]+1]++;
			}
			else a[step[i]]++;
		}
	}
	for(int i=0;i<s.size();i++)
	{
		cout<<a[i]<<" ";
	}
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

#define mod 1000000007;

main(){
  string a,b,c; cin >> a >> b >> c;
  int x=1,y=0,z=0;//次に出すカード
  char now = a[0];
  while(1){
    if(now == 'a'){
      if(x == a.size()){
	cout << 'A' << endl;
	break;
      }else{
	now = a[x];
	x++;
      }
    }else if(now == 'b'){
      if(y == b.size()){
	cout << 'B' << endl;
	break;
      }else{
	now = b[y];
	y++;
      }
    }else if(now == 'c'){
      if(z == c.size()){
	cout << 'C' << endl;
	break;
      }else{
	now = c[z];
	z++;
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>
using namespace std;
main(){
  int w,h,n,i,j;
  int cnt=0;
  pair<int,int> moku[10000];
  cin>>w>>h>>n;
  cin>>i>>j;
  for(int a=1;a<n;a++){
    cin>>moku[a].first>>moku[a].second;
    while(i<moku[a].first&&j<moku[a].second){
      cnt++;
      i++;
      j++;
    }
    while(i>moku[a].first&&j>moku[a].second){
      cnt++;
      i--;
      j--;
    }
    if(i!=moku[a].first&&j!=moku[a].second){
      cnt+=abs(moku[a].first-i);
      cnt+=abs(moku[a].second-j);
    }
    else if(i!=moku[a].first){
      cnt+=abs(moku[a].first-i);
    }
    else if(j!=moku[a].second){
      cnt+=abs(moku[a].second-j);
    }
    i=moku[a].first;
    j=moku[a].second;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1236
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = [i for i in input()]
ans = 0
for i in range(n):
    if i >= k and t[i] == t[i-k]:
        t[i] = "o"
        continue
    if t[i] == "r":
        ans += p
    elif t[i] == "s":
        ans += r
    else:
        ans += s
print(ans)

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <array>

int main(){
    int N,K,X,Y;
    std::cin >> N >> K >> X >> Y;
    int sum;
    for(int i = 1; i < N+1; i++){
        if(i <= K){
            sum += X;
        }
        else if(i > K){
            sum += Y;
        }
    }
    std::cout << sum;
    return 0;
}


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

int main(){
    int a, b;
    int tmp=1;
    int mul;
    cin >> a >> b;
    for(int j=0; j<=3; j++){
        tmp = tmp*10;
        if(b/tmp == 0){
            mul = a*tmp + b;
            break;
        }
    }
    //cout << mul << endl;
    int i=1;
    tmp=i*i;

    while(tmp<=mul){
        if(tmp==mul){
            cout << "Yes" << endl;
            return 0;
        }
        i++;
        tmp=i*i;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    int l = s.size();
    for(int mask = 0; mask < (1LL << (l - 1)); mask++){
        int num = s[0] - '0', tmp = 0;
        for(int i = 0; i < l - 1; i++){
            if(mask & (1LL << i)){
                tmp += num;
                num = s[i + 1] - '0';
            }else{
                num = num * 10 + s[i + 1] - '0';
            }
        }
        tmp += num;
        ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String out = "";
        if (s.equals("Sunny")) {
            out = "Cloudy";
        } else if (s.equals("Cloudy")) {
            out = "Rainy";
        } else {
            out = "Sunny";
        }
        System.out.println(out);

        sc.close();
    }

}


Measured memory_bytes: 19668
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
struct unionfind{
	vector<int> p;
	unionfind(int N){
		p = vector<int>(N, -1);
	}
	int root(int x){
		if (p[x] == -1){
			return x;
		} else {
			p[x] = root(p[x]);
			return p[x];
		}
	}
	bool same(int x, int y){
		return root(x) == root(y);
	}
	void unite(int x, int y){
		x = root(x);
		y = root(y);
		p[x] = y;
	}
};
int main(){
	int N, M;
	cin >> N >> M;
	unionfind UF(N);
	vector<vector<int>> E(N);
	vector<int> c(N, 0);
	vector<pair<int, int>> ans;
	for (int i = 0; i < M; i++){
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		if (UF.same(A, B)){
			ans.push_back(make_pair(A, B));
			c[A] = 1 - c[A];
		} else {
			E[A].push_back(B);
			E[B].push_back(A);
			UF.unite(A, B);
		}
	}
	vector<int> deg(N);
	for (int i = 0; i < N; i++){
		deg[i] = E[i].size();
	}
	queue<int> Q;
	for (int i = 0; i < N; i++){
		if (deg[i] == 1){
			Q.push(i);
		}
	}
	vector<bool> used(N, false);
	while (!Q.empty()){
		int v = Q.front();
		Q.pop();
		used[v] = true;
		for (int w : E[v]){
			if (!used[w]){
				if (c[v] == 0){
					ans.push_back(make_pair(w, v));
					c[w] = 1 - c[w];
				} else {
					ans.push_back(make_pair(v, w));
					c[v] = 1 - c[v];
				}
				deg[w]--;
				if (deg[w] == 1){
					Q.push(w);
				}
			}
		}
	}
	bool ok = true;
	for (int i = 0; i < N; i++){
		if (c[i] == 1){
			ok = false;
		}
	}
	if (!ok){
		cout << -1 << endl;
	} else {
		for (int i = 0; i < M; i++){
			cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << endl;
		}
	}
}

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

#define ll long long

using namespace std;

const int N = 2e5 + 123;

int n, k;

ll a[N], ans;

map <int,int> cnt;

int main () {
    cin >> n >> k;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 0;i < min (k, n + 1);i ++) {
        ans += cnt[(a[i] - i) % k];
        cnt[(a[i] - i) % k] ++;
    }
    for (int i = min (k, n + 1);i <= n;i ++) {
        cnt[(a[i - k] - (i - k)) % k] --;
        ans += cnt[(a[i] - i) % k];
        cnt[(a[i] - i) % k] ++;
    }
    cout << ans;
}


Measured memory_bytes: 11136
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    char s[100005];
    scanf("%s", s);
    long long int ans = 1, p = 1000000007;
    int count[30];
    int i;
    for (i = 0; i < 30; i++)
        count[i] = 0;
    for (i = 0; i < n; i++)
        count[s[i] - 'a']++;
    for (i = 0; i < 30; i++)
    {
        ans *= count[i] + 1;
        ans %= p;
    }
    ans--;
    if (ans < 0)
        ans += p;
    printf("%lld\n", ans);
    return 0;
}

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

int INF=1001001001;

int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<ll> > dp(n+1, vector<ll> (n+1));
    for(int j=1;j<=n-1;j++){
        if(s[j]==s[0]) dp[0][j]=1;
    }
    ll ans=0;
    rep(i, n) rep(j, n){
        if(s[i+1]==s[j+1]){
            if(i+1<j-dp[i][j]+1) dp[i+1][j+1]=dp[i][j]+1;
            else dp[i+1][j+1]=dp[i][j];
        }
        else dp[i+1][j+1]=0;
        ans=max(dp[i][j], ans);
    }

    cout<<ans<<endl;
}

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

int main()
{
    int N = 0;
    cin >> N;
    int S = 0;
    int N1 = N;
    while(N1 != 0){
        S += N1 % 10;
        N1 = N1 / 10;
    }

    if( N%S == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
const int N=2e5+5,M=1e6;

int n,P[N],Q[N],A[N],B[N],lev[N],q[M],h,t;
int S,T,to[M],nx[M],cap[M],hd[N],it[N],sze=1;

il void add(int u,int v,int c){to[++sze]=v,nx[sze]=hd[u],cap[sze]=c,hd[u]=sze;}

il void ins(int u,int v,int c){add(u,v,c),add(v,u,0);}

il int bfs()
{
    memset(lev,0,4*T+4),q[h=t=lev[S]=1]=S; int i,u,v;
    while (h<=t) for (i=hd[u=q[h++]]; i; i=nx[i])
        if (cap[i]&&!lev[v=to[i]]) lev[v]=lev[u]+1,q[++t]=v;
    return lev[T];
}

il int dfs(int u,int f)
{
    if (u==T) return f; int v,res=0,z;
    for (int &i=it[u]; i; i=nx[i])
        if (lev[v=to[i]]==lev[u]+1&&cap[i]&&(z=dfs(v,std::min(f-res,cap[i]))))
        {
            cap[i]-=z,cap[i^1]+=z,res+=z;
            if (res==f) break;
        }
    return res;
}

il int dinic()
{
    int res=0,f;
    while (bfs())
    {
        memcpy(it,hd,4*T+4);
        while (f=dfs(S,1e9)) res+=f;
    }
    return res;
}

int main()
{
    scanf("%d",&n),S=n+n+1,T=S+1; int i,j,s=0;
    for (i=1; i<=n; i++) scanf("%d",P+i),P[i]++,A[i]=i;
    for (i=1; i<=n; i++) scanf("%d",Q+i),Q[i]++,B[i]=i;
    for (i=1; i<=n; i++)
    {
        if (A[i]==i){for (j=P[i]; j!=i; j=P[j]) A[j]=i;}
        if (B[i]==i){for (j=Q[i]; j!=i; j=Q[j]) B[j]=i;}
    }
    for (i=1; i<=n; i++) B[i]+=n;

    for (i=1; i<=n; i++)
        if (P[i]==i&&Q[i]==i) s++;
        else if (P[i]==i) ins(B[i],T,1);
        else if (Q[i]==i) ins(S,A[i],1);
        else if (P[i]!=Q[i]) ins(B[i],A[i],1);
        else ins(A[i],B[i],1),ins(B[i],A[i],1);
    printf("%d",n-dinic()-s);

    return 0;
}

Measured memory_bytes: 16212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a,b,k; cin >> a >> b >> k;
    for(int i = a; i <= b; i++){
        if(i<a+k) cout << i << endl;
        else if(i>b-k) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256