akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>  
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

ll burger(int x) {
    if(x == 0) return 1;
    return 2 * burger(x - 1) + 3;
}
ll paty(int x) {
    if(x == 0) return 1;
    return 2 * paty(x - 1) + 1;
}
ll f(int N, ll X) {
    if(N == 0) return 1;
    if(X == 1) return 0;
    if(X >= 2 && X <= 1 + burger(N - 1)) return f(N - 1, X - 1);
    if(X == burger(N - 1) + 2) return paty(N - 1) + 1;
    if(X >= burger(N - 1) + 3 && X <= 2 * burger(N - 1) + 2) return paty(N - 1) + 1 + f(N - 1, X - burger(N - 1) - 2);
    if(X == burger(N)) return paty(N);
}

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

    int N; cin >> N;
    ll X; cin >> X;

    cout << f(N, X) << "\n";

    return 0;
}

Measured memory_bytes: 256
h, w = gets.to_s.split.map{|t|t.to_i}

c = Array.new(10){ gets.to_s.split.map{|t|t.to_i} + [0] } + ( [0] * 11 )
a = Array.new(h){ gets.to_s.split.map{|t|t.to_i} }.flatten
# a.default = 0

10.times do |k|
  10.times do |i|
    10.times do |j|
      c[i][j] = c[i][k] + c[k][j] if c[i][j] > c[i][k] + c[k][j]
    end
  end
end

ans = 0
a.each{|k| ans += c[k][1] }

puts ans

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  string s; cin >> s;
  if(s.size() == 3) reverse(all(s));
  cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const int maxn = 100001;
const int maxk = 20;
#define is_anc(a, b) (in[a] < in[b] and out[a] >= out[b])
struct info{
	int v, c, w;
};
struct query{
	int id, c, w, y;
};
int n, anc[maxn][maxk], in[maxn], out[maxn], depth[maxn], m;
long long ans[maxn];
vector < info > edge[maxn];
vector < query > ask[maxn];
void dfs(int now, int last = 1){
	static int t = 0;
	static int d = 0;
	depth[now] = d++;
	in[now] = t++;
	anc[now][0] = last;
	for(int i = 1;i < maxk;++i)anc[now][i] = anc[anc[now][i - 1]][i - 1];
	for(auto &i : edge[now])
		if(last != i.v)dfs(i.v, now);
	out[now] = t;
	--d;
}
int get_lca(int a, int b){
	if(depth[a] > depth[b])swap(a, b);
	if(is_anc(a, b))return a;
	for(int i = maxk - 1;i > -1;--i)
		if(!is_anc(anc[b][i], a))b = anc[b][i];
	return anc[b][0];
}
void dfs2(int now, int last = 1){
	static int total_w = 0;
	static int q_of[maxn] = {};
	static int w_of[maxn] = {};
	for(auto &i : ask[now]){
		ans[i.id] += (total_w - w_of[i.c] + q_of[i.c] * i.y) * i.w;
	}
	for(auto &i : edge[now]){
		if(i.v != last){
			++q_of[i.c];
			w_of[i.c] += i.w;
			total_w += i.w;
			dfs2(i.v, now);
			--q_of[i.c];
			w_of[i.c] -= i.w;
			total_w -= i.w;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for(int a, b, c, d, i = 1;i < n;++i){
		cin >> a >> b >> c >> d;
		edge[a].push_back({b, c, d});
		edge[b].push_back({a, c, d});
	}
	dfs(1);
	for(int i = 0, x, y, u, v, lca;i < m;++i){
        cin >> x >> y >> u >> v;
		lca = get_lca(u, v);
		ask[u].push_back({i, x, 1, y});
		ask[v].push_back({i, x, 1, y});
		ask[lca].push_back({i, x, -2, y});
	}
	dfs2(1);
	for(int i = 0;i < m;++i)cout << ans[i] << '\n';
}


Measured memory_bytes: 29940
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

n, m = map(int, input().split())
data = [1 for i in range(m)]
a = []
b = []

for i in range(m):
  _a, _b = map(int, input().split())
  a.append(_a - 1)
  b.append(_b - 1)

csr = csr_matrix((data, (a, b)), (n, n))

print(connected_components(csr, return_labels=False) - 1)

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

int N;
int main() {
    cin >> N;
    string ans = "ABC";
    if (N > 999) {
        ans = "ABD";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,w,dp[100005],ans;
int main()
{
	scanf("%lld%lld",&n,&w);
	for(int i=1;i<=n;i++)
	{
		long long temp1,temp2;
		scanf("%lld%lld",&temp1,&temp2);
		for(int j=w;j>=temp1;j--)
		{
			dp[j]=max(dp[j-temp1]+temp2,dp[j]);
		}
	}
	for(int i=0;i<=w;i++)
	{
		ans=max(ans,dp[i]);
//		printf("%lld\n",dp[i]);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 896
import java.util.Scanner;

/*

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        String[] temp_a = a.split("");
        String[] temp_b = b.split("");

        int ans = 0;
        for (int i = 0; i < temp_a.length; i++) {
            if (!(temp_a[i].equals(temp_b[i]))) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  double A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  
  double max = 0.0; 
  double S = 0.0;
  double T = 0.0;
  
  for (int i = 0; i <= F/(100.0*A); i++) {
    for (int j = 0; j <= F/(100.0*B); j++) {
      for (int k = 0; k <= F/C; k++) {
        for (int l = 0; l <= F/D; l++) {
          if ( (C*k+D*l)/(100.0*A*i+100.0*B*j+C*k+D*l) <= E/(100.0+E) && (C*k+D*l)/(100.0*A*i+100.0*B*j+C*k+D*l) >= max && 100.0*A*i+100.0*B*j+C*k+D*l <= F) {
            max = (C*k+D*l)/(100.0*A*i+100.0*B*j+C*k+D*l);
            S = 100.0*A*i+100.0*B*j+C*k+D*l;
            T = C*k+D*l;            
          }
        }      
      }
    }
  }

  cout << S << " " << T << endl;
      
}

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

int main(void)
{
  int a[10][10],x,y,size,i,j,dots=0,max=0;
  for(i=0;i<10;i++)
    for(j=0;j<10;j++)
      a[i][j]=0;
  while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
    if(size==1 || size==3){
      if(size==3)
	size=2;
      for(i=x-size;i<=x+size;i++)
	for(j=y-size;j<=y+size;j++)
	  if(0<=i &&i<=9 &&0<=j &&j<=9 &&fabs(i-x)+fabs(j-y)<=size)
	    a[i][j]++;
    }
    else if(size==2){
      for(i=x-1;i<=x+1;i++)
	for(j=y-1;j<=y+1;j++)
	  if(0<=i &&i<=9 &&0<=j &&j<=9)
	    a[i][j]++;
    }
  }
  for(i=0;i<10;i++)
    for(j=0;j<10;j++){
      if(a[i][j]==0)
	dots++;
      if(a[i][j]>max)
	max=a[i][j];
    }

  printf("%d\n%d\n",dots,max);

  return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int a[] = new int[n+1];
        int b[] = new int[n];

        for (int i=0; i<n+1; i++) a[i]=sc.nextInt();
        for (int i=0; i<n; i++) b[i]=sc.nextInt();

        long ans = 0;

        for (int i=0; i<n; i++){
            if (b[i]<=a[i]){
                ans += b[i];
            }else {
                ans += a[i];
                int diff=b[i]-a[i];
                int min=Math.min(diff, a[i+1]);
                ans += min;
                a[i+1] -= min;
            }
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 63244
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(b/a<c){
        cout << b/a;
    }else{
        cout << c;
    }
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a*b%2==1){
    cout<<"Odd";
  }
  else cout<<"Even";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

vector<ll> m(51, 0), p(51, 0);
ll dfs(ll x, int l){
    if(l == 0)return 1;
    if(x == m[l])return p[l];
    else if(x > (2 + m[l - 1]))return p[l-1]+1+dfs(x-m[l-1]-2, l-1);
    else if(x == (2 + m[l - 1]))return p[l-1]+1;
    else if(x > 1)return dfs(x-1, l-1);
    else return 0;
}

int main() {
    int n;
    cin >> n;
    ll x;
    cin >> x;
    m[0] = 1;
    p[0] = 1;
    rep(i, 50){
        m[i + 1] = m[i] * 2 + 3;
        p[i + 1] = p[i] * 2 + 1;
    }
    ll ans = dfs(x, n);
    cout << ans << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,k;cin>>n>>k;
	int res=0;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		if(x>=k)res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int x, y;
  cin >> x >> y;
  cout << x+y/2 << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    double sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sum += 1.0/a;
    }
    printf("%.10f\n",1/sum);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(x) ((x) > 0 ? (x) : -(x))

void coloring(char *s){
  char alphabet[30] = {};
  char color = 1;
  int i = 0;
  while(s[i] != 0){
    if(alphabet[s[i] - 'a'] == 0){
      alphabet[s[i] - 'a'] = color;
      color++;
    }
    s[i] = alphabet[s[i] - 'a'];
    i++;
  }
}
  
int
main(int argc, char *argv[])
{
  char s[200001], t[200001];
  scanf("%s", s);
  scanf("%s", t);
  coloring(s);
  coloring(t);

  int i = 0; int flag = 0;
  while(s[i] != 0){
    if(s[i] != t[i]){
      flag++;
      break;
    }
    i++;
  }
  if(flag > 0) printf("No\n");
  else printf("Yes\n");

  return 0;
}

  


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << c << ' ' << a << ' ' << b << endl;

    return 0;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    int n,m;
    cin>>n>>m;
    ll sum=0;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>n) cout << "-1\n";
    else cout << n-sum << "\n";
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3652
S=input()
count=0
for i in range(len(S)):
    """奇数番目を0,偶数番目を1にする"""
    if i%2==1:
        if S[i]=="1":
            count+=1
    else:
        if S[i]=="0":
            count+=1

if count<=len(S)/2:
    print(count)
else:
    print(len(S)-count)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){

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

  long check[n];
  for (int i = 0; i < n; i++) {
    check[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    check[a[i]-1]++;
  }

  long combinations = 0;
  for (int i = 0; i < n; i++) {
    combinations += check[i]*(check[i]-1)/2;
  }

  for (int i = 0; i < n; i++) {
    printf("%ld\n", combinations-check[a[i]-1]+1);
  }

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] == i + 1)cnt++;
    }
    for(int i = 0; i < N - 1; i++){
        if(A[i] == i + 1 && A[i + 1] == i + 2)cnt--, i++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;


void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> k(m);
    for (int i = 0; i < m; i++) {
        int x; cin >> x;
        for (int j = 0; j < x; j++) {
            int y; cin >> y;
            k[i].emplace_back(y-1);
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int res = 0;
    for (int i = 0; i < (1<<n); i++) {
        bool flag = true;
        for (int j = 0; j < m; j++) {
            int cnt = 0;
            for (int x: k[j]) {
                if (i & (1<<x)) cnt++;
            }
            if (cnt%2 != p[j]) {
                flag = false;
                break;
            }
        }
        if (flag) res++;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main() {
  char s[11], t[12];
  scanf("%s\n%s", s, t);
  for (int i = 0; s[i] != '\0'; i++)
  {
    if (s[i] != t[i]) 
    {
      printf("No\n");
      return 0;
    }
  }
  if (strlen(s) + 1 == strlen(t))
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 2084
import math
import heapq
n, m = map(int, input().split())
a = list(map(lambda x:int(x)*(-1), input().split())) 
heapq.heapify(a)
for i in range(m):
    max_value = heapq.heappop(a)*(-1)
    heapq.heappush(a, (max_value//2)*(-1))
print((-1)*sum(a))

Measured memory_bytes: 14380
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,N = map(int,readline().split())
m = map(int,read().split())
AB = zip(m,m)

INF = 10 ** 18
U = 20000
dp = np.full(U, INF, np.int64)
dp[0] = 0

for a,b in AB:
    n = (U + (-U) % a) // a
    dp = np.resize(dp, U + (-U) % a).reshape(-1,a)
    dp -= (np.arange(n) * b)[:,None]
    dp = np.minimum.accumulate(dp, axis=0)
    dp += (np.arange(n) * b)[:,None]
    dp = dp.ravel()[:U]

answer = min(dp[H:])
print(answer)

Measured memory_bytes: 15084
N,M=map(int,input().split())
cakes=[]
for i in range(N):
  x,y,z=map(int,input().split())
  cakes.append([x,y,z])
if M==0:
  print(0)
  quit()
score=[0]*8
s=sorted(map(lambda c: c[0]+c[1]+c[2], cakes))
score[0]=sum(s[-M:])
score[1]=-sum(s[:M])
s=sorted(map(lambda c: c[0]+c[1]-c[2], cakes))
score[2]=sum(s[-M:])
score[3]=-sum(s[:M])
s=sorted(map(lambda c: c[0]-c[1]+c[2], cakes))
score[4]=sum(s[-M:])
score[5]=-sum(s[:M])
s=sorted(map(lambda c: c[0]-c[1]-c[2], cakes))
score[6]=sum(s[-M:])
score[7]=-sum(s[:M])
print(max(score))
quit()


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define pi 3.14159265358979323846

using namespace std;

int main(){
	int x, y;	cin >> x >> y;
	int sum;
	bool ans = false;

	for( int i = 0; i <= x; i++ ){
		if( i * 2 + (x - i) * 4 == y )	ans = true;
	}

	if( ans )	cout << "Yes" << endl;
	else		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;



int main(int argc, char *argv[])
{
	int input;
	string ans;

	//input
	cin >> input;

	//calc
	int input_first = input / 100;
	int input_second = input % 100;

	if ((1 <= input_first && input_first <= 12) &&
		(1 <= input_second && input_second <= 12)){
		ans = "AMBIGUOUS";
	}
	else if (1 <= input_first && input_first <= 12){
		ans = "MMYY";
	}
	else if (1 <= input_second && input_second <= 12){
		ans = "YYMM";
	}
	else{
		ans = "NA";
	}

	//ans
	cout << ans << endl;


	return 0;
}


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

using namespace std;

typedef long long ll;

set<ll> s;
ll n,m;
typedef vector<ll> v1;
v1 e;
v1 ans;

int main(){
  cin >> n >> m;
  e = v1(m);
  for(ll i = 0;i < m;i++){
    cin >> e[i];
  }
  reverse(e.begin(),e.end());
  for(ll i = 1;i <= n;i++){
    s.insert(i);
  }
  for(ll i = 0;i < m;i++){
    if(s.count(e[i])){
      s.erase(e[i]);
      ans.push_back(e[i]);
    }
  }
  for(ll i = 0;i < ans.size();i++){
    cout << ans[i] << endl;
  }
  for(ll x : s){
    cout << x << endl;
  }

}



Measured memory_bytes: 13948
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,N,M;

int main() {
  ios::sync_with_stdio(false);
  cin >> A >> B >> C;
  if(A == B && B == C && A == C) cout << "Yes";
  else cout << "No";



  return 0;
}



Measured memory_bytes: 256
a, b, c = map(int, input().split())
 
x = []
x.append(a)
x.append(b)
x.append(c)
 
y = [5, 7, 5]
for z in y:
    if z in x:
        x.remove(z)
 
if len(x) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
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;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  double ans = 0;
  int x = 0;
  if (n % 2 == 1) x = 1;
  ans = ((n / 2) + x) / (double)n;
  cout << ans << endl;
  return 0;
}

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

typedef struct _contry {
	char str[21];
	int point;
} contry_t;

contry_t c[10];

void insertionsort( int n )
{
	int i, j, v;
	char str[21];
	for ( i = 1 ; i < n ; i++ ) {
		v = c[i].point;
		strcpy( str, c[i].str );
		j = i-1;
		while ( j >= 0 && c[j].point < v ) {
			c[j+1].point = c[j].point;
			strcpy( c[j+1].str, c[j].str );
			j--;
		}
		c[j+1].point = v;
		strcpy( c[j+1].str, str );
	}
}

int main()
{
	int n, win, lose, draw, j, flg = 1;
	char str[30], *p;
	//contry_t c[10];

	while ( scanf( "%d", &n ) == 1 ) {
		if ( n == 0 ) { break; }
		if ( flg == 1 ) {
			flg = 0;
		} else {
			printf( "\n" );
		}

		for ( int i = 0 ; i < n ; i++ ) {
			scanf( "%s %d %d %d", str, &win, &lose, &draw );
			// printf( "%s %d %d %d\n", str, win, lose, draw );
			strcpy( c[i].str, str );
			c[i].point = 3 * win + 0 * lose + 1 * draw;
		}

		insertionsort( n );
		for ( int i = 0 ; i < n ; i++ ) {
			printf( "%s,%d\n", c[i].str, c[i].point );
		}

	}
	return 0;
}



Measured memory_bytes: 2000
import math

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
loopid = [-1 for _ in range(N)]
loop_found = 0
for i in range(N):
    if loopid[i] != -1:
        continue
    loopid[i] = loop_found
    j = P[i]-1
    while loopid[j] == -1:
        loopid[j] = loop_found
        j = P[j]-1
    loop_found += 1

loops = [[] for _ in range(loop_found)]
for nodeid, id in enumerate(loopid):
    loops[id].append(nodeid)

ans = -math.inf
for loop in loops:
    K_tmp = K
    score_tmp = 0
    cs = []
    j = loop[0]
    for _ in range(len(loop)):
        cs.append(C[j])
        j = P[j] - 1
    if sum(cs) >= 0:
        score_tmp += sum(cs)*max(0, K//len(loop)-1)
    K_tmp %= len(loop)
    if K>=len(loop):
        K_tmp += len(loop)

    max_rest = -math.inf
    cs = cs + cs + cs
    for i in range(1, len(cs)):
        cs[i] += cs[i-1]
    j = -1
    tmp_min = math.inf
    for i, c in enumerate(cs):
        max_rest = max(max_rest, c-tmp_min)
        if tmp_min >= c:
            tmp_min = c
            j = i
        if i-j >= K_tmp:
            tmp_min = cs[j+1]
            j += 1
            x = j
            for k, c_ in enumerate(cs[j+1:i+1]):
                if tmp_min >= c_:
                    tmp_min = c_
                    x = k + j + 1
            j = x
    score_tmp += max_rest
    ans = max(ans, score_tmp)
print(ans)


Measured memory_bytes: 70096
#include<stdio.h>
int main(void)
{
    long long N,M,i,k,l,m,x,y,z,max,n = 0;
    long long a[1000];
    long long b[1000];
    long long c[1000];
    long long d[1000];
    long long e[1000];
    long long f[1000];
    long long g[1000];
    long long h[1000];
    


    scanf("%d %d",&N,&M);
    for(i = 0;i < N;i++){
    	scanf("%lld %lld %lld",&x,&y,&z);
        a[i] = x + y + z;
        b[i] = x + y - z;
        c[i] = x - y + z;
        d[i] = x - y - z;
        e[i] = -x + y + z;
        f[i] = -x + y - z;
        g[i] = -x - y + z;
        h[i] = -x - y - z;
        x = y = z = 0;
    }

    for(k = 0;k < N;k++){
        for(l = k;l < N;l++){
            if(a[l] > a[k]){
                m = a[l];
                a[l] = a[k];
                a[k] = m;
            }
            if(b[l] > b[k]){
                m = b[l];
                b[l] = b[k];
                b[k] = m;
            }
            if(c[l] > c[k]){
                m = c[l];
                c[l] = c[k];
                c[k] = m;
            }
            if(d[l] > d[k]){
                m = d[l];
                d[l] = d[k];
                d[k] = m;
            }
            if(e[l] > e[k]){
                m = e[l];
                e[l] = e[k];
                e[k] = m;
            }
            if(f[l] > f[k]){
                m = f[l];
                f[l] = f[k];
                f[k] = m;
            }
            if(g[l] > g[k]){
                m = g[l];
                g[l] = g[k];
                g[k] = m;
            }
            if(h[l] > h[k]){
                m = h[l];
                h[l] = h[k];
                h[k] = m;
            }
        }
    }
    for(m = 0;m < M;m++){
        n = n + a[m];
    }
    max = n;
    n = 0;
    for(m = 0;m < M;m++){
        n = n + b[m];
    }
    if(n > max)
        max = n;
    n = 0;
    for(m = 0;m < M;m++){
        n = n + c[m];
    }
    if(n > max)
        max = n;
    n = 0;
    for(m = 0;m < M;m++){
        n = n + d[m];
    }
    if(n > max)
        max = n;
    n = 0;
    for(m = 0;m < M;m++){
        n = n + e[m];
    }
    if(n > max)
        max = n;
    n = 0;
    for(m = 0;m < M;m++){
        n = n + f[m];
    }
    if(n > max)
        max = n;
    n = 0;
    for(m = 0;m < M;m++){
        n = n + g[m];
    }
    if(n > max)
        max = n;
    n = 0;
    for(m = 0;m < M;m++){
        n = n + h[m];
    }
    if(n > max)
        max = n;

    printf("%lld",max);

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, X;

int main(){
  int N, M, X; cin >> N >> M >> X;
  int C[N], A[N][M];
  for (int i = 0; i < N; i++){
    cin >> C[i];
    for (int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }

  int ans = 1e9;
  for (int i = 0; i < pow(2, N); i++){
    bool check[N]; int num = i;
    for (int j = 0; j < N; j++){
      check[j] = num % 2; num /= 2;
    }

    int now[M] = {}, cost = 0;
    for (int j = 0; j < N; j++){
      if (check[j] == false) continue;
      cost += C[j];
      for (int k = 0; k < M; k++){
        now[k] += A[j][k];
      }
    }
    
    bool flag = true;
    for (int j = 0; j < M; j++){
      if (now[j] < X) flag = false;
    }

    if (flag) ans = min(ans, cost);
  }
  
  if (ans == 1e9) ans = -1;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4016
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

struct order
{
  int i;
  int A;
  bool operator<(const order & rhs)
  {
    return A < rhs.A;
  }
};

int main()
{
  int N;
  cin >> N;
  vector<order> _o(N);
  auto * const o = &_o[0];
  for (int i = 0; i < N; ++i)
  {
    o[i].i = i + 1;
    cin >> o[i].A;
  }
  sort(o, o + N);
  cout << o[0].i;
  for (int i = 1; i < N; ++i)
    cout << " " << o[i].i;
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<map<char,int>>a(n);
  string tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    int size=tmp.size();
    for(int j=0;j<size;j++){
      if(a.at(i).count(tmp.at(j)))a.at(i).at(tmp.at(j))++;
      else a.at(i)[tmp.at(j)]=1;
    }
    if(i!=0){
      for(auto w:a.at(i)){
        if(a.at(0).count(w.first))a.at(0).at(w.first)=min(a.at(0).at(w.first),w.second);
      }
      for(auto w:a.at(0)){
        if(!a.at(i).count(w.first))a.at(0).at(w.first)=0;
      }
    }  
  }
  for(int i=0;i<26;i++){
    if(a.at(0).count((char)(int)'a'+i)){
      for(int j=0;j<a.at(0).at((char)(int)'a'+i);j++){
        cout <<(char)(int)('a'+i);
      }
    }
  }
  cout <<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  ll sum=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sum += A[i];
  }
  ll sum_2=0;
  ll min_sa=sum;
  for(int i=0; i<N; i++){
    sum_2 += A[i];
    min_sa = min(min_sa, abs((sum-sum_2)-sum_2));
  }
  cout << min_sa << endl;
  return 0;
}


Measured memory_bytes: 1024
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(m<n)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}



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

int main(){
  
  int a,b,c,d; cin >> a >> b >> c >> d;
  
  if(abs(a-c) <= d){
    cout << "Yes" << endl;
  }
  
  else if(abs(a-b) <= d && abs(b-c) <= d){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, a; pair<int, char> d[10];
int main() {
	while (true) {
		scanf("%d", &n);
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> d[i].second; d[i].first = i;
			for (int j = 0; j < n - 1; j++) {
				scanf("%d", &a);
				if (a == 0) d[i].first -= 100;
				if (a == 1) d[i].first += 10;
			}
		}
		sort(d, d + n);
		for (int i = 0; i < n; i++) printf("%c\n", d[i].second);
	}
	return 0;
}

Measured memory_bytes: 3200
import math

def koch(start,end,n):
  if n==0:
    return
  else:
    point1=[0,0]
    point2=[0,0]
    point3=[0,0]
    
    point1[0]=(end[0]-start[0])/3 +start[0]
    point1[1]=(end[1]-start[1])/3 +start[1]
    
    point3[0]=(end[0]-start[0])*2/3+start[0]
    point3[1]=(end[1]-start[1])*2/3+start[1]
    
    rad60 = math.radians(60)
    point2[0]=(point3[0]-point1[0])* math.cos(rad60) -(point3[1]-point1[1])*math.sin(rad60) +point1[0]
    point2[1]=(point3[0]-point1[0])* math.sin(rad60) +(point3[1]-point1[1])*math.cos(rad60) +point1[1]
    
    koch(start,point1,n-1)
    print(*point1)
    koch(point1,point2,n-1)
    print(*point2)
    koch(point2,point3,n-1)
    print(*point3)
    koch(point3,end,n-1)

n=int(input())

start=[0,0]
end=[100,0]

print(*start)

if n>0:
  koch(start,end,n)
  

print(*end)


Measured memory_bytes: 5780
/* Simplicity and Goodness */

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

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);

    vector<vi> a(n, vi(m, 0));

    int total_black = 0;

    rep(i, 0, n) {
        rep(j, 0, m) {
            char c;
            cin >> c;
            a[i][j] = c == '#';
            total_black += a[i][j];
        }
    }

    int ways = 0;

    for(int row=0; row<=(1<<n)-1; row++) {
        int here = total_black;
        vector<bool> m_row(n, 0);

        for(int r=0; r<n; r++) {
            if(row & (1<<r)) {
                m_row[r] = 1;
                for(int c=0; c<m; c++)
                    here -= a[r][c];
            }   
        }

        for(int col=0; col<=(1<<m)-1; col++) {
            int here2 = here;
            vector<bool> m_col(m, 0);

            for(int c=0; c<m; c++) {
                if(col & (1<<c)) {
                    m_col[c] = 1;
                    for(int r=0; r<n; r++) {
                        if(!m_row[r])
                            here2 -= a[r][c];
                    }
                }
            }

            if(here2 == k)
                ways ++;
        }
    }   

    prin(ways);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}


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

	int N;
	int A[2][120];
	int max = 0;

	cin >> N;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < N; i++)
	{
		int sum = 0;
		for (int j = 0; j <= i; j++)
		{
			sum += A[0][j];
		}
		for (int j = i; j < N; j++)
		{
			sum += A[1][j];
		}
		if (sum > max) {
			max = sum;
		}
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll n;
int main()
{
	ll fi,cnt=0,m;	
	cin>>n;
	m=n;
	while(n)
	{
		if(n/10==0)
			fi=n;
		n/=10;
		cnt++;
	}
	bool flag=false;
	
	ll pw[20];
	pw[0]=1;
	for(int i=1;i<18;i++)
		pw[i]=pw[i-1]*10;
	if((m+1)%pw[cnt-1]==0)
		flag=true;
	ll res=fi;
	if(cnt>1)
	{
		res=(cnt-1)*9+fi-1;
		res+=flag;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int N,H;
	cin >> N >> H;
    vector<int> a,b;
    
    for(int i=0; i<N; i++)
    {
    	int x,y;
    	cin >> x >> y;
    	a.push_back(x);
    	b.push_back(y);
    }

    int M = *max_element(a.begin(),a.end());
    vector<int> c;

    for(int i=0; i<N; i++)
    {
        if(b[i]>M){ 
        	c.push_back(b[i]);
        }
    }
    vector<int> cnt;
    if(H%M==0)
    {
    	cnt.push_back(H/M);
    }
    else
    {
    	cnt.push_back(H/M+1);
    }

    if(!c.empty()){
    sort(c.begin(),c.end(), greater<int>());
    int z = 0;
    for(int i=1; i<=c.size(); i++)
    { 
        z += c[i-1];
        if(H<=z) cnt.push_back(i);
        else if((H-z)%M==0) cnt.push_back((H-z)/M +i);
        else cnt.push_back((H-z)/M+i+1);
    }
    }

    int m = *min_element(cnt.begin(), cnt.end());
    cout << m << endl;
    
	return 0;
}




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

using namespace std;

struct vw_pair {
    int v, w;
    vw_pair(int v,int w) : v(v), w(w) {};
};

typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<int> vi;
typedef vector <string> vs;
typedef vector <vi> vvi;
typedef vector <vector<vw_pair>> adj_list;
typedef vector <bool> vb;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef priority_queue<int> max_heap_int;
typedef priority_queue<int, vi, greater<>> min_heap_int;

#define isOn(S, j) (S & (1<<j))
#define setBit(S, j) (S |= (1<<j))
#define clearBit(S, j) (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1<<n)-1)

#define modulo(S, N) ((S) & (N-1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S-1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
#define turnOffLastConsecutiveBits(S) ((S) & (S+1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S-1))
#define in_range(lo, hi, x) ((x >= lo && x <= hi))

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

    int n; cin >> n;
    vs arr(n);
    for (int i=0;i<n;++i) {
        cin >> arr[i];
        sort(arr[i].begin(), arr[i].end());
    }
    sort(arr.begin(), arr.end());
    arr.push_back("----");
    ++n;
    ll res = 0;
    for (int i=0;i<n-1;++i) {
        for (int j=i+1;j<n;++j) if (arr[j] != arr[i]) {
            ll range = ll(j-i);
            res += ((range * (range-1)) / 2);
            i = (j-1);
            break;
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    long long n, i;
   
      
    cin >> n;
   
    vector<long long> x(n);

    vector<long long> y(n);

    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> x.at(i);

         y.at(i) = x.at(i);

         }
   

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


    for( i = 0 ; i < n ; i = i + 1 ){

         if( x.at(i) < y.at( n / 2 ) ) cout << y.at( n / 2 ) << endl;

         if( x.at(i) >= y.at( n / 2 ) ) cout << y.at( n / 2 - 1 ) << endl;

         }


    return 0;
                                                          
}

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

int main() {

  int W=0, H=0, x=0, y=0, r=0;

  cin >> W >> H >> x >> y >> r;

  int xjudge = x+r;
  int yjudge = y+r;

  if(0<x && 0<y) {

    if(xjudge<=W && yjudge<=H) {

      cout << "Yes" << endl;
    
      } else {

      cout << "No" << endl;
    
      }
    
  } else if(x<=0 || y<=0) {

    cout << "No" << endl;
  
  } 

}


Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const LL N = 105,M = 20005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL ec = 1,hed[N],cur[N],cap[M],nxt[M],to[M];
void add_edge(LL f,LL t,LL c){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec; cap[ec] = c;
	++ ec; to[ec] = f; nxt[ec] = hed[t]; hed[t] = ec; cap[ec] = 0;
}

LL lev[N];
queue <LL> q;
void bfs(LL s){
	memset(lev,0,sizeof(lev));
	while(!q.empty()) q.pop();
	q.push(s); lev[s] = 1; 
	while(!q.empty()){
		LL u = q.front(); q.pop();
		for(LL i = hed[u];i;i = nxt[i]){
			LL v = to[i];
			if(lev[v] || !cap[i]) continue;
			lev[v] = lev[u] + 1;
			q.push(v);
		}
	}
}

LL dfs(LL u,LL t,LL f){
	if(u == t) return f;
	for(LL i = cur[u];i;i = nxt[i]){
		cur[u] = i;
		LL v = to[i];
		if(lev[v] == lev[u] + 1 && cap[i]){
			LL tmp = dfs(v,t,min(cap[i],f));
			if(tmp){
				cap[i] -= tmp;
				cap[i ^ 1] += tmp;
				return tmp;
			}
		}
	}
	return 0;
}

LL mxf = 0;
void dinic(LL s,LL t){
	LL f = 0;
	while(1){
		bfs(s);
		if(!lev[t]) return;
		for(LL i = 1;i <= t;i ++) cur[i] = hed[i];
		while(1){
			f = dfs(s,t,INF);
			mxf += f;
			if(!f) break;
		}	
	}
}

int main(){
	LL n,S,T,a,sum = 0;
	cin >> n; S = n + 1; T = S + 1;
	for(LL i = 1;i <= n;i ++){
		cin >> a; sum += max(0LL,a);
		if(a > 0) add_edge(i,T,a);
		if(a < 0) add_edge(S,i,-a);
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = i + 1;j <= n;j ++){
			if(j % i == 0) add_edge(i,j,INF);
		}
	}
	dinic(S,T);
	cout << sum - mxf << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;

#define rep(i,s,n)for(ll i = s;i<n;i++)

ll c[10000][10000];
bool v[10000] = { false };
ll A[10000], B[10000];
ll N, M;
ll cnt = 0;

bool isVisitedAll() {
	bool valid = true;
	rep(i, 0, N) {
		valid &= v[i];
	}
	return valid;
}

void dfs(int id) {
	//if (isVisitedAll()) {
	//	cnt++;
	//	return;
	//}

	rep(i, 0, N) {
		if (id != i && c[id][i] != 0 && !v[i]) {
			v[i] = true;
			dfs(i);
			//v[i] = false;
		}
	}
}

int main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		A[i] = a - 1;
		B[i] = b - 1;
		c[a - 1][b - 1] = 1;
		c[b - 1][a - 1] = 1;
	}
	rep(i, 0, M) {
		rep(i, 0, N) v[i] = false;

		c[A[i]][B[i]] = 0;
		c[B[i]][A[i]] = 0;
		v[0] = true;

		dfs(0);
		if (!isVisitedAll()) {
			cnt++;
		}
		c[A[i]][B[i]] = 1;
		c[B[i]][A[i]] = 1;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>
int main()
{
   long long int x,y,i,j,k,count=0,a[432],n,b,t,c ;
   double d ;
   char ch[4534] ;
   scanf("%lld %lld",&n,&k) ;
for(i=1 ; i<=n ; i++)
{
    scanf("%lld %lld",&x,&y) ;
    d=sqrt(x*x + y*y) ;
    if(d>(k*1.0))
        count++ ;


}
printf("%lld",n-count) ;
return 0 ;
}


Measured memory_bytes: 2156
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
  for i in range(4):
    t = list(last4)
    if i >= 1:
      t[i-1], t[i] = t[i], t[i-1]
    if ''.join(t).count('AGC') >= 1:
      return False
  return True

def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == N:
    return 1
  ret = 0
  for c in 'ACGT':
    if ok(last3 + c):
      ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
  memo[cur][last3] = ret
  return ret
    
print(dfs(0, 'TTT'))

Measured memory_bytes: 3872
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int f(int N) {
    int ans = 0;
    while(N%2 == 0) {
        N /= 2;
        ans++;
    }
    return ans;
}

int main() {
    int N; cin >> N;
    int m = 0;
    int ans;
    for(int i = 1; i <= N; i++) {
        if(m < f(i)) {
            ans = i;
            m = f(i);
            }

    }
    if(N == 1) ans = 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;

const int inf  = 1e9+5;

int main (){
	ll n;
	vector<ll> dp(n,inf);
	cin >> n;
	vector<ll> h(n);
	for (ll& x :h){
		std::cin >> x;
	}
	dp[0]=0;
	for (ll i=0;i<n;i++){
		for (ll j:{i+1,i+2}){
			if (j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
			}
		}
	}
	std::cout << dp[n-1];
	return 0;

}





Measured memory_bytes: 33792
# -*- coding: utf-8 -*-
import sys
import io


def main():
    N = int( sys.stdin.readline() )

    XYU_list = []

    for _ in range(N):
        x,y,u = sys.stdin.readline().rstrip().split()
        XYU_list.append( [int(x),int(y),u] )


    diff = float("inf")

    # check(1) rotate 0 degree
    ret = checkSafety_UD(XYU_list)
    diff = min(diff, ret)
    
    ret = checkSafety_UR(XYU_list)
    diff = min(diff, ret)
    
    # check(2) rotate 90 degree
    rotate(XYU_list)

    ret = checkSafety_UD(XYU_list)
    diff = min(diff, ret)
    
    ret = checkSafety_UR(XYU_list)
    diff = min(diff, ret)

    # check(3) rotate 180 degree
    rotate(XYU_list)

    ret = checkSafety_UR(XYU_list)
    diff = min(diff, ret)

    # check(4) rotate 270 degree
    rotate(XYU_list)

    ret = checkSafety_UR(XYU_list)
    diff = min(diff, ret)


    if diff != float("inf"):
        print( int(diff * 10) )
    else:
        print("SAFE")


def rotate(XYU_list :list):
    for i in range(len(XYU_list)):
        x,y,u = XYU_list[i][0], XYU_list[i][1], XYU_list[i][2]
        
        x2 = -y
        y2 = x
        
        if u == "U":  u2 = "L"
        if u == "D":  u2 = "R"
        if u == "L":  u2 = "D"
        if u == "R":  u2 = "U"
        
        XYU_list[i] = [x2,y2,u2]


def checkSafety_UD(XYU_list :list) -> int:
    check_UD = {}

    for x,y,u in XYU_list:
        if (u == "U") or (u == "D"):
            check_UD.setdefault( x , [] )
            check_UD[x].append( (y,u) )

    for key in check_UD:
        check_UD[key].sort()


    diff_min = float("inf")
    
    for arr in check_UD.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "U") and (arr[i+1][1] == "D"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) / 2 )

    return diff_min


def checkSafety_UR(XYU_list) -> int:
    check_UR = {}

    for x,y,u in XYU_list:
        if (u == "U") or (u == "R"):
            check_UR.setdefault( (x+y) , [] )
            check_UR[ (x+y) ].append( (x,u) )

    for key in check_UR:
        check_UR[key].sort()


    diff_min = float("inf")
    
    for arr in check_UR.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "R") and (arr[i+1][1] == "U"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) )

    return diff_min


if __name__ == "__main__":
    main()


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

typedef long long ll;

int main(){

    ll x;
    cin>>x;

    int cnt = 0;
    ll sum = 100;

    while(sum < x){
        ll add = sum/100;
        sum += add;
        cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == ','){
            s[i] = ' ';
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 256