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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

using Graph = vector<Vi>;
Graph g;
int N, M;

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    cin >> N >> M;
    g.resize(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    for (int i = 0; i < N; i++) {
        sort(g[i].begin(), g[i].end());
    }

    ll ans = 0;
    Vi perm(N);
    for (int i = 0; i < N; i++) {
        perm[i] = i;
    }

    while (perm[0] == 0) {
        bool ok = true;
        for (int i = 1; i < N; i++) {
            if (!binary_search(g[perm[i - 1]].begin(), g[perm[i - 1]].end(), perm[i])) {
                ok = false;
            }
            if (!ok) {
                break;
            }
        }

        if (ok) {
            ++ans;
        }

        next_permutation(perm.begin(), perm.end());
    }

    cout << ans << endl;

    return 0;
}

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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<ll, ll>;

signed main() {
	string s; cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	return 0;
}



Measured memory_bytes: 3564
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a=LIST()
    if sum(a)<=21:
        print('win')
    else:
        print('bust')
if __name__ == '__main__':
    do()

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

int main(int argc, const char * argv[]) {
    int a, b;
    
    cin >> a >> b;
    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  var input = input.split("\n");
  var vals = input[0].split(" ");

  var result = vals.reduce((s,v) => +s + +v,0)
  console.log(result > 21 ? 'bust' : 'win');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int N, A_i;
double inv_ans;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> A_i;
        inv_ans += 1.0/A_i;
    }
    
    printf("%.6f", 1/inv_ans);
    
    return 0;
}



Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

def gcd(x, y):
    while(y > 0):
        x, y = y, x%y
    return x

E = C * D // gcd(C, D)
ac = (A-1) // C
ad = (A-1) // D
acd = (A-1) // E
bc = B // C
bd = B // D
bcd = B // E

print(B-A+1-(bc-ac)-(bd-ad)+(bcd-acd))



Measured memory_bytes: 3060
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define PI             acos(-1.0)
#define IOS            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ms(a,b)         memset(a, b, sizeof(a))
#define filein      freopen("input.txt", "r", stdin);
#define fileout     freopen("output.txt", "w", stdout);
#define debug       cout<<"Hello, i am in here."<<endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
using namespace std;
const int MOD = (int)1e9+7;
/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
void solve()
{
 ll n;
 cin>>n;
 if(n%1000==0){
  cout<<0<<endl;
 }
 else cout<<1000-(n%1000)<<endl;
}
int  main()
{
    IOS
    solve();
    return 0;
}


Measured memory_bytes: 3624
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

dp = {}

def dp_search(L, R, D, num_dic):
    global dp
    if (L, R) in dp:
        return dp[(L, R)]
    if L== R:
        return 0

    if L + D == R:
        now_pos = num_dic[L]
        next_pos = num_dic[R]
        dp[(L, R)] =  abs(next_pos[0] - now_pos[0]) + abs(next_pos[1] - now_pos[1])
        return dp[(L, R)]

    dp[(L, R)] = dp_search(L , R - D, D , num_dic) + dp_search(L + D , R, D , num_dic)

    return dp[(L, R)]


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W, D] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    num_dic= {}
    for i in range(H):
        input_raw = read_func().strip().split()
        for j in range(W):
            num_dic[int(input_raw[j])] = (i, j)
    input_raw = read_func().strip().split()
    [Q] = [int(input_raw[0])]
    test_list = []
    for i in range(Q):
        input_raw = read_func().strip().split()
        test_list.append((int(input_raw[0]), int(input_raw[1])))

    dp = [[] for i in range(D)]

    for i in range(0, H * W):
        A = i + 1
        if len(dp[A % (D)]) == 0:
            dp[A % (D)].append((A, 0))
        else:
            (prev_point, prev_cost)= dp[A % D][len(dp[A % D]) - 1]
            prev_pos = num_dic[prev_point]
            now_pos = num_dic[A]
            dp[A % (D)].append((A, prev_cost +abs(prev_pos[0] - now_pos[0]) + abs(prev_pos[1] - now_pos[1])))

    for test in test_list:
        L = test[0]
        R = test[1]
        if L==R:
            print 0
        else:
            print (dp[L % (D)] [R/(D) - 1 + (1 if R % D != 0 else 0)][1] -
                    (dp[L % (D)] [L/(D) - 1 + (1 if L % D != 0 else 0)][1] ))




if __name__ == '__main__':
    main()


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

int main() {
  int h, w;
  cin >> h >> w;
  
  int i, j;
  vector<char> c(w);
  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      cin >> c.at(j);
    }
    for(j = 0; j < w; j++){
      cout << c.at(j);
    }
    cout << endl;
    for(j = 0; j < w; j++){
      cout << c.at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size()) 
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
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 <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

bool dp1[3050];
bool dp2[3050];
int main() {
	int A, B, C, D, E, F, i, j;
	scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);

	dp1[0] = true;
	dp2[0] = true;
	for (i = A; i <= F; i++) dp1[i] |= dp1[i - A];
	for (i = B; i <= F; i++) dp1[i] |= dp1[i - B];
	for (i = C; i <= F; i++) dp2[i] |= dp2[i - C];
	for (i = D; i <= F; i++) dp2[i] |= dp2[i - D];
	
	ll a1 = 1, a2 = 0;
	for (i = 1; i * 100 <= F; i++) {
		for (j = 0; i * 100 + j <= F; j++) {
			if (j > i*E) continue;
			if (!dp1[i] || !dp2[j]) continue;
			ll v1 = i * 100 + j, v2 = j;
			if (a2*v1 <= a1*v2) {
				a1 = v1;
				a2 = v2;
			}
		}
	}
	return !printf("%lld %lld\n", a1, a2);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
int main(void)
{
  double r;
  std::cin >> r;
  std::cout << std::fixed << std::setprecision(6) << r * r * M_PI << " " << 2 * r * M_PI << std::endl;
}

Measured memory_bytes: 1288
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int w = s[0];
            int a = s[1];
            int b = s[2];
            if (b > a + w)
            {
                WriteLine(b - (a + w));
            }
            else if (b + w < a)
            {
                WriteLine(a - (b + w));
            }
            else WriteLine(0);
        }

        
    }
}


Measured memory_bytes: 11348
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try (java.util.Scanner sc = new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                if(n==0){break;}
                int[] scores = new int[n];
                for(int i=0; i < scores.length; i ++){
                    scores[i] = sc.nextInt();
                }
                double average = 0, variance = 0;
                int sum = 0;
                for(int i=0; i < scores.length; i ++){
                    sum += scores[i];
                }
                average = (double)sum / n;
                double var = 0;
                for(int i=0; i<scores.length; i ++){
                    var += Math.pow(scores[i] - average, 2);
                }
                variance = var/n;
                System.out.println(String.format("%.8f",Math.sqrt(variance)));
            }
            sc.close();
        } 
    }
}


Measured memory_bytes: 31764
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

#define MOD 1e7+7
typedef long long ll;

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

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

ll myasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

ll mydsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

int flag;
ll h, w, d, q, a, x[90001], y[90001], l, r, dp[90000];
char s[11];

int main() {
	scanf("%lld%lld%lld", &h, &w, &d);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			scanf("%lld", &a);
			x[a] = i, y[a] = j;
		}
	}
	for (int i = 0; i + d <= h * w; i++) {
		dp[i + d] = dp[i] + labs(x[i] - x[i + d]) + labs(y[i] - y[i + d]);
	}
	scanf("%lld", &q);
	for (int i = 0; i < q; i++) {
		scanf("%lld%lld", &l, &r);
		printf("%lld\n", dp[r] - dp[l]);
	}

	return 0;
}

Measured memory_bytes: 4192
#include <cstdio>

#define MAX 100000

int main()
{
	int N, K, D[MAX], ans, copy[10];
	scanf("%d %d", &N, &K);
	for(int i=0; i<K; i++){
		scanf("%d", &D[i]);
	}
	while(1){
		bool flag=true;
		int i=0;
		ans = N;
		while(1){
			copy[i] = ans%10;
			if(ans/10==0 && ans%10!=0){
				break;
			}
			ans=ans/10;
			i++;
		}
		for(int j=0; j<=i; j++){
			for(int k=0; k<K; k++){
				if(copy[j]==D[k]){
					flag = false;
				}
			}
		}
		if(flag){
			break;
		}
		N++;
	}
	printf("%d\n", N);
	return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    char c;
    cin >> c;

    // 処理
    // 出力
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
int64_t ans;
string s;
int main(){
    cin>>s;
    n=s.size();
    int cur=0;
    for (int i=0;i<n;++i)
        if (s[i]=='>') ++cur;
        else break;
    ans=cur;
    for (int i=0,j;i<n;++i){
        j=i;
        while(j+1<n&&s[j+1]==s[i]) ++j;
        if (s[i]=='>'){
            ans+=(j-i+1LL)*(j-i)/2;
            cur=0;
            i=j;
        }else{
            ans+=(j-i)*1LL*cur+(j-i)*1LL*(j-i+1)/2;
            cur+=j-i+1;
            i=j;
            while(j+1<n&&s[j+1]=='>') ++j;
            cur=max(cur,j-i);
            ans+=cur;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 900
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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 (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int p, q, r;
	cin >> p >> q >> r;
	cout << min({p + q, q + r, r + p}) << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int x = 0;
    for(int i = 0; i < n; i += 2) {
        x ^= a[i];
        x ^= a[i + 1];
    }
    for(int i = 0; i < n; ++i) {
        cout << (a[i] ^ x) << " \n"[i == n - 1];
    }
    return 0;
}



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

typedef long long int ll;

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    
    vector<vector<int> >dp(n+2,vector<int>(3)),v(n+2,vector<int>(3));
    
    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++){
            cin>>v[i][j];
        }
    }
    
    for(int i=0;i<3;i++)dp[1][i]=v[1][i];
    
    for(int i=2;i<=n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k)continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+v[i][j]);
            }
        }
    }
    
    int ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
    
    cout<<ans<<'\n';
    
    return 0;
    
    
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m, c;
  cin >> n >> m >> c;

  vector<int> vb(m);
  for (int i = 0; i < m; i++) {
    cin >> vb[i];
  }

  vector<vector<int>> va(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> va[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = c;
    for (int j = 0; j < m; j++) {
      sum += va[i][j] * vb[j];
    }

    if (sum > 0) {
      ans++;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll INF = 1e18;
int N;
ll a[200005], SUM[200005];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> a[i];
  SUM[0]=a[0];
  rep(i, N) {
    if (i==0) continue;
    SUM[i] = SUM[i-1]+a[i];
  }
  ll MIN = INF;
  rep(i, N-1) {
    MIN = min(MIN, abs(SUM[N-1]-2*SUM[i]));
  }
  cout << MIN << "\n";
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
int main (){
	
	int health,damage,attacks;
	scanf ("%d",&health);

	scanf ("%d",&damage);
	
	attacks= health/damage; 
	

 	(attacks * damage>=health)?  printf("%d", attacks):printf ("%d",++attacks );
	

	
	return 0;
}


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

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    ll n,m;
    cin>>n>>m;
    ll x=n;
    if(n==m){
        cout<<-1<<endl;
    }else if(n>m&&n%m==0){
        cout<<-1<<endl;
    }else if(n>m){
        cout<<n<<endl;
    }else if(n<m){
        cout<<n*m-n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String a = in.next();
        String f = in.next();
        int t = a.length();
        int k = f.length();
        int h = 0;

        for (int i = 0; i < t; i++) {
            if (a.charAt(i) == f.charAt(i) && (t - (k - 1) == 0)) {
                h++;
            }


        }


        if (h == t) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }

    }
}











Measured memory_bytes: 35732
#読み込み
N = int(input())
list = input().split(" ")

#偶数判定
even =[]
for i in range(N):
    if int(list[i]) % 2 == 0:
        even.append(int(list[i]))

number = len(even)

#３と５の判定
last = []
for j in even:
    if (j % 3 == 0) or (j % 5 == 0):
        last.append(j)

#最終判定
if len(last) == len(even):
    print("APPROVED")
else:
    print("DENIED")

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

int main()
{
	int x, i;
	
	i=1;
	
	while(1){
		cin >> x;
		if(x == 0){
			break;
		}
		cout << "Case " << i << ": " << x <<endl;
		i++;
	}
	
	return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
int main(void)
{
  int n,x,l[150],i,sum=0;
  scanf("%d",&n);
  scanf("%d",&x);
  for(i=0;i<n;i++)
	{
	  scanf("%d",&l[i]);
	}
  for(i=0;i<n;i++)
	{
	  sum += l[i];
      if(x<sum)
	break;
	  else if(x == sum){
		i++;
	  break;}

	}
  printf("%d",i+1);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <string>
#include <cmath>
#include <algorithm>
#define DATA_NUM 5
#define swap(type, x, y) do{type temp = x; x = y; y = temp;}while(0);

using namespace std;

void quick_sort(int x[], int left, int right);
int main(void) {
    int x[DATA_NUM] = {0};
    int i;
    
    for(i = 0; i < DATA_NUM; i++)
        scanf("%d", &x[i]);
    
    quick_sort(x, 0, DATA_NUM - 1);
    
    for(i = DATA_NUM - 1; i >= 0; i--) {
        cout << x[i];
        (i) ? putchar(' ') : putchar('\n');
    }
    
    return(0);
}

void quick_sort(int x[], int left, int right) {
    int i, j;
    int pivot;
    i = left;
    j = right;
    pivot = x[(left + right) / 2];
    
    while(1) {
        while(x[i] < pivot) i++;
        while(x[j] > pivot) j--;
        
        if(i >= j) break;
        
        swap(int, x[i], x[j]);
        i++;
        j--;
    }
    if(i - 1 > left) quick_sort(x, left, i - 1);
    if(j + 1 < right) quick_sort(x, j + 1, right);
}

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

"""解説
すべての問題の合計を求める。SUMとする。

・SUM%10 != 0のとき、答えはSUM

・SUM%10 == 0のとき、(SUM-x)%10 == 0となるような最小のxを探す。

"""

def solve():
    N = int(input())
    S = []
    for i in range(N):
        s = int(input())
        S.append(s)
    SUM = sum(S)
    
    if SUM%10 != 0:
        print(SUM)
        return

    S.sort()
    for i in range(N):
        ans = SUM - S[i]
        if ans%10 != 0:
            print(ans)
            return
    
    print(0)
        

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<string>

using namespace std;

class Process {
private:
	string name;
	int time;
public:
	Process( ) { ; }
	Process( string ps, int t ) {
		name = ps;
		time = t;
	}
	string get_name( ) { return name; }
	int get_time( ) { return time; }
	void set_name( string ps ) { name = ps; }
	void set_time( int t ) { time = t; }

};

int main()
{
	int n, q;
	cin>>n>>q;
	
	queue<Process> ps;
	string p;
	int t;
	for( int i=0; i<n; i++ ) {
		cin>>p>>t;
		ps.push( Process( p, t ) );
	}
	
	Process tmp;
	int progress = 0;
	while( !ps.empty( ) ) {
		tmp = ps.front( );
		ps.pop( );
		if( tmp.get_time( ) <= q ) {
			progress += tmp.get_time( );
			cout<<tmp.get_name( )<<' '<<progress<<'\n';
		} else {
			tmp.set_time( tmp.get_time( ) - q );
			ps.push( tmp );
			progress += q;
		}	 
	}

    return 0;
}

Measured memory_bytes: 4404
use proconio::input;

fn main() {
  input! {
    a: isize,
    b: isize,
    c: isize,
  };
  if (a == b && a != c) ||
     (a == c && a != b) ||
     (b == c && a != b) {
    println!("Yes");
  } else {
    println!("No");
  }
}


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

int main() {
    string str;
    cin >> str;
    int ans = 0;
    rep(i, 4) ans += ((str.at(i) == '+')? 1 : -1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, val;
    cin >> n;
    priority_queue<lf, vector<lf>, greater<lf>> pq;
    fore(i,0,n) {
        cin >> val;
        pq.push(val);
    }
    while (pq.size() > 1) {
        lf x = pq.top(); pq.pop();
        lf y = pq.top(); pq.pop();
        pq.push((x+y)/2.0);
    }
    cout << fixed << setprecision(6) << pq.top() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    double l;
    cin >> l;
    l /= 3;
    cout << fixed;
    cout.precision(12);
    cout << l * l * l << '\n';
}


Measured memory_bytes: 3788
import sys


def main():
    s = input()
    t = input()
    n = len(s)

    ss = []

    for ch in range(ord('a'), ord('z') + 1):
        ids = []

        for i in range(n):
            if chr(ch) == s[i]:
                ids.append(i)

        if ids:
            ss.append(ids)

    tt = []

    for ch in range(ord('a'), ord('z') + 1):
        ids = []

        for i in range(n):
            if chr(ch) == t[i]:
                ids.append(i)

        if ids:
            tt.append(ids)

    ss.sort()
    tt.sort()

    # print(ss)
    # print(tt)

    if ss == tt:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 19636
n=int(input())
ab=[]
for _ in range(n):
  ab.append(list(map(int,input().split())))
ab.sort(key=lambda x:x[1])
w=0
ans='Yes'
for i in range(n):
  w+=ab[i][0]
  if w<=ab[i][1]:
    pass
  else:
    ans='No'
    continue
print(ans)

Measured memory_bytes: 53720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long Z, long long W, vector<long long> a){
	if (N == 1) cout << abs(a[N-1]-W) << endl; else cout << max(abs(a[N-2]-a[N-1]), abs(a[N-1]-W)) << endl;
}

int main(){	
	long long N;
	long long Z;
	long long W;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&Z);
	scanf("%lld",&W);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, Z, W, a);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int n;
vector<P>vec;
signed main(){
    cin>>n;
    rep(i,n){
        int x,l;
        cin>>x>>l;
        vec.push_back(make_pair(x+l,l));
    }
    sort(all(vec));
    int r=-INF,ans=0;
    rep(i,n){
        if(r<=vec[i].F-2*vec[i].S){
            ans++;
            r=vec[i].F;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
using namespace std;
int main() {
	int i = 0, size,result=0;
	string S;
	cin >> S;
	size = S.size();
	while (i != size) {
		i++;
		if (S[i - 1] == S[i]) {
			result++;
			S[i] = !(S[i] - '0') + '0';
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b; cin >> a >> b;
  for (int i = 1;; i++) {
    if (i*2/25 == a && i/10 == b) {
      cout << i << nl;
      return 0;
    }
    if (i*2/25 > a) {
      puts("-1");
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define push_back pb

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    repn(i, 1, n){
        if(i%3==0 || i%5==0){
            continue;
        }
        ans += i;
    }
    cout << ans;
}

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

int main() {
  string acgt = "ACGT";
  string s;
  cin >> s;
  int longest = 0;
  for (int i = 0; i < s.size(); i++) {
    for (int j = i; j < s.size(); j++) {
      int start = i;
      int end = j;
      bool is_acgt = true;
      for (int k = start; k <= end; k++) {
        bool in_acgt = false;
        for (int l = 0; l < acgt.size(); l++) {
          if (s.at(k) == acgt.at(l)) in_acgt = true;
        }
        if (!in_acgt) is_acgt = false;
      }
      if (is_acgt && longest < (end - start + 1)) {
        longest = end - start + 1;
      }
    }
  }
  cout << longest << endl;
}

Measured memory_bytes: 256
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(3*n)(sc.nextLong()).sorted
  val ans = a.takeRight(a.length - n).zipWithIndex.filter{ case (e, i) => i % 2 == 0}.map(_._1).sum
  println(ans)
}

Measured memory_bytes: 79168
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

int main() {

	size_t N{}, L{};
	
	std::vector<std::string> vec;
	vec.reserve(N);
	std::cin >> N >> L;
	for (size_t i{ 0 }; i < N; i++) {
		std::string tmp;
		std::cin >> tmp;
		vec.emplace_back(tmp);
	}
	std::sort(std::begin(vec), std::end(vec));

	for (const auto&v : vec) {
		std::cout << v;
	}
	std::cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

#define INF 0x3fffffff
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define pb push_back

const int maxn = 505 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int n, m;
char x[maxn][maxn], res1[maxn][maxn], res2[maxn][maxn];

void solve()
{
	int i, j, k;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)
	{
		scanf("%s", x[i] + 1);
		for (int j = 1; j <= m; j++)
		{
			res1[i][j] = '.';
			res2[i][j] = '.';
		}
		if (i & 1)
		{
			for (int j = 1; j < m; j++)res1[i][j] = '#';
			res2[i][m] = '#';
		}
		else
		{
			for (int j = 2; j <= m; j++)res2[i][j] = '#';
			res1[i][1] = '#';
		}
		for (int j = 1; j <= m; j++)
		{
			if (x[i][j] == '#')
			{
				res1[i][j] = res2[i][j] = '#';
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		printf("%s\n", res1[i] + 1);
	}
	printf("\n");
	for (int i = 1; i <= n; i++)
	{
		printf("%s\n", res2[i] + 1);
	}
}

int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int first = 0;
		int second = 0;
		char firstChar = 0;
		char secondChar = 0;
		for(int i = 0 ; i < 4 ; i++) {
			char c = s.charAt(i);
			if(firstChar == 0) {
				firstChar = c;
				first++;
			} else if(c != firstChar && secondChar == 0) {
				secondChar = c;
				second++;
			} else if(c == firstChar) {
				first++;
			} else if(c == secondChar) {
				second++;
			}
		}
		if(first == 2 && second == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();

	}

}


Measured memory_bytes: 22996
#!/usr/bin/env python3
import sys
S = ['a','b','c','d','e','f','g','h','i','j']
def getResult(current:str,remain:int,used:int):
    if remain==0:
        print(current)
    else:
        for i in range(used):
            getResult(current+S[i],remain-1,used)
        getResult(current+S[used],remain-1,used+1)

def solve(N: int):
    getResult(S[0],N-1,1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4340
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int main(){

    int n;
    cin >> n;
    int p[n];
    
    rep(i,0,n){
	int a;
	cin >> a;
	p[a-1] = i+1;
    }
    rep(i,0,n)PS(p[i]);
    cout  << endl;
    return  0;
}


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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>

const int N = 5e3 + 1;
const ll oo = 1e18;

int c[N], p[N];

void solve() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> p[i], --p[i];
    for (int i = 0; i < n; i++)
        cin >> c[i];

    ll ans = -oo;
    for (int i = 0; i < n; i++) {
        vector<ll> prfx(1, 0);
        for (int j = p[i]; j != i; j = p[j])
            prfx.push_back(c[j]);
        prfx.push_back(c[i]);
        for (int j = 1; j < SZ(prfx); j++)
            prfx[j] += prfx[j - 1];

        ll score = -oo;
        int m = SZ(prfx) - 1;
        ll mx = -oo, mxI = 0;
        for (int j = 1; j <= m; j++) 
            mx = max(mx, prfx[j]);
        for (int j = 1; j <= m; j++)
            if (!mxI && prfx[j] == mx) 
                mxI = j;

        if (k >= m) {
            if (prfx[m] > 0) {
                int q = k / m, r = k % m;
                if (mxI <= r)
                    score = q * prfx[m] + mx;
                else {
                    ll pmx = 0;
                    for (int j = 1; j <= r; j++)
                        pmx = max(pmx, prfx[j]);
                    score = max(q * prfx[m] + pmx, max(q - 1, 0) * prfx[m] + mx);
                }
            }
            else
                score = mx;
        }
        else 
            for (int j = 1; j <= k; j++)
                score = max(score, prfx[j]);
        ans = max(ans, score);
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


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

int main()
{
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if(W-V>=0)
    {
        cout << "NO" << endl ;
        return 0 ;
    }
    ll dis = abs(A - B);
    ll vdis = abs(V - W);
    
    if (dis<=vdis*T)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int k = sc.nextInt(), n = sc.nextInt(), a[] = sc.nextIntArray(n);
        int ans = a[n - 1] - a[0];
        for (int i = 1; i < n; i++)
            ans = Math.min(ans,k-a[i]+a[i-1]);
        out.println(ans);
        out.flush();
        out.close();
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

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

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

    }
}


Measured memory_bytes: 45652
import numpy as np

int_num, length = map(int, input().split())
if length == 0:
    print(int_num)
else:
    num_list = (list(map(int, input().split())))
    num_zettai_list = np.abs(num_list)
    up_int = int_num
    down_int = int_num
    while True:
        up_int += 1
        down_int -= 1
        flg1 = up_int in num_zettai_list
        flg2 = down_int in num_zettai_list
        if int_num not in num_zettai_list:
            print(int_num)
            break
        if not flg1 and not flg2:
            print(down_int)
            break
        elif flg1 and not flg2:
            print(down_int)
            break
        elif flg2 and not flg1:
            print(up_int)
            break


Measured memory_bytes: 27280
# 3_3_bubblesort
# ALDS_1_2_A: Bubble Sort
N = gets.to_i
a = gets.split.map(&:to_i)
# N = 5
# a = [5,3,2,4,1]

def bobble_sort(n,a)
  flag = true
  count = 0
  while flag
    flag = false
    (n-1).step(1,-1) do |j|
      if a[j] < a[j-1]
        a[j] , a[j-1] = a[j-1], a[j]
        flag = true
        count += 1
      end
    end
  end
  puts a.join(' ')
  puts count
end
bobble_sort(N,a)



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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename Ostream,typename Container>
Ostream& operator<<(Ostream& os,const Container& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

int encode(const string& s)
{
	int res=0;
	rep(i,9) res=res*10+s[i]-'0';
	return res;
}
string decode(int x)
{
	string res(9,'#');
	per(i,9){
		res[i]=x%10+'0';
		x/=10;
	}
	return res;
}

int main()
{
	for(int hcost,vcost;cin>>hcost>>vcost && hcost|vcost;){
		string src,dst;
		rep(i,2) rep(j,9){
			int x; cin>>x;
			(i==0?src:dst)+=x+'0';
		}
		
		priority_queue<pii,vector<pii>,greater<pii>> pq;
		pq.emplace(0,encode(src));
		map<int,int> vis;
		while(pq.size()){
			auto p=pq.top(); pq.pop();
			int cc=p.first; string cur=decode(p.second);
			if(!vis.insert(mp(encode(cur),cc)).second) continue;
			if(cur==dst) break;
			int i=cur.find('0');
			rep(k,4){
				int j=(i+array<int,4>{-1,1,-3,3}[k]+9)%9;
				swap(cur[i],cur[j]);
				pq.emplace(cc+(k<2?hcost:vcost),encode(cur));
				swap(cur[i],cur[j]);
			}
		}
		assert(vis.count(encode(dst)));
		cout<<vis[encode(dst)]<<endl;
	}
}

Measured memory_bytes: 21336
from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


def counter(n, a):
    return n // a


a, b, c, d = map(int, input().split())
l = lcm(c, d)
print(b - a + 1 - (counter(b, c) - counter(a - 1, c) +
                   counter(b, d) - counter(a - 1, d) -
                   (counter(b, l) - counter(a - 1, l))))


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

int A, B, C;

string getans(string S) {
	int ca = 0, cb = 0, cc = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'a') ca++;
		if (S[i] == 'b') cb++;
		if (S[i] == 'c') cc++;
	}
	if (cb == 0) return S;

	vector<string>vec;
	for (int i = 0; i < ca; i++) vec.push_back("a");
	for (int i = 0; i < cc; i++) vec[i%ca] += "c";
	sort(vec.begin(), vec.end());
	int Z = 1;
	for (int i = 1; i < vec.size(); i++) { if (vec[i] == vec[i - 1])Z = i + 1; else break; }
	for (int i = 0; i < cb; i++) vec[i%Z] += "b";
	sort(vec.begin(), vec.end());
	
	string G = "a"; int I = 0;
	for (int i = 1; i < vec.size(); i++) {
		if (vec[i] != vec[i - 1]) I++;
		G += ('a' + I);
	}
	vector<string>A = vec; A.erase(unique(A.begin(), A.end()), A.end());
	string V = getans(G), U = "";
	for (int i = 0; i < V.size(); i++) { U += A[V[i] - 'a']; }
	return U;
}

string F;

int main() {
	cin >> A >> B >> C;
	if (A >= 1) F += "a"; if (B >= 1) F += "b"; if (C >= 1) F += "c";
	int P = 0;
	while (A == 0) { A = B; B = C; C = 0; }
	while (B == 0 && C >= 1) { B = C; C = 0; }

	string G = "";
	for (int i = 0; i < A; i++) G += "a";
	for (int i = 0; i < B; i++) G += "b";
	for (int i = 0; i < C; i++) G += "c";

	string ret = getans(G);
	for (int i = 0; i < ret.size(); i++) ret[i] = F[ret[i] - 'a'];
	cout << ret << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n;
	cin >> n;
	map<int, int> mp;
	for(int i = 1; i <= n; i++) {
		int x = i;
		for(int j = 2; j <= x; j++) {
			while(x % j == 0) {
				mp[j]++;
				x /= j;
			}
		}
	}
	vector<long long> dp(81);
	dp[1] = 1;
	for(auto i : mp) {
		for(int j = 80; j >= 0; j--) {
			for(int k = i.second; k > 0; k--) {
				dp[min(80, j * (k + 1))] += dp[j];
			}
		}
	}
	cout << dp[75] << endl;
	return 0;	
}

Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;


int main(int argc, char* argv[]) {

	string N;
	long long sum = 0;

	cin >> N;

	for (int i=0;i<N.size();i++){
		char c[2]={0};
		c[0] = N[i];
		sum += atoi(c);
	}

	long long v;
	std::istringstream iss1(N);
	iss1 >> v;

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

	return 0;

}

Measured memory_bytes: 256