akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
    int K;
    int X;
    cin >> K >> X;
    FOR(i,X-K+1,X+K) cout << i << " ";

 }

Measured memory_bytes: 256
import sys
A,B,C = [str(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
print(A[0].upper() + B[0].upper() + C[0].upper())


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	string result;
	string s = to_string(min(a, b));
	for (int i = 0; i < max(a, b); i++) {
		result.append(s);
	}
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import"fmt"

func main(){

var nin int

fmt.Scanln(&nin)

nin_ := nin

h := nin_ / (60 * 60)
nin_ %= (60 * 60)

m := nin_ / 60
nin_ %= 60

s := nin_

fmt.Printf("%d:%d:%d\n", h, m, s)

}


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

using namespace std;

int main()
{
    int W,H,x,y;
    cin >> W >> H >> x >> y;

    bool TF = false;

    if ((double)x==(double)W/2.0 &&
        (double)y==(double)H/2.0)
    {
        TF = true;
    } 

    double men = (double)W * (double)H / 2.0;

    printf("%11.9f ",men);
    if(TF) cout << '1' << endl;
    else cout << '0' << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    vector<pii> v(n);
    rep(i,n){
        int a;
        cin>>a;
        v[i] = pii(a,i+1);
    }
    
    vector<int> r;
    sort(all(v));
    reverse(all(v));
    
    rep(i,v.size()){
        rep(j,v[i].first){
            r.pb(v[i].second);
        }
    }
    
    
    int ind = 0;
    vector<vector<int>> fir(h,vector<int>(w,-1));
    rep(i,h){
        if(i%2==0){
            rep(j,w){
                fir[i][j] = r[ind++];
            }
        }else{
            for(int j=w-1;j>=0;j--){
                fir[i][j] = r[ind++];
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(j)cout<<" ";
            cout<<fir[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin >> n >> k;

    vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));

    vector<ll> a(n+1);

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

    dp[0][0] = 1;

    for(int i = 1; i < n+1; i++){
        vector<ll> sum(k+1,0);
        sum[0] = dp[i-1][0];
        for(int j = 1; j < k+1; j++){
            sum[j] = sum[j-1] + dp[i-1][j];
        }

        for(int j = 0; j < k+1; j++){
            dp[i][j] = (sum[j] - ((j-a[i]-1 >= 0)? sum[j-a[i]-1] : 0 ))%MOD;
        }
    }

    cout << dp[n][k]%MOD << endl;
    
    return 0;
}

Measured memory_bytes: 80256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var mat = MakeArray(M, _ => G.Skip(1).Aggregate(0ul, (s, i) => s | One(i - 1)));
		var p = G;
		var cnt = 0;
		for (var s = 0uL; s <= All(N); s++)
		{
			var flag = true;
			for (var i = 0; i < M; i++) flag &= BitCount(s & mat[i]) % 2 == p[i];
			if (flag) cnt++;
		}
		WriteLine(cnt);
	}
	public static int BitCount(ulong n)
	{
		n = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555);
		n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333);
		n = (n & 0x0f0f0f0f0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f0f0f0f0f);
		n = (n & 0x00ff00ff00ff00ff) + ((n >> 8) & 0x00ff00ff00ff00ff);
		n = (n & 0x0000ffff0000ffff) + ((n >> 16) & 0x0000ffff0000ffff);
		return (int)((n & 0x00000000ffffffff) + ((n >> 32) & 0x00000000ffffffff));
	}
}
static class Func { }


Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define N 9

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

bool is_set(int a, int b, int c) {
  if (a == b && b == c) return true;
  int array[] = {a, b, c};
  qsort(array, 3, sizeof(int), cmpfunc);
  if (array[2] - array[1] == 1 && array[1] - array[0] == 1) return true;
  return false;
}

void array_remove3(int old_array[], int new_array[], int old_length, int a, int b, int c) {
  int i, new_index = 0;
  bool a_set = false, b_set = false, c_set = false;

  for (i = 0; i < old_length; i++) {
    if (!a_set && old_array[i] == a) {
      a_set = true;
      continue;
    }
    if (!b_set && old_array[i] == b) {
      b_set = true;
      continue;
    }
    if (!c_set && old_array[i] == c) {
      c_set = true;
      continue;
    }
    new_array[new_index] = old_array[i];
    new_index++;
  }
 
}

bool solve_backtrack(int array[], int array_length, bool reset) {
  int i, j, k, l;
  static bool solved = false;
  if (reset) solved = false;
  
  if (array_length == 0) {
    solved = true;
    return true;
  }
  
  for (i = 0; i < array_length; i++) {
    for (j = i+1; j < array_length; j++) {
      for (k = j+1; k < array_length; k++) {
	
	if (is_set(array[i], array[j], array[k])) {
	  int new_length = array_length - 3;
	  if (new_length == 0) {
	    solved = true;
	    return true;
	  }
	  int new_array[new_length];
	  array_remove3(array, new_array, array_length, array[i], array[j], array[k]);
	  
	  solve_backtrack(new_array, new_length, false);
	  
	}
      }
    }
  }
  return solved;
}
	      
int main(int argc, char *argv[])
{

  int entries;
  int i, j;

  fscanf(stdin, "%d", &entries);
 

  for (i = 0; i < entries; i++) {
    int array[N], red[N], blue[N], green[N];
    int red_n = 0, blue_n = 0, green_n = 0;
    for (j = 0; j < N; j++) {
      fscanf(stdin, "%d", &array[j]);
    }
    char color;
    for (j = 0; j < N; j++) {
      fscanf(stdin, " %c", &color);
      if (color == 'R') {
	red[red_n] = array[j];
	red_n++;
      } else if (color == 'B') {
	blue[blue_n] = array[j];
	blue_n++;
      } else if (color == 'G') {
	green[green_n] = array[j];
	green_n++;
      }
    }
    
    if (red_n % 3 != 0 || blue_n % 3 != 0 || green_n % 3 != 0) {
      printf("0\n");
    } else if (solve_backtrack(red, red_n, true) && solve_backtrack(blue, blue_n, true) && solve_backtrack(green, green_n, true)) {
      printf("1\n");
    } else {
      printf("0\n");
    }
  }
  return 0;
}

Measured memory_bytes: 588
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if strings.Count(a+b+c, "5") != 2 || strings.Count(a+b+c, "7") != 1 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec) for(int never = 0; never < vec.size(); never++){ cin>>vec[never];}
#define printVec(vec) for(int never = 0; never < vec.size(); never++){ cout<<vec[never]<<" ";} cout<<endl;
#define S second
#define F first
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;



void solve() {
    // cout << "test" << endl;
    int a,b;
    cin >> a >> b;
    if (a > b) {
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }
    
}

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

    int t;
    t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define int long long 
#define MOD 1000000007
using namespace std;

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

	for (int i=n;;i++){
		if (i==2){
			cout<<i<<'\n';
			break;
		}
		bool x=0;
		for (int y=2;y<(int)(sqrt((double)i)+1);y++)
				if (i%y==0){
					x=1;
					break;
				}
		if (!x)
			{
				cout<<i<<'\n';
				break;
			}
	}

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); in.nextLine();

		boolean hasYellow = false;
		String s = "";
		for ( int i = 0; i < n; i++ ) {
			s = in.next();
			if ( s.equals("Y") ) {
				hasYellow = true;
				break;
			}
		}
		
		if ( hasYellow )
			System.out.println("Four");
		else
			System.out.println("Three");
	}
}

Measured memory_bytes: 21844
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		List<Integer> positions = new ArrayList<>();
		for (int i = 0; i < 5; ++i) {
			positions.add(Integer.parseInt(in.readLine()));
		}
		int K = Integer.parseInt(in.readLine());
		in.close();

		int count = 0;
		for (int i = 0; i < positions.size(); ++i) {
			for (int j = 0; j < positions.size(); ++j) {
				if (positions.get(j) - positions.get(i) > K) {
					++count;
				}
			}
		}
		if(count > 0) {
			System.out.println(":(");
		}else {
			System.out.println("Yay!");
		}

	}

}


Measured memory_bytes: 21204
n,x,y = map(int,input().split())

x -= 1
y -= 1
cnt = [0]*n

for i in range(n):
  for j in range(i+1,n):
    dis = min(j-i,abs(x-i)+1+abs(j-y))
    cnt[dis] += 1
for i in range(1,n):
  print(cnt[i])

Measured memory_bytes: 9228
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define REP(i,n) for (int i = 1; i <= n; i++)
// mp::cpp_int



int solve( ){
  
int n,m;
cin>>n>>m;
map<ll,ll> s;
rep(i,0,n)
{

  int k; cin>>k;
  rep(i,0,k)
  {
    int x;
    cin>>x;
    s[x]++;
  }
}
int count=0;
 for(auto& x:s)if(x.SS==n)count++;
  cout<<count;


return 0;
}
 

int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
 
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
n = int(input())
arr  = input().split(" ")
s = int(arr[-1])
mod = 10**9 +7
ans  = 0

def moduloMultiplication(a, b, mod): 
    res = 0; 
    a = a % mod; 
    while (b): 
        if (b & 1): 
            res = (res + a) % mod; 
        a = (2 * a) % mod; 
  
        b >>= 1;
      
    return res; 

for i in range(len(arr)-2, -1, -1):
    t = int(arr[i])
    ans = (ans+  moduloMultiplication(s,t,mod))%mod
    s = (s+t)
print( ans)

Measured memory_bytes: 24964
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{
  int p,l,r;
};

struct Node T[MAX];
int n,h,D[MAX];

int getDepth(int u){
  int d;

  for(d = 0;T[u].p != NIL;d++){
    u = T[u].p;
  }

  return d;
}

void print(int u){
  int i,c;

  printf("node %d: ",u);
  printf("parent = %d, depth = %d, ",T[u].p,D[u]);

  if(T[u].p == NIL){
    printf("root, ");
  }
  else if(T[u].l == NIL){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }

  printf("[");

  for(i = 0, c = T[u].l;c != NIL;i++, c = T[c].r){
    if(i > 0) printf(", ");
    printf("%d",c);
  }

  printf("]\n");
}

int main(){
  int i,j,d,v,c,l;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for(i = 0;i < n;i++){
    scanf("%d %d",&v,&d);
    for(j = 0;j < d;j++){
      scanf("%d",&c);
      if(j == 0){
	T[v].l = c;
      }
      else{
	T[l].r = c;
      }
      l = c;
      T[c].p = v;
    }
  }

  h = 0;

  for(i = 0;i < n;i++){
    D[i] = getDepth(i);
    if(D[i] > h){
      h = D[i];
    }
  }

  for(i = 0;i < n;i++){
    print(i);
  }

  return 0;
}



Measured memory_bytes: 3316
//  Created by conan1024hao on 2019/11/23.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int x,y;
    cin>>x>>y;
    int ans=0;
    if(x==1)
        ans+=300000;
    else if(x==2)
        ans+=200000;
    else if(x==3)
        ans+=100000;
    if(y==1)
        ans+=300000;
    else if(y==2)
        ans+=200000;
    else if(y==3)
        ans+=100000;
    if(x==1&&y==1)
        ans+=400000;
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(){
  int N, X; cin >> N >> X;
  int m[105];
  int count; count = N; //少なくとも1つずつは作成する
  int min; min = 100000;
  for (int i=0; i<N; i++){
    cin >> m[i];
  }
  
  //全種類のドーナツを1つずつ作る
  for (int i=0; i<N; i++){
    X = X - m[i];
    if (m[i] < min){
      min = m[i];
    }
  }
  
  //最も少ない量の粉でつくれるドーナツを，作れるだけ作る
  count = count + (X/min);
  
  cout << count << endl;
}

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<int> L(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> L[i];
    }

    int ans = 0;
    for (int i = 0; i < N - 2; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            for (int k = j + 1; k < N; ++k) {
                if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
                    if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[k] + L[j] > L[i]) {
                        ++ans;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <algorithm>

#include <vector>
using std::vector;
#include <map>
using std::map;
#include <unordered_map>
using std::unordered_map;
#include <set>
using std::set;
#include <unordered_set>
using std::unordered_set;
#include <deque>
using std::deque;
#include <queue>
using std::priority_queue;

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


inline void print(const vector<int> & V) {
    for (auto v:V) printf("%d ",v);
    printf("\n");
}

int main() {

    int A,P;
    cin >> A >> P;
    cout << (3*A + P)/2 << endl;

	return 0;
}




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

int main()
{  
    //   #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    fast
  
 string s;
 cin>>s;
 int tot=0;
 for(auto x:s)tot+=x-'0';
  if(tot%9==0)cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n; cin >> n;

  int sum = 0;
  int k = 0;
  for(int i=1; sum <= n; i++) {
    sum += i;
    if (sum == n) {
      k = i;
      break;
    }
  }

  if (k == 0) {
    cout << "No" << endl;
    return 0;
  } else {
    cout << "Yes" << endl;
    cout << k+1 << endl;
  }

  vector<int> vec[k+1];

  int now = 1;
  for(int i=0; i<k; i++) {
    for(int j=i+1; j<k+1; j++) {
      vec[i].push_back(now);
      vec[j].push_back(now);
      now++;
    }
  }

  for(int i=0; i<k+1; i++) {
    cout << k << ' ';
    for(auto e : vec[i]) {
      cout << e << ' ';
    }
    cout << '\n';
  }
}

Measured memory_bytes: 2304
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
INF = 10**9

#竹の合成を全パターン、例えば1番の竹をA,B,C,使わないのどれかに定める。
#なので全パターンは4^8=65536で計算できる。

def dfs(cur,a,b,c):
#cursorを使い、注目してる竹をどこに追加するか選択。
#このやり方だと竹を一本も選ばない可能性があるのでその場合はINFを入れる。
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
#合成が完了したら伸ばすor縮むは絶対値の差を取ることで計算可能
    ret0= dfs(cur+1,a,b,c)#なにも合成しない
    ret1= dfs(cur+1,a+l[cur],b,c)+10#Aに合成
    ret2= dfs(cur+1,a,b+l[cur],c)+10#Bに合成
    ret3 =dfs(cur+1,a,b,c+l[cur])+10#Cに合成
    
    return min (ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(),a.end());
    int A,B;
    if(N%2==0)A = B = 0;
    else A = a[0];
    for(int i = N-1; 0 < i; i -=2){
        A += a[i];
        B += a[i-1];
    }
    cout << A - B << endl;
}


Measured memory_bytes: 256
# ABC 103: B – String Rotation
s = input()
t = input()

s_dash = s[-1] + s[:-1]
isExact = 'No'

if s == t:
    isExact = 'Yes'
else:
    while s != s_dash:
        if s_dash == t:
            isExact = 'Yes'
            break
        s_dash = s_dash[-1] + s_dash[:-1]

print(isExact)

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

void solve()
{
    int n,k,ans=0;cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++) ans+=a[i];
    cout<<ans;
}

int main(void){
    int t;//cin>>t;
    t=1;
    while(t--)
    solve();
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int sx,sy,tx,ty;
	cin >> sx >> sy >>tx >>ty;
	FOR(i,tx-sx)
		cout <<'R';
	FOR(i,ty-sy)
		cout <<'U';
	FOR(i,tx-sx)
		cout << 'L';
	FOR(i,ty-sy)
		cout <<'D';
	cout << 'L';
	FOR(i,ty-sy+1)	
		cout << 'U';
	FOR(i,tx-sx+1)
		cout << 'R';
	cout <<'D' <<'R';
	FOR(i,ty-sy+1)
		cout <<'D';
	FOR(i,tx-sx+1)
		cout <<'L';
	cout <<'U';
	return 0;
}

Measured memory_bytes: 256
def how_many_times_divisible(n):
    ans = ~-(n & -n).bit_length()
    res = 0
    while n % 2 == 0:
        n /= 2
        res += 1
    assert res == ans
    return res

N, *A = map(int, open(0).read().split())
ans = min(map(how_many_times_divisible, A))
print(ans)

Measured memory_bytes: 3060
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

const long long mod=1e9+7;

int main(){

    int n,m;
    cin>>n>>m;

    vector<long long> dp(n+1,0);
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        dp[a]=-1;
    }

    dp[0]=1;
    for(int i=0;i<n;i++){
        if(dp[i]==-1) continue;
        if(i+1 <= n && dp[i+1]!=-1) dp[i+1]=(dp[i+1]+dp[i])%mod;
        if(i+2 <= n && dp[i+2]!=-1) dp[i+2]=(dp[i+2]+dp[i])%mod;
    }

    cout<<dp[n]<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<bool> vb;
#define setp ios_base::sync_with_stdio(0); cin.tie(0);
#define usaco(a,b) ofstream cout(a); ifstream cin(b);
#define FOR(i, a, b) for (int i=a; i<(b); i++) 
#define F0R(i, a) for (int i=0; i<(a); i++) 
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--) 
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define sz(x) (int)(x).size() 
#define mp make_pair 
#define pb push_back 
#define fs first 
#define sc second 
#define lb lower_bound 
#define ub upper_bound 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const ll MOD = 1000000007;
const ll INF = 1e18;
const int MAX = 1e6;

ll mod(ll a, ll b)
{ return (a%b+b)%b; }

int main() {
	ll A,B,C,M;
	cin>>A>>B>>C;
	ll mn = mod(A,C);
	M = abs((A-mn)/C);
	ll ans;
	if(B>=M){
		if((B-M)&1)ans = min(abs(mn+C),abs(mn-C));
		else ans = mn;
	}else{
		ans = min(abs(A-(B*C)),abs(A+(B*C)));
	}
	cout<<ans<<endl;

 	return 0;
}

Measured memory_bytes: 3500
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func solve() {
	n := getInt()
	as := getSortedIS(n)
	bs := getSortedIS(n)
	cs := getSortedIS(n)

	ans := 0
	for _, b := range bs {
		cntA := sort.Search(n, func(i int) bool { return as[i] >= b })
		cntC := n - sort.Search(n, func(i int) bool { return cs[i] > b })

		ans += cntA * cntC
	}

	fmt.Fprintln(wr, ans)
}

func getSortedIS(n int) []int {
	is := getIntSlice(n)
	sort.Ints(is)
	return is
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 6144
a,b,c=map(int,input().split())
d=[str(i+1) for i in range(a)]
#print(d)
g=[]
for i in d:
	e=list(i)
	#print(e)
	f=list(map(int,list(e)))
	#print(sum(f))
	g.append(sum(f))
#print(g)
h=0
for i in range(len(g)):
	if b<=g[i]<=c:
		h=h+int(d[i])
print(h)


Measured memory_bytes: 3828
#include<iostream>
#include<string>


using namespace std;

int main(void){
	int H,W;
	char S[52][52];
	cin >> H >> W;
	for(int i=0;i<H;++i){
		cin >> S[i];
	}
	for(int i=0;i<H;++i){
		for(int j=0;j<H;++j){
			if('#' == S[i][j]){
				if('#' == S[i][j-1] || '#' == S[i][j+1] || '#' ==S[i-1][j] || '#' ==S[i+1][j]){
					continue;
				}else{
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	
	cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int H, W;
	cin >> H >> W;

	for (int i = 0; i < H; i++) {
		string a;
		cin >> a;
		cout << a << endl;
		cout << a << endl;
	}

}


Measured memory_bytes: 256
n=int(input())
p=[]
t=n
for m in range(2,int(n**0.5)+1):
    while t%m==0:
        p.append(m)
        t//=m
if t > 1: p.append(t)
from itertools import groupby
g=groupby(p)
ans=n
for p,c in g:
    ans //= p
    ans *= p-1
print(ans)


Measured memory_bytes: 5684
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
using namespace std;

int main() {
    int n, x;
    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        auto c = 0;
        for(auto i = 1; i <= n; ++i) {
            for(auto j = i+1; j <= n; ++j) {
                for(auto k = j+1; k <= n; ++k) {
                    if (i + j +k == x) ++c;
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include<iostream>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        if (i % 3 == 0){
            cout << " " << i;
        }
        else{
            for (int x = i; x != 0; x /= 10){
                if (x % 10 == 3){
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
 
    return 0;
}

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


int main()
{
	char n[10];
	long s=0;
	long nd=0,m=1;
	int i;
	cin >> n;
	for (i = 0; '0' <= n[i] && n[i] <= '9'; i++) {
		s += n[i] - '0';
	}
	while (i >= 0) {
		if ('0' <= n[i] && n[i] <= '9') {
			nd += (n[i] - '0')*m;
			m *= 10;
		}
		
		i--;
	}
	if ((nd%s) == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
ll  a[500000];
ll sum=0;
int main()
{
    int n;
    cin>>n;
    cin>>sum;
    a[0]=sum;
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        sum=sum^a[i];
    }
    for(int i=0;i<n;i++)
    {
        int k=sum^a[i];
        cout<<k<<" ";
    }
    return 0;
}


Measured memory_bytes: 5140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct po{int to,cost;};
int c[1001];
bool visited[1001];
vector <po> v[1001];

int saiki(int ima,int mincost,int flg){
  if(visited[ima]==1) return 0;
  if(flg == 1&&c[ima] !=0) return mincost;
  visited[ima]=1;
  int sum=0;
  for(int i=0;i<v[ima].size();i++)
    if(c[ima]==0)sum+= saiki(v[ima][i].to,v[ima][i].cost,1);
    else sum+=saiki(v[ima][i].to,v[ima][i].cost,0);
  return min(sum,mincost);
}


int main() {
  int n;
  cin >> n;
  for(int i=1;i<n;i++)cin >> c[i];
  for(int i=0;i<n-1;i++){
    int a,b,d;
    cin >> a >> b>> d;
    v[a].push_back(po{b,d});
    v[b].push_back(po{a,d});
  }
  cout << saiki(0,1000000000,0)<<endl;;
  return 0;
}

Measured memory_bytes: 1276
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

func Find(R *[]int, u int) int {
  if (*R)[u] == u { return u }
  (*R)[u] = Find(R, (*R)[u])
  return (*R)[u]
}
func Union(R *[]int, u, v int) {
  ru, rv := Find(R, u), Find(R, v)
  if ru < rv {
    (*R)[rv] = ru
  } else if rv < ru {
    (*R)[ru] = rv
  }
}

func Solve() {
  var N, M, K int
  NextInt(&N, &M, &K)
  G := make([]int, N)
  R := make([]int, N)
  for i := range R {
    R[i] = i
  }
  var A, B, C, D int
  for i := 0; i < M; i++ {
    NextInt(&A, &B)
    A, B = A - 1, B - 1
    G[A]++
    G[B]++
    Union(&R, A, B)
  }
  U := make([]int, N)
  for i := range R {
    U[Find(&R, i)]++
  }
  for i := 0; i < K; i++ {
    NextInt(&C, &D)
    C, D = C - 1, D - 1
    if R[C] != R[D] { continue }
    G[C]++
    G[D]++
  }
  F := make([]int, N)
  for i, g := range G {
    F[i] = U[R[i]] - g - 1
  }
  WriteIntVec(F)
}

func main() {
  Solve()
  Output()
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = std::numeric_limits<double>::infinity() ;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);


  ll N;
  cin >> N;
  vector<ll> x(N);
  vector<ll> l(N);
  REP(i, N){
    cin >> x[i];
    cin >> l[i];
  }

  vector<pair<int, int> > min_max(N);
  REP(i, N){
    ll zero = 0;
    ll val = max(zero, x[i] - l[i]);
    min_max[i] = make_pair(x[i] + l[i], val);
  }

  sort(min_max.begin(), min_max.end());

  ll ans = N;
  ll tmp_max = min_max[0].first;
  FOR(i, 1, N){
    ll con_min = min_max[i].second;
    if (con_min < tmp_max){
      ans--;
    }
    else tmp_max = min_max[i].first;
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int v2(int n){
    int c{};
    while(n%2==0) n/=2,++c;
    return c;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    string s;
    in>>n>>s;
    bool f=true;
    vector<int> a;
    a.reserve(n);
    for(auto i:s){
        a.emplace_back(i-'1');
        if(i=='2') f=false;
    }
    if(f) for(auto&i:a) i/=2;
    else for(auto&i:a) i%=2;
    int c{};
    bool ans=a[0];
    Fr(i,n-1){
        c+=v2(n-i);
        c-=v2(i);
        if((!c)&&a[i]) ans=!ans;
    }
    cout<<(1+f)*ans<<endl;
}


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

#define vi vector<int>

int main() {
	int n; cin >> n;
	vi dp(3);
	for(int d = 0; d<n; d++){
		vi ndp(3, 0);
		vi a(3);
		for(int i=0; i<3; i++) cin>>a[i];

		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(i != j)
					ndp[j] = max(ndp[j], dp[i]+a[j]);
			}
		}

		dp = ndp;
	}

	cout << max({dp[0], dp[1], dp[2]});

return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# DSL_3_A: The Smallest Window I
# binary search


def find(xs, size, s):
    sum_ = sum(xs[:size])
    if s <= sum_:
        return True
    for i in range(len(xs)-size):
        sum_ -= xs[i]
        sum_ += xs[i+size]
        if s <= sum_:
            return True
    return False


def run():
    n, s = [int(i) for i in input().split()]
    li = [int(i) for i in input().split()]

    if s > sum(li):
        print(0)
        return
    elif s < max(li):
        print(1)
        return

    i, j = 0, n
    while i+1 < j:
        # assert(not find(li, i, s))
        # assert(find(li, j, s))
        mid = (i + j) // 2
        # print(i, j, mid)
        if find(li, mid, s):
            j = mid
        else:
            i = mid

    print(j)


if __name__ == '__main__':
    run()



Measured memory_bytes: 16364
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,b,d,e,A,B,N;
  cin>>A>>B;
  N=0;
  for(int i=A;i<B+1;i++){
    a=i%10;
    b=(i/10)%10;
    d=(i/1000)%10;
    e=(i/10000)%10;
    if(a==e&&b==d){
    N++;
    } 
  }
  cout<<N<<endl;
}


Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static void Yes() { print("Yes"); }
        private static void No() { print("No"); }
        private static void print(object obj) { Console.WriteLine(obj); }

        static void Main(string[] args)
        {
            var a = ReadInts();
            
            if(a[0] + a[1] >= a[2])
            {
                Yes();
            }else
            {
                No();
            }

        }
    }
}

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

char mp[60][60];
int f[4][2]= {1,0,-1,0,0,-1,0,1};
int vis[60][60];
int n,m;

struct node
{
    int x,y;
    int num;
};
queue<node>q;


int inin()
{
    node now,naxt;
    while(q.size())
    {
        now=q.front();
        q.pop();
        if(now.x==n-1&&now.y==m-1)
            return now.num;

        for(int i=0; i<4; i++)
        {
            int xx=now.x+f[i][0];
            int yy=now.y+f[i][1];

            if(xx<0||yy<0||xx>=n||yy>=m)
                continue;
            if(vis[xx][yy])
                continue;
            if(mp[xx][yy]=='#')
                continue;
            vis[xx][yy]=1;
            naxt.x=xx;
            naxt.y=yy;
            naxt.num=now.num+1;
            q.push(naxt);
        }
    }
    return -1;
}

int main()
{
    memset(vis,0,sizeof(vis));
    memset(mp,'\0',sizeof(mp));
    scanf("%d %d ",&n,&m);
    for(int i=0; i<n; i++)
        scanf("%s",mp[i]);
    node now;
    now.x=0;
    now.y=0;
    now.num=1;
    vis[0][0]=1;
    q.push(now);
    int pow=inin();
    if(pow==-1)
        printf("%d\n",-1);
    else
    {
        int sum=0;
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                if(mp[i][j]=='.')
                    sum++;
        printf("%d\n",sum-pow);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s,t,m="mcxi";
  int n,a,b,c,i,j,k;cin>>n;
  for(i=0;i<n;i++){
    cin>>s>>t;
    a=b=0;
    for(j=0;j<s.size();j++)
      if('9'<s[j]){
	for(k=3,c=1;k>=0;k--,c*=10)if(s[j]==m[k])break;
	if(j==0||'9'<s[j-1])a+=c;
	else a+=c*(s[j-1]-'0');
      }
    for(j=0;j<t.size();j++)
      if('9'<t[j]){
	for(k=3,c=1;k>=0;k--,c*=10)if(t[j]==m[k])break;
	if(j==0||'9'<t[j-1])b+=c;
	else b+=c*(t[j-1]-'0');
      }
    for(j=0,c=a+b,a=1000;j<4;j++){
      b=c/a,c%=a,a/=10;
      if(b==1)cout<<m[j];
      else if(b>1)cout<<b<<m[j];
    }cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=4005;
const LL M=998244353;

int n,k;
LL C[N][N],cnt[N];

int main() {
	scanf("%d %d",&k,&n);
	// pw[0]=1;
	// for(int i=1;i<=n;i++) {
	// 	pw[i]=pw[i-1]*k%M;
	// }
	C[0][0]=1;
	for(int i=1;i<=k+n;i++) {
		C[i][0]=1;
		for(int j=1;j<=i;j++) {
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%M;
			//printf("C[%d][%d]=%lld\n",i,j,C[i][j]);
		}
	}
	cnt[0]=1;
	for(int i=1;i<=n;i++) {
		cnt[i]=C[k+i-1][k-1];
	}
	for(int i=2;i<=2*k;i++) {
	//for(int i=62;i<=62;i++) {
		LL ans=cnt[n];
		int t=0;
		if(i%2==1) {
			t=min(i/2,k-i/2);
		}
		else {
			t=min(i/2-1,k-i/2);
		}
		for(int j=1;j<=(i%2==0?t+1:t) && n>=j*2;j++) {
			LL x=(C[t][j]+(i%2==0?C[t][j-1]:0))%M*cnt[n-j*2]%M;
			//printf("i=%d j=%d x=%lld\n",i,j,x);
			ans=(ans+(j%2==0?1:-1)*x+M)%M;
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 123776
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = [0] + a
    B = [0] * (N + 1)

    for i in range(N, 0, -1):
        j = 2
        count = 0
        while i * j <= N:
            count += B[i * j]
            j += 1
        if (count + A[i]) % 2 == 0:
            pass
        else:
            B[i] = 1
    print(sum(B))

    for i in range(len(B)):
        if B[i]==1:
            print(i,end=" ")

if __name__ == "__main__":
    main()


Measured memory_bytes: 97520
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main() {
    ll x, n;
    vector<bool> vec(100, false);
    cin >> x >> n;
    --x;
    for (int i = 0; i < n; ++i) {
        unsigned int index;
        cin >> index;
        --index;
        vec[index] = true;
    }

    ll diff1 = 0;
    while (x - diff1 >= 0 && vec[x - diff1]){
        ++diff1;
    }

    ll diff2 = 0;
    while (x + diff2 < vec.size() && vec[x + diff2]){
        ++diff2;
    }

    cout << ((diff1 <= diff2) ? (x - diff1 + 1) : (x + diff2 + 1)) << endl;
}




Measured memory_bytes: 3188
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int l[200000];
int n;

int poss(int m) {
    vector<pair<int, int> > v;
    v.push_back({0, l[0]});
    for (int i = 1; i < n; i++) {
        if (l[i] > l[i-1]) {
            v.push_back({0, l[i] - l[i-1]});
        } else {
            int s = l[i-1];
            int c = 0;
            while (s > l[i]) {
                pair<int, int> p = v.back(); v.pop_back();
                c = p.first;
                s -= p.second;
            }
            if (s < l[i])
                v.push_back({c, l[i] - s});
            s = 0;
            while (v.size() && v.back().first == m-1) {
                s += v.back().second; v.pop_back();
            }
            if (v.empty())
                return 0;
            pair<int, int> p = v.back(); v.pop_back();
            if (p.second > 1)
                v.push_back({p.first, p.second - 1});
            v.push_back({p.first + 1, 1});
            if (s)
                v.push_back({0, s});
        }
    }
    return 1;
}

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

    n = gi();
    for (int i = 0; i < n; i++)
        l[i] = gi();

    int L = 1, R = n;
    while (L < R) {
        int M = (L+R)/2;
        if (poss(M))
            R = M;
        else
            L = M+1;
    }

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

    return 0;
}


Measured memory_bytes: 4692
#include <iostream>
using namespace std;
int main(){
  int n;cin >> n;
  int v[n], c[n];
  for(int i = 0; i < n; i++)cin >> v[i];
  for(int j = 0; j < n; j++)cin >> c[j];
  int sum = 0;
  for(int k = 0; k < n; k++){
    if(v[k]>c[k])sum += v[k]-c[k];
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

long long n;
vector <double> v;

int main () {
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	while(v.size() != 1) {
		double c;
		c = v.back();
		v.pop_back();
		double k;
		k = v.back();
		v.pop_back();
		v.push_back((c + k) / 2);
	}
	cout << v.back();
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	
	/* 0 ... Unvisited
	 * 1 ... visiting
	 * 2 ... visited
	 */
	public static boolean visit(final int n, boolean[][] adj, final int cur, Stack<Integer> order, int[] color){
		color[cur] = 1;
		for(int i = 0; i < n; i++){
			if(!adj[cur][i]){
				continue;
			}
			
			if(color[i] == 2){
				continue;
			}else if(color[i] == 1){
				return false;
			}else if(!visit(n, adj, i, order, color)){
				return false;
			}
		}
		
		order.push(cur);
		color[cur] = 2;
		return true;
	}
	
	public static boolean topological_sort(final int n, boolean[][] adj, Stack<Integer> stack){
		int[] color = new int[n];
		
		for(int i = 0; i < n; i++){
			if(color[i] == 0 && !visit(n, adj, i, stack, color)){
				stack.clear();
				return false;
			}
		}
		
		return true;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int m = sc.nextInt();
		final int n = sc.nextInt();
		
		boolean[][] relate = new boolean[m][m];
		
		for(int i = 0; i < n; i++){
			final int x = sc.nextInt() - 1;
			final int y = sc.nextInt() - 1;
			
			relate[x][y] = true;
		}
		
		Stack<Integer> stack = new Stack<Integer>();
		if(!topological_sort(m, relate, stack)){
			return;
		}
		
		while(!stack.empty()){
			System.out.println(stack.pop() + 1);
		}
		
	}
}

Measured memory_bytes: 18776