akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int H, W, m; cin >> H >> W >> m;
    vint sum_h(H,0), sum_w(W,0);
    vector<P> data(m);
    rep(i,m) {
        int h, w; cin >> h >> w;
        h--; w--;
        data[i] = P(h,w);
        sum_h[h]++;
        sum_w[w]++;
    }
    int mx_h = *max_element(all(sum_h));
    int mx_w = *max_element(all(sum_w));
    int ct_h = 0, ct_w = 0;
    rep(i,H) if (sum_h[i] == mx_h) ct_h++;
    rep(i,W) if (sum_w[i] == mx_w) ct_w++;
    int sum = ct_h * ct_w;
    rep(i,m) {
        if (sum_h[data[i].first] == mx_h && sum_w[data[i].second] == mx_w) {
            sum--;
        }
    }
    int ans = mx_h + mx_w;
    if (sum != 0) cout << ans << endl;
    else cout << ans - 1 << endl;
}

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


class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main() {
    Radix r;
    // 10 進数を n 進文字列に
    ll num=0;
    int sin=0;
    cin>>num>>sin;
    string ans;
    ans=r.to(num, sin);
    cout<<ans.size()<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <math.h>
#define MODD 1000000007
#define MAXN 120000
#define ll long long
using namespace std;

ll A[11111];
ll B[11111];

int main() {
    
    int N;
    cin>>N;
    for(int i=1;i<=N;i++)
        cin>>A[i];
    for(int i=1;i<=N;i++)
        cin>>B[i];
    
    
    ll Sc = 0;
    ll minksum = 0;
    for(int i=1;i<=N;i++) {
        // A[i]+2*k,B[i]+p
        
        
        // p = A[i]-B[i]+2*k
        
        // C[i]=A[i]-B[i];
        // (k,C[i]+2*k)
        
        
        //printf("k vs %lld+2*k\n",A[i]-B[i]);
        
        // C[i]+2*k >= 0
        // 2*k >= B[i]-A[i]
        //printf("minn is %lld\n",max(0ll,(B[i]-A[i]+1)/2));
        minksum += max(0ll,(B[i]-A[i]+1)/2);
        
        Sc += A[i]-B[i];
    }
    
    //printf("minn=%lld %lld\n",minksum,-Sc);
    
    // Sc+2*Sp=Sp
    // Sp = -Sc
    ll Sp = -Sc;
    if (Sp < minksum) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    
    
    
    
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

k,n = map(int, input().split())
a = list(map(int, input().split()))

diff = [a[i + 1] - a[i] for i in range(n - 1)]
diff.append(k - a[n - 1] + a[0])

ma = 0
for i in range(n):
    ma = max(ma, diff[i])

print(k - ma)


Measured memory_bytes: 31428
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;


void solve(long long K){
    queue<int> que;
    
    for(int i=1;i<10;i++)que.push(i);

    if(K<=10){
        cout<<K<<endl;
        return;
    }
    long long tmp=0;
    long long count=9;
    int A;
    while(count<K){
        tmp=que.front();
        que.pop();
        count++;
        A=tmp%10;
        if(A==0){
            //cout<<1;
            if(count==K)cout<<tmp*10+A<<endl;
            que.push(tmp*10+A);
            count++;
            if(count==K)cout<<tmp*10+A+1<<endl;
            que.push(tmp*10+A+1);
        }else if(A==9){
            //cout<<2;
            if(count==K)cout<<tmp*10+A-1<<endl;
            que.push(tmp*10+A-1);
            count++;
            if(count==K)cout<<tmp*10+A<<endl;
            que.push(tmp*10+A);
        }else{
            //cout<<3;
            if(count==K)cout<<tmp*10+A-1<<endl;
            que.push(tmp*10+A-1);
            count++;
            if(count==K)cout<<tmp*10+A<<endl;
            que.push(tmp*10+A);
            count++;
            if(count==K)cout<<tmp*10+A+1<<endl;
            que.push(tmp*10+A+1);
        }
        
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 512
n=int(input())
a,b,c=[list(map(int,input().split())) for _ in range(3)]
s=sum(b)
add_s=0
for i in range(n-1):
      if a[i]==a[i+1]-1:
            add_s+=c[a[i]-1]
print(s+add_s)


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

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

void sub()
{
    const auto X(cin2var<size_t>());
    cout << "ai1333" << string(X / 100, '3') << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N),b(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    b.at(i)=a.at(i);
  }
  sort(b.begin(),b.end());
  int Bmmi=b.at(N/2-1);
  int Bmmx=b.at(N/2);
  for(int i=0;i<N;i++){
    int L=a.at(i);
    if(L<=Bmmi){
      cout << Bmmx;
    }else{
      cout << Bmmi;
    }
    cout << endl;
  }
}

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

using namespace std;

int a, b;
char A[2000], B[2000];
int dp[2001][2001][2];

int main() {
	cin >> a >> b;
	for (int i = 0; i < a; i++)cin >> A[i];
	for (int i = 0; i < b; i++)cin >> B[i];
	int Max = 0;
	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			if (i < a) {
				if (A[i] == 'I')dp[i + 1][j][0] = max(dp[i][j][1] + 1, dp[i + 1][j][0]);
				else if(A[i] == 'O' && dp[i][j][0])dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][0] + 1);
			}
			if (j < b) {
				if (B[j] == 'I')dp[i][j + 1][0] = max(dp[i][j + 1][0], dp[i][j][1] + 1);
				else if(B[j] == 'O' && dp[i][j][0]) dp[i][j + 1][1] = max(dp[i][j + 1][1], dp[i][j][0] + 1);
			}
			ans = max(ans, dp[i][j][0]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34372
#include <iostream>
using namespace std;
string check(int a)
{
	int arr[] = {1,2,3,5,6,9,10,13,17};
	for(int i = 0; i < sizeof arr/sizeof arr[0]; i++)
		if( a == arr[i] )
			return "No";
	return "Yes";
}
int main()
{
	int a;
	cin >> a;
	cout << check( a % 28 );
}

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

int main(){
    string s; cin >> s;
    string ans = "";

    rep(i, s.size()) ans += 'x';
    cout << ans << 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;
using P = pair<int,int>;
using ll = long long;
int main() {
    string s, t;
    cin >> s >> t;
    int sum = 0;
    rep(i, s.length()){
        if(s[i] != t[i]) ++sum;
    }
    cout << sum << endl;
}



Measured memory_bytes: 3880
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<P> r((size_t) n, P(0, 0)), b((size_t) n, P(0, 0));
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        r[i] = P(x, y);
    }
    sort(r.begin(), r.end());
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        b[i] = P(x, y);
    }
    sort(b.begin(), b.end());

    int ans = 0;
    vector<bool> used((size_t)n, false);
    for (int i = 0; i < n; ++i) {
        int bx = b[i].first, by = b[i].second;

        int pi = n;
        for (int j = 0; j < n; ++j) {
            int rx = r[j].first, ry = r[j].second;
            if (rx < bx && ry < by && !used[j]){
                if (pi == n || r[pi].second < ry) pi = j;
            }
        }

        if (pi != n){
            ++ans;
            used[pi] = true;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, n;
	cin >> h >> n;
	vector<int> dp(h + 1, MOD);
	dp[0] = 0;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		rep(j, h) {
			int nj = min(j + a, h);
			dp[nj] = min(dp[nj], dp[j] + b);
		}
	}
	cout << dp[h];
}



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

#define REP(i,j) for(int i=0;i<j;i++)
#define REPR(i,j) for(int i=j;i>=0;i--)
#define FOR(i,j,k) for(int i=j;i<k;i++)

int main(){
    int A = 0;
    int N;
    scanf("%d",&N);
    int a[N];
    REP(i,N){
        scanf("%d",&a[i]);
    }
    while (1){
        REP(i,N){
            if(a[i]%2 != 0){
                cout << A << "\n";
                return 0;
            }else{
                a[i] = a[i] / 2;
            }
        }
        A++;
    }
}

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

struct StronglyConnectedComponents {
    int sz;
    vector <vector <int>> G, rG;
    vector <pair <int, int>> edges;
    vector <int> vs, used, root;
    int numOfVertexAfterSCC = -1;

    StronglyConnectedComponents ( int v )
        : sz( v ), G( v ), rG( v ), used( v, 0 ), root( v, -1 ) {}

    int operator [] ( int i ) {
        if ( numOfVertexAfterSCC == -1 ) scc();
        return root[i];
    }

    void add_edge( int from, int to ) {
        G[from].push_back( to );
        rG[to].push_back( from );
        edges.emplace_back( from, to );
    }

    void dfs( int v ) {
        if ( used[v] ) return;
        used[v] = true;
        for ( auto & i : G[v] ) dfs( i );
        vs.push_back( v );
    }

    void rdfs( int v, int k ) {
        if ( root[v] != -1 ) return;
        root[v] = k;
        for ( auto & i : rG[v] ) rdfs( i, k );
    }

    int scc() {
        if ( numOfVertexAfterSCC != -1 ) return numOfVertexAfterSCC;
        for ( int i = 0; i < sz; i++ ) dfs( i );
        numOfVertexAfterSCC = 0;
        reverse( vs.begin(), vs.end() );
        for ( auto & i : vs ) if ( root[i] == -1 ) rdfs( i, numOfVertexAfterSCC++ );
        return numOfVertexAfterSCC;
    }

    vector <vector <int>> getDAG() {
        vector <vector <int>> res( scc() );
        set <pair <int, int>> connect;
        for ( auto & i : edges ) {
            int from = root[i.first], to = root[i.second];
            if ( from == to ) continue;
            if ( connect.count( { from, to } ) ) continue;
            res[from].push_back( to );
            connect.emplace( from, to );
        }
        return res;
    }
};

int main() {
    int v, e;
    cin >> v >> e;
    StronglyConnectedComponents G( v );

    rep (i, e) {
        int s, t;
        cin >> s >> t;
        G.add_edge( s, t );
    }

    int q;
    cin >> q;

    rep (i, q) {
        int u, v;
        cin >> u >> v;
        cout << ( G[u] == G[v] ) << endl;
    }

    return 0;
}


Measured memory_bytes: 4644
#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>;

void Main()
{
  int N, K; cin >> N >> K;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  sort(p.begin(), p.end());
  int amount = 0;
  rep(i,K) amount += p[i];
  cout << amount << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3660
h, w = map(int, input().split())

grid = []
for _ in range(h):
    x = input()
    if x.count(".") != len(x):
        grid.append(x)

grid = list(map(list, zip(*grid)))

grid_t = []
for g in grid:
    if g.count(".") != len(g):
        grid_t.append(g)

ans = list(map(list, zip(*grid_t)))

for a in ans:
    print("".join(a))

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    const ll MOD = 1e9+7;
    int n;
    cin >> n;
    ll s = 0, s2 = 0;
    FOR(i, n){
        ll ai;
        cin >> ai;
        s += ai;
        s2 += ai*ai % MOD;
    }

    s %= MOD;
    s2 %= MOD;
    ll sol = s*s%MOD - s2;
    sol += MOD * (sol < 0);
    sol = sol * (MOD+1)/2;
    sol %= MOD;
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3656
import Control.Monad

main :: IO ()
main = do
  t <- readLn
  if t == 0
    then return ()
    else do
      n <- readLn
      ls <- replicateM n getLine
      let ls' = map (map read . words) ls
      putStrLn $ solve t ls'
      main

solve :: Int -> [[Int]] -> String
--solve t []
--  | t <= 0 = "OK"
--  | otherwise = show t
--solve t ([a,b]:xs)
--  | t <= 0 = "OK"
--  | otherwise = solve (t - (b - a)) xs
solve t ls
  | sumLs >= t = "OK"
  | otherwise = show (t - sumLs)
  where
    sumLs = sumOf ls
    sumOf :: [[Int]] -> Int
    sumOf [] = 0
    sumOf ([a,b]:r) = (b - a) + (sumOf r)

Measured memory_bytes: 4064
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

vector<int> divisor[100001];
int cnt[100001];
bool f[100001];

int main() {
  const int N = 100000;
  for (int i=1; i<=N; ++i) {
    for (int j=i; j<=N; j+=i)
      divisor[j].push_back(i);
  }
  int w,n;
  while(cin>>n>>w) {
    int ans = w;
    for (int i=1; i<=w; ++i) {
      f[i] = 1;
      FOR(it, divisor[i]) {
        if (++cnt[*it] == 2 && !f[i]) ans++;
      }
    }
    cout << ans;
    for (int i=1; i<=n-w; ++i) {
      f[i+w] = 1;
      ans++;
      FOR(it, divisor[i])
        if (--cnt[*it] == 1 && !f[*it]) ans--;
      FOR(it, divisor[i+w])
        if (++cnt[*it] == 2 && !f[*it]) ans++;
      f[i] = 0;
      if (cnt[i] < 2) ans--;
      cout << " " << ans;
    }
    cout << endl;
  }
}

Measured memory_bytes: 12048
N = int(input())
ab = [[0, 0]] + [list(map(int, input().split())) for i in range(N)]
ab = sorted(ab, key=lambda x: x[1])
for i in range(len(ab) - 1):
    ab[i + 1][0] += ab[i][0]
    if ab[i + 1][1] < ab[i + 1][0]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 55064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Card {
  String suit;
  int value;
  int storedNo;

  public Card( String suit, int value, int storedNo ) {
    this.suit  = suit;
    this.value = value;
    this.storedNo = storedNo;
  }
  public Card( Card card ) {
    this(card.suit, card.value, card.storedNo);
  }

  @Override
  public String toString() {
    return suit + String.valueOf(value);
  }
}

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Card[][] cards = new Card[2][n];
      String[] line = br.readLine().split(" ");
      for (int i=0; i < n; i++) {
        cards[0][i] = new Card(
          line[i].substring(0, 1),
          Integer.parseInt(line[i].substring(1)),
          i );
        cards[1][i] = new Card(cards[0][i]);
      }

      bubbleSort(cards[0], n);
      dispIntArray(cards[0]);
      System.out.println(isStableSorted(cards[0], n) ? "Stable" : "Not stable");
      selectionSort(cards[1], n);
      dispIntArray(cards[1]);
      System.out.println(isStableSorted(cards[1], n) ? "Stable" : "Not stable");
    }
  }

  static int bubbleSort(Card[] a, int n) {
    int count=0;
    Card t;

    for(int i=0,f=1; f==1 || i<n; i++ ) {
      f=0;
      for(int j=n-1; j>0; j-- ) {
        if( a[j].value < a[j-1].value) {
          t = a[j]; a[j] = a[j-1]; a[j-1] = t;
          count++;
          f=1;
        }
      }
    }

    return count;
  }

  static int selectionSort(Card a[], int n) {
    int count = 0;
    Card t;

    for(int i=0,min; i<n-1; i++ ) {
      min = i;
      for(int j=i+1; j<n; j++ ) {
        if( a[min].value > a[j].value) min = j;
      }
      if( min != i ) {
        t = a[i]; a[i] = a[min]; a[min] = t;
        count++;
      }
    }

    return count;
  }

  static boolean isStableSorted(Card[] sorted, int n) {
    boolean ret = true;

    for (int i=0, max=n-1; i < max; i++) {
      if( sorted[i].value == sorted[i+1].value
        && sorted[i].storedNo > sorted[i+1].storedNo )
        ret = false;
    }

    return ret;
  }

  public static void dispIntArray(Card[] a) {
    StringBuilder s = new StringBuilder();

    for (Card c : a) { s.append(c.toString()).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 24392
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
int main(){
  int n;
  scanf("%d", &n);
  std::vector<int > v(n);
  for (int i=0; i<n; i++){
    scanf("%d", &v[i]);
  }
  std::vector<int > A0(100005, 0);
  std::vector<int > A1(100005, 0);
  int even = 0;
  int odd = 0;
  for (int i=0; i<n; i=i+2){
    A0[v[i]]++;
    even++;
  }
  for (int i=1; i<n; i=i+2){
    A1[v[i]]++;
    odd++;
  }
  auto itr = std::max_element(A0.begin(), A0.end());
  int maxentry_0 = int(itr-A0.begin());
  int maxcount_0 = A0[int(itr-A0.begin())];
  itr = std::max_element(A1.begin(), A1.end());
  int maxentry_1 = int(itr-A1.begin());
  int maxcount_1 = A1[int(itr-A1.begin())];
  //  printf("maxentry_0=%d\n", maxentry_0);
  //printf("maxcount_0=%d\n", maxcount_0);
  //printf("maxentry_1=%d\n", maxentry_1);
  //printf("maxcount_1=%d\n", maxcount_1);
  int ans;
  if (maxentry_0!=maxentry_1){
    ans = even - maxcount_0 + odd - maxcount_1;
  } else {
    A0[maxentry_0] = 0;
    A1[maxentry_1] = 0;
    itr = std::max_element(A0.begin(), A0.end());
    int maxentry2_0 = int(itr-A0.begin());
    int maxcount2_0 = A0[int(itr-A0.begin())];
    itr = std::max_element(A1.begin(), A1.end());
    int maxentry2_1 = int(itr-A1.begin());
    int maxcount2_1 = A1[int(itr-A1.begin())];
    ans = std::min(even-maxcount2_0+odd-maxcount_1,
                   even-maxcount_0+odd-maxcount2_1);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>


int main() {
	std::string str; std::cin >> str;
	if (std::count(str.begin(), str.end(), '7') == 0) {
		std::cout << "No\n";
	}
	else {
		std::cout << "Yes\n";
	}
}

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

using namespace std;
int main(){
    int i=0,count=0;
    string forecast;
    string actual;
    getline (cin, forecast);
    getline (cin, actual);
    
    for(i=0;i<3;i++){
        char ch1=forecast.at(i);
        char ch2=actual.at(i);
        if(ch1==ch2){
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,fa[100010],a[100010],b[100010];
vector<int> v[100010];
ll s[100010];
inline int getf(int x)
{
	return x==fa[x]?x:fa[x]=getf(fa[x]);
}
inline void merge(int x,int y)
{
	x=getf(x);y=getf(y);
	fa[x]=y;
	if(x!=y)s[y]+=s[x];
}
pair<int,int> p[100010];
bool flag[100010];
ll f[100010];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		p[i]=make_pair(a[i]-b[i],i);
	}
	sort(p+1,p+n+1);
	for(int i=1,a,b;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=n;i++)
	{
		int pos=p[i].second;
		f[pos]=max(a[pos]-b[pos],0);
		s[pos]=b[pos];
		for(int &x:v[pos])
		{
			if(flag[x])
			{
				int t=getf(x);
				f[pos]=min(f[pos],max(f[t],a[pos]-b[pos]-s[t]));
			}
		}
		for(int &x:v[pos])
			if(flag[x])merge(x,pos);
		flag[pos]=1;
	}
	printf("%lld\n",f[p[n].second]+s[p[n].second]);
	return 0;
}

Measured memory_bytes: 9468
N,U,V=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N-1)]
inf=10**20
c=[[] for i in range(N)]
for u,v in AB:
    c[u-1].append(v-1)
    c[v-1].append(u-1)
from heapq import heappop,heappush
def dij(c,N,s):
    d=[inf]*N
    d[s]=0
    prev=[-1]*N
    q=[]
    heappush(q,(0,s))
    while q:
        u=heappop(q)[1]
        for v in c[u]:
            temp=d[u]+1
            if d[v]>temp:
                d[v]=temp
                prev[v]=u
                heappush(q,(d[v],v))
    return d
d1=dij(c,N,U-1)
d2=dij(c,N,V-1)
r=0
for i in range(N):
    if d1[i]<d2[i]:
        r=max(r,d2[i]-1)
print(0 if len(c[U-1])==1 and c[U-1][0]==V-1 else r)

Measured memory_bytes: 103000
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

ll n,a[100010],sum[100010];

ll f(ll x){
	bool can=true;
	ll tmp = sum[x+1];
	reg(i,x+1,n-1){
		if(tmp*2>=a[i]){
			tmp+=a[i];
		}else{
			can=false;
			break;
		}
	}
	return can;
}


int main(void){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	sum[0]=0;
	rep(i,n)sum[i+1]=sum[i]+a[i];//sum[i]=0..i-1の和
	ll r=n-1,l=-1;//r:絶対できる,l:絶対できない
	while(r-l>1){
		ll mid=(r+l)/2;
		if(f(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	cout<<(n-r)<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;
 
#define ll long long
 
#define pii pair<int,int>
/**==Info==
*Program:2
*Problem:Small Mutilple
*Date:2017-11-18
*Algorithm:Dijkstra
*Stats:Unknown*/
 
bool debug=false;
template<typename T> struct pq_small{
	priority_queue<T,vector<T>,greater<T> > pq;
	void push(T x){
		pq.push(x);
	}
 
	void pop(){
		pq.pop();
	}
 
	int size(){
		return pq.size();
	}
 
	bool empty(){
		return pq.empty();
	}
 
	T top(){
		return pq.top();
	}
};
 
bool visit[205][100005];
 
int main(int argc,char* argv[]){
	int k;
	cin>>k;
	pq_small<pii> pq; //{The sum of numbers,the mod>
	pq.push(make_pair(1,1));
	int mn=1e9;
	
	while(!pq.empty()){
		pii last=pq.top();
		//cout<<last.first<<" "<<last.second<<endl;
		pq.pop();
		if(last.first>mn) continue;
		if(visit[last.first][last.second]) continue;
		visit[last.first][last.second]=true;
		if(last.second==0){
			mn=min(mn,last.first);
		}
		//x10
		if(!visit[last.first][last.second*10%k]){
			pq.push(make_pair(last.first,last.second*10%k)); 
		}
		//+1
		if(!visit[last.first+1][(last.second+1)%k]){
			pq.push(make_pair(last.first+1,(last.second+1)%k));
		}
	}
	
	cout<<mn;
	return 0;
}

Measured memory_bytes: 6016
#include<cstdio>
#include<cmath>
#include<algorithm>
#define neko 100010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
int n,m,t,ciru,cirv,ans,tp,flag;
struct node
{int v,nex;}e[neko<<1];
typedef int arr[neko];
arr num,dep,head,fa,s;
void add(int x,int y)
{
	e[++t].v=y,e[t].nex=head[x],head[x]=t;
	e[++t].v=x,e[t].nex=head[y],head[y]=t;
}
void dfs(int u)
{
	num[u]=((dep[u]=dep[fa[u]]+1)&1)?1:-1;
	for(register int i=head[u],v=e[i].v;i;i=e[i].nex,v=e[i].v)
	{
		if(v^fa[u])
		{
			if(dep[v]){if(!flag)ciru=u,cirv=v,flag=1;}
			else fa[v]=u,dfs(v),num[u]+=num[v];
		}
	}
}
void solve_odd()
{
	if(num[1]&1){ans=-1;return;}
	int fix=-num[1]/2,x;
	ans=abs(fix);
	for(x=ciru;x;x=fa[x])num[x]+=fix;
	for(x=cirv;x;x=fa[x])num[x]+=fix;
	f(i,1,n)ans+=abs(num[i]);
}
void solve_even()
{
	if(num[1]){ans=-1;return;}
	for(int x=ciru;x^cirv;x=fa[x])s[++tp]=num[x],dep[x]=0;
	//网上一些Solution没flag标记，可能最终会导致最后找到的那条环边一定是从上往下的，所以他们写的从cirv跳到ciru才是正确的。
	int mid=(tp+1)>>1,now;
	std::nth_element(s+1,s+mid,s+tp+1);
	if(tp&1)now=s[mid];
	else now=(s[mid]+s[mid+1])/2;
	ans=abs(now);
	f(i,1,n)if(dep[i])ans+=abs(num[i]);
	f(i,1,tp)ans+=abs(s[i]-now);
}
int main()
{
	int x,y;
	scanf("%d%d",&n,&m);
	f(i,1,m)scanf("%d%d",&x,&y),add(x,y);
	dfs(1);
	if(m==n-1)if(num[1])ans=-1;else f(i,1,n)ans+=abs(num[i]);
	else if((dep[ciru]-dep[cirv]+1)&1)solve_odd();
	else solve_even();
	int xx[10]={0,1,4,2,3};
	return printf("%d\n",ans),0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    string ans = "No";
    for(auto c : s){
        if(c == '7'){
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
int N;
cin >> N;

int ans = 0;
REP(i, N) ans += i + 1;
print(ans);

}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  long long int h;
  scanf("%lld", &h);
  
  long long int i=1;
  long long int s=0;
  while(h!=1){
	s+=i;
    i*=2;
    h/=2;
  }
  printf("%ld", s+=i);
  return 0;
}

Measured memory_bytes: 128
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 05/30/20 16:02:55
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<ll> A(n+1); for (auto& a:A) cin>>a;
  auto solve = [&]() -> ll {
    ll leaves = accumulate(A.begin(), A.end(), 0ll);
    auto l = leaves;
    ll w = 1;
    ll ans = 0;
    for (int d = 0; d <= n; d++) {
      ans += w;
      if (w < A[d])
        return -1;
      w -= A[d];
      l -= A[d];
      ll diff = l-w;
      if (diff == 0)
        continue;
      w += min(w, diff);
    }
    return ans;
  };
  cout << solve() << endl;

  return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    long long k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<int> was(n, -1);
    auto r = k;
    int cur = 0;
    int tm = 0;
    while (r > 0) {
        if (was[cur] == -1) {
            was[cur] = tm++;
        } else {
            if (r > n) {
                r %= tm - was[cur];
                continue;
            }
        }
        cur = a[cur];
        r--;
    }
    cout << cur + 1 << endl;
}


Measured memory_bytes: 4784
s = input()
flg = True
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 'L':
            flg = False
    if i % 2 != 0:
        if s[i] == 'R':
            flg = False
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    n--;
    long long ans = (1 + n)*n;
    ans = ans/2;
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int A[251];

int main()
{
  int n, i;

  scanf("%d", &n);

  for (i = 1; i <= n; i++)
  {
    scanf("%d", &A[i]);
  }

  for (i = 1; i <= n; i++)
  {
    printf("node %d: ", i);
    printf("key = %d, ", A[i]);
    if (i != 1) printf("parent key = %d, ", A[i / 2]);
    if (i * 2 <= n) printf("left key = %d, ", A[i * 2]);
    if (i * 2 + 1 <= n) printf("right key = %d, ", A[i * 2 + 1]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2124
N, X = map(int, input().split())
ans = N
a, b = sorted((X, N - X))
while a != 0:
    if b % a == 0:
        ans += 2 * (b // a - 1) * a + a
        print(ans)
        break
    else:
        ans += 2 * (b // a) * a
        a, b = sorted((a, b % a))

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const long long mod=1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return a%b?gcd(b,a%b):b;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
int n;
cin>>n;
n*=2;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
sort(a.begin(),a.end());
int ans=0;
for(int i=0;i<n;i++){
  if(i%2==0)ans+=a.at(i);
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
/*  ex7_3
    B30095    */
#include <stdio.h>
#include <stdlib.h>

void print_compressed(char ** grid, int rows, int cols);

int main(void){
    int rows, cols, isRowEmpty, isColEmpty, i, j;
    char ** grid;
    
    scanf("%d %d", &rows, &cols);
    
    // memory allocation
    grid = (char **)malloc(rows * sizeof(char *));
    if(grid == NULL) return -1;
    for(i = 0; i < rows; i++){
        grid[i] = (char *)malloc(cols * sizeof(char));
        if(grid[i] == NULL) return -1;
    }

    // input grid
    for(i = 0; i < rows; i++){
        for(j = 0; j < cols; j++){
            scanf(" %c", &(grid[i][j]));
        }
    }

    print_compressed(grid, rows, cols);

    // memory deallocation
    for(i = 0; i < rows; i++){
        free(grid[i]);
    }
    free(grid);

    return 0;
}


void print_compressed(char ** grid, int rows, int cols){
    int isRowEmpty, isColEmpty, i, j;

        // substitue empty rows with whitespaces
    for(i = 0; i < rows; i ++){
        isRowEmpty = 1;
        
        // check if the row is empty
        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') {
                isRowEmpty = 0;
            }
        }

        // fill in empty rows with whitespaces
        if(isRowEmpty){
            for(j = 0; j < cols; j++){
                grid[i][j] = ' ';
            }
        }
    }

    // substitue empty columns with whitespaces
    for(j = 0; j < cols; j ++){
        isColEmpty = 1;
        
        // check if the column is empty
        for(i = 0; i < rows; i++){
            if(grid[i][j] == '#') {
                isColEmpty = 0;
            }
        }

        // fill in empty columns with whitespaces
        if(isColEmpty){
            for(i = 0; i < rows; i++){
                grid[i][j] = ' ';
            }
        }
    }


    // print compressed result
    for(i = 0; i < rows; i++){
        isRowEmpty = 1;

        for(j = 0; j < cols; j++){
            if(grid[i][j] == '#') isRowEmpty = 0;
            if(grid[i][j] != ' ') printf("%c", grid[i][j]);
            
        }

        if(!isRowEmpty) printf("\n");  // new line should not be printed when the row is empty
    }
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue<long long int> 
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;


int main()
{
    flash;
    ll T=1,n,q,k,i,j;
    while(T--)
    {
        cin>>n;
        ll sum = 100;
        FOR(i,1,10000)
        {
            sum += (sum/100);
            if(sum>=n)
                break;
        }
        cout<<i<<endl;
    }
}

Measured memory_bytes: 3660
n = int(input())
ll = [list(input().split()) for _ in range(n)]
x = input()

spl = 0
ti = 0
flg = 0

for l in ll:
    if flg == 1:
        ti += int(l[1])
    if l[0] == x:
        flg = 1


print(ti)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int X, D;
	cin >> X >> K >> D;
	if (X < 0)
		X = -X;
	int M = X / D;
	M = min(M, K);
	K -= M;
	X -= M * D;
	if (K & 1)
		X = X - D;
	cout << abs(X) << endl;
	return 0;
}

Measured memory_bytes: 3636
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

vector<int>mm[40];
vector<int>B;
int n,m,c;

int go(){
	int cc=0;
	FER(i,0,n){
		int sum=c;
		FER(j,0,m)sum+=B[j]*mm[i][j];
		if(sum>0)cc++;
	}
	return cc;
}

int main(){	
	fastio;
	cin>>n>>m>>c;
	FER(i,0,m){
		int k;cin>>k;
		B.pb(k);
	}
	FER(i,0,n){
		FER(j,0,m){
			int k;cin>>k;
			mm[i].pb(k);
		}
	}
	cout<<go()<<endl;

	return 0;
}


Measured memory_bytes: 256
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int t = 1;
    while (a > 0 && c > 0) {
        if (t) {
            c -= b;
        } else {
            a -= d;
        }
        t = !t;
    }
    if (a <= 0) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int main(){
	string s;
	cin >> s;
	int nn = 0, sn = 0, en = 0, wn = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'N') nn++;
		if(s[i] == 'S') sn++;
		if(s[i] == 'W') wn++;
		if(s[i] == 'E') en++;
	}
	if(!(nn == 0 ^ sn == 0) && !(wn == 0 ^ en == 0)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m = list(map(int,input().split()))
graph = [[] for _ in range(n+1)]
for i in range(m):
    a, b = list(map(int,input().split()))
    graph[a].append(b)
    graph[b].append(a)
# print(graph)
arrow = [-1]*(n+1)
d = deque()
d.append(1)

while d:
    v = d.popleft()
    for i in graph[v]:
        if arrow[i]!=-1:
            continue
        arrow[i] = v
        d.append(i)
    # print(dist)

print('Yes')
print(*arrow[2:], sep='\n')

Measured memory_bytes: 35496
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3 = (y1-y2) + x2,y3=-(x1-x2)+y2,x4=-(y2-y1)+x1,y4=(x2-x1)+y1;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 888
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
X = []
Y = []
for x, y in LIR(n):
    X += [x]
    Y += [y]


ret = 0
for pat in list(permutations((range(n)))):
    for i in range(len(pat) - 1):
        ret += ((X[pat[i]] - X[pat[i + 1]]) ** 2 + (Y[pat[i]] - Y[pat[i + 1]]) ** 2) ** 0.5

print(ret / factorial(n))




Measured memory_bytes: 48368
#include <stdio.h>
 
 int main() {
 	int sideA, sideB, sideC, luas;
 	scanf("%d", &sideA);
 	scanf("%d", &sideB);
 	scanf("%d", &sideC);
 	
 	luas = sideA*sideB / 2;
 	printf("%d", luas);
 	return 0;
 }

Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
// #define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+2;
const int M=1e9+7;
int dp[N][3][3][3];
int n,a,b,c;
string s[N];
int go(int idx,int aa,int bb,int cc)
{
  if(aa<0 || bb<0 || cc<0)
  return 0;
  if(idx==n+1){
    return 1;
  }
  int &ans=dp[idx][aa][bb][cc];
  if(ans!=-1)
  return ans;
  ans=0;
  if(s[idx]=="AB")
  {
    int pp=bb+1,qq=aa+1;
    if(bb+1>2)
    pp=2;
    if(aa+1>2)
    qq=2;
    ans=ans|(go(idx+1,aa-1,pp,cc));
    ans=ans|(go(idx+1,qq,bb-1,cc));
  }
  else if(s[idx]=="AC")
  {
    int pp=aa+1,qq=cc+1;
    if(aa+1>2)
    pp=2;
    if(cc+1>2)
    qq=2;
    ans=ans|(go(idx+1,aa-1,bb,qq));
    ans=ans|(go(idx+1,pp,bb,cc-1));
  }
  else
  {
    int pp=bb+1,qq=cc+1;
    if(bb+1>2)
    pp=2;
    if(cc+1>2)
    qq=2;
    ans=ans|(go(idx+1,aa,bb-1,qq));
    ans=ans|(go(idx+1,aa,pp,cc-1));
  }
  return ans;
}
void god(int idx,int aa,int bb,int cc)
{
  
  if(idx==n+1){
    return;
  }
  
  if(s[idx]=="AB")
  {
    int pp=bb+1,qq=aa+1;
    if(bb+1>2)
    pp=2;
    if(aa+1>2)
    qq=2;
    // ans=ans|(go(idx+1,aa-1,pp,cc));
    // ans=ans|(go(idx+1,qq,bb-1,cc));
    if(go(idx+1,aa-1,pp,cc))
    {
      cout<<"B"<<endl;
      god(idx+1,aa-1,pp,cc);
    }
    else
    {
      cout<<"A"<<endl;
      god(idx+1,qq,bb-1,cc);
    }
    
    
  }
  else if(s[idx]=="AC")
  {
    int pp=aa+1,qq=cc+1;
    if(aa+1>2)
    pp=2;
    if(cc+1>2)
    qq=2;
    // ans=ans|(go(idx+1,aa-1,bb,qq));
    // ans=ans|(go(idx+1,pp,bb,cc-1));
    if(go(idx+1,aa-1,bb,qq))
    {
      cout<<"C"<<endl;
      god(idx+1,aa-1,bb,qq);
    }
    else
    {
      cout<<"A"<<endl;
      god(idx+1,pp,bb,cc-1);
    }
  }
  else
  {
    int pp=bb+1,qq=cc+1;
    if(bb+1>2)
    pp=2;
    if(cc+1>2)
    qq=2;
    // ans=ans|(go(idx+1,aa,bb-1,qq));
    // ans=ans|(go(idx+1,aa,pp,cc-1));
    if(go(idx+1,aa,bb-1,qq))
    {
      cout<<"C"<<endl;
      god(idx+1,aa,bb-1,qq);
    }
    else
    {
      cout<<"B"<<endl;
      god(idx+1,aa,pp,cc-1);
    }
  }
  // return ans;
}
void solve()
{
  cin>>n>>a>>b>>c;
  f(i,1,n) cin>>s[i];
  a=min(a,2);
  b=min(b,2);
  c=min(c,2);
  memset(dp,-1,sizeof(dp));
  int res=go(1,a,b,c);
  if(res==false)
  {
    cout<<"No";
    return;
  }
  cout<<"Yes"<<endl;
  god(1,a,b,c);
  
}
signed main()  
{
  FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
      // cout<<"Case #"<<tc<<": ";
      solve();
    }
}


Measured memory_bytes: 25100