akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int c[2][52];
string s[2];
vector <int> v;
const ll base=1000000007;
int n;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>n>>s[0]>>s[1];
    FFOR(i, 0, n){
        if(s[0][i]==s[1][i]) v.pb(0);
        else{
            v.pb(1);
            i++;
        }
    }
    ll ans=v[0]?6:3;
    FFOR(i, 1, v.size()){
        if(v[i]){
            if(v[i-1]) ans=(ans*3)%base;
            else ans=(ans*2)%base;
        }
        else{
            if(v[i-1]) ans=(ans*1)%base;
            else ans=(ans*2)%base;
        }
    }
    writeln(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   if(a<=c&&c<=b)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}

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

int main()
{
    // 入力
    int n; // 都市数
    cin >> n;
    vector<vector<double> > dist(n, vector<double>(2)); 
    for (int i = 0; i < n; ++i) {
      cin >> dist[i][0] >> dist[i][1];
    }

    // 初期順列
    vector<int> order(n);
    for (int i = 0; i < n; ++i) order[i] = i;


    // 探索
    double sum = 0;
    double q = 0;
    do {
        double res = 0;
       for(int i = 0; i < n-1; i++){
         double r = pow(dist[order[i]][0] - dist[order[i+1]][0], 2) + pow(dist[order[i]][1] - dist[order[i+1]][1], 2); 
         res += pow(r, 0.5);
       }
       sum += res;
       q++;
    } while (next_permutation(order.begin(), order.end()));

    sum /= q;

    // 答えを出力
    cout << fixed << setprecision(8);
    cout << sum << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int Obs[100000] = {0};
int Ans[100000] = {0};
int main(){
    int N,M;
    cin >> N >>M;
    for(int i = 1;i<= N;i++){
        int num;
        cin >>num;
        Obs[i] = num;
    }
    for(int i = 1;i<= M;i++){
        int A,B;
        cin >> A >>B;
        if(Obs[A]> Obs[B]){
            Ans[B] = 1;
        }else if(Obs[A]< Obs[B]){
            Ans[A] = 1;
        }else{
            Ans[A] = 1;
            Ans[B] = 1;
        }
    }
    int count = 0;
    for(int i= 1;i<=N;i++){
        if(Ans[i] != 1){
            count ++;
        }
    }
    cout << count;
}

Measured memory_bytes: 3948
#include <stdio.h>

int main(void)
{
    int H, A, B;
    int h, n;
    
    scanf("%d%d%d", &H, &A, &B);
    
    n = 0;
    for (h = A; h <= B; h++){
        if (H % h == 0){
            n++;
        }
    }
    
    printf("%d\n", n);

    return (0);
}



Measured memory_bytes: 2120
def main():
    s = input()
    t = input()
    
    n = len(t)
    ans = n
    if len(s)==n:
        temp = 0
        for i in range(n):
            if s[i] != t[i]:
                temp+=1
        ans = temp

    for i in range(len(s)-n):
        temp = 0
        for j in range(n):
            if s[j+i] != t[j]:
                temp+=1

        if ans > temp:
            ans = temp
    
    print(ans)
main()

Measured memory_bytes: 8992
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long

signed main(){
	long long n, m;
	cin >> n >> m;
	cout << (1 << m) * (1900 * m + (n - m) * 100) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
    string a_name, b_name, u;
    int a_num, b_num;
    cin >> a_name >> b_name;
    cin >> a_num >> b_num;
    cin >> u;
    if (u == a_name) {
        cout << a_num-1 <<' '<< b_num << endl;
    }
    else if (u == b_name) {
        cout << a_num <<' '<< b_num-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b, c, d;
	double e;
	scanf("%d%d", &a, &b);
	c=a/b;
	d=a%b;
	e=1.0*a/b;
	printf("%d ",c);
	printf("%d ",d);
	printf("%.5f\n",e);
	return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

// 素因数分解
vector<pair<Int, Int>> factorization(Int n) {
    vector<pair<Int, Int>> ret;
    for (Int i = 2; i * i <= n; i++) {
        Int cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) {
            ret.emplace_back(i, cnt);
        }
    }
    if (n > 1) {
        ret.emplace_back(n, 1);
    }
    return ret;
}

int main() {
    Int x;
    cin >> x;
    vector<pair<Int, Int>> a = factorization(360);
    vector<pair<Int, Int>> b = factorization(x);
    map<Int, Int> mp;
    for (Int i = 0; i < (Int)b.size(); i++) {
        mp[b[i].first] = b[i].second;
    }
    Int res = 1;
    for (Int i = 0; i < (Int)a.size(); i++) {
        if (mp[a[i].first] < a[i].second) {
            for (Int j = 0; j < a[i].second - mp[a[i].first]; j++) {
                res *= a[i].first;
            }
        }
    }
    print(res);
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9+7;

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

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

	ll k;
	cin >> k;
	vll a(k);
	REP(i, k) cin >> a[i];

	//dp[i] : i ターン終了後の最小/最大人数
	vll dpmin(k + 1), dpmax(k + 1);
	dpmin[k] = dpmax[k] = 2;

	REPR(i, k){
		dpmin[i] = ((dpmin[i + 1] - 1) / a[i] + 1) * a[i];
		dpmax[i] = (dpmax[i + 1] / a[i]) * a[i] + a[i] - 1;
		if(dpmin[i] > dpmax[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << dpmin[0] << " " << dpmax[0] << endl;
    return 0;
}

Measured memory_bytes: 2560
#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<ll, ll>;
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};

ll sum(ll n) {
  ll res = 0, i = 0;
  while(n > 0) {
    ll now = n % 10;
    now *= pow(10, i);
    res += now;
    n /= 10;
  }
  return res;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  rep2(i, 1, n + 1) {
    ll now = sum(i);
    if(a <= now && now <= b) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s = '0' + input() + '0'
prev = 0
n = len(s)
t = ''
L = []
for i in range(n):
  if s[i] != 'x':
    L.append(i)
    t = t[:] + s[i]
flg = True
n = len(t)
for i in range(n//2):
  flg *= (t[i] == t[n-i-1])
for i in range(n-1):
  L[i] = L[i+1] - L[i] - 1
n -= 1
if flg:
  cnt = 0
  for i in range(n//2):
    cnt += abs(L[i] - L[n-i-1])
  print(cnt)
else:
  print(-1)

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

int N, M;
int a[30], b[30];

int jud(vector<int> v){
    int cou = 0;

    if(v[0] == 1){
        for(int i = 0; i < N - 1; i++){
            vector<int>::value_type t = v[i];
            vector<int>::value_type s = v[i + 1];
            if(t > s){
                for(int j = 0; j < M; j++){
                    if(t == b[j] && s == a[j]){
                            cou++;              
                    }
                }
            }else{
                for(int j = 0; j < M; j++){
                    if(t == a[j] && s == b[j]){
                        cou++;                    
                    }
                }
            }
        }
        if(cou == N - 1){
            return 1;
        }else{
            return 0;
        }
    }else{
        return 0;
    }

    return 0;
}

int main() {

    cin >> N >> M;

    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }

    vector<int> v(N);
    for(int i = 0; i < N; i++){
        v[i] = i + 1;
    }

    int ans =0;
 
    do {
        ans += jud(v);
        /*for(int i = 0; i < N; i++){
            cout << v[i] << " ";
        }
        cout << endl;
        cout << ans << endl;*/
    } while( next_permutation(v.begin(), v.end()) );     

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, N, K);
    vector<int> a(N);
    read(a);
    sort(all(a));

    i64 ans = INF;
    rep(i, 0, N - K + 1) { chmin(ans, a[i + K - 1] - a[i]); }

    print(ans);

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main() {
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    while(A > 0 && C > 0) {
        C = C-B;
        if(C <= 0) {
            printf("Yes\n");
            break;
        }
        A = A-D;
        if(A <= 0) {
            printf("No\n");
            break;
        }
    }
}

Measured memory_bytes: 1616
// PrintARectangle.c
// たてH cm よこ W cm の長方形を描くプログラムを作成して下さい。
// 1 cm × 1cm の長方形を '#'で表します。
// 【入力】
// 入力は複数のデータセットから構成されています。各データセットの形式は以下のとおりです：
//   H W
// H, W がともに 0 のとき、入力の終わりとします。
// 【出力】
// 各データセットについて、H × W 個の '#' で描かれた長方形を出力して下さい。
// 各データセットの後に、１つの空行を入れて下さい。
// 【制約】
// 1 ≤ H, W ≤ 300
// 【例】
// 入力：
// 3 4
// 5 6
// 2 2
// 0 0
// 出力：
// ####
// ####
// ####
//
// ######
// ######
// ######
// ######
// ######
//
// ##
// ##
#include<stdio.h>

int main( void) {
  int H, W;

  while ( 1) {
    scanf( "%d %d", &H, &W);

    if ( H == 0 && W == 0) break;

    for ( int h = 1; h <= H; h++ ) {
      for ( int w = 1; w <= W; w++) {
	printf( "#");
      }
      printf( "\n");
    }
    printf( "\n");
  }
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define maxn 200010
#define fi first
#define se second
#define LL long long 
#define pb push_back
#define Pii pair<LL,int>
#define mp make_pair
using namespace std;
int main(){
	int m;
	cin >> m;
	cout << 24 + 24 - m;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n;
 cin>>n;
 int  a[n+1],ans=0;
 for(int i=1;i<=n;i++)
 {
 	cin>>a[i];
 } 
 sort(a+1,a+n+1);
 deque<int> q;
 q.push_back(a[n]);
 int i;
 int pos=1;
 for(i=1;i<=((n+1)/2)-1;i++)
 {
 	pos++;
 	ans+=q.back();
 	q.push_back(a[n-i]);
 }
 //cout<<ans<<" "<<pos<<endl;
 if(n%2==0)
 {
 	pos++;
 	ans+=q.back();
 }
 int mn=1e18;
 i=n-pos;
 for(;i>=1;i--)
 {
 	//cout<<q.back()<<endl;;
 	mn=q.back();
 	ans+=mn;
 	q.pop_back();
 }

 cout<<ans;
  
}


Measured memory_bytes: 6000
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
long long seg_tree[2][seg_size*3];
long long find_seg(long long now,long long now_l,long long now_r,long long want_l,long long want_r,long long bit){
	if(want_l <= now_l&&now_r <= want_r){
		if(bit == 0){
			return seg_tree[0][now] + seg_tree[1][now] * (now_r - now_l);
		}else{
			seg_tree[1][now] += bit;
			return 0;
		}
	}
	if(now_r <= want_l||want_r <= now_l) return 0;
	if(bit != 0){
		seg_tree[0][now] += bit * (min(want_r,now_r) - max(want_l,now_l));
	}
	seg_tree[1][now*2] += seg_tree[1][now];
	seg_tree[1][now*2+1] += seg_tree[1][now];
	seg_tree[0][now] += seg_tree[1][now] * (now_r - now_l);
	seg_tree[1][now] = 0;
	return find_seg(now*2,now_l,(now_l+now_r)/2,want_l,want_r,bit) + find_seg(now*2+1,(now_l+now_r)/2,now_r,want_l,want_r,bit);
}
int main(){
	int n,query;
	cin >> n >> query;
	REP(i,query){
		long long a;
		cin >> a;
		if(a == 0){
			long long b,c,d;
			cin >> b >> c >> d;
			find_seg(1,0,seg_size,b-1,c,d);
		}else{
			long long b,c;
			cin >> b >> c;
			cout << find_seg(1,0,seg_size,b-1,c,0)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5412
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  char c[9][10]={"',.!?","abcABC","defDEF","ghiGHI","jklJKL",
		 "mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"};
  int len[9]={5,6,6,6,6,6,8,6,8};
  while(cin>>s){
    s+="*";
    string ans;
    rep(i,s.size()){
      char a=s[i];
      int t=0;
      if(s[i]=='*')break;
      while(s[i]==s[i+1])i++,t++;
      if(a=='0')rep(j,t)ans+=" ";
      else ans+=c[a-'1'][t%len[a-'1']];
    }
    cout<<ans<<endl;
  }
}

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

int main(){
    ll a,b,c,n,m;
    cin>>n;
    string k[110];
    for(int i=0;i<n;i++)
    {
        cin>>k[i];
    }
    ll count = 0;
    ll ac = 0;
    ll uc = 0;
    for(int i=0;i<n;i++)
    {
        if(k[i] == "A")
        {
            uc = 0;
            ac++;
        }
        else
        {
            if(ac!=0)
            {
                count++;
                ac--;
            }
            else
            {
                cout<<"NO"<<endl;
                return 0;
            }
            
        }
        
    }
    if(ac!=0)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int n, m, count1, count2, colour[MAXN];
vi v[MAXN], g[MAXN];
vector<pii> h;
bool visited[MAXN];

void getComplement() {
    REP(i,n) {
        MEM(visited, false);
        for(auto j: v[i]) {
            visited[j] = true;
        }
        REP(j,n) if(!visited[j] && i != j) g[i].PB(j);
    }
}

bool dfs(int p, int clr) {
    visited[p] = true;
    colour[p] = clr;
    if(clr) count1++;
    else count2++;
    bool flag = true;
    for(auto i: g[p]) {
        if(visited[i]) {
            if(colour[i] == colour[p]) flag = false;
        }
        else flag &= dfs(i, clr^1);
    }
    return flag;
}

int dp[MAXN][MAXN];

int calc(int index, int l, int r) {
    if(index == h.size()) {
        return ((l*(l-1))/2) + ((r*(r-1))/2);
    }

    if(dp[index][l] != -1) return dp[index][l];
    int res = 0;
    res = min(calc(index+1, l+h[index].x, r+h[index].y), calc(index+1, l+h[index].y, r+h[index].x));
    return dp[index][l] = res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int rn = uniform_int_distribution<int>(0, MAXN)(rng);

    cin>>n>>m;
    REP(i,m) {
        int x,y;
        cin>>x>>y;
        x--, y--;
        v[x].PB(y); v[y].PB(x);
    }

    getComplement();
    bool flag = true;
    MEM(visited, false);
    REP(i,n) {
        if(!visited[i]) {
            count1 = count2 = 0;
            flag &= dfs(i,0);
            //cout<<count1<<" "<<count2<<" as"<<endl;
            h.PB(MP(count1, count2));
        }
    }
    MEM(dp,-1);
    if(flag) cout<<calc(0,0,0);
    else cout<<"-1";
	return 0;
}






Measured memory_bytes: 7296
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t solve(int64_t n, vector<int>& buying, vector<int>& selling, int f)
{
    if (f == 0) {
        return n / buying[0] * selling[0] + n % buying[0];
    }

    int64_t result = 0;
    irep(i, n / buying[f])
    {
        int64_t tmp = i * selling[f];
        tmp += solve(n - i * buying[f], buying, selling, f - 1);
        result = max(result, tmp);
    }
    return result;
}

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

    vector<int> a(3), b(3);
    rep(i, 3)
    {
        cin >> a[i];
    }
    rep(i, 3)
    {
        cin >> b[i];
    }

    vector<int> ab, as, bb, bs;
    rep(i, 3)
    {
        if (a[i] < b[i]) {
            ab.push_back(a[i]);
            as.push_back(b[i]);
        } else if (a[i] > b[i]) {
            bb.push_back(b[i]);
            bs.push_back(a[i]);
        }
    }

    int64_t result = n;
    if (ab.size() > 0) {
        result = solve(result, ab, as, ab.size() - 1);
    }

    if (bb.size() > 0) {
        result = solve(result, bb, bs, bb.size() - 1);
    }
    cout << result << endl;

    return 0;
}

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

int main(){
    long double A, B;
    scanf("%Lf\n%Lf", &A, &B);
    if (A > B) printf("GREATER\n");
    else if (A < B) printf("LESS\n");
    else if (A == B) printf("EQUAL\n");
    return 0;
}

Measured memory_bytes: 128
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<char> S(N); REP(i, N) cin >> S[i];
    
    string ans = "Three";
    for(char c : S){
        if (c=='Y') {
            ans = "Four";
            break;
        }
    }
  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b;

    scanf("%d %d", &a, &b);

    if (a > b) {
        printf("a > b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }

    return 0;
}

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

int main(){
 string s;
 cin >> s;
  int counter = 700;
  if (s[0] == 'o') counter += 100;
  if (s[1] == 'o') counter += 100;
  if (s[2] == 'o') counter += 100;
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {long sx, sy, tx, ty;
cin >> sx >> sy >> tx >> ty;
long v = ty - sy; long h = tx - sx;
rep(i, v) cout << 'U';
rep(i, h) cout << 'R';
rep(i, v) cout << 'D';
rep(i, h) cout << 'L';
cout << 'L';
rep(i, v) cout << 'U';
cout << "UR";
rep(i, h) cout << 'R';
cout << 'D';
cout << 'R';
rep(i, v) cout << 'D';
cout << "DL";
rep(i, h) cout << 'L';
cout << 'U';


cout << endl;

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



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

using namespace std;

int main(){
    int n, k;
    cin >> n >>k;
    map<int, int> mp;
    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;
            mp[a]++;
        }
    }

    int ans = n - mp.size();
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N, t[100009], x[100009], y[100009];
	cin >> N;
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;

	int tg, dg;
	for (int i = 1; i <= N; i++) {
		cin >> t[i] >> x[i] >> y[i];
		tg = t[i] - t[i - 1];
		dg = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);

		if (tg < dg) {
			cout << "No" << endl;
			return 0;
		}
		else if ((tg - dg) % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,x0=map(int,input().split())
x=list(map(int,input().split()))
x.append(x0)
x.sort()
d=[0]*n
for i in range(n):
    d[i]=x[i+1]-x[i]
res=d[0]
for i in range(1,n):
    res=math.gcd(res,d[i])
print(res)

Measured memory_bytes: 20448
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll 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);
  return (ret);
}

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

signed main() {
  init();
  ll N, D, A;
  cin >> N >> D >> A;
  vector<P> p(N);

  rep(i, N) cin >> p[i].first >> p[i].second;
  SORT(p);

  D *= 2;
  ll tot = 0;
  queue<P> q;
  ll ans = 0;
  rep(i, N) {
    ll x = p[i].first;
    ll h = p[i].second;
    while (q.size() && q.front().first < x) {
      tot -= q.front().second;
      q.pop();
    }
    h -= tot;
    if (h > 0) {
      ll num = (h + A - 1) / A;
      ans += num;
      ll damage = num * A;
      tot += damage;
      q.emplace(x + D, damage);
    }
  }

  ANS;
  return 0;
}

Measured memory_bytes: 7832
N, A, B = map(int, input().split())

res = 0
if N >= (A + B) * pow(10, 100):
  print(A * pow(10, 100))
else:
  tmp1 = N // (A + B) * A
  if N % (A + B) >= A:
    tmp2 = A
  else:
    tmp2 = N % (A + B)

print(tmp1 + tmp2)

Measured memory_bytes: 38256
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	int h,w,n,sx,sy,i,j;
	char s[200000],t[200000];
	scanf("%d%d%d%d%d",&h,&w,&n,&sy,&sx);
	scanf("%s%s",s,t);
	int sl[200000]={0};
	int sr[200000]={0};
	int su[200000]={0};
	int sd[200000]={0};
	int tl[200000]={0};
	int tr[200000]={0};
	int tu[200000]={0};
	int td[200000]={0};
	int f=0;
	for(i=0;i<n;i++){
		if(i>0){
			sl[i]=sl[i-1];
			sr[i]=sr[i-1];
			su[i]=su[i-1];
			sd[i]=sd[i-1];
			tl[i]=tl[i-1];
			tr[i]=tr[i-1];
			tu[i]=tu[i-1];
			td[i]=td[i-1];
		}
		if(s[i]=='L')sl[i]++;
		if(s[i]=='R')sr[i]++;
		if(s[i]=='U')su[i]++;
		if(s[i]=='D')sd[i]++;
		if(sx-sl[i]+tr[i]<1)f=1;
		if(sx+sr[i]-tl[i]>w)f=1;
		if(sy+sd[i]-tu[i]>h)f=1;
		if(sy-su[i]+td[i]<1)f=1;
	//	printf("%d\n",sy-su[i]+td[i]);
		if(t[i]=='R'&&sx-sl[i]+tr[i]+1<=w)tr[i]++;
		if(t[i]=='L'&&sx+sr[i]-tl[i]-1>=1)tl[i]++;
		if(t[i]=='U'&&sy+sd[i]-tu[i]-1>=1)tu[i]++;
		if(t[i]=='D'&&sy-su[i]+td[i]+1<=h)td[i]++;
	}
	/*int txr=0,tnr=0,txu=0,tnu=0;
	int f=0;
	for(i=0;i<n;i++){
		if(i>0){
			slr[i]=slr[i-1];
			sud[i]=sud[i-1];
			tlr[i]=tlr[i-1];
			tud[i]=tud[i-1];
		}
		if(s[i]=='L')slr[i]--;
		if(s[i]=='R')slr[i]++;
		if(s[i]=='U')sud[i]--;
		if(s[i]=='D')sud[i]++;
		if(sx+slr[i]+tnr>=w)f=1;
		if(sx+slr[i]+txr<1)f=1;
		if(sy+sud[i]+tnu>=h)f=1;
		if(sy+sud[i]+txu<1)f=1;
		printf("%d\n",sy+sud[i]+txu);
		if(t[i]=='L')tlr[i]--;
		if(t[i]=='R')tlr[i]++;
		if(t[i]=='U')tud[i]--;
		if(t[i]=='D')tud[i]++;
		txr=max(txr,tlr[i]);
		tnr=min(tnr,tlr[i]);
		txu=max(txu,tud[i]);
		tnu=min(tnu,tud[i]);
	}*/
/*	int f=0,maxr=slr[0],minr=slr[0],maxu=sud[0],minu=sud[0];
	for(i=0;i<n;i++)maxr=max(maxr,slr[i]);
	for(i=0;i<n;i++)minr=min(minr,slr[i]);
	for(i=0;i<n;i++)maxu=max(maxu,sud[i]);
	for(i=0;i<n;i++)minu=min(minu,sud[i]);
	int r=maxr+tnr;
	int l=minr+txr;
	int u=maxu+tnu;
	int d=minu+txu;
	if(r+sx>=w)f=1;
	if(l+sx<=0)f=1;
	if(u+sy<=0)f=1;
	if(d+sy>=h)f=1;*/
	if(f==1)puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	lli r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, m, t, u, w;
  string s;
  cin >> n >> m >> s;
  v1i v = {0}; t = n;
  rep(i, n) if(s[i+1] == '0') v.push_back(i+1);
  stack<int> c; u = v.size()-1;
  while(t > 0){
    w = lower_bound(v.begin(), v.end(), t - m) - v.begin();
    if(w == u) break;
    else{
      c.push(v[u] - v[w]);
      u = w;
      t = v[u];
    }
  }
  if(t > 0) cout << -1 << "\n";
  else {
    while(!c.empty()){
      cout << c.top();
      c.pop();
      if(c.empty()) cout << "\n";
      else cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 1400
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

const int inf=2147483647;

int n,m;

int a[111][111];
int x[11111];
int c;

int main()
{
	cin>>n>>m;
	cin>>c;
	
	for(int i=1;i<=c;i++) cin>>x[i];
	
	int nx=1;
	int ny=0;
	
	for(int i=1;i<=c;i++)
	{
		for(int j=1;j<=x[i];j++)
		{
			if(nx%2==1)
			{
				ny++;
				
				if(ny>m)
				{
					ny--;
					nx++;
				}
			}
			else
			{
				ny--;
				
				if(ny<=0)
				{
					ny++;
					nx++;
				}
			}
			
			a[nx][ny]=i;
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<a[i][j]<<' ';
		}
		puts("");
	}
	
	return 0;
}

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

#define ll long long int
#define ld long double
#define pb push_back

ll mod = 1000000007;

using namespace std;

int main()
{
	
	 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	 int n,m;
	 cin>>n>>m;
	 int s,e;
	 cin>>s>>e;
	 for (int i = 0; i < m-1; ++i)
	 {
	 	int l,r;
	 	cin>>l>>r;

	 	s = max(s,l);
	 	e = min(e,r);
	 }

	 if(s <= e)
	 {
	 	cout<<e-s+1<<"\n";
	 }
	 else
	 {
	 	cout<<0<<"\n";
	 }
	return 0;
}

Measured memory_bytes: 256
n, p = list(map(int, input().split()))

factors = {}

while p > 1:
    f = False
    for i in range(2, int(p**0.5)+1):
        if p % i == 0:
            if i in factors:
                factors[i] += 1
            else:
                factors[i] = 1

            p //= i
            f = True
            break

    if not f:
        if p in factors:
            factors[p] += 1
        else:
            factors[p] = 1
        break

ans = 1
for factor, exp in factors.items():
    x = exp // n
    if x > 0:
        ans *= factor**x

print(ans)

Measured memory_bytes: 9444
#include <iostream>
#include <algorithm>
#include <vector>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

int main() {

    int n ;
    cin >> n  ;
    vector<int> a(n) ;
    int sum = 0 ;
    rep(i,n){
        cin >> a[i] ;
        sum+=a[i] ;
    }
    sort(a.begin(),a.end()) ;
    int mean = sum/n ;
    int ans = 0 ;
    int ans2 = 0 ;
    rep(i,n){
        ans+=(a[i]-mean)*(a[i]-mean) ;
    }

    rep(i,n){
        ans2+=(a[i]-(mean+1))*(a[i]-(mean+1)) ;
    }

    cout << min(ans,ans2) << endl ;

    return 0 ;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>
#include <sstream>
#include <iterator>
#include <map>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <limits>
#include <typeinfo>
#include <numeric>
 
#include <stdio.h>
#include <string.h>
 
using namespace std;
  
int main(int argc, char* argv[])
{
 
	unsigned N;
	bool flg;
	long long sum;
 
	cin >> N;
 
	vector <int> s(N);
 
	for(unsigned i=0;i<N;i++){
		cin >> s[i];
	}
  
	sort(s.begin(),s.end());
 
	int cnt = 0;
	flg=false;
	sum = std::accumulate(s.begin(),s.end(),0ll);
	if(sum % 10 !=0){
		flg = true;
		cout << sum << endl;
	}else{
		while(cnt < s.size()){
			if((sum - s[cnt]) % 10 != 0){
				cout << sum-s[cnt] << endl;
				flg=true;
				break;
			}
			cnt++;	
		}
	}

	if(!flg){
		cout << 0 << endl;
	}
 
	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    vec<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vec<Pa<int,int>> B;
    for(int i=0;i<H;i++){
        if(i%2){
            for(int j=W-1;j>=0;j--) B.emplace_back(i,j);
        }else{
            for(int j=0;j<W;j++) B.emplace_back(i,j);
        }
    }
    vvec<int> ans(H,vec<int>(W));
    int now = 0,sum = 0;;
    int id = 0;
    for(auto& p:B){
        if(sum+A[id]>now){
            ans[p.first][p.second] = id;
        }else{
            sum += A[id++];
            ans[p.first][p.second] = id;
        }
        now++;
    }
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cout << ans[i][j]+1 << (j!=W-1? " ":"\n");
}

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

using lint = long long int;

int main(){
    long N;
    lint A[100002]={};
    lint count = 0;

    cin >> N;
    for(long i=0;i<N;i++) cin >> A[i];

    for(long i=0;i<N;i++){
        if(A[i]%2==0){
            count += A[i]/2;
        }
        else{
            if(A[i+1]>=1){
                A[i]--;
                A[i+1]--;
                count++;
            }
            count += A[i]/2;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
N=int(b[0])
K=int(b[1])
ans=[]
c=input()
l=c.split(" ")
l1=map(int,l)
l2=list(l1)
for w in range(K):
    ans.append(max(l2))
    max_idx = l2.index(max(l2))
    del l2[max_idx]
print(sum(ans))

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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N <= A || N%500 <= A || N%500 == 0) {
	cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
int a[101010];
int main(){
    int n;
    cin>>n;
    int m=100000;
    rep(i,n){
        int x;
        scanf("%d",&x);
        a[x-1]++;
    }
    int ans1=0,ans2=0;
    rep(i,m){
        if(a[i]%2)ans1++;
        else if(a[i]>=2)ans2++;
    }   
    if(ans2%2)ans1--;
    cout<<ans1+ans2<<endl;
   return 0;
}

Measured memory_bytes: 640
n, k = gets.split(" ").map(&:to_i)

a = []
n.times do
  a.push gets
end

a.uniq!

m = {}
a.each do |i|
  if m[i[0]]
    m[i[0]] += 1
  else
    m[i[0]] = 1
  end
end

m = m.values.sort.reverse
c = 0
while m.size >= k
  (0..k-1).each do |i|
    m[i] -= 1
  end
  m.delete(0)
  m.sort!.reverse!
  c += 1
end

puts c


Measured memory_bytes: 4220
url = "https://atcoder.jp/contests/abc043/tasks/abc043_b"

def main():

    a = input()
    a = list(a)

    ans = []

    for v in a:
        if v == "B":
            if len(ans) == 0:
                pass
            else:
                ans.pop(-1)
        else:
            ans.append(v)
    print(''.join(ans))


if __name__ == '__main__':
    main()




Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=200005;
int n,m,vis[maxn],flg,cnt;long long ans,a,b,c;
int e,son[maxn],lnk[maxn],nxt[maxn],w[maxn];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
inline void add_e(int x,int y,int z){son[++e]=y;w[e]=z;nxt[e]=lnk[x];lnk[x]=e;}
void DFS(int x,int y){
	if(~vis[x]){flg|=vis[x]!=y;return;}
	vis[x]=y;y==0?a++:y==1?b++:c++;
	for (int i=lnk[x];i;i=nxt[i]) DFS(son[i],(y+3+w[i])%3),cnt+=w[i]>0;
} 
int main(){
	n=read(),m=read();
	for (int i=1,x,y;i<=m;i++)
	x=read(),y=read(),add_e(x,y,1),add_e(y,x,-1);
	memset(vis,255,sizeof vis);
	for (int i=1;i<=n;i++) if(!~vis[i]){
		a=b=c=flg=cnt=0;DFS(i,0);
		if(flg) ans+=(a+b+c)*(a+b+c);
		else if(b&&c) ans+=a*b+b*c+c*a;else ans+=cnt;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    int cnt=1;
    int first=a[0];
    for(int i=1; i<n;i++){
        if(first > a[i]){
            cnt++;
            first=a[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int x;
	cin >> x;
	int ans = 1;
	while(1) {
		if((ans * x % 360) == 0) {
			cout << ans;
			return 0;
		}
		ans++;
	}

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    if(n == 1) cout << 0;
    else{
        sort(a.begin(),a.end());
        cout << a[n-1] - a[0];
    }
}


Measured memory_bytes: 256
def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d[i] = cnt
    
    if temp!=1:
        d[temp] = 1
    
    if len(d) == 0:
        d[n] = 1
    
    return d

def check(d):
  v = d[0]
  if v == 1:
    return False
  for _v in d:
    if _v != v:
      return False
  return True

X = int(input())
for x in range(X, 1, -1):
  d = list(factorization(x).values())
  if check(d):
    print(x)
    quit()
  
print(1)  

Measured memory_bytes: 3188
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n=0;
		char p='.';
		for (char ch : sc.next().toCharArray()) {
			n=((p=='.'||p=='S') && ch=='R') ? 1 : n;
			if (ch=='R' && p=='R') n++;
			p=ch;
		}
		System.out.println(n);
		sc.close();	
	}

	public static void main(String args[]) {
		solve();
	}

}


Measured memory_bytes: 35336
#include<bits/stdc++.h>
using namespace std;
#define N 100005
typedef long long LL;
int n,tot;
LL a[N],a1[N];
int main()
{
	int T=1;
	//scanf("%d",&T);
	while(T--)
	{
		tot=0;
		map<LL,LL>mp;
		bool f1=0,ff=0;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%lld",&a[i]);
			if(a[i]==0)
				f1=1;
			mp[a[i]]++;
			if(mp[a[i]]==1)
				a1[++tot]=a[i];
			if(tot>3)
			{
				ff=1;
				break;
			}
		}
		if(f1)
		{
			if(tot>2)
			{
				ff=1;
			}
			else if(tot==2)
			{
				for(int i=1;i<=2;i++)
					if(a1[i]!=0)
					{
						if(mp[a1[i]]!=2*mp[0])
							ff=1;
						break;
					}
				printf("%s\n",ff?"No":"Yes");
				continue;
			}
		}
		else if(tot!=3)
			ff=1;
		for(int i=1;i<3;i++)
			if(mp[a1[i]]!=mp[a1[i+1]])
				ff=1;
		if(ff)
		{
			printf("No\n");
			continue;
		}
		ff=1;
		for(int i=1;i<=3;i++)
			for(int j=1;j<=3;j++)
				for(int k=1;k<=3;k++)
					if(i!=j&&j!=k&&i!=k&&(a1[i]^a1[j])==a1[k])
						ff=0;
		printf("%s\n",ff?"No":"Yes");
	}
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

long long int arr[(int)1e5 + 1];
long long int dp[(int)1e5 + 1];

int main() {
	
	int n,k; scanf("%d %d",&n,&k);

	for(int i = 0; i < n; i++)
		scanf("%lld",&arr[i]);

	for(int i = 0; i < n; i++){
		
		if(i == 0)
			dp[i] = 0;
		else if(i == 1)
			dp[i] = abs(arr[i]-arr[i-1]);
		else if(i < k) {

			dp[i] = abs(arr[i]-arr[i-1]) + dp[i-1];

			for(int j = 1; j <= i; j++){
				dp[i] = min(dp[i],abs(arr[i]-arr[i-j]) + dp[i-j]);
			}
		}
		else {
			
			dp[i] = abs(arr[i]-arr[i-1]) + dp[i-1];
			
			for(int j = 1; j <= k; j++){
				dp[i] = min(dp[i],abs(arr[i]-arr[i-j]) + dp[i-j]);
			}
		}
	}

	printf("%lld\n",dp[n-1]);

	return 0;
}

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

int main() {
  int N,M;
  cin >> N>>M;
  vector<int> a(N+1);
  int i;
  for(i=0;i<2*M;i++){
    int s;
    cin >> s;
    a.at(s)++;
  }
  for(i=1;i<N+1;i++){
    cout<<a.at(i)<<endl;
  }
}


Measured memory_bytes: 256