akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
};
using namespace utils;


void sub_main(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    vector<ll> A(N);
    ll sum = 0;
    for (auto &&a : A) {
        cin >> a;
        sum += a;
    } // end a
    A.push_back(A[0]);
    ll Ns = N * (N + 1) / 2;
    if(sum % Ns != 0) {
        cout << "NO\n";
        return;
    }
    ll k = sum /Ns ;

    ll tsum = 0;
    for (auto &&i : Repeater(0, N)) {
        ll dif = k - A[i+1] + A[i];
        if(dif % N != 0 or dif < 0){
            cout << "NO\n";
            return ;
        }
        tsum += dif / N;
    } // end i

    if(tsum == k) cout << "YES\n";
    else cout << "NO\n";


}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test_B.txt";
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

typedef long long ll;
const ll maxn = 1e18;

int main() {
	/* freopen("input.in", "r", stdin);
	freopen("output.o", "w", stdout); */
	ll h, w;
	scanf("%lld %lld", &h, &w);
	ll a1, a2, a3;
	ll ans = maxn;
	ll totarea = h * w;
	for (ll i = 1; i <= h; i++) {
		a1 = i * w;
		ll tmp = totarea - a1;
		if (tmp % 2 == 0) {
			a2 = tmp / 2;
			a3 = tmp / 2;
		} else {
			ll diff = min(h-i, w);
			a2 = (tmp - diff) / 2;
			a3 = a2 + diff;
		}
		ll minn = min(min(a1, a2), a3);
		ll maxx = max(max(a1, a2), a3);
		ans = min(ans, maxx - minn);
	}
	ll pls;
	pls = h;
	h = w;
	w = pls;
	for (ll i = 1; i <= h; i++) {
		a1 = i * w;
		ll tmp = totarea - a1;
		if (tmp % 2 == 0) {
			a2 = tmp / 2;
			a3 = tmp / 2;
		} else {
			ll diff = min(h-i, w);
			a2 = (tmp - diff) / 2;
			a3 = a2 + diff;
		}
		ll minn = min(min(a1, a2), a3);
		ll maxx = max(max(a1, a2), a3);
		ans = min(ans, maxx - minn);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
int main(int argc, char const *argv[]){
    ll n, k;
    bool flg=true;
    cin >> n >> k;
    vector<ll> a(n+10);
    vector<ll> b(n+10);
    rep(i, n) cin >> a[i];
    for(int i=0;i<k;i++){
        b = vector<ll>(n+10,0);
        rep(i,n){
            b[(-a[i]+i) > 0 ? (-a[i]+i):0]++;
            b[(i+a[i])>n ? n : (i+a[i]+1)]--;
        }
        ll tot=0;
        flg=true;
        rep(i,n){
            tot+=b[i];
            a[i]=tot;
            if(tot!=n)flg=false;
        }
        if(flg)break;
    }
    rep(i,n-1){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    return 0;
}




Measured memory_bytes: 7940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  double R; cin >> R;
  cout << fixed << setprecision(6) << 2.0*M_PI*R << endl;
  return 0;
}


Measured memory_bytes: 3772
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)
	for i := 1; i < len(s); i++ {
		mid := (len(s) - i) / 2
		if s[:mid] == s[mid:len(s)-i] {
			fmt.Println(mid * 2)
			return
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll N;
    cin >> N;
    ll ans = 0;
    vector<ll> fives(30);
    fives[0] = 1;
    REP(i,27)fives[i+1] = fives[i] * 5;
    if(N%2 == 1){
        ans = 0;
    }else{
        REP(i,26){
            ans = ans + N/2/fives[i+1];
        }
    }
    cout <<ans<< "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	int ans = min({a+b, b+c, c+a});
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	ll H, N,sm=0;
	cin>>H >> N;
	string s = "No";
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
		sm += vec.at(i);
	}

	if (sm >= H) {
		s = "Yes";
	}
	cout << s << endl;
	
	
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    // printf("%lld\n", scoring(BestT));

    double BestScore = scoring(BestT);

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1);

    double T0 = 1e6;
    double T1 = 1e2;
    double TL = 1950;

    ll count = 0;

    while (1)
    {
        auto end = chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                 // 要した時間を計算
        auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();

        if (msec >= 1950)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        double score = scoring(t);

        if (exp((score - BestScore) / T) > 0.5)
        {
            BestT = t;
            BestScore = score;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }

    // printf("%lld\n", scoring(BestT));
}


Measured memory_bytes: 4488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
  

  int main(){
      lint N,Q;
      string s;
      cin>>N>>Q;
     if(N*500>=Q) cout<<"Yes";
     else cout<<"No";
  }
  

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int x = 0, y = 0, z = 0;
    rep(i, n){
        if(p[i] <= a)       x++;
        else if(p[i] <= b)  y++;
        else                z++;
    }

    cout << min(x, min(y, z)) << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000;

LL dfs(LL N,LL x,LL sum){
    if(N%x==0){
        return sum+=N*2-x;
    }
    return dfs(x,N%x,sum+N/x*2*x);
}

int main(){
    LL N,x;
    cin >> N >> x;
    if(x%(N-x)==0){
        cout << x*3 << endl;
    }
    else if(x>N-x) cout << dfs(N-x,x%(N-x),x/(N-x)*(N-x)*2+N) << endl;
    else cout << dfs(N-x,x,x/(N-x)*(N-x)*2+N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,x=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++)
	{
		if(c%i==0)
		{
			x++;
		}
	}
	cout<<x<<endl;
		return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

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

	char c[10000];

	scanf("%s", c);

	int cnt = 0;
	while(c[cnt] != '\0') {
		c[cnt] += N;
		if (c[cnt] > 'Z') {
			c[cnt] = c[cnt] - 'Z' + 'A'-1;
		}

		printf("%c", c[cnt]);

		cnt++;
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
cond = [int(n) for n in input().split(" ")]
exclude = {n for n in range(10)}
answer = ""
mo = {str(n) for n in input().split(" ")}
exclude = exclude - mo
for n in range(cond[0],100000):
    for m in [n for n in str(n)]:
        if m in mo:
            break
    else:
        print(n)
        break

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

namespace AGC018A
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NK = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            long[] A = Console.ReadLine().Split(' ').Select(b => long.Parse(b)).ToArray();
            Console.WriteLine(solve(NK[1], A) ? "POSSIBLE" : "IMPOSSIBLE");
        }

        static bool solve(long K, long[] A)
        {
            if (K > A.Max())
            {
                return false;
            }

            long Gcd = A[0];

            for (int i = 0; i < A.Length; i++)
            {
                Gcd = gcd(A[0], A[i]);
            }

            if (K % Gcd == 0)
            {
                return true;
            }

            return false;
        }

        static long gcd(long a, long b)
        {
            long mod;
            while (b != 0)
            {
                mod = a % b;
                a = b;
                b = mod;
            }

            return a;
        }
    }
}

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

int main(){

	int a,b,c;
	int ans = 0;

	cin >> a >> b >> c;
	for (int i = a; i <= b; i++){
		if ((c % i) == 0){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1164
def f(a,b):
    a,b=min(a,b),max(a,b)
    if b%a==0:
        return (2*b//a-1)*a
    else:
        return 2*a*(b//a)+f(a,b%a)

n,x=map(int,input().split())
print(n+f(x,n-x))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans;
	for(int i=1;i<b+1;i++){
		if((a*i)%b == c){
			ans = "YES";
			break;
		}else{
			ans = "NO";
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
// int = ll;

int main(){
	
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	
	ll a[2];	
	
	cin >> a[0] >> a[1] >> a[2];
	
	if((a[0]+a[1]+a[2])>=22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
	
return 0;	
}


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

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

    double propbability = 0;
    for (int i = 1; i < n + 1; i++){
        double proi = 1.0 / n;
        int point = i;
        while (point < k){
            point *= 2;
            proi *= 0.5;
        }

        propbability += proi;
    }
    cout << fixed;
    cout << setprecision(10) << propbability << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main() {
  int N,x,count=0;
  cin>>N>>x;
  vector<int> a(N);
  	for(int i=0;i<N;i++){
      cin>>a.at(i);
    }
  sort(a.begin(),a.end());
      for(int i=0;i<N-1;i++){
      	x-=a.at(i);
        	if(x<0){
              break;
            }
        count++;
      }
  if(x==a.at(N-1)){
    count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)
#define endl "\n"
//#define LLONG_MAX 99999999999999
typedef long long int lli;
int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    lli n,i,j,b,a,q,m;
    lli t=1;
    //cin>>t;
    while(t--){
        cin>>n;
        map<string,lli> mp;
        lli ac,wr,tl,rt;
        ac=0;
        wr=0;
        rt=0;
        tl=0;
        while(n--){
					string s;
					cin>>s;
					if(s[0]=='A'){
						ac++;
					}
					if(s[0]=='W'){
						wr++;
					}
					if(s[0]=='T'){
						tl++;
					}
					if(s[0]=='R'){
						rt++;
					}
        }
        cout<<"AC x "<<ac<<endl<<"WA x "<<wr<<endl<<"TLE x "<<tl<<endl<<"RE x "<<rt<<endl;

    }


}



Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static int min2(int a,int b){
        return (a<b)?a:b;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int H=sc.nextInt();
        int W=sc.nextInt();
        int[][] MAP=new int[H][W];
        int[][] D=new int[H][W];
        
        for(int i=0;i<H;i++){
            String tmp=sc.next();
            for(int j=0;j<W;j++){
                if(tmp.charAt(j)=='#'){
                    MAP[i][j]=1;
                }else{
                    MAP[i][j]=0;
                }
            }
        }
        
        if(MAP[0][0]==0){
            D[0][0]=0;
        }else{
            D[0][0]=1;
        }
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                int Upper;
                int Lefty;
                if(i==0&&j==0){
                    continue;
                }
                
                if(i>0&&j>0){
                    if(MAP[i][j]==1&&MAP[i-1][j]==0){
                        Upper=D[i-1][j]+1;
                    }else{
                        Upper=D[i-1][j];
                    }
                    
                    if(MAP[i][j]==1&&MAP[i][j-1]==0){
                        Lefty=D[i][j-1]+1;
                    }else{
                        Lefty=D[i][j-1];
                    }
                    
                    D[i][j]=min2(Upper,Lefty);
                }else if(i==0&&j>0){
                    if(MAP[i][j]==1&&MAP[i][j-1]==0){
                        D[i][j]=D[i][j-1]+1;
                    }else{
                        D[i][j]=D[i][j-1];
                    }
                }else{
                    if(MAP[i][j]==1&&MAP[i-1][j]==0){
                        D[i][j]=D[i-1][j]+1;
                    }else{
                        D[i][j]=D[i-1][j];
                    }
                }
            }
        }
        
        System.out.println(D[H-1][W-1]);
    }
}


Measured memory_bytes: 22100
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	int N;cin >> N;
	if(N%1000 == 0){
		cout << 0 << endl;
		return 0;
	}
	cout << 1000 - N % 1000 << endl;
}	

Measured memory_bytes: 11004
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int X = in.nextInt();
        int count = 0; 
        
        for (int i = 0; i <= A; i++)
        {
            for (int j= 0; j <= B; j++)
            {
                for (int k = 0; k <= C; k++)
                {
                    if ((i*500) + (j*100) + (k*50) == X)
                    {
                        count++;
                    }
                }   
            }
        }
        System.out.println(count);



    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


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

using namespace std;

const long long inf = 1e18 + 7;
const int maxn = 1e2 + 5;
const int maxv = 1e5 + 5;
long long dp[maxv]; // min weight to make an exact value of v
int n, w, g;
pair<int, int> a[maxn];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long total = 0;
    cin >> n >> w;
    for(int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second; // first is weight, second is value
        total += a[i].second;
    }
    fill(dp, dp + 1 + total, inf);
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = total; j >= 0; j--) {
            if(a[i].second <= j) {
                dp[j] = min(dp[j - a[i].second] + a[i].first, dp[j]);
            }
        }
    }
    for(int i = total; i >= 0; i--) {
        if(dp[i] <= w) {
            cout << i << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 1024
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max = a + b;
		if(a - b > max){max = a - b;}
		if(a * b > max){max = a * b;}
		System.out.println(max);
	}
}


Measured memory_bytes: 35684
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAX=1e5+5;
int a[MAX];
int G[105][105];

int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;++i)
            cin>>a[i];
        int c=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[c]>0) {G[i][j]=c;--a[c];}
                   else if(a[c]==0) {++c;G[i][j]=c;--a[c];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[c]>0) {G[i][j]=c;--a[c];}
                    else if(a[c]==0) {++c;G[i][j]=c;--a[c];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) cout<<G[i][j]<<" ";
                else cout<<G[i][j]<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String a = sc.next();
		String b = sc.next();
		int c = Integer.valueOf(a + b);
		String ans = "Yes";
		
		if (Math.sqrt(c) % 1 != 0) {
			ans = "No";
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(i < 10 || (i >= 100 && i <= 999) ||
           (i >= 10000 && i <= 99999)){
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	bool flag=0;
	int N;
	string S;

	cin >> N;
	cin >> S;

	rep(i, N/2 -1){
		if(S[i] != S[i+N/2]){
			flag = 1;
		}
	}
	if(N == 1 || N % 2 == 1)
		flag = 1;
	if (flag == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


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


int main() 
{
    int N,K;
    cin >> N >> K;
    
    int ans = 1e9;
    for (int i = 1; i <= N; i++) {
        int sum = 1; 
        for (int j = 1; j <= i; j++) {
            sum *= 2;
        }
        sum += K*(N-i);
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int a, b;
    cin >> a >> b;
    int s = 6;
    cout << s - a - b << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        x--;
        p[x] = i;
    }
    int t = 1, mx = 1;
    for(int i = 0; i < n-1; i++) {
        if(p[i]<p[i+1]) {
            t++;
        }else{
            t = 1;
        }
        chmax(mx, t);
    }
    int ans = n-mx;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge{
    int from, to;
    lint cost;
};

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

bool bellman_ford(int v, const vector<edge>& es, vector<long long>& cost, int s = 0, int g = -1){
    if(g == -1){
        g = v - 1;
    }

    constexpr long long INF = 1LL << 61;

    cost.resize(v);
    fill(cost.begin(), cost.end(), INF);
    cost[s] = 0;

    for(int i = 0 ; i < v * 2 ; ++i){
        for(auto& e : es){
            if(cost[e.from] < INF && cost[e.from] + e.cost < cost[e.to]){
                if(i >= v - 1 && e.to == g){
                    return false;
                }else if(i >= v - 1){
                    cost[e.to] = -INF;
                }else{
                    cost[e.to] = cost[e.from] + e.cost;
                }
            }
        }
    }

    return true;
}

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

    int n, m;
    lint p;
    cin >> n >> m >> p;

    vector<edge> es;
    for(int i = 0 ; i < m ; ++i){
        int a, b;
        lint c;
        cin >> a >> b >> c;
        es.push_back({a - 1, b - 1, p - c});
    }

    vector<lint> cost;

    if(bellman_ford(n, es, cost)){
        cout << max(-cost[n - 1], 0LL) << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

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

int main()
{
	int N;
	float A[51];

	cin >> N;

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

	float tmp;

	

	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j > i; j--)
		{
			if (A[j] < A[j-1])
			{
				tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
			}
		}
	}

	float avg = (A[0] + A[1])/2;

	for (int i = 2; i < N; i++)
	{
		avg = (A[i] + avg) / 2;
	}

	cout << avg << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 100

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main()
{
    int n, i, j, k, tmp1, tmp2, sum=0;
    
    scanf("%d", &n);
    
    for (i=1; i<=n; i++) {
        for (j=1; j<=n; j++) {
            tmp1=euclid(i, j);
            for (k=1; k<=n; k++) {
                sum+=euclid(tmp1, k);
            }
        }
    }
    
    printf("%d", sum);
    
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<ll> a(n); rep(i,n) cin >> a[i];

  ll left = 0, left_p = 0;
  ll right = 0, right_p = n-1;
  rep(i,n){
    if(left < right){
      left += a[left_p];
      left_p++;
    }
    else{
      right += a[right_p];
      right_p--;
    }
  }

  ll ans = abs(left-right);


  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <vector>
using namespace std;

typedef vector<int> Row;
typedef vector<Row> Matrix;

Matrix scan_matrix(int r, int c)//?????????????????????
{	
	Matrix matrix;
	
	for(int i = 0; i < r; i++){	
		Row row;//???
		for(int j = 0; j < c; j++){
			int a;
			scanf("%d", &a);
			row.push_back(a);
		}
		matrix.push_back(row);
	}
	return matrix;
}

void print_matrix(Matrix matrix)//???????????????
{
	int r = matrix.size();
	for(int i = 0; i < r; i++){	
		Row row = matrix[i];
		int c = row.size();
		for(int j = 0; j < c; j++){
			if(j == 0){
				printf("%d", row[j]);
			}
			else{
				printf(" %d", row[j]);
			}
		}
		printf("\n"); 
	}
}

Matrix add_sum(Matrix matrix)//????????????????????????????¨?????????????
{	
	//???????????????????¨??????????
	int r = matrix.size();
	for(int i = 0; i < r; i++){	
		Row row = matrix[i];//???
		int row_sum = 0;	//??????????¨?
		int c = row.size();	//?????°
		for(int j = 0; j < c; j++){
			row_sum += row[j];
		}
		matrix[i].push_back(row_sum);
	}
	
	//?????????????¨?????????????????????????
	Row row = matrix[0];
	int c = row.size();	//?????°
	Row retsu_sum(c);	//??????????¨?
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			retsu_sum[j] += matrix[i][j];
		}
	}
	
	matrix.push_back(retsu_sum);
	
	return matrix;
}

int main(void)
{
	vector<Row> matrix;
	
	int r, c;//r???c???
	scanf("%d %d", &r, &c);
	
	matrix = scan_matrix(r, c);
	matrix = add_sum(matrix);
	print_matrix(matrix);
}

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

n = int(input())
task = []
time_total = [-1 for i in range(n)]
for i in range(n):
    task.append([int(i) for i in input().split()])
task_sorted = sorted(task, key = lambda x:x[1])
time_total[0] = task_sorted[0][0]
for i in range(n - 1):
    time_total[i + 1] = time_total[i] + task_sorted[i + 1][0]
for i in range(n):
    if time_total[i] > task_sorted[i][1]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 47608
#include <iostream>

using namespace std;


string solve(int n){
  if(n % 100 >= 13 || n % 100 == 0){
    if(n / 100 >= 13 || n / 100 == 0){
      return "NA";
    }
  }
  if(n % 100 >= 1 && n % 100 <= 12){
    if(n / 100 >= 1 && n / 100 <= 12){
      return "AMBIGUOUS";
    }
  }
  if(n % 100 >= 1 && n % 100 <= 12){
    return "YYMM";
  }
  if(n / 100 >= 1 && n / 100 <= 12){
    return "MMYY";
  }
}

int main(void){
  int n;
  scanf("%d", &n);
  // cout << n << '\n';
  cout << solve(n) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if(a[i] < a[j])
            {
                ans++;
            }
        }
    }
    ll per = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(a[i] < a[j])
            {
                per++;
            }
        }
    }
    ans = ans * k % MOD;
    ll ex = k * (k-1) / 2 % MOD;
    ll suma =  per * ex % MOD;
    cout << (ans + suma) % MOD << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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 (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<int> p(m),y(m);
    vector<vector<pair<int,int>>> a(n);
    REP(i,m){
        cin >> p[i] >> y[i];
        p[i]--;
        a[p[i]].push_back({y[i],i});
    }
    vector<pair<int,int>> ans(m);
    REP(i,n){
        sort(ALL(a[i]));
        REP(j,a[i].size()){
            ans[a[i][j].second]={i+1,j+1};
        }
    }
    REP(i,m){
        printf("%06d%06d\n",ans[i].first,ans[i].second);
    }
}

Measured memory_bytes: 10288
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
//typedef long long int LL;
//typedef __int64 LL;

int n;
int p[20004];
int a[20004], b[20004];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);

	for (int i = 1; i <= n; i++) {
		a[i] = 2 * n * i;
	}

	for (int i = 1; i <= n; i++) {
		b[p[i]] = 2 * n * (n - p[i] + 1) + i - 1;
	}

	for (int i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");

	for (int i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", b[i]);
	}
	printf("\n");

	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
    while(true){
        int h, w;
        cin >> h >> w;
        if (h + w == 0) break;
        vector <string> ans(h, string(w, '#'));
        REP(i, h) {
            REP(j, w) {
                if ((i + j) % 2 == 1) {
                    ans[i][j] = '.';
                }
            }
            cout << ans[i] << endl;
        }
        cout << endl;
    }
}


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

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

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

    sort(a, a + n);

    cout << abs(a[0] - a[n - 1]) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int red=0;
    int white=0;
    vector<char> C(N);
    for (int i=0;i<N;i++) {
        cin >> C.at(i);
        if(C.at(i)=='R') {
            red++;
        }
        else{
            white++;
        }
    }
    
    int ans=red;
    int R=red;
    int L=0;
    for (int i=0;i<N;i++) {
        if(C.at(i)=='R') {
            R--;
        }else {
            L++;
        }
        ans=min(ans,max(L,R));
    }
    
    cout << ans << endl;        
}

Measured memory_bytes: 3616
//##MohK
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
using ld = long double;
int main()
{
  ll a,sum=0;
  cin>>a;
  ll x=a;
  while(a!=0){
    sum=sum+a%10;
    a=a/10;
  }
  ll y=x%sum;
  if(y==0){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }

    return 0;
}


Measured memory_bytes: 256
import math
N,D = map(int,input().split())

df = []
for i in range(N):
  df.append(list(map(int,input().split())))
 
count = 0
for i in range(N):
  for j in range(i + 1,N):
    a = 0
    for k in range(D):
      a += (df[i][k] - df[j][k])**2
    
    a = math.sqrt(a)
    if a - int(a) == 0:
      count += 1
print(count)

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

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return;
        if (-par[x] < -par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};
    
int main() {
    int N; cin >> N;
    vector<long long> x(N), y(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

   
    using pint = pair<int,int>;
    using Edge = pair<long long, pint>;
    vector<Edge> edges;

   
    vector<int> ids(N);
  
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[j]; });
    for (int i = 0; i+1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(x[v] - x[u], pint(u, v)));
    }

    
    sort(ids.begin(), ids.end(), [&](int i, int j) { return y[i] < y[j]; });
    for (int i = 0; i+1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(y[v] - y[u], pint(u, v)));
    }

    
    sort(edges.begin(), edges.end());
    UnionFind uf(N);
  
    long long res = 0;
  
    for (auto e : edges) {
      
        int u = e.second.first, v = e.second.second;
        long long ant = e.first;
        if (uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += ant;
    }
    cout << res << endl;
}

Measured memory_bytes: 8432
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()


ll n;
 
void solve(){
 cin >> n;
 vp res;
 rep(i,1,n+1){ 
  rep(j,1,i){
   if(n%2&&(i+j)==n) continue;
   if(n%2==0&&(i+j)==n+1) continue;
   res.eb(P(i,j)); 
  }
 }
  cout << res.size() << endl;
  for(P p:res) cout << p.fi << " " << p.se << endl;

}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

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

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

	int K;
	cin >> K;
	vector<int> ans = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout << ans[K-1] << "\n";
}

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

int main(){
	vector<vector<double> > mat(2, vector<double>(3));
	while(cin>>mat[0][0]>>mat[0][1]>>mat[0][2]>>mat[1][0]>>mat[1][1]>>mat[1][2]){
		if(mat[1][0]!=0) swap(mat[0], mat[1]);
		for(int i=0; i<2; i++){
			if(mat[i][0]!=0){
				for(int j=2; j>=0; j--){
					mat[i][j] /= mat[i][0];
				}
			}
		}
		if(mat[1][0]!=0){
			for(int i=0; i<3; i++){
				mat[1][i] -= mat[0][i];
			}
		}
		mat[1][2] /= mat[1][1];
		mat[0][2] -= mat[1][2]*mat[0][1];
		
		cout << fixed;
		cout << setprecision(3);
		cout << mat[0][2] << " " << mat[1][2] << endl;
	}
	return 0;
}

Measured memory_bytes: 3180