akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int num,building,floor,room,v;
        int full_house[][][] = new int[4][3][10];
         num=sc.nextInt();
        for(int i=0;i<num;i++){
            building=sc.nextInt();
            floor=sc.nextInt();
            room=sc.nextInt();
            v=sc.nextInt();
            full_house[building-1][floor-1][room-1]+=v;
        }
        for (int i=0;i< 4;i++){
            for (int j=0;j< 3;j++){
                 for(int k = 0;k < 10 ;k++){
                     System.out.print(" "+full_house[i][j][k]);
                }
                System.out.println();
            }
            if (i!=3)
                System.out.println("####################");
            
        }
    }
}


Measured memory_bytes: 29304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,a,b;
    bool hantei = false;
    cin >> n >> a >> b;
    int cnt =0;
    rep(i,1000){
        if(cnt>=a && cnt<=b) hantei=true;
        cnt +=n;
    }
    
    if(hantei) cout << "OK" <<endl;
    else cout << "NG"<<endl;
} 

Measured memory_bytes: 3592
#include<stdio.h>
 
int m[101][101];
 
void matrixChainMultiplication(int n, int *p){
  int i,j,k,l;
   
  for(i=1; i<n+1; i++){
    m[i][i]=0;
  }
  for(l=2; l<n+1; l++){
    for(i=1; i<n-l+2; i++){
      j=i+l-1;
      m[i][j]=100000000;
      for(k=i; k<j; k++){
    if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
      }
    }
  }
}
 
int main(){
  int i,p[101],n;
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    scanf("%d%d", &p[i-1], &p[i]);
  }
  matrixChainMultiplication(n,p);
  printf("%d\n", m[1][n]);
   
  return 0;
}

Measured memory_bytes: 636
# -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))
N, M = min(N, M), max(N, M)  # N <= Mとしても一般性は失われない


def main() -> None:
    """Entry point
    """
    # 求解処理
    """
    各カードが奇数回または偶数回裏返されるかを考える。
    """
    result = 0
    if N == 1:
        if M == 1:
            result = 1
        else:
            result = M - 2
    else:
        result = (N - 2) * (M - 2)

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9076
function main(arg) {
   a = arg.split(" ");
   x = a[0];
   y = a[1];
   z = a[2];
   incr = 0;

       for(var i=x*y; i> 0; i--){

           if(x%i === 0 && y%i === 0){

             incr++;
             if(incr == z){console.log(i);}

            }
       }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int H[100100];
int DP[100100];

int main(){
    int N;
    cin >> N;
    REP(i,N){
        int h;
        cin >> h;
        H[i] = h;
    }

    DP[0] = 0;
    DP[1] = abs(H[0] - H[1]);
    for(int i = 2; i < N; i++){
        DP[i] = min(DP[i-1] + abs(H[i]-H[i-1]), DP[i-2] + abs(H[i]-H[i-2]));
    }

    cout << DP[N-1] << endl;
    return 0;
}


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

int main() {
  int x;
  cin>>x;
  int ans=1;
  for(int i=1;i<=x;i++){
    for(int b=2;b<=10;b++){
      int c=pow(i,b);
      if(c<=x) ans=max(ans,c);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int n;
  cin>>n;
  int v[n];
  for(int i = 0; i < n; i++){
    cin>>v[i];
  }
  sort(v,v+n);
  double tmp=v[0];
  for(int i = 1; i < n; i++){
    tmp=(v[i]+tmp)/2;
  }
  cout<<tmp<<endl;
  return 0;
}

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

#define m 1046527
#define nil (-1)
#define l 14

char H[m][l];

int gC(char ch){
if(ch=='A')return 1;
else if(ch=='C')return 2;
else if(ch=='G')return 3;
else if(ch=='T')return 4;
else return 0;
}

long long gK(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(gC(str[i]));
    p*=5;
  }
return sum;
}

int h1(int key){return key%m;}
int h2(int key){return 1+(key%(m-1));}

int find(char str[]){
  long long key,i,h;
  key=gK(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%m;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=gK(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%m;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
return 0;
}

int main(){
  int i,n,h;
  char str[l],com[9];
  for(i=0;i<m;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
if(com[0]=='i'){
  insert(str);
}else{
  if(find(str)){
    printf("yes\n");
  }
else {
  printf("no\n");
}
}
  }
return 0;
}


Measured memory_bytes: 16016
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void p(vector<int>& xs) { return;
  cout<<xs.size()<<": ";
  for(auto x:xs) cout<<x<<",";
  cout<<endl;
}
main() {
  int N,M; cin>>N>>M;
  if(N>=M) { cout<<0<<endl; exit(0); }
  vector<int> X(M); for(auto& x:X) cin>>x;
  p(X);
  sort(X.begin(), X.end());
  p(X);
  vector<int> dist;
  for(int i=1;i<M;++i) dist.push_back(X[i]-X[i-1]);
  p(dist);
  sort(dist.begin(), dist.end());
  p(dist);
  vector<int> sum=dist;
  for(int i=1;i<sum.size();++i) sum[i]+=sum[i-1];
  p(sum);
  cout<< sum[sum.size()-N] <<endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll q, h, s, d, n ;
  cin >> q >> h >> s >> d >> n ;
  ll a = min({q*4,h*2,s}) ;
  ll ans = 0 ;
  ll b = min(2*a,d) ;
  if(n%2==1){
    ans += a ;
    ans += (n-1)/2*b ;
  }
  else{
    ans += n/2*b ;
  }
  
  cout <<ans <<endl ;
  
  
  
  
  
  return 0 ;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


int main(){
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	for(int i=K; i<N; i++){
		if(A[i] > A[i-K]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}



	return 0;
}



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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int res = 0;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    char c = s[i];
    if (c == 'R') {
      cnt++;
    } else {
      cnt = 0;
    }
    res = max(res, cnt);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3616
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools, copy, math
from bisect import *
from heapq import *
from collections import *


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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, X, M = In.ints()

ans = 0
steps = 1
seen = dict()
stepsseen = dict()
stepsseen[0] = 0

while X != 0 and N>0 and X not in seen:    
    ans += X
    seen[X] = (ans, steps)
    stepsseen[steps] = ans
    X = (X**2)%M
    N-=1
    steps+=1


if X not in seen:
    Out.int(ans)
else:
    stepsDiff = steps-seen[X][1]
    ansDiff = ans-stepsseen[seen[X][1]-1]

    remloops = N//stepsDiff
    N = N%stepsDiff

    ans += remloops*ansDiff

    while X != 0 and N>0:    
        ans += X
        X = (X**2)%M
        N-=1
    
    Out.int(ans)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 88616
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
    string s,t;
    cin >> s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s<t){
        cout << "Yes" <<endl;
    }
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<double, 10> l;
  double v1, v2;
  char c;

  while ( cin >> l[0] )
    {
      double al = l[0];

      for ( auto i = 1; i < 10; ++i )
        {
          cin >> c >> l[i];
          al += l[i];
        }
  
      cin >> c >> v1 >> c >> v2;

      double p = al * v1 / (v1 + v2);

      double cl = 0;

      for ( auto i = 0; i < 10; ++i )
        {
          cl += l[i];
          if ( cl >= p )
            {
              cout << i + 1 << endl;
              break;
            }
        }
    }
  
  return 0;
}

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

//#include <tuple>

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

int main() {
  int N, b;
  cin >> N;
  ll c = pow(10, 8);
  vector<int> a(N);

  rep(i, N){
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  bool flag = true;

  rep(i, N-1){
    if(a[i]== a[i+1]) flag = false;
  }

  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1024
// C++のテンプレート
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
    int W,H,N;
    cin >> W >> H >> N;
    vector<vector<bool>> board(H,vector<bool>(W));
    int x,y,a;
    for(int iter=0;iter<N;iter++){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                for(int i=0;i<H;i++){
                    for(int j=0;j<x;j++){
                        board[i][j] = true;
                    }
                }
                break;
            case 2:
                for(int i=0;i<H;i++){
                    for(int j=x;j<W;j++){
                        board[i][j] = true;
                    }
                }
                break;
            case 3:
                for(int i=0;i<y;i++){
                    for(int j=0;j<W;j++)
                        board[i][j] = true;
                }
                break;
            case 4:
                for(int i=y;i<H;i++){
                    for(int j=0;j<W;j++){
                        board[i][j] = true;
                    }
                }
        }
    }
    int count = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++)
            if(!board[i][j])
                count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vector<ll> G[201010];
vector<ll> X(201010);
void dfs(ll s, ll p=-1){
    for(auto v : G[s]){
        if (v == p) continue;
        X[v] += X[s];
        dfs(v,s);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    vector<ll> a(n),b(n);
    rep(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    rep(i,q){
        ll p,x;
        cin >> p >> x;
        p--;
        X[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout<<X[i]<<endl;
    }
}

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

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<int> G[N];
    int A, B;
    for (int i = 0; i < M; ++i) {
        std::cin >> A >> B;
        --A;
        --B;

        G[A].push_back(B);
        G[B].push_back(A);
    }
    
    int guide[N];
    std::memset(guide, -1, sizeof(int) * N);

    std::queue<int> que;
    que.push(0);
    guide[0] = 0;
    while (que.empty() == false) {
        const int p = que.front();
        que.pop();

        for (int v : G[p]) {
            if (guide[v] == -1) {
                guide[v] = p;
                que.push(v);
            }
        }
    } 

    std::cout << "Yes" << std::endl;
    for (int i = 1; i < N; ++i) {
        std::cout << guide[i] + 1 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 10388
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a[26]={0};
	for(int i=0;i<s.length();i++)
	{
		a[s[i]-'a']++;
	}
	for(int i=0;i<26;i++)
	{
		if(a[i]%2!=0)
		{
			cout<<"No";return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
from math import *

def inv(a, m) : 
	
	m0 = m 
	x0 = 0
	x1 = 1

	if (m == 1) : 
		return 0

	# Apply extended Euclid Algorithm 
	while (a > 1) : 
		# q is quotient 
		q = a // m 

		t = m 

		# m is remainder now, process 
		# same as euclid's algo 
		m = a % m 
		a = t 

		t = x0 

		x0 = x1 - q * x0 

		x1 = t 
	
	# Make x1 positive 
	if (x1 < 0) : 
		x1 = x1 + m0 

	return x1 

def findMinX(num, rem, k) : 
	
	# Compute product of all numbers 
	prod = 1
	for i in range(0, k) : 
		prod = prod * num[i] 

	# Initialize result 
	result = 0

	# Apply above formula 
	for i in range(0,k): 
		pp = prod // num[i] 
		result = result + rem[i] * inv(pp, num[i]) * pp 
	
	
	return result % prod 

n = int(input())

ans = 1e18
m = 2*n
i = 1
while(i <= m):
	if(n == i):
		print(i*2 - 1)
		exit(0)
	i *= 2

i = 2
while(i*i <= m):
	if(m % i == 0):
		if(gcd(i, m // i) == 1):
			num = [0, 0]
			rem = [0, 0]
			num[0] = i
			num[1] = m // i
			rem[0] = 0
			rem[1] = m // i - 1
			ans = min(ans, findMinX(num, rem, 2))
			num[0] = m // i
			num[1] = i
			rem[0] = 0
			rem[1] = i - 1
			ans = min(ans, findMinX(num, rem, 2))
	i += 1

print(ans)


Measured memory_bytes: 69032
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    string SN = to_string(N);
    ll S = accumulate(SN.begin(),SN.end(),0LL) - (SN.length()*'0');
    if(N%S==0) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int64_t burgers[51];
int64_t patis[51];
void PRE(){
    burgers[0]=1;
    for(int i=0;i<50;i++){
        burgers[i+1] = 2*burgers[i]+3;
    }

    patis[0]=1;
    for(int i=0;i<50;i++){
        patis[i+1]=2*patis[i]+1;
    }
}
int64_t BurgerS(int64_t n){
    /*
    if(n==0){
        return 1;
    }
    else{
        return 2*BurgerS(n-1)+3;
    }*/
    return 4*pow(2,n)-3;
}

/*
int64_t PatiS(int64_t n){
   return pow(2,n+1)-1;
}
*/
int64_t SliceP(int64_t n,int64_t x){//レベルnバーガーのxまでのパティの数
    if(n==0 && x==1){
        return 1;
    }
    if(x==0){
        return 0;
    }
    if(x-1>burgers[n-1]){
        return patis[n-1]+1+SliceP(n-1,x-burgers[n-1]-2);
    }
    else{
        return SliceP(n-1,x-1);
    }
}
int main(){
    int64_t n,x;
    cin>>n>>x;
    PRE();
   cout<<SliceP(n,x)<<endl;

}


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

int main(void) {
    int n, x, harshad=0;
    cin >> n;
    x=n;
    while(x!=0) {
        harshad+=x%10;
        x/=10;
    }
    if(n%harshad==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main(){
    string str;
    cin >> str;
    int Ans=0;
    int ans=0;
    for(int i=0;i<str.size();i++){
        if(i % 2 == 0){
            if(str[i] != '1') ans += 1;
        }else{
            if(str[i] != '0') ans += 1;
        }
        Ans = ans;
    }
    ans = 0;
    for(int i=0;i<str.size();i++){
        if(i % 2 == 0){
            if(str[i] != '0') ans += 1;
        }else{
            if(str[i] != '1') ans += 1;
        }
    }
    if(ans < Ans) Ans = ans;
    cout << Ans << endl;
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = n - 1; i < (int)n; --i)
#define FOR(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define RFOR(i, l, r) for (int i = (int)(r); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, x;
    cin >> n >> x;
    vll a(n);
    REP(i, n) cin >> a[i];

    ll ans  = 0;
    FOR (i, 1, n) {
        int k = a[i] + a[i - 1] - x;
        if (k > 0) {
            ans += k;
            if (k > a[i]) {
                a[i] = 0;
                a[i - 1] = k - a[i];
            } else {
                a[i] -= k;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x[] = new int[3];
        for (int i = 0; i < 3; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int count = 0;
        while (x[1] < x[2]) {
            x[0]++;
            x[1]++;
            count++;
        }
        if ((x[1] - x[0]) % 2 == 0) {
            count += (x[1] - x[0]) / 2;
        } else {
            count += (x[1] + 1 - x[0]) / 2 + 1;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21332
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn decrease_flavor(l: i64, n: i64, i: usize) -> i64 {
    (l..(l + n)).enumerate()
        .filter(|&(j, _)| j != i)
        .map(|(_, x)| x)
        .sum()
}

fn main() {
    let v: Vec<i64> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let (n, l) = (v[0], v[1]);
    let source: i64 = (l..(l + n)).sum();
    let flavors_diff: Vec<i64> = (0..n)
        .map(|i| (source - decrease_flavor(l, n, i as usize)).abs())
        .collect();

    let answer = flavors_diff
        .into_iter()
        .enumerate()
        .map(|(i, x)| (x, i))
        .min()
        .unwrap();
    
    println!("{}", decrease_flavor(l, n, answer.1));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

bool used[1000000];
int main() {
	/*vector<int>v(7);
	iota(v.begin(), v.end(), 1);
	set<int>se;
	do {
		vector<int>d1, d2 = v;
		while (d2.size() > 1) {
			rep(i, d2.size() - 2) {
				vector<int>e{ d2[i],d2[i + 1],d2[i + 2] };
				sort(e.begin(), e.end());
				d1.push_back(e[1]);
			}
			d2 = d1;
			d1.clear();
		}
		if (d2[0] == 5) {
			for (int j : v) {
				cout << j << ' ';
			}
			cout << endl;
		}
		se.insert(d2[0]);
	} while (next_permutation(v.begin(), v.end()));
	for (int i : se) {
		cout << i << endl;
	}*/
	ll n, x; scanf("%lld%lld", &n, &x);
	ll j = 2 * n - 1;
	if (x != 1 && x != j) {
		puts("Yes");
		if (x + j / 2 <= j) {
			for (ll i = x + j / 2; i >= x; i--) {
				printf("%lld\n", i); used[i] = true;
			}
			for (ll i = 1; i <= j; i++) {
				if (!used[i])printf("%lld\n", i);
			}
		}
		else {
			for (ll i = x - j / 2; i <= x; i++) {
				printf("%lld\n", i); used[i] = true;
			}
			for (ll i = j; i >= 1; i--) {
				if (!used[i])printf("%lld\n", i);
			}
		}
	}
	else {
		puts("No");
	}
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
using namespace std;
int main(){
  long long int k;
  string s;bool flag=true;
  cin >> s>> k; string j;
  for(long long int i=0;i<k;i++){
    if(s[i]!='1') {
      cout <<s[i]<<endl;
      return 0;
    }
}
cout <<'1'<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
const int MAXN = 200005;
int n, K, L;
int c[MAXN], d[MAXN];
int f(int x) {
	if (x == c[x]) return x;
	return c[x] = f(c[x]);
}
int g(int x) {
	if (x == d[x]) return x;
	return d[x] = g(d[x]);
}
int ans[MAXN];
unordered_map <int, int> v[MAXN];
int main() {
	scanf("%d%d%d", &n, &K, &L);
	for (int i = 1; i <= n; i++) c[i] = d[i] = i;
	for (int i = 0; i < K; i++) {
		int x, y; scanf("%d%d", &x, &y);
		x = f(x); y = f(y);
		c[x] = y;
	}
	for (int i = 0; i < L; i++) {
		int x, y; scanf("%d%d", &x, &y);
		x = g(x); y = g(y);
		d[x] = y;
	}
	for (int i = 1; i <= n; i++) {
		c[i] = f(i);
		d[i] = g(i);
		v[c[i]][d[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		ans[i] = v[f(i)][g(i)];
		printf("%d ", ans[i]);
	}
	puts("");
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int arr[] = new int[n];
 
        for(int i=0; i<n; i++)
            arr[i] = scanner.nextInt();
 
        for(int i=0; i<arr.length; i++){
            int idx = i;
 
            while(idx > 0 && arr[idx-1] > arr[idx]){
                int temp = arr[idx-1];
                arr[idx-1] = arr[idx];
                arr[idx] = temp;
                idx--;
            }
            Show(arr);
        }
 
    }
 
    static void Show(int[] arr){
        int i;
        for(i=0; i<arr.length-1; i++){
            System.out.print(arr[i] + " ");
        }
        System.out.println(arr[i]);
	}
}


Measured memory_bytes: 30948
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   (*(x.begin()))
#define le(x)                   (*(x.rbegin()))
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x,id)               (*(x.find_by_order(id)))
#define ook(y)                  order_of_key(y)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      long long TC;  scanf("%lld",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;
#define mx 1000002
int ar[mx];



main(){
//read;

for(int i = 1; i<mx; i++){
    for(int j = i; j<mx; j+=i)
        ar[j]++;
}

int n;
cin>>n;
ll ans = 0;

for(ll i = 1; i<n; i++){
    ans+=ar[n-i];
}
cout<<ans;

return 0;
}


Measured memory_bytes: 7572
fun main(args: Array<String>) {
    val (n,a,b) =  readLine()!!.split(' ').map { it.toLong() }

    val nn = n / (a+b)
    var blue = nn * a
    val red = nn * b

    if (blue + red + a <= n) blue += a
    else blue += (n - (blue + red))

    println(blue)

}


Measured memory_bytes: 38248
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	if (s.size() <= n) {
		cout << s << endl;
	}
	else {
		rep(i, n) {
			cout << s[i];
		}
		cout << "..." << endl;
	}
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

bool comp(const string& i, const string& j){
	return (i > j);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n , t;
	cin >> n >> t;
	vector<lli> x(n);

	cin >> x[0];
	x[0] = abs(x[0]-t);//初期設定
	lli ans = x[0];

	loop(i, 1, n){
		cin >> x[i];
		x[i] = abs(x[i]-t);
		ans = __gcd(ans, x[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
#define MAX_V (110)

struct edge{int to, cap, rev; };

vector <edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t)return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

signed main(){
	int n;
	cin >> n;
	vi a(n);
	int can_flow = 0;
	rep(i, n){
		cin >> a[i];
		can_flow += a[i] >= 0 ? a[i] : 0;
		add_edge(0, i + 1, a[i] > 0 ? a[i] : 0);
		add_edge(i + 1, n + 1, a[i] > 0 ? 0 : -a[i]);
	}
	loop(i, 1, n + 1){
		loop(j, 1, n + 1){
			if(j % i == 0 && i != j){
				add_edge(j, i, INF);
			}
		}
	}
	int va = max_flow(0, n + 1);
	cout << can_flow - va << endl;
}

Measured memory_bytes: 256
a = input()
input_list = []
for k in a:
    input_list.append(int(k))
n=3
fomul_list = []
for i in range(2 ** n):
    fomul = str(input_list[0])
    for j in range(3):
        if (i >> j)&1:
            fomul = fomul + "+" + str(input_list[j+1])
        else:
            fomul = fomul + "-" + str(input_list[j+1])
    if eval(fomul) == 7:
        print(fomul + "=7")
        exit()

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

#define NMAX 100005

using namespace std;
using ll =  long long;


int N,H,A[NMAX],B[NMAX];

bool check(int x){
  int i = 0;
  ll sum = 0;
  for(; x > 0 && i < N && A[0] <= B[i]; --x){
      sum += B[i++];
  }
  sum += (ll)x * A[0];
  return sum >= H;
}

int main(){
  cin >> N >> H;
  for(int i = 0; i < N; ++i){
    scanf("%d %d", &A[i], &B[i]);
  }
  sort(A, A + N, greater<int>());
  sort(B, B + N, greater<int>());
  // solve
  int low = 0, hi = H;
  while(hi - low > 1){
    int mid = low + (hi - low) / 2;
    if(check(mid)){
      hi = mid;
    }
    else {
      low = mid;
    }
  }
  // answer
  cout << hi << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cctype>
#include <utility>
#include <stack>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	static const int tr[] = {0, 1, 2, 3, 5, 7, 8, 9};
	stack<int> s;
	for (int n; (n = in());) {
		for (; n; n /= 8)
			s.push(tr[n % 8]);
		for (; !s.empty(); s.pop())
			out(s.top());
		outl();
	}
}


Measured memory_bytes: 2448
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int n;
   cin>>n;
   vector<int> h(n+10,0);
   vector<int> a(n+10,0);

   rep(i,n){
      int x;
      cin>>x;
      h[i]=x;
   }

   ll ans=0;

   bool f=true;
   while(f){
      int l=-1;
      int r=-1;
      rep(i,n){
         if(a[i]!=h[i] && l==-1){
            l=i;
            for(int j=i+1;j<n;j++){
               if(a[j]==h[j] && r==-1){
                  r=j-1;
                  break;
               }
            }
         }
         if(r!=-1) break;
      }
      if(l==-1 && r==-1) {
         f=false;
         break;
      }
      else if(l!=-1 && r==-1) r=n-1;
      for(int i=l;i<=r;i++){
            a[i]++;
      }
      ans++;
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
    int price;
    int change;
    int cnt;
    int i;

    while (1){
        scanf("%d", &price);
        if (price == 0){
            break;
        }

        change = 1000 - price;
        cnt = 0;

        for (i = 100; i > 0; i /= 10){
            cnt += change / 5 / i;
            change %= 5 * i;
            cnt += change / i;
            change %= i;
        }
        printf("%d\n", cnt);
    }

    return (0);
}

Measured memory_bytes: 600
MOD = 10**9 + 7


def main():
    _ = int(input())
    A = [int(i) for i in input().split()]

    ans = (sum(A)**2) % MOD - (sum(pow(a, 2, MOD) for a in A)) % MOD
    ans *= pow(2, MOD-2, MOD)
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 105192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0; i<n; i++){
  	cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i=0; i<k; i++){
  	ans += p[i];
  }
  cout << ans << endl;
    return 0;
}


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

int main() {
  int n,m,x;  
  cin >> n >> m >> x;
  int l[n][m+1];
  int flg = 0;
  for(int i = 0; i<n;i++){
    for(int j = 0; j<m+1;j++){
      cin >> l[i][j];
    }
  }
  int cos = 1000000000;
  // すべての選び方を試して、総和がKになるものがあるかを調べる
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    //bitset<12> s(tmp);  // 最大20個なので20ビットのビット列として扱う
 
    // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
    int sum = 0;
    int val[m+1]{0};
    for (int i = 0; i < n; i++) {
      //if (s.test(i)) {
      if (tmp & (1<<i)){
        for(int j =0;j < m+1;j++){
          val[j] += l[i][j];
        }
      }
    }
    flg =0;
    for(int i =1;i<m+1;i++){
      if(val[i] < x){
        flg = 1;
        break;
      }
    }
    if(flg == 0){
      cos = min(cos,val[0]);
    }
    
  }
  if(cos == 1000000000){
    cout << -1;
  }else{
    cout << cos << endl;
  }
 }


Measured memory_bytes: 3628
package main

import (
	"fmt"
	"sort"
)

type susi struct {
	t int
	d int
}

type sushi []susi

func (s sushi) Len() int {
	return len(s)
}

func (s sushi) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sushi) Less(i, j int) bool {
	return s[i].d < s[j].d
}

func maxInt(a, b int) int {
	switch {
	case a > b:
		return a
	default:
		return b
	}
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var sushi sushi = make([]susi, n)
	for i := range sushi {
		fmt.Scan(&sushi[i].t, &sushi[i].d)
	}
	sort.Sort(sort.Reverse(sushi))

	pointD := 0
	typeNum := 0
	types := make([]int, n+1)
	for i := 0; i < k; i++ {
		pointD += sushi[i].d
		types[sushi[i].t]++
		if types[sushi[i].t] == 1 {
			typeNum++
		}
	}
	pointSum := pointD + (typeNum * typeNum)

	iRemove := k - 1
	iAdd := k
	for typeNum < k {
		for ; iRemove > 0; iRemove-- {
			if types[sushi[iRemove].t] > 1 {
				pointD -= sushi[iRemove].d
				types[sushi[iRemove].t]--
				break
			}
		}
		if iRemove == 0 {
			break
		}
		iRemove--

		for ; iAdd < n; iAdd++ {
			if types[sushi[iAdd].t] == 0 {
				pointD += sushi[iAdd].d
				types[sushi[iAdd].t]++
				typeNum++
				break
			}
		}
		if iAdd == n {
			break
		}
		iAdd++

		pointSum = maxInt(pointSum, pointD+(typeNum*typeNum))
	}
	fmt.Println(pointSum)
}


Measured memory_bytes: 6912
#include<iostream>

int main(void){
    char str[3];
    std::cin >> str;

    if(str[0] == str[1] && str[0] == str[2]){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int check(int x){
    if(x == 4 || x == 6 || x == 9 || x == 11) return 1;
    else if (x == 2) return 2;
    else return 0;
}

int main(){
    int x, y; cin >> x >> y;
    int a = check(x);
    int b = check(y);
    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#include <iostream>
#include <string>
using namespace std;

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

	cin >> N >> K;
	
	int ans = 0;
	if(N%K==0){ ans = 0; }
	else{ ans = 1;}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
/*input
20 100000
14309 -32939
-56855 100340
151364 25430
103789 -113141
147404 -136977
-37006 -30929
188810 -49557
13419 70401
-88280 165170
-196399 137941
-176527 -61904
46659 115261
-153551 114185
98784 -6820
94111 -86268
-30401 61477
-55056 7872
5901 -163796
138819 -185986
-69848 -96669
*/
 
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.14159265
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr
 
#define mod 998244353
 
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}
 
 
 ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 





 
int main() 
{
    ll n,D; cin>>n>>D;
    ll x[200005], y[200005];
    ll ans=0;
    rep(i,n){
    	cin>>x[i]>>y[i];
    	ll dist = x[i]*x[i] + y[i]*y[i];
    	double d = 1.0*dist;
    	double act_dist = sqrt(d);

    	ll fin = 10000000*act_dist;
    	if(fin <= 10000000*D)
    		++ans;
    }
    cout<<ans<<endl;
    return 0;  
}
 

Measured memory_bytes: 6804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,k;
    string s;
    cin >> n;
    pair<pair<string, int>, int> p[n];
    rep(i, n){
        cin >> s >> k;
        p[i] = make_pair(make_pair(s, k * -1), i);
    }
    sort(p,p+n);
    rep(i, n){
        cout << p[i].second + 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
p_list = p.copy()
p.sort()
sum=0
for i in range(N):
  if p[i] != p_list[i]:
    sum += 1
if sum == 0 or sum == 2:
  print('YES')
else:
  print('NO')

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int
#define endl '\n'

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/*template*/
template<class T>constexpr bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>constexpr bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
constexpr int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
constexpr int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
constexpr int32_t LCM(int32_t a, int32_t b){return a / GCD(a, b) * b;}
constexpr int64_t LCM(int64_t a, int64_t b){return a / GCD(a, b) * b;}

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7;
constexpr int32_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

//#define int int64_t

/*global*/



signed main()
{
	int n; cin >> n;
	if(n == 1) {
		cout << 1 << '\n';
		return 0;
	}
	else if(n==2)
	{
		cout << 8 << '\n';
		return 0;
	}
	else
	{
		cout << n*n*n << '\n';
	}
	
}

Measured memory_bytes: 256
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
#define MOD 1000000007
using namespace std;
long long int N;
	long long int M;
	long long int flag[100001];
	long long int dp[100001];

int main() {
	long long int a;
	cin >> N >> M;
	for (long long int i = 0; i < M; i++) {
		cin >> a;
		flag[a] = 1;
	}

	for (long long int i = 0; i < N + 1; i++) {
		if (i == 0 || i == 1)dp[i] = 1;
		else {
			
			dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= MOD;
			
		}
		if (flag[i]) {
			dp[i] = 0;
		}
	}

	cout << dp[N] << endl;




	return(0);
}

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

using namespace std;

typedef long long ll;

const ll L=5E15;

char s[1010];
ll K,cur;

int main()
{
    cin>>s+1;
    cin>>K;
    for(int i=1;s[i];i++)
    {
        if(i>=K) {printf("%c\n",s[i]);break;}
        if(s[i]!='1') {printf("%c\n",s[i]);break;}
    }
}

Measured memory_bytes: 256
from bisect import bisect_left,bisect_right

TO_ACII = 97

N = int(input())
S = ["0"] + list(input())
Q = int(input())

ABC = [[]for i in range(0,26,1)]#該当文字a:0 b:1 ...z:26 が何文字目に出てきたかを保持する配列

for i in range(1,N+1,1):
    ABC[ord(S[i])-TO_ACII].append(i)

ans = []
for i in range(0,Q,1):
    q = list(input().split())
    if q[0]=="1":#文字変更
        changed = S[int(q[1])]
        ABC[ord(changed)-TO_ACII].pop(bisect_left(ABC[ord(changed)-TO_ACII],int(q[1])))
        ABC[ord(q[2])-TO_ACII].insert(bisect_left(ABC[ord(q[2])-TO_ACII],int(q[1])),int(q[1]))
        S[int(q[1])]=q[2]
    else:
        tmpans = 0
        for i in range(0,26,1):

            if bisect_right(ABC[i],int(q[1])-1)<len(ABC[i]) and int(q[2]) >= ABC[i][bisect_right(ABC[i],int(q[1])-1)]:
                tmpans+=1
        ans.append(tmpans)

for i in range(0,len(ans),1):
    print(ans[i])


Measured memory_bytes: 35376
from collections import deque 
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ans+=1
q=deque([[0,0]])
dx=[1,0,-1,0]
dy=[0,1,0,-1]
s[0][0]=0
while q:
    p=q.popleft()
    if p[0]==h-1 and p[1]==w-1:
        break
    for i in range(4):
        x=p[0]+dx[i]
        y=p[1]+dy[i]
        if 0<=x<h and 0<=y<w and s[x][y]==".":
            s[x][y]=s[p[0]][p[1]]+1
            q.append([x,y])
print(-1 if s[-1][-1]=="." else ans-s[-1][-1]-1)

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

int main(void)
{
    int h,w;
    string ans;

    while (true)
    {
        cin >> h >> w;
        if (h == 0 && w == 0)   break;

        ans = "";
        rep(i, w)
            ans += "#";

        rep(i, h)
            cout << ans << endl;

        cout << endl;
    }
}



Measured memory_bytes: 3140
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int>l(n);
	for(int& x : l)cin >> x;
	sort(l.begin(), l.end());
	cout << (l[l.size() - 1] < accumulate(l.begin(), l.end() - 1, 0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256