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

int main(void){
  int H, W;
  int i, j;


  while ( scanf("%d %d", &H, &W) != EOF){
    if( H == 0){
      if( W == 0){
       
	break;
      }else{
	for(i = 1; i <= H; i++){
	  for (j = 1; j <= W; j++)
	    if((i == 0)||(i == H - 1)||(j == 0)||(j == W -1)){

	    putchar('#');
	    }else{
	      putchar('.');
	    }
	  putchar('\n');
	}
		printf("\n");
      }
    }
    else{
	for(i = 1; i <= H; i++){
	  for (j = 1; j <= W; j++)
	    if((i == 1)||(i == H )||(j == 1)||(j == W )){

	    putchar('#');
	    }else{
	      putchar('.');
	    }
	  putchar('\n');
	}
		printf("\n");
  }
    }
  return 0;
}



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

const string YES = "Yes";
const string NO = "No";
int main(){
  int N, M; cin >> N >> M;
  vector<int> A(N); rep(i, N) cin >> A[i];
  sort(A.rbegin(), A.rend());
  int all = 0;
  rep(i, N) {
    all += A[i];
  }

  if(all%(4*M)==0){
    all -= 1;
  }
  if (A[M - 1]>all/(4*M)){
    cout << YES << endl;
  }
  else cout << NO << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011
#define maxD 12

int n, m, i, q, x, y, v, d, c;
vector<int> list[maxN];
int col[maxN];
int id[maxD][maxN];
int last[maxN];




int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d%d", &n, &m);
    for (i = 1; i <= m; i++) {
        scanf("%d%d", &x, &y);
        list[x].pb(y);
        list[y].pb(x);
    }

    scanf("%d", &q);
    for (i = 1; i <= q; i++) {
        scanf("%d%d%d", &v, &d, &c);
        col[i] = c;
        id[d][v] = i;
    }

    for (int lvl = 10; lvl > 0; lvl--) {
        for (int node = 1; node <= n; node++) {
            last[node] = max(last[node], id[lvl][node]);

            for (auto to : list[node])
                id[lvl - 1][to] = max(id[lvl - 1][to], id[lvl][node]);
        }
    }

    for (i = 1; i <= n; i++) last[i] = max(id[0][i], last[i]);
    for (i = 1; i <= n; i++)
        printf("%d\n", col[last[i]]);




    return 0;
}


Measured memory_bytes: 12024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a!=i+1)cnt++;
  }
  if(cnt==0||cnt==2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
/*
 * atcoder/dp_2nd/a.cpp
 */

// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <cstring>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

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

const Int INFTY = 100000000000000000;
const Int MAX_N = 100100;
Int N;
vector<Int> A;
Int dp[MAX_N];

void input() {
  cin >> N;
  Int a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
}

void solve() {
  loop(i,0,N+1) dp[i] = INFTY;
  dp[0] = 0;
  for (int i=0; i<N-1; i++) {
    chmin(dp[i+1], dp[i] + abs(A[i+1] - A[i]));
    if (i+2 < N) chmin(dp[i+2], dp[i] + abs(A[i+2] - A[i]));
  }
  cout << dp[N-1] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

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

  while (1) {
    bool is_prime = false;
    int cnt = 0;
    int num = 0;
    for (int i = 2; i <= X; i++) {
      if (X % i == 0) {
        cnt++;
        num = i;
      }
      if (num == X && cnt == 1) {
        is_prime = true;
        break;
      }
    }
    if (is_prime) {
      break;
    }
    X++;
  }

  cout << X << endl;
  return 0;
}


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

int main(void){
  int num=0;
  char bloodtype[3];
  int countA=0;
  int countB=0;
  int countAB=0;
  int countO=0;

  while(scanf("%d,%s",&num,bloodtype)!=EOF){
    if(strcmp(bloodtype,"A")==0){ countA++; }
    else if(strcmp(bloodtype,"B")==0){ countB++; }
    else if(strcmp(bloodtype,"AB")==0){ countAB++; }
    else if(strcmp(bloodtype,"O")==0){ countO++; }
    bloodtype[0]='\0';
  }
  printf("%d\n%d\n%d\n%d\n",countA,countB,countAB,countO);
  return 0;
}



Measured memory_bytes: 1972
#include <iostream>
#include <algorithm>

using namespace std;

void SelectSort(int x[], int N);
void BubbleSort(int x[], int N);
void InsertSort(int x[], int N, int num);
void ShellSort(int x[], int N);
void Trace(int x[], int N);

int gCount = 0;

int main() {
    int N;

    cin >> N;

    int x[N];

    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    //SelectSort(x, N);
    //BubbleSort(x, N);
    InsertSort(x, N, 1);
    Trace(x, N);
    //cout << gCount << endl;

    return 0;
}


void SelectSort(int x[], int N) {
    int min;

    for (int i = 0; i < N - 1; i++) {
        min = i;
        for (int j = i; j < N; j++) {
            if (x[min] > x[j]) {
                min = j;
            }
        }
        if (i != min) {
            gCount++;
            swap(x[min], x[i]);
        }
    }
}

void BubbleSort(int x[], int N) {
    for (int i = 0; i < N - 1; i++) {
        for (int j = N - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {
                swap(x[j - 1], x[j]);
                gCount++;
            }
        }
        //Trace(x, N);
    }
}

void InsertSort(int x[], int N, int num) {
    for (int i = 1; i < N; i++) {
        int v = x[i];
        int j = i - 1;
        Trace(x, N);
        while (j >= 0 && x[j] > v) {
            x[j + 1] = x[j];
            j--;
        }
        x[j+1] = v;
    }
}

void Trace (int x[], int N) {
    int i;
    for (i = 0; i < N - 1; i++) {
        cout << x[i] << " ";
    }
    cout << x[i] << endl;
}

Measured memory_bytes: 3084
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, j = 0;
    scanf("%d", &n);
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) scanf("%d", a.begin() + i);
    for (int i = n - 1; i >= 0; i -= 2, ++j) b.at(j) = a.at(i);
    for (int i = n % 2; i < n; i += 2, ++j) b.at(j) = a.at(i);
    for (int i = 0; i < n - 1; ++i) printf("%d ", b.at(i));
    printf("%d\n", b.back());
    return 0;
}


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

int main() {
 string S;
 cin >> S;
 long int ans;ans=0;
  string mstr="";
  int n=S.size();
  
 for(int tmp=0;tmp<(1<<S.size()-1);tmp++){
 	bitset<10>g(tmp);
   for(int i=0;i<S.size()-1;i++){
     //プラスなら、そこまでの文字列を加え、mstrメモ用のstringをリセット
     if(g.test(i)){
     mstr+=S.at(i);
     ans+=stol(mstr);
     mstr="";
     }
    //プラスでないなら文字列を伸ばすだけ！
     else{
     mstr+=S.at(i);
     }                                
    }
   //さいごの一文字の処理は手動
   mstr+=S.at(n-1);
    ans+=stol(mstr);
    mstr="";
 }
  cout <<ans<<endl; 
  
}
 

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int sum=0;
  int num;
  for(int i=1;i<=n;i++){
    num=0;
    for(int j=0;j<5;j++){
      num += i / (int)pow(10.0,(double)j) % 10;
    }
    if(a <= num && num <= b){
      sum += i;
    }
  }
  cout << sum;
}



Measured memory_bytes: 512
// 2011/08/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int m;
		cin >> m;
		if(m==0)
			break;

		int M[200][2];
		for(int i=0; i<m; i++)
			cin >> M[i][0] >> M[i][1];

		for(int i=0; i<m-1; i++)
			for(int j=i+1; j<m; j++)
				if(M[i][0]>M[j][0]||(M[i][0]==M[j][0]&&M[i][1]>M[j][1])){
					int tmp = M[i][0];
					M[i][0] = M[j][0];
					M[j][0] = tmp;
					tmp     = M[i][1];
					M[i][1] = M[j][1];
					M[j][1] = tmp;
				}

		int n;
		cin >> n;

		int N[1000][2];
		for(int i=0; i<n; i++)
			cin >> N[i][0] >> N[i][1];

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

		int X, Y;
		for(int i=0; i<n; i++){
			X = N[i][0]-M[0][0];
			Y = N[i][1]-M[0][1];

			int k = 1;
			if(k==m)
				break;

			bool flg = false;
			for(int j=i+1; j<n; j++){
				if(N[j][0]==M[k][0]+X&&N[j][1]==M[k][1]+Y){
					k++;
					if(k==m)
						flg = true;
				}
				else if(N[j][0]<M[k][0]+X||(N[j][0]==M[k][0]+X&&N[j][1]<M[k][1]+Y)){
					continue;
				}
				else{
					break;
				}
				if(flg)
					break;
			}

			if(flg)
				break;
		}

		cout << X << ' ' << Y << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int S=count(s.begin(),s.end(),'S');
    int W=count(s.begin(),s.end(),'W');
    int E=count(s.begin(),s.end(),'E');
    int N=count(s.begin(),s.end(),'N');
    if(S==0&&N==0&&W>0&&E>0 || W==0&&E==0&&S>0&&N>0 || W>0&&E>0&&S>0&&N>0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
using System;
class program{
	static void Main()
    {
      int ac = 0;
      int wa = 0;
      int tle = 0;
      int re = 0;
		int n = int.Parse(Console.ReadLine());
		for(int i=0;i<n;i++){
          String j = Console.ReadLine();
          if(j == "AC") ac++;
          else if(j == "WA") wa++;
          else if(j == "TLE") tle++;
          else if(j == "RE") re++;
        }
		Console.WriteLine("AC x " + ac);
		Console.WriteLine("WA x " + wa);
		Console.WriteLine("TLE x " + tle);
		Console.WriteLine("RE x " + re);		
	}
}

Measured memory_bytes: 30600
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;
int divup(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}

signed main(){
    int d,g;cin>>d>>g;
    int p[d],c[d];
    REP(i,d)cin>>p[i]>>c[i];
    int ans=INF;
    for(int tmp=0;tmp<(1<<d);tmp++){
        int sp=0;
        int sum=0;
        int MA=-1;
        REP(i,d){
            if(tmp>>i & 1){
                sp+=100*(i+1)*p[i]+c[i];
                sum+=p[i];
            }
          	else chmax(MA,i);
        }
        if(sp>=g)chmin(ans,sum);
        else{
            if(MA==-1)continue;
            int d=divup(g-sp,(MA+1)*100);
            if(d<=p[MA]){
                sum+=d;
                sp+=d*100*(MA+1);
            }
            if(sp>=g)chmin(ans,sum);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ************************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ************************************/
int SumOfNum(string s) {
  int sum = 0;
  for (char c : s) sum += c - '0';
  return sum;
}
/******* Main ****************************************/
void Main() {
  string s;
  while (cin >> s, s != "0") {
    cout << SumOfNum(s) << endl;
  }
}

/******************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

******************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3180
package main

import (
	"fmt"
)

func main() {
	var a [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scanf("%d", &a[i][j])
		}
	}
	var n int
	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		var b int
		fmt.Scanf("%d", &b)
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if a[j][k] == b {
					a[j][k] = -1
				}
			}
		}
	}

	answer := bingo(a)
	if answer {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func bingo(a [3][3]int) bool {
	for i := 0; i < 3; i++ {
		if a[i][0] == -1 && a[i][0] == a[i][1] && a[i][0] == a[i][2] {
			return true
		}
		if a[0][i] == -1 && a[0][i] == a[1][i] && a[0][i] == a[2][i] {
			return true
		}
	}
	if a[0][0] == -1 && a[0][0] == a[1][1] && a[0][0] == a[2][2] {
		return true
	}
	if a[2][0] == -1 && a[2][0] == a[1][1] && a[2][0] == a[0][2] {
		return true
	}
	return false
}


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

int main() {

    int N;
    cin >> N;

    vector<int> X(N);


    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
    }


    int sum_min = 2000000000;
    int sum = 0;
    for (int i = -100; i <= 200; i++) {

        sum = 0;

        for (int j = 0; j < N; j++) {
            sum += (X.at(j) - i)*(X.at(j) - i);
        }

        if (sum_min > sum) {
            sum_min = sum;
        }
    }

    cout << sum_min << endl;    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;

int cf[10];
int vis[1000000];
struct node {
	int num[10];
	int place;
	int Code() {
		int ret=0;
		for(int i=0;i<8;i++) {
			int cnt=0;
			for(int j=i+1;j<8;j++)
				if(num[i]>num[j])
					cnt++;
			ret+=cnt*cf[8-i];
		}
		return ret;
	}
}p;

void Dfs(node x,int dep);
void Change(node tmp,int x,int y,int tdep) {
	swap(tmp.num[x],tmp.num[y]);
	tmp.place=y;
	Dfs(tmp,tdep);
}
void Dfs(node x,int dep) {
	if(dep>50) return ;
	int code=x.Code();
	if(vis[code]!=-1)
		if(vis[code]<dep)
			return ;
	vis[code]=dep;
	int &res=x.place;
	if(res%4!=0) Change(x,res,res-1,dep+1);
	if(res%4!=3) Change(x,res,res+1,dep+1);
	if(res<4)
		Change(x,res,res+4,dep+1);
	else Change(x,res,res-4,dep+1);
}
int main() {
	memset(vis,-1,sizeof(vis));
	cf[0]=1;
	for(int i=1;i<=9;i++)
		cf[i]=cf[i-1]*i;
	for(int i=0;i<8;i++)
		p.num[i]=i;
	p.place=0;
	Dfs(p,0);
	while(~scanf("%d",&p.num[0])) {
		for(int i=1;i<8;i++)
			scanf("%d",&p.num[i]);
		printf("%d\n",vis[p.Code()]);
	}
	return 0;
}


Measured memory_bytes: 6572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input = scanner.next();
		//String input = args[0];
		
		int num = Integer.parseInt(input);
		
		
		int total = 0;
		for (int i = 0; i < input.length(); i++) {
			String string = input.substring(i, i+1);
			total += Integer.parseInt(string);
		}
		
		if (num%total==0) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
		scanner.close();
	}

}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

// -------------------------------------------


void solve(long long A, long long B, long long H, long long M){
  static const double pi = 3.141592653589793;
  double a = 0.5;
  double b = 6.;
  double t = H*60. + M;
  double x = min(abs(b*M-a*t),360.-abs(b*M-a*t));
  double y = 180/x;
    
  std::cout << setprecision(10) << (double)sqrt(A*A+B*B-2*A*B*cos(pi/y)) << std::endl;
}

int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long H;
  scanf("%lld",&H);
  long long M;
  scanf("%lld",&M);
    solve(A, B, H, M);
    return 0;
}


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

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

LL d[201][201];
int N,M,R;

void wf(){
    REP(k,N)REP(i,N)REP(j,N)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}
int main(){
    cin>>N>>M>>R;
    vector<int>r(R);
    REP(i,R){
        cin>>r[i];r[i]--;
    }
    REP(i,201)REP(j,201)d[i][j]=1e9;
    REP(i,M){
        int A,B,C;
        cin>>A>>B>>C;A--;B--;
        d[A][B]=d[B][A]=C;
    }
    wf();
    vector<int>vec;
    REP(i,R)vec.PB(i);
    LL res=1e9;
    do{
        LL tmp=0;
        REP(i,R-1){
            //cout<<r[vec[i]]<<" "<<r[vec[i+1]]<<endl;
            tmp+=d[r[vec[i]]][r[vec[i+1]]];
        }
        //cout<<tmp<<endl;
        res=min(res,tmp);
    }while(next_permutation(vec.begin(),vec.end()));
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6+7;
const long long mod = 1e9+7;
long long fi[MAX];
void init(){
    fi[0]=1;
    for(int i=1;i<MAX;i++){
        fi[i]=(fi[i-1]*i)%mod;
    }
}
long long quick_mod(long long a,long long b){
    long long res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
long long inv(long long n){
    return quick_mod(n,mod-2);
}
int main(){
    init();
    long long x,y;
    while(cin>>x>>y){
        if((x+y)%3!=0){
            printf("0\n");
            continue;
        }
        if(x*2<y || 2*y<x || (x*2-y)%3!=0 || (2*y-x)%3!=0){
            printf("0\n");
            continue;
        }
        long long n=(2*y-x)/3,m=(2*x-y)/3;
        long long ans=fi[n+m]*inv(fi[n]*fi[m]%mod)%mod;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (ll i=(a); i<(b);++i)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<ll,ll> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a,k) sort(a,a+k,greater<ll>())
#define rsrt(a) sort(a.begin(),a.end(),greater<ll>())
#define sz(a) (ll)a.size()
//#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define setbits(a) __builtin_popcount(a)
const ll M=1e9+7;
const ll mxx=3001;

int main()
{  


  ll k,x;
  cin>>k>>x;
  if(500*k>=x)cout<<"Yes";
  else cout<<"No";
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define positiverep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t h,n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  if(h <= accumulate(a.begin(),a.end(),0L)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
}

Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 15
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

print(3.14 * I() * 2)


Measured memory_bytes: 76684
a['~~'],v;f(char*p){int i=4;for(;i;--*p-45||++v-f(p))p+="G&G"[--i]-36;}main(){for(;scanf("%*d%d",&v)*v;f(memchr(a,64,4e3)),printf("%d\n",v+1))for(memset(a,0,4e3);v;scanf("%s",a+9*v--));}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

const int INF = 1e6;
int main(void){
  int n;
  int cost[100][100];
  REP(i,100)REP(j,100)cost[i][j] = (i!=j)?INF:0;
  cin>>n;
  REP(i,n){
    int r,k;
    cin>>r>>k;
    r--;
    while(k--){
      int t;
      cin>>t;
      t--;
      cost[r][t] = 1;
    }
  }
  int p;
  cin>>p;
  REP(k,n)REP(i,n)REP(j,n)cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]);
  while(p--){
    int s,d,v;
    cin>>s>>d>>v;
    int c = cost[s-1][d-1];
    c++;
    if(c<=v)cout<<c<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

const int Z = 2019;

int main() {
    int l, r;
    cin >> l >> r;

    r = l + Z < r ? l + Z : r;

    int ans = Z;
    for (int i = l; i <= r; i++) {
        for (int j = i + 1; j <= r; j++) {
            ans = 1ll * i * j % Z < ans ? 1ll * i * j % Z : ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
        _t: String,
        mut a: i32,
        mut b: i32,
        u: String,
    }

    if s == u {
        a -= 1;
    } else {
        b -= 1;
    }

    println!("{} {}", a, b);
}


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

int main() {
 	int k;
  	cin >> k;
  	int ans = 0;
  	for(int i = 1; i <= k; i++) {
      	for(int j = 1; j <= k; j++) {
         	for(int z = 1; z <= k; z++) {
              	int x = __gcd(i, j);
              	ans += __gcd(x, z);
            }
        }
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 3620
from math import pi,cos,sin
import numpy

A,B,H,M=map(int,input().split())

#A=3
#B=4
#H=10
#M=40


hth=pi/6*H+pi/360*M
mth=pi/30*M

if H>=0 and H<3:
    hx=A*cos(pi/2-hth)
    hy=A*sin(pi/2-hth)
    
    mx=B*cos(pi/2-mth)
    my=B*sin(pi/2-mth)
elif H>=3 and H<6:
    hx=A*cos(-pi/2+hth)
    hy=-A*sin(-pi/2+hth)
    
    mx=B*cos(-pi/2+mth)
    my=-B*sin(-pi/2+mth)
elif H>=6 and H<9:
    hx=-A*cos(3*pi/2-hth)
    hy=-A*sin(3*pi/2-hth)

    mx=-B*cos(3*pi/2-mth)
    my=-B*sin(3*pi/2-mth)
else:
    hx=-A*cos(-3*pi/2+hth)
    hy=A*sin(-3*pi/2+hth)
    
    mx=-B*cos(-3*pi/2+mth)
    my=B*sin(-3*pi/2+mth)
    
a = numpy.array([hx, hy])
b = numpy.array([mx, my])
u = b - a
print(numpy.linalg.norm(u))


Measured memory_bytes: 27284
using System;

class Program
{
    static void Main(string[] args)
    {
        var K = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();

        if (S.Length <= K)
        {
            Console.WriteLine(S);
        }
        else
        {
            Console.WriteLine($"{S.Substring(0, K)}...");
        }
    }
}

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

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

int main(){

	int N; cin >> N;
  for (int i = 0; i < 100010; ++i) dp[i] = N;
  dp[0] = 0;


	// ループ
	for(int i=1;i<=N;++i){
    for(int pow6=1;pow6<=i;pow6*=6){
      chmin(dp[i],dp[i-pow6]+1);
    }
    for(int pow9=1;pow9<=i;pow9*=9){
      chmin(dp[i],dp[i-pow9]+1);
    }
  }

	cout << dp[N] << endl;

	}


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


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

    int N;
    cin >> N;

    bool approved = true;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;

        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) approved = false;
        }
    }

    string out = (approved) ? "APPROVED" : "DENIED";
    cout << out;
 
    return 0;
}

/*
file=b
g++ -W -Wall -pedantic --std=c++17 -ggdb3 -o ${file}.out ${file}.cpp && ./${file}.out

*/


Measured memory_bytes: 256
#include "cstdio"
#include "algorithm"
#include "cstring"
int map[104][104];
int a[10004];

int main()
{
    int H,W,N,k,x,y;
    while (scanf ("%d%d",&H,&W) != EOF)
    {
        scanf ("%d",&N);
        for (int i=1;i<=N;i++)
        {
            scanf ("%d",&a[i]);
        }
        x=k=y=0;
        for (int i=1;i<=N;i++)
        {
            while (a[i]--)
            {
                map[x][y] = i;
                if (k == 0)
                {
                    y++;
                }
                else
                {
                    y--;
                }
                if (y == W)
                {
                    k ^= 1;
                    x++;
                    y--;
                }
                else if (y == -1)
                {
                    k ^= 1;
                    x++;
                    y++;
                }
            }
        }
        for (int i=0;i<H;i++)
        {
            for (int j=0;j<W;j++)
            {
                printf("%d%c",map[i][j],j==W-1?'\n':' ');
            }
        }
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[]P = new int[N];
    
      for(int i=0; i<N; i++){
		P[i] = sc.nextInt();
      } 
        Arrays.sort(P); 	

      int ans = 0;
      for(int i=0; i<K; i++){
        ans += P[i];        
      }     
         System.out.println(ans);
    }
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

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


void Main()
{
	int N;
	cin >> N;
	vvi ABC(N, vi(3, 0));
	for (size_t i = 0; i < N; i++)
	{
		cin >> ABC[i][0] >> ABC[i][1] >> ABC[i][2];
	}

	vvi dp(N + 1, vi(3, 0));

	for (size_t i = 0; i < N; i++)
	{
		for (size_t j = 0; j < 3; j++)
		{
			for (size_t k = 0; k < 3; k++)
			{
				if (j == k)continue;
				chmax(dp[i + 1][k], dp[i][j] + ABC[i][k]);
			}
		}
	}

	ll result = max(dp[N][0], max(dp[N][1], dp[N][2]));
	cout << result << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
}

Measured memory_bytes: 11264
// #[proconio::fastout]
fn main() {
    let (x, y): (usize, usize) = (read::<usize>(), read::<usize>());
    for i in 0..x + 1 {
        if 2 * i + 4 * (x - i) == y {
            println!("Yes");
            exit(0);
        }
    }
    println!("No");
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2096
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
 
using namespace std;
 
using ll = long long;

int main() {
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    constexpr int V = 50;
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];

    vector<vector<bool>> reach(V + 1, vector<bool>(V + 1));
    vector<int> use(V + 1, true);
    ll result = 0;

    RFOR(d, 1, V + 2) {
        if (d <= V) {
            use[d] = false;
        }

        REP(i, V + 1) REP(j, V + 1) reach[i][j] = false;
        REP(i, V + 1) reach[i][i] = true;
        FOR(i, 1, V + 1) {
            FOR(d, 1, i + 1) {
                if (use[d]) {
                    reach[i][i % d] = true;
                }
            }
        }
        REP(k, V + 1) REP(i, V + 1) REP(j, V + 1) {
            if (!reach[i][j] && reach[i][k] && reach[k][j]) {
                reach[i][j] = true;
            }
        }

        REP(i, N) {
            if (!reach[a[i]][b[i]]) {
                if (d <= V) {
                    use[d] = true;
                    result |= 1LL << d;
                } else {
                    result = -1;
                }
                break;
            }
        }
    }

    cout << result << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

vector<vector<P>> G;
vector<ll> lists;

void dfs(int p, ll c) {
  for (auto g : G[p]) {
    if (lists[g.first] != -1)
      continue;
    lists[g.first] = c + g.second;
    dfs(g.first, c + g.second);
  }
}

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

  int n;
  cin >> n;
  lists.resize(n, -1);
  G.resize(n);
  rep(i, 0, n - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].emplace_back(b, c);
    G[b].emplace_back(a, c);
  }

  int q, k;
  cin >> q >> k;
  k--;
  lists[k] = 0;
  dfs(k, 0);

  rep(i, 0, q) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << lists[x] + lists[y] << endl;
  }
}


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

int main() {
	int N, tmp, ds = 0;
	cin >> N;
	tmp = N;
	while (tmp != 0) {
		ds += (tmp % 10);
		tmp /= 10;
	}
	if (N % ds == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

# N,Cを取得
n, c = map(int, input().split())

# x1, v1..xN, vNを取得
xs = []
vs = []
for _i in range(n):
    x, v = map(int, input().split())
    xs.append(x)
    vs.append(v)

r1, r2, l1, l2 = [[], [], [], []]
r_sum, l_sum = [0, 0]
for i in range(n):
    r_sum += vs[i]
    r1.append(r_sum - xs[i])
    r2.append(r_sum - 2 * xs[i])

    i_rev = n - i - 1
    l_sum += vs[i_rev]
    l1.append(l_sum - (c - xs[i_rev]))
    l2.append(l_sum - 2 * (c - xs[i_rev]))

r1_max, r2_max = [0, 0]
l1_max, l2_max = [0, 0]
r1_maxs, r2_maxs = [[0], [0]]
l1_maxs, l2_maxs = [[0], [0]]
for i in range(n):
    r1_max = max(r1_max, r1[i])
    r1_maxs.append(r1_max)
    r2_max = max(r2_max, r2[i])
    r2_maxs.append(r2_max)
    l1_max = max(l1_max, l1[i])
    l1_maxs.append(l1_max)
    l2_max = max(l2_max, l2[i])
    l2_maxs.append(l2_max)

r1_l2_max = 0
l1_r2_max = 0
for i in range(0, n + 1):
    r1_l2_max = max(r1_l2_max, r1_maxs[i] + l2_maxs[n - i])
    l1_r2_max = max(l1_r2_max, l1_maxs[i] + r2_maxs[n - i])

total_max = max(r1_l2_max, l1_r2_max)

# 結果を出力
print("{}".format(total_max))


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

int main(){
	string str;
	cin >> str;
	
	string nox="";
	for(int i=0; i<(int)str.length(); i++){
		if(str[i]!='x'){
			nox += str.substr(i,1);
		}
	}
	bool ispal = true;
	for(int i=0; i<(int)nox.length(); i++){
		if(nox[i]!=nox[nox.length()-i-1]){
			ispal = false;
			break;
		}
	}
	if(!ispal){
		cout << -1 << endl;
		return 0;
	}
	
	int ans=0;
	int b=0, e=str.length()-1;
	while(b<e){
		if(str[b]==str[e]){
			b++;
			e--;
		}else if(str[b]=='x'){
			b++;
			ans++;
		}else{
			e--;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define LINE_BUF_SIZE 256

int main(){

    int i,j,k;
    int N;
    char line[LINE_BUF_SIZE];
    long long int m=0,a=0,r=0,c=0,h=0;
    int bit2[5][10] = {
        {1,1,1,1,1,1,0,0,0,0},
        {1,1,1,0,0,0,1,1,1,0},
        {1,0,0,1,1,0,1,1,0,1},
        {0,1,0,1,0,1,1,0,1,1},
        {0,0,1,0,1,1,0,1,1,1},
    };

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d", &N);

    for(i=0;i<N;i++){
        fgets(line,sizeof(line),stdin);
        if(strncmp(&line[0],"M",1)==0)m++;
        if(strncmp(&line[0],"A",1)==0)a++;
        if(strncmp(&line[0],"R",1)==0)r++;
        if(strncmp(&line[0],"C",1)==0)c++;
        if(strncmp(&line[0],"H",1)==0)h++;
    }

    long long int count=1,ans = 0;

    for(i=0;i<10;i++){
        if(bit2[0][i]!=0)count *= bit2[0][i] * m;
        if(bit2[1][i]!=0)count *= bit2[1][i] * a;
        if(bit2[2][i]!=0)count *= bit2[2][i] * r;
        if(bit2[3][i]!=0)count *= bit2[3][i] * c;
        if(bit2[4][i]!=0)count *= bit2[4][i] * h;
        ans += count;
        count = 1;
    }

    printf("%lld",ans);

    return 0;

}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;


int main(){
    int s;
    cin>>s;
    bool f=true;
    while(s!=0){
      if(s%10==9){
          cout<<"Yes"; f=false;
          break;
      }
      s/=10;   
    }
    if(f)
      cout<<"No";
    return 0;
}


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

#define MOD		1000000007
#define ll		long long int
#define pll		pair<ll, ll>
#define pb		push_back
#define endl	"\n"
#define f 		first
#define s 		second
#define fastio 	ios_base::sync_with_stdio(false);cin.tie(NULL)

ll power(ll x, ll y) { ll ans = 1; x %= MOD; while (y) {if (y & 1)ans = (x * ans) % MOD; x = (x * x) % MOD; y >>= 1;} return ans;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)


int main() {
	fastio;
	int n, x, t;
	cin >> n >> x >> t;
	ll ans = n/x;
	if(n%x) {
        ans++;
	}
	cout << ans * t << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  if(N==1){
      cout << 1;
      return 0;
  }
  
  int64_t  two = 2;
  int64_t  one = 1;
  uint8_t i = 2;
  int64_t sum = 0;
  
  for(int i=2; i<= N; i++){
    sum = one + two;
    two = one;
    one = sum;

  }
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10,mod=1e9+7;
int Fac[N],inv[N],n,f[N];

inline int C(int n,int m){
    return 1ll*Fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main(){
  cin>>n;
  int ans=0,li=(n+1)/2;
  Fac[0]=inv[0]=inv[1]=1;
  for(int i=1;i<=n;i++)Fac[i]=1ll*Fac[i-1]*i%mod;
  for(int i=2;i<=n;i++)inv[i]=(mod-1ll*(mod/i)*inv[mod%i]%mod)%mod;
  for(int i=2;i<=n;i++)inv[i]=1ll*inv[i]*inv[i-1]%mod;
  for(int i=li;i<n;i++)f[i]=1ll*C(i-1,n-1-i)*Fac[i]%mod*Fac[n-1-i]%mod;
  for(int i=n-1;i>=li;i--)f[i]=(f[i]-f[i-1]+mod)%mod;
  for(int i=n-1;i>=li;i--)ans=(ans+1ll*i*f[i])%mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
 
int main(){
	int t;
	cin>>t;
	int ac=0;
	int tle =0;
	int wa =0 ;
	int re= 0;
	while(t--){
		string s;
		cin>>s;
		if(s=="AC")	ac++;
		else if(s=="TLE")	tle++;
		else if(s=="WA")	wa++;
		else if(s=="RE")	re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}




Measured memory_bytes: 3584
use strict;
use warnings;
use utf8;

use feature qw(say);

my $limit = <STDIN>;
chomp $limit;
my $input = <STDIN>;
chomp $input;
my $array = [split / /, $input];

my $count = 0;
my $step_num = 1;
for my $num (@$array) {
    if ($step_num % 2 == 1) {
        $count++ if $num % 2 == 1
    }
    $step_num++;
}

say $count;

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

int main() {
	
	int n,m;
	
	cin>>n >> m;
	int heights[n];
	vector<set<int>> arr(n+1);
	for(int i = 0; i < n; i++){
		cin>>heights[i];
	}
	for(int i = 0;i < m; i++){
		int s,f;
		cin>> s >> f;
		arr[s].insert(f);
		arr[f].insert(s);
	}
//	cout<<"elements"<<endl;
//	for(int i = 1; i <= n; i++){
////		if(arr[i].size() > 0) {
//		cout<<i<<" ";
//			for(auto el: arr[i]){
//				cout <<" " << el;
//			}
//			cout<<endl;
////		}
//	}
//	cout<<"hello";
	int count = 0;
	for(int i = 1; i <= n; i++){
		int currheight = heights[i-1];
		bool isgood = true;
		for(auto el: arr[i]){
			if(heights[el-1] >= currheight){
				isgood = false;
				break;
			}
		}
		if(isgood)
			count++;
	}
	cout<<count;
	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }


int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    lli a,b;
    cin>>a>>b;
    for(int i = 1 ; i < N ; i++){
        lli ta,tb;
        cin>>ta>>tb;
        lli k = max((a-1)/ta+1,(b-1)/tb+1);
        a = ta*k;
        b = tb*k;
    }
    cout<<a+b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
constexpr int tv[]={-3,-1,1,3};
constexpr int p10[]={100000000,10000000,1000000,100000,10000,1000,100,10,1};
constexpr int fact[]={40320,5040,720,120,24,6,2,1};

int my_hash(int f){
    int flag=0,ret=0;
    rep(i,8){
        ret+=fact[i]*(f%10-__builtin_popcount(flag&((1<<(f%10))-1)));
        flag|=1<<(f%10);
        f/=10;
    }
    return ret;
}


int main(){
    
    int h,v;
    string a="123456789",b="123456789";
    using data=pair<int,int>;
    
    while(cin>>h>>v, h or v){
        vector<int> hm(362880,-10000000);
        int tc[]={v,h,h,v};
        rep(i,9)cin>>a[i];
        rep(i,9)cin>>b[i];
        int sa=stoi("1"+a)-1000000000,sb=stoi("1"+b)-1000000000;

        priority_queue<data> q;
        q.emplace(0,sa);
        
        while(1){
            int cost=q.top().fs;
            int board=q.top().sc;
            if(board==sb){
                cout<<-cost<<endl;
                break;
            }
            q.pop();
            int index=to_string(board).find('0');
            if(index==-1)index=0;
            rep(i,4){
                int fixed=(index+tv[i]+9)%9;
                int next=board;
                int fx=board/p10[fixed]%10;
                next=next+(p10[index]-p10[fixed]) * fx;
                int nc=cost-tc[i];
                int hval=my_hash(next);
                if(hm[hval]<nc){
                    q.emplace(nc, next);
                    hm[hval]=nc;
                }
            }
        }
    }
}



Measured memory_bytes: 7428
#include <stdio.h>
#include <string.h>
#include <math.h>
#define MIN(a,b) (a<b?a:b)
int main()
{
    char s[10];
    int len, i, a[10]={0};
    int min = 1000;

    scanf("%s",&s);
    len = strlen(s);
    for(i=0; i<len-2; i++) {
        a[i] = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        a[i] = abs(a[i]-753);
        min = MIN(min, a[i]);
    }
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,w,k; cin >> h >> w >> k;
    char c[6][6]; rep(i,h){rep(j,w)cin >> c[j][i];}
    ll res = 0;
    rep(tmp1,(1 << w)){
        rep(tmp2,(1 << h)){
            bitset<6> tate(tmp2);
            bitset<6> yoko(tmp1);
            ll black = 0;
            rep(i,h){
                rep(j,w){
                    if(tate.test(i) && yoko.test(j) && c[j][i] == '#')black++;
                }
            }
            if(black == k)res++;

        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3648
n="0"+input()
A,b,c=0,0,0
for i in n[::-1]:
    a=int(i)+b
    if a==5 and c==0:
        A+=5
        b=0
        c=1
    elif a<5:
        A+=a
        b=0
        c=0
    else:
        A+=10-a-c
        b=1
        c=0
print(A)


Measured memory_bytes: 62192