akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007

// one-based numbering
template<class T> struct Fenwick2D {
    vector<vector<T>> bit; int N, M;
    Fenwick2D(int n, int m) {
        N = n; M = m;
        bit.assign(n+1, vector<T>(m+1, 0));
    }
    void add(int a, int b, T w) {
        for (int x = a; x <= N; x += x & -x) {
            for (int y = b; y <= M; y += y & -y) {
                bit[x][y] = (bit[x][y] + w) % mod;
            }
        }
    }
    T sum(int a, int b) {
        if (!a || !b) return 0;
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) {
            for (int y = b; y > 0; y -= y & -y) {
                ret = (ret + bit[x][y]) % mod;
            }
        }
        return ret;
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> s(n), t(m);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];
    Fenwick2D<long long> f(n+1, m+1);
    f.add(1, 1, 1LL); long long ans = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                long long tmp = f.sum(i+1, j+1);
                tmp %= mod;
                tmp = (tmp + mod) % mod;
                f.add(i+2, j+2, tmp);
                ans += tmp; ans %= mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            a[i] = temp - 1;
        }
        int idx = 0;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt++;
            idx = a[idx];
            if (idx == 1) {
                System.out.println(cnt);
                return;
            } else if (idx == 0) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 49300
N = int(input())
d = {}
for _ in range(N):
    S = "".join(sorted(input()))
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
ans = 0
for v in d.values():
    ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 17852
#include<stdio.h>

int main(){
	int n,i,l=0,max=0,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&l);
		sum+=l;
		if(l>max)max=l;
	}
	if(max*2<sum)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
from collections import deque

n, q = map(int, input().split())
que = deque()
for _ in range(n):
	for x in input().split():
		if (x.isdigit()):
			que.append(int(x))
		else:
			que.append(x)
t = 0
while que:
	name = que.popleft()
	lefttime = que.popleft()
	if (lefttime <= q):
		t += lefttime
		print(name, t)
	else:
		t += q
		lefttime -= q
		que.append(name)
		que.append(lefttime)


Measured memory_bytes: 9880
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
//#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
int n,m;
int a[114514],sa[114514];
signed main() {
  cin>>n>>m;
  int cnt=0;
  rep(i,m) cin>>a[i];
  sort(a,a+m);
  rep(i,m-1) sa[i]=a[i+1]-a[i];
  sort(sa,sa+m-1);
  rep(i,m-n) {
    cnt+=sa[i];
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(ll i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define FIND(v,item) find(v.begin(),v.end(),item)
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
#define REVS(v) reverse(v.begin(),v.end())
#define PI 3.14159265359
using namespace std;
typedef long long ll;
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main(){
  ll n,ans;
  IN1(n);
  vector<ll>aarray(n);
  FOR(i,n){
    cin >> aarray.at(i);
  }

  if (vector_finder(aarray,0) == 1){
    ans = 0;
    goto ANSS;
  }

  ans = aarray[0];
  FORS(i,1,n){
    if (aarray[i] > 1000000000000000000 / ans){
      ans = -1;
      goto ANSS;
    }
    else{
      ans = ans*aarray[i];
    }
  }
  ANSS:
  OUT(ans);
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  vi num(2, 0);
  rep(i, s.size()) num[s[i] - '0']++;
  cout << min(num[0], num[1]) * 2 << endl;
}

Measured memory_bytes: 512
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion

lint dp[1000][2020];

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	lint n; cin >> n;
	lint x = -INF;//x+y最大
	lint y = INF;
	lint s = -INF;
	lint q = INF;
	for (int i = 0; i < n; i++) {
		lint a, b; cin >> a >> b;
		x = max(x, a + b);
		y = min(y, a + b);
		s = max(s, a - b);
		q = min(q, a - b);
	}
	cout << max(x - y ,s - q) << endl;

	return 0;
}


Measured memory_bytes: 3648
using System;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');

            //int n = int.Parse(Console.ReadLine());

            string str = Console.ReadLine();
            if(str == "AAA" || str == "BBB")
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }



            //ここまで
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a,ans=0;
  double m=1000;
  cin>>n>>t>>a;
  int h[n];
  for(int i=0;i<n;++i){
    cin>>h[i];
  }
  for(int i=0;i<n;++i){
    double tem = abs(a - (t - h[i]*0.006));
    //cout<<tem<<endl;
    if(m>tem){
      m = tem;
      ans = i+1;
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 51000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long modd(long long a, long long m) {
    return (a % m + m) % m;
}
lli nCr(lli N, lli K) {
  if(K < 0 || N < K) return 0;
  lli ret = 1;
  for(lli i = 1; i <= K; ++i) {
    ret *= N--;
    ret%=mod;
    ret = ret * modinv(i,mod);
    ret=modd(ret,mod);
  }
  return ret;
}
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> A >> B;
  M=repow(2,N,mod);
  M=modd((M-1),mod);
  C=nCr(N,A);
  D=nCr(N,B);
  X=modd((M-C-D),mod);
  Out(X);
}


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

int main() {
	ll x;
	cin >> x;
	for(ll i = 0;i < 1000;i++){
		for(ll j = -1000;j < 1000;j++){
			if(pow(i,5) - pow(j,5) == x){
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 4028
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s.size()%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    while(1){
        for(int i=1;i<s.size();i++){
            if(s[0]==s[i]){
                s.erase(s.begin()+i);
                i--;
            }
        }
        s.erase(s.begin());
        if(s.size()%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
        if(s.size()==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

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

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a, b;

	cin >> a >> b;

	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
xy = []
xplusy = []
xminusy = []

for i in range(N):
    x, y = map(int, input().split())
    xplusy.append(x+y)
    xminusy.append(x-y)


ans1 = max(xplusy) - min(xplusy)
ans2 = max(xminusy) - min(xminusy)

print(max(ans1, ans2))




Measured memory_bytes: 96764
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    ll n;
    cin >> n;
    while(n!=0){
        vector<ll> vec(n);
        for(ll i=0;i<n;i++){
            cin >> vec.at(i);
        }
        vector<ll> rsw(n+1);
        rsw.at(0) = 0;
        for(int i=1;i<n+1;i++){
            rsw.at(i) = rsw.at(i-1) + vec.at(i-1);
        }
        ll ans = vec.at(0);
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                if(ans < rsw.at(j+1)-rsw.at(i)){
                    ans = rsw.at(j+1) - rsw.at(i);
                }
            }
        }
        cout << ans << endl;
        cin >> n;

    }
}


Measured memory_bytes: 3136
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

ll choose2(ll x) {
	return (x * (x - 1)) / 2;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vi a(n);
	vi wys(n);
	ll res = 0;
	REP(i, n) {
		cin >> a[i];
		--a[i];
		++wys[a[i]];
	}
	REP(i, n) {
		res = (res + choose2(wys[i]));
	}
	REP(i, n) {
		int kol = a[i];
		ll nres = res - choose2(wys[kol]) + choose2(wys[kol] - 1);
		cout << nres << endl;
	}
}

Measured memory_bytes: 4224
#include<iostream>

using namespace std;
int main(){

    int a,b,c;
    cin >> a >> b >> c;

    int num_5 = 0, num_7 = 0;

    if(a == 5){

        num_5++;
    }else if(a == 7){

        num_7++;
    }
    if(b == 5){

        num_5++;
    }else if(b == 7){

        num_7++;
    }
    if(c == 5){

        num_5++;
    }else if(c == 7){

        num_7++;
    }
    
    if(num_5 == 2 && num_7 == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
while True:
	a,b,c = map(str,raw_input().split())
	a=int(a)
	c=int(c)
	if b=="+":
		print a+c
	elif b=="-":
		print a-c
	elif b=="*":
	    print a*c
	elif b=="/":
		print a/c
	else:
		break

Measured memory_bytes: 6436
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a,b,c,d;
cin>>a>>b>>c>>d;
int ans=max(a*c,max(a*d,max(b*c,b*d)));
cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n;
  double x;
  cin >> n >> x;
  double sumM;
  double minM = x+1;
  for(int i = 0; i < n; ++i) {
    double m;
    cin >> m;
    sumM += m;
    if(minM > m) {
      minM = m;
    }
  }

  cout << floor((x - sumM) / minM) + n;
}


Measured memory_bytes: 256
[M, D] = [int(i) for i in input().split()]

product = 0

for i in range(1,M+1):
    for j in range(1, D+1):
        d1 = int(str(j)[0])
        d10 = 0
        if len(str(j)) != 1:
            d10 = int(str(j)[1])
            
        if d1 >= 2 and d10 >= 2 and d1*d10 == i:
            product += 1

print(product)


Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main(){

    int d;
    int n;
    while(readf("%d\n",&d)){
	int ans = 0;
	int dd = d;
	for(int i=0;dd<600;i++){
	    ans += dd * dd * d;
	    dd += d;
	}
	writeln(ans);
    }
}

Measured memory_bytes: 2448
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int d,t,s;
	cin >> d >> t >> s;
	//cout << d/s << endl;
	if((int)d/s==t)
	{
		if(d%s!=0)
		cout << "No" << endl;
		else
		cout << "Yes" << endl;
		return;
	}
	cout << (d/s<=t?"Yes":"No") << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n+1),b(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int m=0;
	for(int i=n;i>=1;i--){
		int tempi=i*2;
		int sum=0;
		while(tempi<=n){
			sum+=b[tempi];
			tempi+=i;
		}
		b[i]=(sum+a[i])%2;
		m+=b[i];
	}
	cout<<m<<endl;
	for(int i=1;i<=n;i++){
		if(b[i]){
			cout<<i<<' ';
		}
	}cout<<endl;
	return 0;
}


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

using namespace std;

int main() {
  long long q, h, s, d;
  cin >> q >> h >> s >> d;
  long long n;
  cin >> n;
  s = min(s, min(4 * q, 2 * h));
  d = min(d, 2 * s);
  long long ans = d * (n / 2) + s * (n % 2);
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N; cin>>N;
    vector<ll>A(N);
    int cnt4=0, cnt2=0,cnt=0;
    rep(i,N){
        cin>>A[i];
        if(A[i]%4==0)cnt4++;
        else if(A[i]%2==0)cnt2++;
        else cnt ++;
    }
    if(cnt2==0 && cnt<=cnt4+1)cout<<"Yes"<<endl;
    else if(cnt2>0 && cnt<=cnt4)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
def Bubble_Sort(C1, N):
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if C1[j][1] < C1[j-1][1]:
                a = C1[j]
                C1[j] = C1[j-1]
                C1[j-1] = a
    
    return(C1)

def SelectionSort(C2, N):
    for i in range(N):
        minj = i
        for j in range(i,N):
            if C2[j][1] < C2[minj][1]:
                minj = j

        a = C2[minj]
        C2[minj] = C2[i]
        C2[i] = a
        #print(C)
    return(C2)

N = int(input())
A1 = list(map(str,input().split()))
A2 = A1.copy()
B1 = Bubble_Sort(A1,N)
B2 = SelectionSort(A2,N)

print(' '.join(map(str, A1)))
print("Stable")
print(' '.join(map(str, A2)))
if A1 == A2:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5608
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int dig = str.length();
        long in = Long.parseLong(str);
        long sum = 0;
        for(long i = 0; i < (1 << dig - 1); i++){
            long csum = 0;
            long c = in;
            for(int j = 0; j < dig - 1; j++){
                if((i >> j & 1) == 1){
                    csum += c / Math.round(Math.pow(10, dig - 1 - j));
                    c %= Math.round(Math.pow(10, dig - 1 - j));
                }
            }
            csum += c;
            sum += csum;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21972
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

lli sum(lli n)
{
    return n*(n+1)/2;
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    cout<<sum(n)-3*sum(n/3)-5*sum(n/5)+15*sum(n/15)<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  int n, m; cin>>n>>m;
  vector<vector<bool>> g(n, vector<bool>(n, false));
  rep(i, m) {
    int a,b; cin>>a>>b; a--; b--;
    g[a][b] = true;
    g[b][a] = true;
  }

  vector<int> c(n);
  rep(i, n) c[i] = i;

  int ans = 0;
  do {
    if (c[0] != 0) continue;
    bool flg = true;
    for (int i=0; i<n-1; i++) {
      if (!g[c[i]][c[i+1]]) {
        flg = false;
        break;
      }
    }
    if (flg) ans++;
  } while (next_permutation(c.begin(), c.end()));
  cout << ans << endl;

  return 0;
}


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

int main() {
	int n,k;
	cin>>n>>k;
	vector<ll> h(n);
	
	rep(i,n)cin>>h[i];
	sort(h.begin(),h.end(),greater<ll>());
	
	ll sum=0;
	if(n<=k){
		cout<<0<<endl;
		return 0;
	}
	for(int i=k;i<n;i++){
		sum+=h[i];
	}
	cout<<sum<<endl;
}

//なぜ？

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	k=ceil(double(n+m)/2.0);

	cout<<k<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    vi t(2), a(2), b(2);
    cin >> t[0] >> t[1];
    cin >> a[0] >> a[1];
    cin >> b[0] >> b[1];

    // t[0]、t[1]それぞれで縮まる距離
    ll t0d = (a[0] - b[0]) * t[0];
    ll t1d = (a[1] - b[1]) * t[1];
    // 高橋くんが遅れてる状況で符号を統一
    if(t0d > 0) t0d = -t0d, t1d = -t1d;

    // 初期地点(0m)を除いて、二人の距離が0になった時に出会ったといえる
    // t[0]とt[1]でどのように距離が縮まるか、p+qの値で場合分けする
    
    // 1. 無限回出会うケース（時刻がt[0]+t[1]のたびに二人の距離が0になる）
    if(t0d + t1d == 0) cout << "infinity" << endl;

    // 2. 高橋くんが永遠に離されるケース
    else if(t0d + t1d < 0) cout << "0" << endl;

    // 3. 複数回出会う可能性のあるケース
    else{
        // t[0]+t[1]を1サイクルと呼ぶとすると、k回目のサイクルが終了した時点での位置はk*(p+q)である
        // 次のサイクルに入ることを考えると、
        // 1. k*(t0d+t1d)+t0d < 0 : 正の位置から負に行き、再度+t1dで正に戻ってくるため、0を2回通る
        // 2. k*(t0d+t1d)+t0d = 0 : 正の位置から0に行き、そこから+t1dされるため0を1回通る
        // 3. k*(t0d+t1d)+t0d > 0 : 正の位置から正のまま、そこから+t1dされるため0を1度も通らない
        // と場合分けできる。
        // 1回目のサイクルのみ二人の距離が0mからスタート（出会った状態からスタート）なので+1回
        
        // 上の式を変更し、kは -t0d/(t0d+t1d)の商となり、余りで場合分けする
        ll p = -t0d/(t0d+t1d);
        ll q = -t0d%(t0d+t1d);
        if(q == 0) cout << 2*p -1 +1 << endl;
        else if(q > 0) cout << 2*p +1 << endl;

    }
    return 0;
}

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

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

    int x;
    if (((a+b) % 2) == 0) {
        x = (a + b) / 2;
    } else {
        x = ((a + b) / 2) + 1;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Long = long long;
template<typename W>
using Edge = pair<int, W>;
template<typename W>
using WeightedGraph = vector<vector<Edge<W>>>;
using UnWeightedGraph = vector< vector<int>>;
template< typename G >
// Strongly Connected Component
// 時間計算量 : O(V+E)
struct SCC {
    // G : Unweighted Graph or Weighted Graph
    // g : SCCを求める対象のグラフ
    const G &g;
    // forward : 順向きの辺
    // backward : 逆向きの辺
    UnWeightedGraph forward, backward;
    // comp[i] : 頂点iが属す強連結成分のindex
    // order : 1回目の順向きdfsの帰りがけ順を格納
    // used : 1回目の順向きdfsで通ったかを記憶
    vector< int > comp, order, used;

    SCC(UnWeightedGraph &g) : g(g), forward(g.size()), backward(g.size()), comp(g.size(), -1), used(g.size()) {
        for(int i = 0; i < g.size(); i++) {
            for(auto& e : g[i]) {
                forward[i].emplace_back((int) e);
                backward[(int) e].emplace_back(i);
            }
        }
    }

    template<typename W>
    SCC(WeightedGraph<W> &g) : g(g), forward(g.size()), backward(g.size()), comp(g.size(), -1), used(g.size()) {
        for(int i = 0; i < g.size(); i++) {
            for(auto& e : g[i]) {
                forward[i].emplace_back((int) e.first);
                backward[(int) e.first].emplace_back(i);
            }
        }
    }

    void dfs(int idx) {
        if(used[idx]) return;
        used[idx] = true;
        for(int to : forward[idx]) 
            dfs(to);
        // 帰りがけを記憶.
        order.push_back(idx);
    }

    void rdfs(int idx, int cnt) {
        if(comp[idx] != -1) return;
        comp[idx] = cnt;
        for(int to : backward[idx]) rdfs(to, cnt);
    }

    int buildDAG(UnWeightedGraph &t) {
        for(int i = 0; i < forward.size(); i++) 
            dfs(i);
        // 帰りがけの遅かった頂点から探索
        reverse(begin(order), end(order));
        int ptr = 0;
        for(int i : order) {
            if(comp[i] == -1) {
                // 強連結ごとに逆向きdfsが停止.
                rdfs(i, ptr);
                ptr++;
            }
        }
        // DAG構築
        t.resize(ptr);
        for(int i = 0; i < g.size(); i++) {
            for(auto &to : g[i]) {
                int x = comp[i], y = comp[to];
                if(x == y) continue;
                t[x].push_back(y);
            }
        }
        return ptr;
    }

    int build() {
        for(int i = 0; i < forward.size(); i++) 
            dfs(i);
        // 帰りがけの遅かった頂点から探索
        reverse(begin(order), end(order));
        int ptr = 0;
        for(int i : order) {
            if(comp[i] == -1) {
                // 強連結ごとに逆向きdfsが停止.
                rdfs(i, ptr);
                ptr++;
            }
        }
        return ptr;
    }
};

int main(void) {
    int V, E, Q;
    cin >> V >> E;
    UnWeightedGraph G(V);
    for(int i = 0;i < E;i++) {
        int s, t;
        cin >> s >> t;
        G[s].emplace_back(t);
    }
    SCC<UnWeightedGraph> scc(G);
    scc.build();
    cin >> Q;
    for (int i = 0;i < Q;i++) {
        int u,v;
        cin >> u >> v;
        cout << (scc.comp[u] == scc.comp[v]) << endl;
    }
}


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
struct book
{
	int c;
	string p;
};
bool crt(book x,book y)
{
	if((x).p>(y).p)
	return false;
	if((x).p<(y).p)
	return true;
	if((x).c<(y).c)
	return false;
	return true;
}
int main()
{
	int n;
	cin >>n;
	book e[111];
	int f[111];
	for(int i=0;i<n;i++)
	{
		cin >>e[i].p>>e[i].c;
		f[i]=e[i].c;
	}
	sort(e,e+n,crt);
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	{
		if(e[i].c==f[j])
		{
			cout <<j+1<<endl;
			continue;
		}
	}
//	cout <<e[1].c;
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);

int main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  map <int, int> r, b;
  r[1] = 1;
  for (int i = 2; i <= n; ++i)
    b[i] = 1;
  map <int, int> cnt;
  for (int i = 1; i <= n; ++i)
    cnt[i] = 1;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    if (r[x] && b[x]) {
      ++r[y];
      ++b[y];
      cnt[x]--;
      if (!cnt[x]) {
        r[x] = 0;
        b[x] = 0;
      }
      ++cnt[y];
    }
    else if (r[x]) {
      r[x]--;
      cnt[x]--;
      if (!cnt[x]) {
        r[x] = 0;
        b[x] = 0;
      }
      ++r[y];
      ++cnt[y];
    }
    else if (b[x]) {
      b[x]--;
      cnt[x]--;
      if (!cnt[x]) {
        r[x] = 0;
        b[x] = 0;
      }
      ++b[y];
      ++cnt[y];
    }
  }
  int ret = 0;
  for (int i = 1; i <= n; ++i)
    ret += (r[i] != 0 && cnt[i] != 0);
  cout << ret;
  return 0;
}


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

int main(){
  int n, i=0, a[5], min, aaa, b, c;
  while(cin >> n){
    a[i] = n;
    i++;
  }

  min = a[0] * a[3] + a[1] * a[4];
  for(i=1;i<=100000;i++){
    if(a[3] - i >= 0){
      b = a[3] - i;
    }
    else{
      b = 0;
    }
    if(a[4] - i >= 0){
      c = a[4] - i;
    }
    else{
      c = 0;
    }
    aaa = a[2] * 2 * i + a[0] * b + a[1] * c;
    if(aaa < min)min = aaa;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
a=[0]
for i in range(n):
  a.append(h[i])
a.append(0)
s=0
for i in range(n+1):
  s+=abs(a[i]-a[i+1])
for i in range(1,n+1):
  if min(a[i+1],a[i-1])<=a[i]<=max(a[i-1],a[i+1]):
    print(s)
  elif a[i]<=min(a[i-1],a[i+1])<=max(a[i-1],a[i+1]):
    print(s-2*abs(a[i]-min(a[i+1],a[i-1])))
  else:
    print(s-2*abs(max(a[i-1],a[i+1])-a[i]))


Measured memory_bytes: 13920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define dd double
#define f0(i, n) for(int i = 0; i < n; i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define f1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second





int main() {


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

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


//ios_base& scientific (ios_base& str);
	int n;
	cin >> n;

	int dp[n][3];

	int a[n][3];
	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {

			cin >> a[i][j];
		}
	}

	for (int i = 0; i < 3; i++) {

		dp[0][i] = a[0][i];
	}


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

		for (int j = 0; j < 3; j++) {

			if (j == 0) {
				dp[i][j] = a[i][j] + max(dp[i - 1][1], dp[i - 1][2]);
			}
			else if (j == 1) {

				dp[i][j] = a[i][j] + max(dp[i - 1][0], dp[i - 1][2]);
			}
			else {
				dp[i][j] = a[i][j] + max(dp[i - 1][1], dp[i - 1][0]);
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < 3; i++) {

		ans = max(ans, dp[n - 1][i]);
	}


	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int main()
{
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif
 
#define mp make_pair
#define pb push_back
#define put(x) { cout << #x << " = "; cout << (x) << endl; }
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef double db;
 
const int M = 1e6 + 15;
const int Q = 1e9 + 7;
 
int a[M];
 
int dp[M][2];
int main() {
    srand(time(NULL));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(0);
 
	int n;
	cin >> n;
	if (n <= 2) {
		cout << 1;
		return 0;
	}	
	int ans = 1;
	for (int i = 0; i < n; i++) cin >> a[i];
	dp[n - 1][0] = dp[n - 1][1] = 1;
    for (int i = n - 2; i >= 0; i--) {
    	for (int it = 0; it < 2; it++) {
    		if (a[i] <= a[i + 1]) 
    			dp[i][0] = dp[i + 1][0];
    		else 
    			dp[i][0] = 1 + min(dp[i + 1][0], dp[i + 1][1]);

			if (a[i]>= a[i + 1]) 
    			dp[i][1] = dp[i + 1][1];
    		else 
    			dp[i][1] = 1 + min(dp[i + 1][0], dp[i + 1][1]);
    	}
    }
    cout << min(dp[0][0], dp[0][1]) << endl;
 
    return 0;
}   

Measured memory_bytes: 5120
n=list(map(str,input()))
for i in range(0,len(n)):
    if n[i]>="D":
        n[i]=ord(n[i])
        n[i]=n[i]-3
        n[i]=chr(n[i])
    elif n[i]=="A":
        n[i]="X"
    elif n[i]=="B":
        n[i]="Y"
    else:
        n[i]="Z"
print("".join(n))




Measured memory_bytes: 5564
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    vector<pair<pair<int,int>,int> > x;
    bool flag = true;
    while (1)
    {
        int n, l;
        vector<int> vec;
        cin >> n >> l;
        if (l == 0)
        {
            break;
        }
        flag = true;
        while (flag)
        {
            vector<int> a(l);
            for (int i = l - 1; 0 <= i; i--)
            {
                a[i] = n % 10;
                n /= 10;
            }

            // maxの値を作成
            vector<int> ma(l);
            copy(a.begin(), a.end(), ma.begin());
            sort(ma.begin(), ma.end());
            reverse(ma.begin(), ma.end());

            // minの値を作成
            vector<int> mi(l);
            copy(a.begin(), a.end(), mi.begin());
            sort(mi.begin(), mi.end());
            int ma_n = 0, mi_n = 0,be_a=0;
            for (int i = 0; i < l; i++)
            {
                // cout << a[i];
                be_a += a[i] * pow(10, l - i - 1);
            }
            vec.push_back(be_a);
            for (int i = 0; i < l; i++)
            {
                // cout << ma[i];
                ma_n += ma[i] * pow(10, l - i - 1);
                mi_n += mi[i] * pow(10, l - i - 1);
            }
            // cout << endl;
            // cout << ma_n << " - " << mi_n << " = " << ma_n - mi_n << endl;
            int diff = ma_n - mi_n;
            for(int i=0; i<vec.size();i++){
                if(vec[i] == diff){
                    x.push_back(make_pair(make_pair(i,diff),vec.size()-i)); // j a i-j
                    flag = false;
                }
            }
            n = diff;
        }
    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i].first.first <<" "<< x[i].first.second <<" "<< x[i].second << endl;
    }
}



Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int arr[100];


int main(){
    scanf("%d", &n);
    for(int i = 0; i < n ; ++i){
        scanf("%d", &arr[i]);
    }
    int ans =0;
    sort(arr, arr+n);
    for(int i =0 ; i< n-2 ; ++i){
        for(int j = i+1 ; j < n-1 ; ++j){
            for(int k = j+1 ; k < n ; ++k){
                if(arr[i] == arr[j] or arr[j] == arr[k] or arr[k] == arr[i]) continue;
                if(arr[i] + arr[j] > arr[k]) ans++;
            }
        }
    }

    printf("%d", ans);
    
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool flag = false;
  vector<char> vec(4);
  vec.at(0) = s.at(0);
  vec.at(1) = s.at(1);
  vec.at(2) = s.at(2);
  vec.at(3) = s.at(3);
  sort(vec.begin(), vec.end());
  if (vec.at(0) == vec.at(1)) {
    if (vec.at(1) != vec.at(2)) {
      if (vec.at(2) == vec.at(3)) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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



int main(){
    int n,m,q;
    cin >> n >> m >> q;
    vector<vector<int>> train(n,vector<int>(n));
    vector<vector<int>> cum(n+1,vector<int>(n+1));

    rep(i,n) rep(j,n) train[i][j] = 0;

    rep(i,m){
        int l,r;
        cin >> l >> r;
        l--; r--;
        train[l][r]+=1;
    }

    rep(i,n+1) cum[0][i]=0;
    rep(i,n+1) cum[i][0]=0;

    rep(i,n){
        rep(j,n){
            cum[i+1][j+1] = train[i][j]+cum[i][j+1]+cum[i+1][j]-cum[i][j];
        }
    }

    vector<int> res;
    rep(i,q){
        int p,q;
        cin >> p >> q;
        p--;

        cout << cum[q][q]-cum[q][p]-cum[p][q]+cum[p][p] << endl;

    }


}

Measured memory_bytes: 2944
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

r,c,n = map(int,readline().split())
data = list(map(int,read().split()))
p = []
for i in range(n):
    x1,y1,x2,y2 = data[i*4:i*4+4]
    if((x1==0)|(x1==r)|(y1==0)|(y1==c))&((x2==0)|(x2==r)|(y2==0)|(y2==c)):
        for x,y in zip([x1,x2],[y1,y2]):
            num = 0
            if(x==0):
                num = y
            elif(x==r):
                num = r+2*c-y
            elif(y==0):
                num = 2*(r+c)-x
            else:
                num = c+x
            p.append([num,i])

p.sort()
d = []
for _,i in p:
    if(not d):
        d.append(i)
    else:
        right = d.pop()
        if(right != i):
            d.append(right)
            d.append(i)

if(len(d)==0):
    print('YES')
else:
    print('NO')

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

vector<int> divisor(int n)
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main()
{
    int N;
    cin >> N;
    int A[N];
    map<int, int> mp;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        mp[A[i]]++;
    }
    for (int i = 0; i < N; i++)
    {
        auto yaku = divisor(A[i]);
        for (auto j : yaku)
        {
            if (j == A[i])
                continue;
            if (mp[j] >= 1)
            {
                mp[A[i]]++;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (mp[A[i]] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
  	if (S[i] == T[i]) {
    	count++;
    }
  }
  cout << count << endl;
}


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

using ll = long long;
static const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  vector<vector<ll>> x(s.size() + 1, vector<ll>(13));
  x.at(0).at(0) = 1;
  for(int i = 0; i < s.size(); i++){
    if('0' <= s.at(i) && s.at(i) <= '9'){
      int now = s.at(i) - '0';
      for(int j = 0; j < 13; j++){
        x.at(i + 1).at((j * 10 + now) % 13) += x.at(i).at(j);
        x.at(i + 1).at((j * 10 + now) % 13) %= MOD;
      }
    }
    else{
      for(int j = 0; j < 13; j++){
        for(int k = 0; k <= 9; k++){
          x.at(i + 1).at((10 * j + k) % 13) += x.at(i).at(j);
          x.at(i + 1).at((10 * j + k) % 13) %= MOD;
        }
      }
    }
  }
  
  cout << x.at(s.size()).at(5) << '\n';
}

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

struct s
{
	int a, b;
};

int main()
{
	long long n;

	cin >> n;
	long long sum = 0;
	for (long long  i = 1; i <= n; ++i)
	{
		if(i % 3 == 0 && i % 5 == 0) {
			continue;
		}
		else if (i % 3 == 0)
		{
			continue;
		}
		else if (i % 5 == 0)
		{
			continue;
		}
		else{
			sum += i;
		}
	}
	cout << sum << "\n";
}


Measured memory_bytes: 3596
# -*- coding: utf-8 -*-

import sys

n = int(raw_input().split()[0])
a = [int(e) for e in raw_input().split()]
d = dict()
#print n
#print a

for ai in a:
    d[ai] = d.get(ai, 0) + 1

n = 0
for k, v in d.iteritems():
    if k > v:
        n += v
    elif v > k:
        n += (v - k)
        
sys.stdout.write('%d\n' % n)
sys.stdout.flush()


Measured memory_bytes: 16464
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N, Y, C;
    cin >> N >> Y >> C;
    
    cout << (C/N)*Y << endl;

    return 0;
}



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

void solve(std::string S, std::string T){
    cout << T << S << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
'use strict';
function Main(stdin){
  const input = stdin.trim().split(' ');
  const N = input[0], K = input[1];
  let result = K;

  for (let i = 0; i < N-1; i++){
      result *= (K-1);
  }
  console.log(result);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064