akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

struct edge {
    int from, to;
    ll cost;

    edge() :from(0), to(0), cost(0) {}
    edge(int f, int t, ll c) :from(f), to(t), cost(c) {}
};

int n, m;
ll p;
ll d[2505];
edge es[5005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n >> m >> p;
    std::fill(d, d + n, -inf);

    for (int i = 0; i < m; ++i) {
        int a, b;
        ll c;
        std::cin >> a >> b >> c;

        --a, --b;
        es[i] = { a,b,c - p };
    }

    d[0] = 0;
    for (int num = 0; num < n; ++num) {
        for (int i = 0; i < m; ++i) {
            auto e = es[i];

            if (d[e.from] != -inf && d[e.to] < d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }

    ll ans = d[n - 1];

    for (int num = 0; num < n; ++num) {
        for (int i = 0; i < m; ++i) {
            auto e = es[i];

            if (d[e.from] != -inf && d[e.to] < d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }

    if (ans == d[n - 1])
        std::cout << std::max(0LL, ans) << std::endl;
    else
        std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 384
D,N=map(int,input().split())

if N!=100:
  if D==0: 
    print(N)
  elif D==1: 
    print(100*N)
  else: 
    print(10000*N)
else:
  if D==0: 
    print(101)
  elif D==1: 
    print(10100)
  else: 
    print(1010000)


Measured memory_bytes: 2940
A,B,C,D=map(int,input().split())
i=0
while A>0 and C>0:
    C=C-B
    i+=1
    if A>0 and C>0:
        A=A-D
        i+=1
    else:
        break
if i%2!=0:
    print('Yes')
if i%2==0:
    print('No')

Measured memory_bytes: 9036
def solve():
    from sys import stdin
    from itertools import combinations
    from heapq import heappush, heappop
    f_i = stdin
    
    while True:
        n = int(f_i.readline())
        if n == 0:
            break
        
        bldgs = (tuple(map(int, f_i.readline().split())) for i in range(n))
        adj = [[] for i in range(n + 1)]
        for b1, b2 in combinations(bldgs, 2):
            n1, x1, y1 = b1
            n2, x2, y2 = b2
            d = (x1 - x2) ** 2 + (y1 - y2) ** 2
            if d <= 2500:
                d **= 0.5
                adj[n1].append((n2, d))
                adj[n2].append((n1, d))
        
        m = int(f_i.readline())
        for i in range(m):
            s, g = map(int, f_i.readline().split())
            pq = [[0, s]]
            isCalculated = [False] * (n + 1)
            distance = [250000] * (n + 1)
            distance[s] = 0
            
            while pq:
                path1 = heappop(pq)
                n1 = path1[-1]
                
                if n1 == g:
                    print(*path1[1:])
                    break
                
                if path1[0] > distance[n1]:
                    continue
                
                isCalculated[n1] = True
                
                for n2, d2 in adj[n1]:
                    if isCalculated[n2]:
                        continue
                    t_d = distance[n1] + d2
                    if t_d < distance[n2]:
                        distance[n2] = t_d
                        path2 = path1[:]
                        path2[0] = t_d
                        path2.append(n2)
                        heappush(pq, path2)
            else:
                print('NA')

solve()


Measured memory_bytes: 5836
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
char s[30005];
int pre[30005][11]={0};
int suf[30005][11]={0};
int vis[1005]={0};
void solve(int dd,int num){
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(pre[dd-1][i]&&suf[dd+1][j]){
                vis[i*100+num*10+j]=1;
            }
        }
    }
}
int main()
{
    int n;
    scanf("%d%s",&n,s);
    for(int i=0;i<n;i++){
        if(i)
        for(int j=0;j<10;j++)
            pre[i][j]=pre[i-1][j];
        pre[i][s[i]-'0']++;
        //for(int j=0;j<10;j++)
       //     cout << pre[i][j] << " \n"[j==9];
    }
    for(int i=n-1;i>0;i--){
        
        for(int j=0;j<10;j++)
            suf[i][j]=suf[i+1][j];
        suf[i][s[i]-'0']++;
        //for(int j=0;j<10;j++)
        //    cout << suf[i][j] << " \n"[j==9];
    }
    for(int i=1;i<=n;i++){
        solve(i,s[i]-'0');
    }
    int ans = 0 ;
    for(int i=0;i<1000;i++){
        if(vis[i]){
           // cout << i << endl;
            ans++;
        }
            
    }
    cout << ans <<endl;
    return 0;
}


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



int main(){
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=vec.at(i);
  }
  if(sum%10!=0){
    cout<<sum<<endl;
    return 0;
  }
  else{
    for(int i=0;i<N;i++){
      if(vec.at(i)%10!=0){
        sum-=vec.at(i);
        cout<<sum<<endl;
        return 0;
      }
    }
    cout<<0<<endl;
  }
}

Measured memory_bytes: 3636
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;

int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	if(C < A) {
		printf("No\n");
	}	
	else if(C > B) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


void max_u(ll&m, ll v)
{
	if(m<v) m=v;
}

int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi a(n+1);

		for(int i=0;i<n;i++) scanf("%d", &a[i]);


		int m=n/2;

		vvll dp(3);

		for(auto&mdp:dp) mdp.resize(m+1);

		for(int i=0;i<m;i++)
		{
			dp[0][i+1]=dp[0][i]+a[i*2  ];
			dp[1][i+1]=dp[1][i]+a[i*2+1];
			dp[2][i+1]=dp[2][i]+a[i*2+2];
			max_u(dp[1][i+1], dp[0][i]+a[i*2+1]);
			max_u(dp[2][i+1], dp[0][i]+a[i*2+2]);
			max_u(dp[2][i+1], dp[1][i]+a[i*2+2]);
		}

		ll ans=max(dp[0][m], dp[1][m]);
		if(n&1) ans=max(ans, dp[2][m]);

		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s;
	cin >> s;
	vector<int> v(3);
	rep(i,s.size()) v[s[i] - 'a']++;
	int mx = 0;
	int mn = INF;
	rep(i,3) mx = max(mx, v[i]), mn = min(mn, v[i]);
	if (mx - mn < 2) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    if (n%(2*d+1) == 0) {
        cout << n/(2*d+1) << endl;
    } else {
        cout << n/(2*d+1)+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

using namespace std;

double memo[512][512];

double solve(int rest, int known){
  if(rest == known) return 0.0;
  if(rest <= 1)     return 0.0;
  if(memo[rest][known] > -1)
    return memo[rest][known];

  double ret = 0.0;
  int all     = rest * 2;
  int unknown = all - known;

  {
    // first: unknown one
    double p1 = (double)(unknown - known) / (double)unknown;
    double pp = 1.0;
    {
      // second: the same one
      double p2 = (double)(1) / (double)(unknown - 1);
      ret += p1 * p2 * solve(rest - 1, known);
      pp -= p2;
    }

    if(unknown - 2 - known > 0){
      // second: unknown one
      double p2 = (double)(unknown - 2 - known) / (double)(unknown - 1);
      ret += p1 * p2 * (1.0 + solve(rest, known + 2));
      pp -= p2;
    }

    {
      // second: known one
      double p2 = pp;
      ret += p1 * p2 * (1.0 + solve(rest - 1, known));
    }
  }

  {
    // first: known one
    double p1 = 1.0 - (double)(unknown - known) / (double)unknown;
    ret += p1 * solve(rest - 1, known - 1);
  }

  // printf("solve(%d, %d): %.2f\n", rest, known, ret);

  return memo[rest][known] = ret;
}

int main(){
  while(int n = getInt()){
    int m = n / 2;

    REP(i, m + 1) REP(j, m + 1)
      memo[i][j] = -2.0;

    double ans = solve(m, 0);

    printf("%.8f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2932
# include <cstdio>
# define R register int

using namespace std;

const int maxn=100005;
int n,M,ans,cnt,a[maxn],v[maxn],b1,b2,mb1,mb2,mc1,mc2,c1,c2;

inline int min (int a,int b) { return b>=a?a:b; }
inline int max (int a,int b) { return b>=a?b:a; }

int main()
{
	scanf("%d",&n);
	for (R i=1;i<=n;++i) 
		scanf("%d",&a[i]),M=max(M,a[i]);
	for (R i=1;i<=n;i+=2) 
		v[ a[i] ]++;
	for (R i=1;i<=M;++i) 
		if(v[i]>=mb1)
			b2=b1,mb2=mb1,mb1=v[i],b1=i;
		else
			if(v[i]>mb2) mb2=v[i],b2=i;
	for (R i=1;i<=n;i+=2) 
		v[ a[i] ]--;
	for (R i=2;i<=n;i+=2) 
		v[ a[i] ]++;
	for (R i=1;i<=M;++i) 
		if(v[i]>=mc1)
			c2=c1,mc2=mc1,mc1=v[i],c1=i;
		else
			if(v[i]>mc2) mc2=v[i],c2=i;
	if(b1!=c1)
		ans=n-mb1-mc1;
	else
		ans=min(n-mb1-mc2,n-mb2-mc1);
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 896
var
i,j,c,d,e,b,x,y:longint;
s,s1,s2,s3:string;
begin
readln(s);
readln(s1);
for i:=1 to length(s)+length(s1) do
if (i mod 2<>0) then begin inc(x); write(s[x]);end
else
begin
inc(y);
write(s1[y]);
end;
writeln;
end.


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n;
    cin>>n;
    pair<pair<string, ll>, int> x[101];
    for(int i=0;i<n;++i){
        string s;
        ll p;
        cin>>s>>p;
        auto z=make_pair(s, -p);
        x[i]=make_pair(z,i+1);
    }
    sort(x,x+n);
    for(int i=0;i<n;++i){
        cout<<x[i].second<<endl;
    }
}

Measured memory_bytes: 256
n = int(input().split()[0])
c = list(filter(lambda x:x <= n,map(int,input().split())))
m = len(c)

minimum = [ i for i in range(n+1) ]
for i in c:
    minimum[i] = 1

for i in range(1,n+1):
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1

print(minimum[n])

Measured memory_bytes: 9648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	vector<ll> t(n);
	vector<ll> a(n);
	rep(i,n) cin >> t.at(i);
	rep(i,n) cin >> a.at(i);
	vector<ll> b(n,1000000000000);
	vector<bool> c(n,true);
	c[0]=false;
	c[n-1]=false;
	if(n==1 && a[0]!=t[0]){
		cout << 0 << endl;
		return 0;
	}
	rep(i,n-1){
		if(t[i+1]>t[i]){
			c[i+1]=false;
			if(t[i+1]>a[i+1]){
				cout << 0 << endl;
				return 0;
			}
		}
		else if(t[i+1]==t[i]) b[i+1]=min(t[i+1],b[i+1]);
		else{
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i,n-1){
		if(a[n-2-i]>a[n-1-i]){
			c[n-2-i]=false;
			if(a[n-2-i]>t[n-2-i]){
				cout << 0 << endl;
				return 0;
			}
		}
		else if(a[n-2-i]==a[n-1-i]) b[n-2-i]=min(b[n-2-i],a[n-2-i]);
		else{
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans=1;
	rep(i,n){
		if(c[i]){
			ans*=b[i];
			ans%=mod;
		}
	}
	cout << ans << endl;
}

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

#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int h,w,n;

map<pair<int,int>, int>m;

int check(int x, int y)
{
	return (x <= h && x >= 1 && y <= w && y >= 1);
}

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

int32_t main(){
	fast;
	cin >> h >> w >> n;
	while(n--)
	{
		int x,y;
		cin >> x >> y;
		for(int i=0 ; i<3; i++)
		{
			for(int j=0 ; j<3 ; j++)
			{
				if(check(x+dx[i] , y + dy[j]) && check(x+dx[i]+2, y + dy[j] + 2) )
				{
					m[mp(x+dx[i] , y + dy[j])]++;
				}
			}
		}
	}
	
	int ans[10] = {0};
	int sum = 0;
	for(auto x:m)
	{
		ans[x.S]++;
	}
	
	ans[0] = (h-2)*(w-2) - m.size();
	for(int i=0 ; i<=9 ; i++)
	{
		cout << ans[i] << "\n";
	}
	
}







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

int main()
{
  int n,x,m;
  cin>>n>>x>>m;
  int l[m],r[m],s[m];
  for(int i=0;i<m;i++)
    cin>>l[i]>>r[i]>>s[i];
  int tmp[n];
  for(int i=0;i<n;i++)
    tmp[i]=x;
  bool flag=true;
  int cnt=pow(x,n+1);
  // cerr<<cnt<<endl;
  while(flag&&cnt>=0)
    {
      bool check=true;
     for(int i=0;i<m&&check;i++)
       {
	 int sum=0;
	 for(int j=l[i]-1;j<r[i];j++)
	   {
	     sum+=tmp[j];
	   }
	 if(sum!=s[i])
	   check=false;
       }

     if(check)
       {
	 flag=false;
	 for(int i=0;i<n;i++)
	   {
	     cout<<tmp[i];
	     if(i==n-1)
	       cout<<endl;
	     else
	       cout<<" ";
	   }
	 break;
       }
      for(int i=0;i<n;i++)
	{
	  if(tmp[i]>0)
	    {
	      tmp[i]--;
	      break;
	    }
	      tmp[i]=x;
	}
      cnt--;
      /*
     cerr<<"T,[cnt="<<cnt<<"] ";
	 for(int i=0;i<n;i++)
	   {
	     cerr<<tmp[i];
	     if(i==n-1)
	       cerr<<endl;
	     else
	       cerr<<" ";
	   }
      */

    }
  if(flag)
    cout<<"-1"<<endl;
}

Measured memory_bytes: 1200
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe
import Data.List

main :: IO ()
main = do
  [a,b,c] <- readInts
  print . showAnswer $ solve (a,b,c)

type Input  = (Int, Int, Int)
type Output = Int

solve :: Input -> Output
solve (a,b,c) = maximum (map f xs)
  where
    xs = permutations [a,b,c]
    f [a,b,c] = (a*10) + b + c

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
solve [] n = n
solve [_] n = n
solve [_,_] n = n
solve ('A':'B':'C':ss) n = solve ss (n+1)
solve (_:'A':'B':ss) n = solve ('A':'B':ss) n
solve (_:_:'A':ss) n = solve ('A':ss) n
solve (_:_:_:ss) n = solve ss n

main = do
  _ <- getLine
  s <- getLine
  putStrLn . show $ solve s 0

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

int main()
{
	int n, k;
	
	while (cin >> n >> k, n || k){
		int s[101], b[101];
		bool f = true;
		
		for (int i = 0; i < k; i++){
			cin >> s[i];
		}
		
		for (int i = 0; i < n; i++){
			for (int j = 0; j < k; j++){
				cin >> b[j];
				s[j] -= b[j];
			}
		}
		
		for (int i = 0; i < k; i++){
			if (s[i] < 0){
				f = false;
			}
		}
		
		if (f){
			cout << "Yes" << endl;
		}
		
		else {
			cout << "No" << endl;
		}
		
	}
	
	return (0);
}

Measured memory_bytes: 1148
public class Main {

  private static void solve() {
    int n = ni();
    int k = ni();
    char[] s = ns();

    int change = 0;
    for (int i = 0; i < n - 1; i++) {
      if (s[i] != s[i + 1]) {
        change++;
      }
    }
    change = Math.max(0, change - 2 * k);
    System.out.println(n - change - 1);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 26580
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 2000000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define ALL(a) (a).begin(),(a).end()

signed main(){ INIT
    VAR(int, n);
    int i = 1;
    while(i*(i+1)/2 < n) i++;
    int a = i*(i+1)/2 - n;
    FOR(t, 1, i+1) if(t != a) OUTL(t);
RET;}

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

using namespace std;
const int MAXN = 2005;
char a[MAXN], b[MAXN], c[MAXN];
bool ab[MAXN * 5], ac[MAXN * 5], bc[MAXN * 5];
int main()
{

    scanf("%s%s%s", a, b, c);
    int lena = strlen(a), lenb = strlen(b), lenc = strlen(c);
    for (int i = 0; i < lena; i++)
    {
        for (int j = 0; j < lenb; j++)
        {
            if (!(a[i] == b[j] || a[i] == '?' || b[j] == '?'))
            {
                ab[i - j + 4000] = 1;
            }
        }
    }
    for (int i = 0; i < lena; i++)
    {
        for (int j = 0; j < lenc; j++)
        {
            if (!(a[i] == c[j] || a[i] == '?' || c[j] == '?'))
            {
                ac[i - j + 4000] = 1;
            }
        }
    }
    for (int i = 0; i < lenb; i++)
    {
        for (int j = 0; j < lenc; j++)
        {
            if (!(b[i] == c[j] || b[i] == '?' || c[j] == '?'))
            {
                bc[i - j + 4000] = 1;
            }
        }
    }
    int ans = 1e9;
    for (int i = -4000; i <= 4000; i++)
    {
        for (int j = -4000; j <= 4000; j++)
        {
            if (!ab[i + 4000] && !ac[j + 4000] && !bc[j - i + 4000])
            {
                int L = min(0, min(i, j));
                int R = max(lena, max(lenb + i, lenc + j));
                ans = min(ans, R - L);
            }
        }
    }
    printf("%d\n", ans);
    int t;
    cin >> t;
    // cout << '1';
}

Measured memory_bytes: 3820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			String number = scn.nextLine();
			if (number.equals("0")) {
				break;
			}
			char[] changedData = number.toCharArray();
			int sum = 0;
			for (int i = 0; i < changedData.length; i++) {
				sum = sum + Character.getNumericValue(changedData[i]);
			}
			System.out.println(sum);
		}
	}
}
 


Measured memory_bytes: 26616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int N,M;
vvi G;
vi dp;

int dfs(int u){
    
    if(dp[u] > 0) return dp[u];
    int res = 0;
    
    for (auto p : G[u]) {
        chmax(res,dfs(p)+1);
    }

    return dp[u] = res;
    
}


int main(){
    
    cin >> N >> M;
    G.resize(N);
    dp.assign(N,-1);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--,b--;
        
        G[a].pb(b);
    }
    
    rep(i,N) if(dp[i] < 0) dfs(i);
    
    int ans = 0;
    rep(i,N) chmax(ans, dp[i]);
    cout << ans << endl;
    
    
    
    
    

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  string t;
  int q;
  cin >> q;
  rep(qi,q){
    int ty;
    cin >> ty;
    if (ty == 1){
      swap(s,t);
    }else{
      int f; char c;
      cin >> f >> c;
      if (f == 1){
	t += c;
      }else{
	s+=c;
      }}
  }
  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 1128
#include "bits/stdc++.h"
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 N;
	cin >> N;
	REP(i,25+1){//4の数
		REP(j,20){//7の数
			if(4*i+7*j>100) break;
			if(N-4*i-j*7==0){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    } 
    for(int i = n - 1; i >= 0; --i){
        printf("%d", a[i]);
        if(i != 0) printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    for(int n = 0; n <= N; n++) {
        for(int m = 0; m < M; m++) {
            int now = m * n + (M - m) * (N - n);
            if(now == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
int n,l=0,p[20];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d ",&p[i]);
}

for(int i=1;i<n-1;i++){
if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1]))l++;
}
printf("%d ",l);
}

Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <string>


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

  std::string o, e;
  std::cin >> o >> e;
  for (decltype(e)::size_type i = 0; i < e.length(); i++) {
    std::cout.put(o[i]);
    std::cout.put(e[i]);
  }
  if (o.length() > e.length()) {
    std::cout.put(*std::prev(std::cend(o)));
  }
  std::cout << std::endl;

  return EXIT_SUCCESS;
}


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

int main(){
    string w;
    cin >> w;
    map<char, int> mp;
    for(auto c : w){
        mp[c]++;
    }
    bool flag = true;
    for(auto x : mp){
        if(x.second & 1){
            flag = false;
        }
    }
    cout << (flag ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n, m, a, b; cin >> n >> m; 
  vvi G(n), H(n);
  vi indeg(n,0);
  forall(i,0,m){
    cin >> a >> b;
    G[a-1].pb(b-1);
    H[b-1].pb(a-1);
    indeg[b-1] ++;
  }
  
  // linearize
  queue<int> Q;
  forall(i,0,n) if(indeg[i]==0){
    Q.push(i);
  }
  vi ord;
  while( !Q.empty() ){
    auto x = Q.front(); Q.pop();
    ord.pb(x);
    for(auto y : G[x]){
      indeg[y] --;
      if( indeg[y] == 0 ){
        Q.push(y);
      }
    }
  }

  debug("ord", sz(ord));
  print_(ord);
  
  vi dist(n, -1);
  for(auto x : ord){
    if( H[x].empty() ){
      dist[x] = 0;
    }else{
      for(auto y : H[x]){
        dist[x] = max(dist[x], 1+dist[y]);
      }
    }
    trace(x, dist[x]);
  }
  cout << *max_element(all(dist)) << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    ll n, r=0, g=0, b=0;
    string s;
    cin >> n >> s;
    for(auto c : s){
        if(c == 'R') r++;
        if(c == 'G') g++;
        if(c == 'B') b++;
    }
    ll ans = r * g * b;
    ll count = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(s[i] == s[j]) continue;
            int k = 2 * j -i;
            if(k >= n || s[i] == s[k] || s[k] == s[j]) continue;
            count++;
        }
    }
    cout << ans - count << endl;
    return 0;
}

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

using namespace std;

int main()
{
	unsigned int N, Y;
	unsigned int x, y;
	cin >> N >> Y;

	Y /= 1000;
	unsigned int z = Y % 5;
    Y -= z;
	N -= z;

	for(x = 0; x <= N; ++x) {
		for(y = 0; y <= N; ++y) {
			if (Y == x * 10 + y * 5 + N - x - y) {
				cout << x << " " << y << " " << N - x - y + z << endl;
				return 0;
			}
			if (Y <= 10 * x + 5 * y)
				break;
		}

		if (Y <= 10 * x)
			break;
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}



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

int main()
{
  int size=13;
  int
  spade[13] = { 0 },
  heart[13] = { 0 },
  club[13] = { 0 },
  diamond[13] = { 0 };

  int maxn;
  cin >> maxn;

  for( int i = 0; i < maxn; i++ ) {
    string suits = "";
    int num = 0;

    cin >> suits >> num;

    if( suits == "S" ) {   spade[ num - 1 ] = 1; }
    if( suits == "H" ) {   heart[ num - 1 ] = 1; }
    if( suits == "C" ) {    club[ num - 1 ] = 1; }
    if( suits == "D" ) { diamond[ num - 1 ] = 1; }
  }

  for( int j = 0; j < size; j++ ) {
    if( spade[ j ] == 0 ) {   cout << "S " << j + 1 << endl;  }
  }
  for( int j = 0; j < size; j++ ) {
    if( heart[ j ] == 0 ) {   cout << "H " << j + 1 << endl;  }
  }
  for( int j = 0; j < size; j++ ) {
    if( club[ j ] == 0 ) {    cout << "C " << j + 1 << endl;  }
  }
  for( int j = 0; j < size; j++ ) {
    if( diamond[ j ] == 0 ) { cout << "D " << j + 1 << endl;  }
  }

  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   int cnt1 = -1, ans;
   rep(i, 1, n + 1) {
      int cnt2 = 0;
      int num = i;
      while (num % 2 == 0) {
         num /= 2;
         cnt2++;
      }
      if (cnt2 >= cnt1) {
         cnt1 = cnt2;
         ans = i;
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> A(h,vector<char>(w));
    rep(i,h) {
        rep(j,w) {
            cin >> A[i][j];
        }
    }
    vector<vector<bool>> AA(h,vector<bool>(w, false));
    int hh = h;
    int ww = w;
    // 行
    rep(i,h) {
        int hh = count(all(A[i]), '.');
        if (hh == w) {
            rep(j,w) {
                AA[i][j] = true;
            }
            hh--;
        }
    }
    // 列
    rep(i,w) {
        int cntw = 0;
        rep(j,h) {
            if (A[j][i] == '.') {
                cntw++;
            }
        }
        if (cntw == h) {
            rep(k,h) {
                AA[k][i] = true;
            }
            ww--;
        }
    }

    rep(i, h) {
        int hh = count(all(AA[i]), true);
        if (hh == w) continue;
        rep(j,w) {
            if (AA[i][j] == false) {
                cout << A[i][j];
            }
        }
        cout << "\n";
    }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int N = S.size();
  int M = T.size();
  
  vector<int> V;
  int P = 0;
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < M; j++) {
      if (S.at(i + j) == T.at(j)) P++;
    }
    V.push_back(M - P);
    P = 0;
  }
  
  sort(V.begin(), V.end());
  cout << V.at(0) << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

const int N = 1<<18|3, mo = 1e9+7, inv2 =(mo+1)/2;
const ll MOD=7LL*mo*mo;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}

int fac[N],ifac[N];
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
inline int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
int n,a,b,f[2][N],dp[N],dp2[N];

int main() {
	read(n);read(a);read(b);iniC(N-1);
	if(a<b)swap(a,b);//a>=b
	
	f[1][0]=1;
	rep(i,1,n){
		rep(j,0,i-1)add(f[0][i],f[1][j]);
		rep(k,0,i-b)add(f[1][i],f[0][k]);
		dp[i]=(f[0][i])%mo;
		dp2[i]=(f[1][i])%mo;//f[0][i]+
	}
	memset(f,0,sizeof(f));
	
	rep(i,0,1)f[i][0]=1;
	rep(i,1,n){
		rep(k,max(0,i-a+1),i-1){
			add(f[0][i],1ll*f[1][k]*dp[i-k]%mo);
			if(i==n||k==0)add(f[0][i],1ll*f[1][k]*dp2[i-k]%mo);
		}
		rep(k,max(0,i-b+1),i-1)add(f[1][i],f[0][k]);
	}
	int res=((power(2,n)-f[0][n]-f[1][n])%mo+mo)%mo;
	cout<<res;
	return 0;
}


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

int main(void) {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = 1e9;
	for (int i = 0; i <= 100000; i++) {
		ans = min((2*c*i + max(x-i, 0)*a + max(y-i, 0)*b), ans);

	}
	cout << ans << endl;

	return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) { 
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;
int n,m_a,m_b,dp[401][401],a[40],b[40],c[40];
void solve(){
    cin >> n >> m_a >> m_b;
    rep(i,0,n) cin >> a[i] >> b[i] >> c[i];
    fill_n((int*)dp,401*401,inf);
    dp[0][0]=0;
    rep(i,0,n){
        for(int j=400; j>=0; --j){
            for(int k=400; k>=0; --k){
                if(j-a[i]<0 or k-b[i]<0) continue;
                dp[j][k]=min(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
            }
        }
    }

    int ans=inf;
    {
        int i=1;
        for(;;){
            ans=min(ans,dp[m_a*i][m_b*i]);
            ++i;
            if(m_a*i>400 or m_b*i>400) break;
        }
    }
    if(ans==inf) cout << -1 << endl;
    else cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 896
"use strict";

const main = arg => {

  const input = arg.trim().split("\n");

  const N = parseInt(input[0].split(" ")[0]);
  const M = parseInt(input[0].split(" ")[1]);
  const A = input[1].split(" ").map(n=>parseInt(n));
  let result = N;
  A.forEach(elm => {
    result -= elm
  })
  if(result < 0) {
  	console.log(-1)
  } else {
  	console.log(result)
  }

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

Measured memory_bytes: 30536
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)
#define int long

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;


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

int findlcm(vector<int> arr, int n){
	int ans = arr[0];
	for(int i = 1 ; i < n ; i++){
		ans = (arr[i] * ans) / gcd(arr[i],ans);
	}
	return ans;
}

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  long N;
  long M;

  cin >> N >> M;

  vector<long> a;
  a.resize(N);
  for(int i = 0 ; i < N ; i++){
  	cin >> a[i];
  	a[i] = a[i] / 2;
  }
  int lcm = findlcm(a,N);
  if(lcm > M){
    cout << 0 << endl;
    return 0;
  }

  for(auto i : a){
    if(lcm / i % 2 == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  int possi = M / lcm;
 
  if(possi%2 == 0){
    cout << possi/2 << endl;
  }
  else{
    cout << possi/2 + 1 << endl;
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using Graph = std::vector<std::vector<uint32_t>>;

void dfs(const Graph& G, uint32_t start, std::vector<uint32_t>& group,
         uint32_t mark) {
  group[start] = mark;
  for (auto&& g : G[start]) {
    if (group[g] == mark) continue;
    dfs(G, g, group, mark);
  }
  return;
}

int main() {
  uint32_t n = 0, m = 0;
  std::cin >> n >> m;
  Graph G(n);
  for (size_t i = 0; i < m; i++) {
    uint32_t s = 0, t = 0;
    std::cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  std::vector<uint32_t> group(n, 0);
  uint32_t g = 0;
  for (size_t i = 0; i < n; i++) {
    if (group[i] == 0) {
      g++;
      dfs(G, i, group, g);
    }
  }

  uint32_t q = 0;
  std::cin >> q;
  for (size_t i = 0; i < q; i++) {
    uint32_t s = 0, t = 0;
    std::cin >> s >> t;
    std::cout << (group[s] == group[t] ? "yes" : "no") << std::endl;
  }

  return 0;
}


Measured memory_bytes: 13416
#include<stdio.h>
int main(){
  int i;//制御変数
  int n,d1[101],d2[101];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d %d",&d1[i],&d2[i]);

  for(i=0;i<n;i++){
    if(d1[i]==d2[i]){//条件1達成
      if(d1[i+1]==d2[i+1]){//条件2達成
        if(d1[i+2]==d2[i+2]){//条件3達成
          printf("Yes");
          return 0;
        }
      }
    }
  }
  printf("No");
  return 0;
}

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

using namespace std;

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

	while(1){
		string inputstr;
		//getline(cin, inputstr);
		cin >> inputstr;
		if(inputstr == "-")break;
		int count;
		cin >> count;
		string s = inputstr;
		for(int i= 0; i< count; i++){
			int h;
			cin >> h;
			int len = s.length();
			s = s.substr(h , len - h) + s.substr(0, h);
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3208
import math

n = int(input())
m = n
ans = []
i = 2
k = math.sqrt(n)
dic = {}
while i <= k:
    if n%i == 0:
        n = n//i
        ans.append(i)
        i -= 1
        if n == 1:
            break
    i += 1
if len(ans) == 0 or n != 1:
    ans.append(n)
ans = list(set(ans))
sum = m
for i in ans:
    sum *= (1-1/i)
print(int(sum))


Measured memory_bytes: 5664
n = int(input())
a = list(input())
b = list(input())
c = list(input())

count = 2 * n

for i in range(n):
    if a[i] == b[i] or a[i] == c[i] or b[i] == c[i]:
        count -= 1
        if a[i] == b[i] and b[i] == c[i]:
            count -= 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a==c){
    cout <<0<< endl;
  }else{
    cout << 1 << endl;
  }
}


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

const int maxn = 1e6+5, inf = 2e9;

struct minstack{
	stack<pair<int,int>> p;
	int getmin(){
		return p.empty() ? inf : p.top().second;
	}
	int top(){
		return p.top().first;
	}
	void push(int x){
		p.push({ x, p.empty() ? x : min(x, p.top().second) } );	
	}
	bool empty() { return p.empty(); }
	void pop() { if (p.size()) p.pop(); }
};

struct minqueue{
	minstack l, r;
	bool empty() { return l.empty() && r.empty(); }
	void push(int x) { l.push(x); }
	void pass() { 
		while(!l.empty()) {
			r.push(l.top()); 
			l.pop(); 
		}
	}
	void pop(){
		if (r.empty()) pass();
		if (!r.empty()) r.pop();
	}
	int getmin(){
		return min(l.getmin(), r.getmin());
	}

};

int n, k, a[maxn];

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 0; i<n; i++) scanf("%d", &a[i]);
	int r = 0;
	minqueue q;
	for(int l = 0; l+k<=n; l++, q.pop()){
		while(r<l+k) q.push(a[r++]);
		printf("%d%c", q.getmin(), " \n"[l+k==n]);
	}
	return 0;
}


Measured memory_bytes: 7552
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
#define MOD 1000000007

#define ARRAY_MAX 60
int h,w;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
int mp[ARRAY_MAX][ARRAY_MAX];
int B = 0,W = 0;


int dfs(int y,int x,int num,int sum,bool& white,bool& black){
    //今いるところをnumに置き換える
    //y座標、x座標、置き換える数字,
    mp[y][x] = num;
    int cnt = 0;//今の位置から何回dfsを呼び出したか

    //移動方向をループ
    REP(i,4){
        int nx = x + dx[i], ny = y + dy[i];
        if(mp[ny][nx] == -2){
            black = true;
        }
        if(mp[ny][nx] == -3){
            white = true;
        }
        if(0 <= nx && nx < w && 0 <= ny && ny < h && mp[ny][nx] == -1){
            cnt += dfs(ny,nx,num,sum,white,black);
            cnt++;//自信の数をカウント
        }
    }
    return cnt;
}

int solve(){
    //B,W以外の領域に番号を振る
    int res = 0;
    for(int y = 0;y < h;y++){
        for(int x = 0;x < w;x++){
            if(mp[y][x] == -1){
                bool white = false,black = false;
                int sum = dfs(y,x,res,1,white,black)+1;//孤立領域の面積のカウント
                res++;
                if(black == true && white == false){
                    B += sum;
                }else if(black == false && white == true){
                    W += sum;
                }
            }
        }
    }
    return res;
}

int main(){

    while(cin >> w >> h,h){

        REP(i,ARRAY_MAX){
            REP(j,ARRAY_MAX){
                mp[i][j] = INF;//適当な文字で初期化
            }
        }
        REP(i,h){
            REP(j,w){
                char c;
                cin >> c;
                if(c == '.'){
                    mp[i][j] = -1;
                }
                if(c == 'B'){
                    mp[i][j] = -2;
                }
                if(c == 'W'){
                    mp[i][j] = -3;
                }
                //cin >> mp[i][j];
            }
        }
        
        solve();

        cout << B << " " << W << endl;
        B = W = 0;
    }

    

    return 0;
}


Measured memory_bytes: 3204