akhauriyash/Code-Regression huggingface dataset:
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int gcd1(int a, int b)
{
    if (b == 0)
        return a;
    else
    {
        return gcd1(b, a % b);
    }
}

int gcd2(int a, int b)
{
    if (b == 0)
        return a;
    else
    {
        return gcd2(b, a % b);
    }
}

int main(void)
{
    int K;

    cin >> K;
    int a, b, c;
    int ab;
    ll sum = 0;

    for (a = 1; a <= K; a++)
    {
        for (b = 1; b <= K; b++)
        {
            ab = gcd1(a, b);
            for (c = 1; c <= K; c++)
            {
                sum += gcd2(ab, c);
            }
        }
    }
    cout << sum << endl;
    return (0);
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

char A[51][51], B[51][51];

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, N) rep(j, N) cin >> A[i][j];
    rep(i, M) rep(j, M) cin >> B[i][j];

    
    for(int i = 0; i < N-M+1; i++){
      for(int j = 0; j < N-M+1; j++){
        bool flag = true;
        for(int h = 0; h < M; h++){
          for(int w = 0; w < M; w++){
            if(A[i+h][j+w] != B[h][w]) flag = false;
          }
        }
        if(flag){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }

    cout << "No" << endl;

    return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  long double degree = abs((H * 60 + M) / 720 * 360 - M / 60 * 360);
  long double rad = M_PI * degree / 180;
  cout << sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(rad));
}


Measured memory_bytes: 4100
k,n=map(int,input().split())
houses=list(map(int,input().split()))
houses.sort()
maxx=-float('INF')
for i in range(n-1):
    if houses[i+1]-houses[i]>maxx:
        maxx=houses[i+1]-houses[i]

maxx=max([maxx,k-(houses[-1]-houses[0])])
print(k-maxx)


Measured memory_bytes: 26420
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AHitachiString {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        if (s.size() % 2 == 1) {
            cout << "No" << endl;
            return;
        }

        bool ok = true;
        for (int i = 0; i < s.size(); i += 2) {
            if (s[i] != 'h' || s[i+1] != 'i') {
                ok = false;
                break;
            }
        }
        if (!ok) {
            cout << "No" << endl;
            return;
        }
        cout << "Yes" << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    AHitachiString solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include<string>
#include<cstring>
#include<complex>
#include<cmath>
using namespace std;
#define rep(i, n)   for(long long i = 0; i < (long long)(n); i++)
#define rrp(i, n)   for(long long i = ((long long)(n)); i >=0; i--)
#define mpp(i,j,k)  make_pair((int)(i),make_pair((int)(j),(int)(k)))
typedef pair<int,pair<int,int > > ppp;
typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<vi>  vvi;

long long n,s,t;

long long f(long long x,long long y){if(y<x){
                             return y;}
                     else{
                             return f(x,floor(y/x))+(y%x);}
                     }

int main(){
 cin>>n>>s;
  if(n<s){cout<<-1<<endl;return 0;}
  t=-1;
  if(n==s){cout<<n+1<<endl;return 0;}
  rep(i,floor(sqrt(n))+1){if(i>1 && s==f(i,n)){t=i;break;}}

  rrp(i,floor(sqrt(n))){if(t<0 && i>0 && (n-s)%i==0 && (n-s)/i+1>floor(sqrt(n)) && s==f((n-s)/i+1,n) ){t=(n-s)/i+1;break;}}

 cout<<t<<endl;
  return 0;}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H;
	int R;
	cin >> H >> R;
	if (H>=R){
		cout << "1" << endl;
	}else if(H*-1==R){
		cout << "0" << endl;
	}else if (H*-1>=R){
		cout << "-1" << endl;
	}else if (H<=R){
	    cout << "1" << endl;
	}else if (H==0){
	    cout << "1" << endl;
	}
}


Measured memory_bytes: 3092
#include <iostream>

#include <vector>

#include <algorithm>
#include <iomanip>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

using std::setprecision;
using std::sort;

int
main()
{
  int N;
  cin >> N;
  vector<double> v(N);
  for (int n = 0; n < N; n++)
  {
    cin >> v[n];
  }
  sort(v.begin(), v.end());
  double value = v[0];
  for (int n = 1; n < N; n++)
  {
    value = (value + v[n]) / 2;
  }
  cout << setprecision(10) << value << endl;
  return 0;
}


Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 140164
fun main() {
    val (x, n) = readLine()!!.split(" ").map { it.toInt() }
    if (n == 0) {
        println(x)
        return
    }

    val list = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()
    var diff = 0
    while (true) {
        val min = x - diff
        if (!list.contains(min)) {
            println(min)
            return
        }
        val max = x + diff
        if (!list.contains(max)) {
            println(max)
            return
        }

        diff += 1
    }
}

Measured memory_bytes: 38996
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d=sc.nextInt(),n=sc.nextInt();
		if(d==0)d = 1;
		else if(d==1)d = 100;
		else if(d==2)d = 10000;
		int ans = n*d;
		if(n == 100) ans += d;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

ll t[1000];
int main(){
    int N;
    while(cin>>N && N){
        ll A,B;
        scanf("%lld %lld",&A,&B);
        ll C;
        scanf("%lld",&C);
        ll cost=A, cal=C;
        for(int i=0;i<N;i++){
            scanf("%lld",t+i);
        }
        sort(t,t+N);
        reverse(t,t+N);
        for(int i=0;i<N;i++){
            if(1.* (cal+t[i]) / (cost+B) >= 1. * cal/cost){
                cal+=t[i];
                cost+=B;
            }else break;
        }
        cout << cal/cost << endl;
    }
}

Measured memory_bytes: 1244
short*p,v[][99];main(c,n,m,i,y){for(;m=scanf("%d %[^\n] %[^\n]",&n,v,v+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=0,y=n-1;c<m&y>0;y-=y==n|*p&2?-1:*p&p[-1]&1?1:!++c+2)p=y+v[c+i&1];}

Measured memory_bytes: 0
s = input()
n = len(s)
ans = [1]*n
for i in range(n) :
    if s[i] == "R" and s[i+1] == "R":
        ans[i+2] += ans[i]
        ans[i]=0
    m = n-i-1
    if s[m] == "L" and s[m-1]== "L" :
        ans[m-2] += ans[m]
        ans[m] = 0

print(*ans)





Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
#include<queue>
#define INF 100000000
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> P2;

int main(){
  int w,h;
  char grid[100][50];
  int d[2][100][50];
  int dy[] = {-2,-1,0,1,2,-1,0,1,0} , dx[] = {1,1,1,1,1,2,2,2,3};

  while(scanf("%d%d",&w,&h), w||h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	scanf(" %c ",&grid[i][j]);

    priority_queue<P2,vector<P2>,greater<P2> > q;

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(grid[i][j] == 'S'){
	  d[0][i][j] = d[1][i][j] = 0;
	  q.push(P2(P(0,0),P(i,j)));
	  q.push(P2(P(0,1),P(i,j)));
	}else d[0][i][j] = d[1][i][j] = INF;

    while(q.size()){
      P2 p = q.top();q.pop();
      int t = p.first.first, f = p.first.second;
      int y = p.second.first, x = p.second.second;

      if(grid[y][x] == 'T'){
	q.push(p);
	cout << t << endl;
	break;
      }

      for(int k=0;k<9;k++){
	int ty = y+dy[k], tx = !f?(x+dx[k]):(x-dx[k]),tt = -1;
	if(ty<0 || tx<0 || h<=ty || w<=tx)continue;
	if(d[1-f][ty][tx]<INF)continue;

	if('1'<=grid[ty][tx] && grid[ty][tx]<='9')tt = grid[ty][tx]-'0';
	if(grid[ty][tx] == 'T')tt = 0;

	if(tt>=0 && d[1-f][ty][tx] > t + tt){
	  d[1-f][ty][tx] = t+tt;
	  q.push(P2(P(t+tt,1-f),P(ty,tx)));
	}
      }
    }
    if(q.empty())cout << -1 << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] != t[i])
            ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3808
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N, M, X, Y; cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M); cin >> x >> y;
  x.push_back(X), y.push_back(Y);
  sort(x.rbegin(), x.rend());
  sort(y.begin(), y.end());
  if (y[0] <= x[0]) {
    cout << "War" << endl;
    return 0;
  }
  cout << "No War" << endl;
}


Measured memory_bytes: 3628
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;

struct Edge { 
  int from, to;
  ll cost;
  Edge() {}
  Edge(int f, int t, ll c): from(f), to(t), cost(c) {}
};

struct Node {
  int id;
  ll cost;
  Node(int id, ll c) : id(id), cost(c) {}
  friend bool operator < (const Node& lhs, const Node& rhs) { return lhs.cost < rhs.cost; };
  friend bool operator > (const Node& lhs, const Node& rhs) { return rhs < lhs; };
  friend bool operator <= (const Node& lhs, const Node& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Node& lhs, const Node& rhs) { return !(lhs < rhs); };
};

typedef vector<vector<Edge>> Graph;

ll dist[100010];
bool visit[100010];
void dijkstra(Graph &g) { 
  for (int i = 0; i < g.size(); ++i) { 
    dist[i] = -1;
  }
  dist[0] = 0;
  priority_queue<Node, vector<Node>, greater<Node>> pq;
  pq.push(Node(0, 0));
  while (!pq.empty()) { 
    Node node = pq.top(); pq.pop();
    if (visit[node.id]) continue;
    visit[node.id] = true;
    // cerr << node.id << " " << node.cost << endl;
    for (Edge& e: g[node.id]) { 
      ll cost = dist[e.from]+e.cost;
      if (dist[e.to] != -1 && dist[e.to] <= cost) {
        continue;
      }
      // cerr << e.from << " " << e.to << " " << cost << endl;
      dist[e.to] = cost;
      pq.push(Node(e.to, dist[e.to]));
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  for (int i = 0; i < n-1; ++i) { 
    g[i+1].emplace_back(i+1, i, 0);
  }
  for (int i = 0; i < m; ++i) { 
    int l, r;
    ll c;
    cin >> l >> r >> c;
    --l; --r;
    g[l].emplace_back(l, r, c);
  }
  dijkstra(g);
  cout << dist[n-1] << endl;
}



Measured memory_bytes: 10104
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi;
typedef vector<double> vd;
 
double mypow(double b ,int e){
      if(e == 0) return 1;
      if(e%2==0)
            return mypow( b*b, e/2 );
      else
            return mypow( b*b, e/2 ) * b;
}
 
int main(){
 
 
      int N,M,L; cin >> N >> M >> L ;
      if(N==1){
            cout << 1.0 << endl;
            return 0;
      }
      vector<vd> prob(N,vd(M+1,0.0));
      vector<vd> dist(N,vd(M+1,0.0));
 
      vd p(N),t(N),v(N);
      for(int i=0; i<N; i++) cin >> p[i] >> t[i] >> v[i];
 
      // PRE PROCESS
      for(int i=0; i<N; i++){
            dist[i][0] = (double)L / v[i];
            for(int j=1; j<=M; j++){
                  dist[i][j] = dist[i][j-1] + t[i];
            }
      }
      for(int i=0; i<N; i++)
            prob[i][0] = mypow((100-p[i])/100,M);
      for(int i=0; i<N; i++){
            for(int j=1; j<=M; j++){
                  if(p[i] != 100)
                        prob[i][j] = (prob[i][j-1] * (p[i]/100)) / ((100-p[i])/100);
                  else
                        prob[i][j] = 1.0;
            }
      }
      double comb = 1;
      for(int j=1; j<=M; j++){
            comb = comb * (M - j + 1) / j; 
            for(int i=0; i<N; i++){
                  prob[i][j] *= comb;
            }
      }
       
      vector<vd> sum = prob;
      for(int i=0; i<N; i++){
            for(int j=M-1; j>=0; j--){
                  sum[i][j] += sum[i][j+1];
                  if(sum[i][j] > 1) sum[i][j] = 1;
            }
      }
 
      vector<vd> ans = prob;
      for(int i=0; i<N; i++){
            for(int j=0; j<=M; j++){
                  for(int k=0; k<N; k++){
                        if(i==k) continue;
                        int id = upper_bound(dist[k].begin(),dist[k].end(), dist[i][j]) - dist[k].begin();
                        if(id > M) ans[i][j] = 0.0;
                        else       ans[i][j] *= sum[k][id];
 
                  }
            }
      }
 
      for(int i=0; i<N; i++){
            double tmp = 0.0;
            if(p[i] == 100) tmp = ans[i][M];
            else
                  for(int j=0; j<=M; j++)
                        tmp += ans[i][j];
            if(tmp > 1) tmp = 0;
            printf("%.10f\n",tmp);
      }
                         
}

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

vector<vector<pair<int,int>>>data;

int dice[6][6][4]{
	{
		{
			0, 0, 0, 0
		}, {
			2, 3, 5, 4
		}, {
			3, 5, 4, 2
		}, {
			4, 2, 3, 5
		}, {
			5, 4, 2, 3
		}, {
			0, 0, 0, 0
		}
	}, {
		{
			1, 4, 6, 3
		}, {
			0, 0, 0, 0
		}, {
			3, 1, 4, 6
		}, {
			4, 6, 3, 1
		}, {
			0, 0, 0, 0
		}, {
			6, 3, 1, 4
		}
	}, {
		{
			1, 2, 6, 5
		}, {
			2, 6, 5, 1
		}, {
			0, 0, 0, 0
		}, {
			0, 0, 0, 0
		}, {
			5, 1, 2, 6
		}, {
			6, 5, 1, 2
		}
	}, {
		{
			1, 5, 6, 2
		}, {
			2, 1, 5, 6
		}, {
			0, 0, 0, 0
		}, {
			0, 0, 0, 0
		}, {
			5, 6, 2, 1
		}, {
			6, 2, 1, 5
		}
	}, {
		{
			1, 3, 6, 4
		}, {
			0, 0, 0, 0
		}, {
			3, 6, 4, 1
		}, {
			4, 1, 3, 6
		}, {
			0, 0, 0, 0
		}, {
			6, 4, 1, 3
		}
	}, {
		{
			0, 0, 0, 0
		}, {
			2, 4, 5, 3
		}, {
			3, 2, 4, 5
		}, {
			4, 5, 3, 2
		}, {
			5, 3, 2, 4
		}, {
			0, 0, 0, 0
		}
	}
};

int dx[4] = { -1, 0, 1, 0 };
int dy[4] = { 0, 1, 0, -1 };

void datapop(int t, int f, int high, int x, int y)
{
	if (high == 0)
	{
		data[x][y].second = t;
		data[x][y].first = 1;
		return;
	}
	int memo=0,memo2=0;
	for (size_t i = 0; i < 4; i++)
	{
		if (data[x + dx[i]][y + dy[i]].first < high)
		{
			if (dice[t-1][f-1][i] == 4)
			{
				if (memo < 4)
				{
					memo = 4;
					memo2 = i;
				}
			} else if (dice[t-1][f-1][i] == 5)
			{
				if (memo < 5)
				{
					memo = 5;
					memo2 = i;
				}
			} else if (dice[t-1][f-1][i] == 6)
			{
				if (memo < 6)
				{
					memo = 6;
					memo2 = i;
				}
			}
		}
	}
	if (!memo)
	{
		data[x][y].first++;
		data[x][y].second = t;
		return;
	}
	switch (memo2)
	{
		case 0:f = t; break;
		case 1:break;
		case 2:f = 7 - t; break;
		case 3:break;
		default:
			break;
	}
	datapop(7 - memo, f, data[x + dx[memo2]][y + dy[memo2]].first, x + dx[memo2], y + dy[memo2]);
	return;
}

int main()
{
	int n;
	int t, f;
	while (cin >> n, n)
	{
		data.clear();
		data.resize(30);
		for (size_t i = 0; i < 30; i++)
		{
			data[i].resize(30);
		}
		for (size_t i = 0; i < n; i++)
		{
			cin >> t >> f;
			datapop(t, f, data[15][15].first, 15, 15);
		}
		vector<int>ans;
		ans.resize(6);
		for (auto x : data)
		{
			for (auto y : x)
			{
				if (y.second)
				{
					ans[y.second - 1]++;
				}
			}
		}
		for (size_t i = 0; i < 5; i++)
		{
			cout << ans[i] << " ";
		}
		cout << ans[5] << endl;
	}
}

Measured memory_bytes: 1208
#include <stdio.h>
	int main(void){
		int a,b,c;
		char op;
		while(1){
			scanf("%d %c %d",&a,&op,&b);
			if(op=='?'){
				break;
			}else if(op=='+'){
				c=a+b;
			}else if(op=='-'){
				c=a-b;
			}else if(op=='*'){
				c=a*b;
			}else if(op=='/'){
				c=a/b;
			}
			printf("%d\n",c);
		}
	return 0;
}

Measured memory_bytes: 600
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

char buf[200000+10];

int main(void) {
  cin >> buf;
  int n = strlen(buf);
  ll res = 0;
  ll a = 0;
  REP(i, n) {
    // cerr << i << " " << a << endl;
    if(buf[i] == 'A') {
      ++a;
      continue;
    }
    if(i+1 < n && buf[i] == 'B' && buf[i+1] == 'C') {
      res += a;
      ++i;
      continue;
    }
    a = 0;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  ll a,b;
  cin >> a >> b;
  cout << (a + b) / 2 << endl;
  return 0;
}


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

int main(){
  int c = 0, c_max = 0;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); ++i){
    if(s[i] == 'A' || s[i] == 'G'|| s[i] == 'C'|| s[i] == 'T'){
      c++;
    } else {
      c = 0;
    }
    
    if(c_max < c){
      c_max = c;
    }
  }
  cout << c_max << '\n';
}

Measured memory_bytes: 256
_ = int(input())
A = [int(x) for x in input().split()]
q = int(input())
for _ in range(q):
    b, m, e = [int(x) for x in input().split()]
    B = A[:]
    for k in range(e-b):
        A[ b + (k+e-m)%(e-b)] = B[b+k]

print(*A)





Measured memory_bytes: 5844
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, K: int):
    flag = False
    for k1 in range(K+1):
        for k2 in range(K+1):
            for k3 in range(K+1):
                if not k1 + k2 + k3 <= K:
                    break
                if B * (2 ** k2) > A * (2 ** k1) and C * (2 ** k3) > B * (2 ** k2):
                    flag = True

    if flag == True:
        print(YES)
    else:
        print(NO)
    return


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

if __name__ == '__main__':
    main()


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

using namespace std;

long long MOD = 1000000007;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<bool> A(N+1, true);
    for (int i = 0; i < M; i++)
    {
        int a;
        cin >> a;
        A[a] = false;
    }
    vector<long long> ans(N+1, 0);
    ans[0] = 1;
    if (A[1])
    {
        ans[1] = 1;
    }
    
    for (int i = 2; i <= N; i++)
    {
        if (A[i])
        {
            if (A[i-1])
            {
                ans[i] = ans[i-1];
            }
            if (A[i-2])
            {
                ans[i] = (ans[i] + ans[i-2]) % MOD;
            }
        }
    }
    cout << ans[N] << endl;
}

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

Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

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

  vector<int> ok(n+1, true);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ok[a] = false;
  }
  vector<long long> dp(n+1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j <= min(n, i+2); j++) {
      if(ok[j]) {
        dp[j] += dp[i];
        dp[j] %= mod;
      }
    }
  }
  cout << dp[n] << endl;  
}


Measured memory_bytes: 1408
s = input();

vec = list()

vec.append(s[0])

idx = 1
while idx < len(s):
    if s[idx]==vec[-1]:
        if idx==len(s)-1:
            break
        else:
            vec.append(s[idx]+s[idx+1])
        idx += 2
    else:
        vec.append(s[idx])
        idx += 1

print(len(vec))

Measured memory_bytes: 8296
#include <iostream>

using namespace std;

int main(void){

  double n;
  while( cin >> n , n > 0 ){

    if( n >= 256 ){
      cout << "NA" << endl;
      continue;
    }

    int l[8],r[4];
    int N = n;
    n = n - N;
    for( int i = 7 ; i >= 0 ; i-- ){
      l[i] = N % 2;
      N /= 2;
    }

    for( int i = 0 ; i < 4 ; i++ ){
      r[i] = n * 2;
      n *= 2;
      int t = n;
      n = n - t;
    }
    if( n != 0 ){
      cout << "NA" << endl;
      continue;
    }

    for( int i = 0 ; i < 8 ; i++ )
      cout << l[i];
    cout << '.';
    for( int i = 0 ; i < 4 ; i++ )
      cout << r[i];
    cout << endl;

  }
  return 0;
}

Measured memory_bytes: 1224
N = int(input())
C = [1, 2, 4, 8, 16, 32, 64]
for i in range(len(C)):
  if N == C[i]:
    print(N)
    break
  elif C[i] < N and N < 64:
    continue
  elif N >= 64:
    print(64)
    break
  else:
    print(C[i-1])
    break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int maxi = 5e5+5, n;
vector<int>  val(maxi), ano(maxi);
vector<vector<int>> node;

void init(){
    long long hei = ceil(log2(n));
    hei = 2*pow(2, hei);
    node.clear();
    node.resize(hei);
    unordered_map<int, int> tmp;
    for (int i=n; i; i--){
        if (tmp.find(val[i])==tmp.end())
            ano[i] = n+1;
        else ano[i] = tmp[val[i]];
        tmp[val[i]] = i;
    }
}
vector<int> merge(vector<int> &a, vector<int> &b){
    vector<int> to_ret;
    int i = 0, j = 0;
    while (i<int(a.size()) && j<int(b.size()))
        if (a[i]<b[j]) to_ret.emplace_back(a[i++]);
        else to_ret.emplace_back(b[j++]);
    while (i<int(a.size())) to_ret.emplace_back(a[i++]);
    while (j<int(b.size())) to_ret.emplace_back(b[j++]);
    return to_ret;
}

void build(int cur, int start, int end){
    if (start==end) {
        node[cur].emplace_back(ano[start+1]);
        return;
    }
    int mid = (start+end)/2;
    build(2*cur, start, mid);
    build(2*cur+1, mid+1, end);
    node[cur] = merge(node[2*cur], node[2*cur+1]);
}

int query(int cur, int l, int r, int rl, int rr, int k){
    if (rr<l || r<rl)
        return 0;
    if (l>=rl && r<=rr)
        return node[cur].size()-(upper_bound(node[cur].begin(), node[cur].end(), k)-node[cur].begin());
    int mid = (l+r)/2;
    return query(2*cur, l, mid, rl, rr, k)+query(2*cur+1, mid+1, r, rl, rr, k);
}

int solve2(int l, int r){
    r = min(r, n);
    return query(1, 0, n-1, l-1, r-1, r);
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int l, r;
    int q;
    cin>> n >> q ;
    for (int j=1; j<=n; j++)
        cin >> val[j];
    init();
    build(1, 0, n-1);
    while (q--){
        cin>> l >> r;
        cout << solve2(l, r) << "\n";
    }
}

Measured memory_bytes: 98212
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

ll M = 1000000007;
ll fac[100005];

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

    fac[1]=fac[0]=1;
    for (ll i = 2; i < 100005; i++) {
        fac[i] = fac[i-1] * i % M;
    }

    if (abs(n-m) > 1) {
        cout << 0 << endl;
    } else if (n == m) {
        cout << fac[n] * fac[m] % M * 2 % M << endl;
    } else {
        cout << fac[n] * fac[m] % M << endl;
    }

    return 0;
}

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

map<int, int> MP;

int N, Ans;

int main() {
	ios::sync_with_stdio(false);
	
	cin >> N;
	for(int i = 0, c; i < N; i++) {
		cin >> c;
		MP[c]++;
	}
	for(auto &v : MP) {
		int a, b; tie(a, b) = v;
		if(a < b) Ans += b-a;
		else if(a > b) Ans += b;
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int a[100005];

int main()
{
	int a, b, c;
	while (~scanf("%d%d%d", &a, &b, &c))
	{
		if (a + b == c || a + c == b || b + c == a)
		printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//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())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    long K,N;cin>>K>>N;
    vector<long>A(N);
    REP(i,N)cin>>A[i];
    vector<long>res;
    REP(i,N)res.PB(min(abs(A[(N+i)%N]-A[(N+i+1)%N]),K-abs(A[(N+i)%N]-A[(N+i+1)%N])));
    long maxi=0;
    REP(i,N)if(res[i]>maxi){
        maxi=res[i];
    }
    long sum=0;
    REP(i,N){
        sum+=res[i];
    }
    cout<<sum-maxi<<endl;
    return 0;
}

Measured memory_bytes: 3956
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N + 1)]
x = []

for n in range(N):
    i = N - n
    BB = B[::i]
    if (sum(BB)) % 2 == A[i - 1]:
        B[i] = 0
    else:
        B[i] = 1
    if B[i] == 1:
        x.append(str(i))

if len(x) == 0:
    print(0)
else:
    print(len(x))
    print(' '.join(x))

Measured memory_bytes: 82396
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();

        int N, K;
        int[] A;
        void solve() {

            N = cin.nextInt();
            K = cin.nextInt();
            A = new int[N];

            for (int i = 0; i < N; i++)
                A[i] = cin.nextInt();

            Mathf mat = new Mathf();

            int G = mat.GCD(A);

            bool isPossible = K <= A.Max() && K % G == 0;

            Console.WriteLine(isPossible ? "POSSIBLE" : "IMPOSSIBLE");

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }

        class Mathf {
            private int mod = 1000000007;//10^9+7
            public int Mod { get; set; }
            public Mathf() { }
            public Mathf(int mod) { this.mod = mod; }
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
            public int GCD(int a, int b) {//最大公約数
                if (a < b) Swap(ref a, ref b);
                while (true) { int tmp = a % b; a = b; b = tmp; if (tmp == 0) break; }
                return a;
            }
            public int GCD(int[] array) {return array.Aggregate((v, next) => GCD(v, next));}
            public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        }
    }
}

Measured memory_bytes: 20576
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i, n){
    cin >> v[i];
    v[i]--;
  }
  int logK = 1;
  while((1ll << logK) < k) logK++;


  // iから2^k進んだ町
  vector<vector<ll>> doubling(logK, vector<ll>(n));

  rep(i, n) doubling[0][i] = v[i];

  for (int i = 1; i < logK; ++i) {
    for (int j = 0; j < n; ++j) {
      doubling[i][j] = doubling[i-1][doubling[i-1][j]];
    }
  }

  int node = 0;
  rep(d, 60){
    if(k & (1ll << d)) node= doubling[d][node];
  }

  cout << node+1 << endl;

}


Measured memory_bytes: 100068
#include<stdio.h>

int main(void)
{
  int n;
  int pay;
  int change=-1;

  scanf("%d",&n);

  for(int i=0;i<10;i++){
    pay = (i+1)*1000;
    if(n<=pay) change = pay - n;

    if(change>=0) break;
  }

  printf("%d\n", change);

  return 0;
}

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

struct card{
	char	s;
	int	v;
	int	i;
};
typedef struct card CARD;


int swap( CARD *c1, CARD *c2 ){

	CARD t;

	t.s = c1->s;
	t.v = c1->v;
	t.i = c1->i;

	c1->s = c2->s;
	c1->v = c2->v;
	c1->i = c2->i;

	c2->s = t.s;
	c2->v = t.v;
	c2->i = t.i;

	return 0;
}

int main(){

	CARD c1[37], c2[37], t_card;
	int n, i, j;
	int stable;
	int mini;
	char t;


	//input
	scanf( "%d\n", &n );

	for( i=0; i<n; i++ ){
		scanf( "%c%d", &c1[i].s, &c1[i].v );
		c1[i].i = i;
		memcpy( &c2[i], &c1[i], sizeof(CARD) );
		scanf( "%c", &t );
	}

	
	//bubble sort
	for( i=0; i<n; i++ ){
	for( j=(n-1); j>i; j-- ){

		if( c1[j].v < c1[j-1].v )
			swap( &c1[j], &c1[j-1] );

	}}


	//output
	for( i=0; i<n; i++ )
		printf( "%c%d%c", c1[i].s, c1[i].v, i!=(n-1)?' ':'\n' );

	//stable?
	stable=0;
	for( i=1; i<n; i++ ){
		if( c1[i-1].v == c1[i].v ){
			if( c1[i-1].i > c1[i].i ){
				stable++;
				break;
			} 
		}
	}
	if(stable) printf( "Not stable\n" );
	else printf( "Stable\n" );



	//selection sort
	for( i=0; i<n; i++ ){
		mini=i;
		for( j=i; j<n; j++ ){
			if( c2[j].v < c2[mini].v ) 
				mini = j;
		}
		
		swap( &c2[i], &c2[mini] );
	}


	//output
	for( i=0; i<n; i++ )
		printf( "%c%d%c", c2[i].s, c2[i].v, i!=(n-1)?' ':'\n' );

	//stable?
	stable=0;
	for( i=1; i<n; i++ ){
		if( c2[i-1].v == c2[i].v ){
			if( c2[i-1].i > c2[i].i ){
				stable++;
				break;
			} 
		}
	}
	if(stable) printf( "Not stable\n" );
	else printf( "Stable\n" );



	return 0;

}

Measured memory_bytes: 608
def resolve():
  N = int(input())
  N_to_str = ""
  alphabet_list = "zabcdefghijklmnopqrstuvwxyz"
  # N -= 1
  while N > 0:
    N-=1
    N_to_str=alphabet_list[N%26+1]+N_to_str
    # if N==26:
    #   break
    N = (N-N%26)//26
  print(N_to_str)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 61880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            int n = Integer.parseInt(line);
            if (n == -1) {
                break;
            }
            double x = 1.0;
            double y = 0.0;
            for (int i = 0; i < n - 1; i++) {
                double d = Math.hypot(x, y);
                double dx = -y / d;
                double dy = x / d;
                x += dx;
                y += dy;
            }
            out.println(x);
            out.println(y);
        }
    }
}

Measured memory_bytes: 9744
//fr u gotta do it
//get up and solve
//CMON
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	long double a, b, c, sa, sb;
	cin>>a>>b>>c;
	if(a+b+2*sqrt(a*b)<c){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/
vi move1 = {0,0,1,-1};
vi move2 = {1,-1,0,0};

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int m; cin >> m;
    vs sss(m);
    rep(i,m) cin >> sss[i];
    rep(l, m) {
        string s = sss[l];
        set<string> sset;
        int cnt = 0;
        for(int i = 0; i < s.size()-1; ++i) {
            string t1, t2, tr1, tr2;
            for(int j = 0; j <= i; ++j) tr1.push_back(s[j]);
            for(int k = i+1; k < s.size(); ++k) tr2.push_back(s[k]);
            t1 =tr1;
            t2 = tr2;
            reverse(all(tr1));
            reverse(all(tr2));
            sset.insert(t1+t2);
            sset.insert(t2+t1);
            sset.insert(tr1+t2);
            sset.insert(t2+tr1);
            sset.insert(tr2+t1);
            sset.insert(t1+tr2);
            sset.insert(tr1+tr2);
            sset.insert(tr2+tr1);
        }
        cout << sset.size() << endl;
    }
}


Measured memory_bytes: 3300
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll a, b; cin >> a >> b;
	if (a*b % 2 == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

int main() {
  int n;
  cin >> n;
  int ac = 0, wa= 0, tle= 0, re=0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if(s == "AC") {
      ac++;
    } else if(s =="WA") {
      wa++;
    } else if(s == "TLE") {
      tle++;
    } 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: 3624
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, std::vector<long long> A){
    double res = 0;
    for(int i = 0; i < N; ++i) {
        res += 1.0 / A[i];
    }
    printf("%.10f\n", 1.0 / res);
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}

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

int main() 
{
	std::string s;
	std::cin >> s;
	int k = 0;

	for (int i = 0; i < s.size() ; i++) {
		k = k + s[i] - '0';
	}
	
	int j = stoi(s);
	if (j % k == 0) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

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

int main(void) {
    string s;
    cin >> s;
    int a, b;
    a = b = 0;
    int size = s.size();
    for (int i = 0; i < size; i++) {
        if ((s[i] - '0') == (i & 1)) {
            ++a;
        } else {
            ++b;
        }
    }
    cout << min(a, b) << endl;
}


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

void bfs(vector<vector<int> > &g, queue<int> &q, vector<int> &michi, int x) {
    for (int y: g.at(x)) {
        if (!michi.at(y-1)) {
            q.push(y);
            michi.at(y-1) = x;
        }
    }
    if (q.empty()) {
        return;
    }
    int z = q.front();
    q.pop();
    bfs(g, q, michi, z);
    return;
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > g(n+1);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }
    vector<int> michi(n, 0);
    michi.at(0) = -1;
    queue<int> q;
    bfs(g, q, michi, 1);
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << michi.at(i) << endl;
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    ll hp, atk, def, spd;
    cin >> hp >> atk >> def >> spd;
    vector<ll> h, a, d, s;
    for (int i = 0; i < n; i++)
    {
        ll htmp, atmp, dtmp, stmp;
        cin >> htmp >> atmp >> dtmp >> stmp;
        if (dtmp >= atk && atmp > def)
        {
            cout << -1 << endl;
            return 0;
        }
        if (atmp <= def)
            continue;
        atmp -= def;
        h.push_back(htmp);
        a.push_back(atmp);
        d.push_back(dtmp);
        s.push_back(stmp);
    }
    n = h.size();
    vector<ll> turn(n), dmg(n);
    for (int i = 0; i < n; i++)
    {
        dmg[i] = a[i];
        ll tmp = atk - d[i];
        turn[i] = (h[i] - 1) / tmp + 1;
    }
    vector<int> idx(n);
    for (int i = 0; i < n; i++)
        idx[i] = i;
    sort(idx.begin(), idx.end(), [&](int i, int j) { return turn[i] * dmg[j] < turn[j] * dmg[i]; });
    ll ret = 0, cnt = 0;
    for (auto i : idx)
    {
        hp -= cnt * a[i];
        ret += cnt * a[i];
        if (hp <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        cnt += turn[i];
        if (s[i] > spd)
        {
            hp -= turn[i] * a[i];
            ret += turn[i] * a[i];
        }
        else
        {
            turn[i]--;
            hp -= turn[i] * a[i];
            ret += turn[i] * a[i];
        }
        if (hp <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ret << endl;
}



Measured memory_bytes: 4664
class UnionFind
  attr_accessor :parent

  def initialize(size)
      @parent = Array.new(size, -1)
  end

  def root(x)
      if @parent[x] < 0
          x
      else
          @parent[x] = root(@parent[x])
      end
  end

  def same_parent?(x, y)
      root(x) == root(y)
  end

  def merge(x, y)
      x_root = root(x)
      y_root = root(y)

      return false if x_root == y_root

      if @parent[x_root] > @parent[y_root]
          x_root, y_root = y_root, x_root
      end

      @parent[x_root] += @parent[y_root]
      @parent[y_root] = x_root

      return true
  end

  def size(x)
      return -@parent[root(x)]
  end
end

N, M = gets.split.map(&:to_i)
uf = UnionFind.new(N + 1)

m = 0
M.times do |i|
  pair = gets.split.map(&:to_i)
  t = uf.merge(pair[0],pair[1])
end

N.times do |i|
  a = uf.size(i + 1)
  m = a if m < a
end

puts m


Measured memory_bytes: 15892
x, n = gets.split.map(&:to_i)
p = gets.split.map{|i| [i.to_i, true]}.to_h

if n == 0
  p x
  exit
end

(n+1).times do |i|
  if p[x - i].nil?
    p x - i
    exit
  elsif p[x + i].nil?
    p x + i
    exit
  end
end

Measured memory_bytes: 14288
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007 
#define rep(i,j,l) for(int i=j;i<=l;i++)
#define dec(i,j,l) for(int i=j;i>=l;i--)
#define inp(a,n) rep(i,0,n-1)cin>>a[i] 
#define out(a,n) rep(i,0,n-1)cin>>a[i]
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
/* int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


int main()
{  ios_base::sync_with_stdio(0); 
   cin.tie(NULL);
   ll n,W;
   cin>>n>>W;
    ll w[n+1],v[n+1];
    rep(i,1,n) 
    cin>>w[i]>>v[i]; 
    ll dp[n+1][W+1];
    /*       W......
  w[i],v[i] . 
            .
            .
            .
            .   */  
            
     rep(i,0,n)
      dp[i][0]=0;  
     rep(i,0,W)
      dp[0][i]=0; 
     
     rep(i,1,n)
      {rep(j,1,W)
       {
          dp[i][j] = (j>=w[i]) ? max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]) : dp[i-1][j];   
       
           //cout<<dp[i][j]<<' ';
       } //cout<<"\n";
      } 
       cout<<dp[n][W];
   return 0;            
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a==b){
      for(int i=0;i<a;i++){
          cout << a;
      }
  }else if(a>b){
      for(int i=0;i<a;i++){
          cout << b;
      }
  }else{
      for(int i=0;i<b;i++){
          cout << a;
      }
  }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        Console.WriteLine(Math.Min(cin.nextInt(), cin.nextInt()) + Math.Min(cin.nextInt(), cin.nextInt()));
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13140