akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")
  
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>
  
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
  
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>
  
#include <memory.h>
#include <cassert>
#include <time.h>
  
using namespace std;
  
#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
  
#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
  
typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;
  
const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
  
#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif
  
void prepare(string s)
{
#ifdef MY_DEBUG
    freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
#else
    if (s.length() != 0)
    {
        freopen ((s + ".in").c_str(), "r", stdin);
        freopen ((s + ".out").c_str(), "w", stdout);
    }
#endif
}

string s, t;

void read() {
  cin >> s >> t;
}

void solve() {
  if (s.length() + 1 == t.length()) {
    if (t.substr(0, s.length()) == s) {
      puts("Yes");
      return;
    }
  }
  puts("No");
}

int main() {
  prepare("");

  read();
  solve();
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#define sz(x) ((int)(x).size())
#define mp make_pair
#define full(a) a.begin(), a.end()
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5;

void solve()
{
    int n; cin >> n;
    int res = 0;
    for (int c = 1; c < n; c++)
    {
        int num = n - c;
        for (int j = 1; j * j <= num; j++)
        {
            if (num % j == 0)
            {
                if (num / j == j) res++;
                else res += 2;
            }
        }
    }
    cout << res;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
    /*int tc; cin >> tc;
    while (tc--)*/
        solve();

    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<functional>
using namespace std;
int main() {
	int h,w;
	bool field[20][20];
	int dp[20][20];
	int n;
	while(scanf("%d%d",&w,&h)){
		if(w + h == 0)break;
		scanf("%d",&n);
		for(int i = 0; i < 20; i++){
			for(int j = 0; j < 20; j++){
				field[i][j] = 0;
				dp[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++){
			int x,y;
			scanf("%d%d",&x,&y);
			field[y][x] = 1;
		}
		dp[1][1] = 1;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				if(!field[i][j]) dp[i][j] += dp[i-1][j] + dp[i][j-1];
			}
		}
		printf("%d\n",dp[h][w]);
	}
    return 0;
}

Measured memory_bytes: 1188
function Main(input) {
	tmp = input.split("\n");
	var n = parseInt(tmp[0]);
	var w = tmp[1].split(" ");
	var min = 0;
	for(var i = 1; i < n; i++) {
		var ts1 = 0;
		var ts2 = 0;
		for(var j = 0; j < n; j++) {
			if(j <= i){
				ts1 += parseInt(w[j]);
			}else{
				ts2 += parseInt(w[j]);
			}
		}
		if(i == 1 || Math.abs(ts1-ts2) <= min){
			min = Math.abs(ts1-ts2);
		}	
	}
	console.log(min);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

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

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	double a, b, x; cin >> a >> b >> x;
	x /= a;
	if (x > a*b/2) {
		cout << atan(2 * (a*b - x) / (a*a)) * 180 / M_PI << endl;
	} else {
		cout << atan((b*b) / (2*x)) * 180 / M_PI << endl;	
	}
}

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


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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

class DisjointSet
{
private:
    int forestNum;
    vector<int> pa, sz;
public:
    void init(int n)
    {
        forestNum = n;
        pa.resize(n);
        sz.resize(n);
        for(int i = 0; i < n; i++)
        {
            pa[i] = i, sz[i] = 1;
        }
    }
    int findrt(int x) 
    {
        if(pa[x] == x) return x;
        else return pa[x] = findrt(pa[x]);
    }
    bool same(int x, int y) { return findrt(x) == findrt(y); }
    void uni(int x, int y)
    {
        x = findrt(x), y = findrt(y);
        if(x == y) return;
        forestNum--;
        if(sz[x] > sz[y]) swap(x, y);
        pa[x] = y;
        sz[y] += sz[x];
    }
    int ccNum() { return forestNum; }
};

int n, m;
DisjointSet ds;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> m;
    ds.init(n);
    while(m--)
    {
        int a, b, c; cin >> a >> b >> c;
        ds.uni(a, b);
    }
}

void process()
{
    cout << ds.ccNum() << endl;
}



Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long ll;
typedef pair<ll,ll> p;

ll transaction(ll n, vector<p> ls){
  ll res = 0;
  switch(ls.size()){
    case 0: return n;
    case 1: return n/ls[0].first*ls[0].second+n%ls[0].first;
    case 2:
    REP(i,n/ls[0].first+1){
      res = max(res,i*ls[0].second+(n-i*ls[0].first)/ls[1].first*ls[1].second+(n-i*ls[0].first)%ls[1].first);
    }
    return res;
    case 3:
    REP(i,n/ls[0].first+1) REP(j,(n-i*ls[0].first)/ls[1].first+1){
      ll sum = n - i*ls[0].first-j*ls[1].first;
      res = max(res,i*ls[0].second+j*ls[1].second+sum/ls[2].first*ls[2].second+sum%ls[2].first);
    }
    return res;
  }
  return res;
}

int main(){
  ll n; cin >> n;
  p trans[3];
  REP(i,3) cin >> trans[i].first;
  REP(i,3) cin >> trans[i].second;

  vector<p> ab,ba;
  REP(i,3){
    if(trans[i].first<trans[i].second) ab.push_back(trans[i]);
    else{
      swap(trans[i].first,trans[i].second);
      ba.push_back(trans[i]);
    }
  }

  cout << transaction(transaction(n,ab),ba) << endl;

  return 0;
}


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

//#define int long long
#define DEBUG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

//??¶?´?????????£???????????? int:INF ll:INFL
#define INFG INFL
using Weight = ll;//int;

class Edge {
public:
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s = 0, int d = 0, Weight w = INFG) : s(s), d(d), w(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
//???????????\: g[u].push_back(Edge(u, v, c));
//????????¨???????????????????????°??????????????\?????????????????????
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;


//??????????????????????????? O(E+V)
//??\?¬???°???0????????¨???????????????????????????ret????????£??????
vector<int> topologicalSort(const Graph &g) {
	int n = g.size(), k = 0;
	vector<int> ord(n), indeg(n); //??\?¬???°
	for (auto &es : g) for (auto &e : es) indeg[e.d]++;
	queue<int> Q;
	for (int i = 0; i < n; i++) if (indeg[i] == 0) Q.push(i);
	while (!Q.empty()) {
		int v = Q.front(); Q.pop(); ord[k++] = v;
		for (auto &e : g[v]) if (--indeg[e.d] == 0) Q.push(e.d);
	}
	return *max_element(indeg.begin(), indeg.end()) == 0 ? ord : vector<int>();
}

signed main() {
	int m, n; cin >> m >> n;
	Graph g(m);
	rep(i, 0, n) {
		int x, y; cin >> x >> y; x--, y--;
		g[x].emplace_back(x, y);
	}
	vector<int> ans = topologicalSort(g);
	rep(i, 0, m) {
		cout << ans[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
from collections import deque
texts = deque(str(input()))
Q = int(input())


reverse = False
start_text = deque('')
end_text = deque('')
input_texts = []
for _ in range(Q):
    input_texts.append(list(input().split()))

for input_text in input_texts:
    if len(input_text) == 1:
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        if input_text[1] == '1':  # 先頭に
            if reverse:
                end_text.append(str(input_text[2]))
            else:
                start_text.appendleft(str(input_text[2]))
        else:  # 末尾に
            if reverse:
                start_text.appendleft(input_text[2])
            else:
                end_text.append(input_text[2])

# print(start_text, texts, end_text)
# print(''.join(texts))

texts.appendleft(''.join(start_text))
texts.append(''.join(end_text))
# print(''.join(texts))

# print(texts)
if reverse:
    texts = deque("".join(texts))
    texts.reverse()
    print("".join(texts))
else:
    # texts = start_text + texts + end_text
    print(''.join(texts))


Measured memory_bytes: 132696
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

  vector<bool> b(n, true);
  int on = 0;
  int cnt = 0;
  while(true) {
    cnt ++;
    if (a[on] == 2) {
      cout << cnt << endl;
      return 0;
    }
    if (b[on]) {
      b[on] = false;
      on = a[on] - 1;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
}


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

using namespace std;


struct day {
    long long a,b,c;
};

const int N = 1e5+2;
day dp[N];
int n;


int main(){
    ios_base::sync_with_stdio(0);

    cin >> n;
    
    long long x,y,z;
    for (int i=0; i<n; i++){

        day d;
        cin >> x >> y >> z;

        d.a=x; d.b=y; d.c=z;
        dp[i] = d;
    }

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

        day d;

        d.a = max(dp[i-1].b+dp[i].a, dp[i-1].c+dp[i].a);
        //cout << "d.a " << d.a << " ";
        d.b = max(dp[i-1].a+dp[i].b, dp[i-1].c+dp[i].b);
        //cout << "d.b " << d.b << " ";
        d.c = max(dp[i-1].b+dp[i].c, dp[i-1].a+dp[i].c);
        //cout << "d.c " << d.c << "\n";
        dp[i] = d;
    }

    long long one= dp[n-1].a, two=dp[n-1].b, three = dp[n-1].c;
    long long odp;
    odp = max(one, two);
    odp = max(odp,three);


    cout << odp;


}

Measured memory_bytes: 2560
s = input()


def dfs(pos, fm):
    if (pos >= len(s)):
        #print(pos, fm, eval(fm))
        return eval(fm)
    #print(pos, fm)
    return dfs(pos+1, fm+s[pos])+dfs(pos+1, fm+'+'+s[pos])


print(dfs(0, '')//2)

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll S; cin >> S;
  ll result = 0;

  c_fac();
  repr(i,1,S) {
    if (i*3>S) break;
    result = (result + nck(S-i*3+(i-1),i-1)) % MOD;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 11148
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, a[N];
vi G[N];

void DFS(int v, int p = 0){
	if (G[v].size() == 1) return;
	int sm = 0;
	int mx = 0;
	for (auto u:G[v]){
		if (u == p) continue;
		DFS(u, v);
		mx = max(mx, a[u]);	
		sm += a[u];
	}
	int Max = 0;
	if (mx > sm - mx){
		Max = sm - mx;
	}else{
		Max = sm / 2;	
	}
	if (sm < a[v]){
		cout << "NO";
		exit(0);
	}

	
	if (a[v] - (sm - a[v]) < 0){
		cout << "NO";
		exit(0);
	}
	if (Max < sm - a[v]){
		cout << "NO";
		exit(0);
	}
	a[v] -= sm - a[v];
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n - 1; i++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u);
		G[u].pb(v);
	}
	if (n == 2) return cout << (a[1] == a[2] ? "YES" : "NO"), 0;
	int root = 0;
	for (int i = 1; i <= n; i++){
		if (G[i].size() != 1){
			DFS(i);
			root = i;
			break;
		}
	}	
	return cout << (a[root] ? "NO" : "YES"), 0;










	return 0;
}


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

int a,b;

signed main(){
  int c=0;
  cin>>a>>b;
  for(int n=a;n<=b;n++){
    if (
      n/10000==n%10 &&
      n/1000%10==n/10%10
      ){
        c++;
      }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int ab = stdin.nextInt();
	    final int af = stdin.nextInt();
	    if ( ab == 0 && af == 0 ) {
		break;
	    }
	    int maxIndex = 0;
	    int maxSum = ab + af;
	    for ( int i = 1; i < 5; i++ ){
		final int sum = stdin.nextInt() + stdin.nextInt();
		if ( maxSum < sum ) {
		    maxIndex = i;
		    maxSum = sum;
		}
	    }
	    System.out.printf( "%c %d\n", ( char )( 'A' + maxIndex ), maxSum );
	}	
    }    
}

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


def solve(N: int):
    n = N % 10
    if n == 3:
        print("bon")
    elif n == 0 or n == 1 or n == 6 or n == 8:
        print("pon")
    else:
        print("hon")
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a;
  cin>>n>>a;
  int cnt =1;
  int d=0;
  rep(i,n){
    int x;
    cin>>x;
    d+=x;
    if(d<=a)cnt++;
  }
  cout<<cnt<<endl;
}



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

//コンビネーションを求める関数
ll nck(ll n, ll k){
    
    ll p=1000000007;
    ll p2;
    p2=p-2;
    vector <int> r(35);
    vector <ll> r2(36);

    rep(j,35){
        r[j]=(p2>>j)&1;
    }

    ll ans;
    ans=1;

    if (k!=0){
    rep(i,k-1){   
        r2[0]=i+2;
        rep(j,35){
           
            r2[j+1]=(r2[j]*r2[j])%p;
            if(r[j]==1){
            ans*=r2[j];
            ans=ans%p;
            }
        }
    }
    rep(i,k){
        ans*=n-i;
        ans=ans%p;
    }
    }
    return ans;
}

int main(){
    int s,s2;
    cin >> s;
    s2=s;
    ll ans=0;
    ll mod=1e9+7;

    rep(i,s){
        s2=s;
        if(i==0){
            continue;
        }
        else{
            s2-=3*i;
            if(s2<0){
                break;
            }
            ans+=nck(s2+i-1,i-1);
            ans=ans%mod;

        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3612
while True:
    arr = input().split()
    H = int(arr[0])
    W = int(arr[1])

    if H == 0 and W == 0:
        break
    else:
        s = ''
        for j in range(W):
            s += '#'
        for i in range(H):
            print(s)

        print('')



Measured memory_bytes: 5608
def main():
    from collections import defaultdict
    n,m = map(int,input().split())
    G = defaultdict(set)
    for _ in range(m):
        a,b = map(int,input().split())
        G[a].add(b)
        G[b].add(a)

    flg = 0
    for i in G[1]:
        if n in G[i]:
            flg = 1
    if flg == 1:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

main()

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

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

typedef long long ll;



int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N, vector<int>(N,0)), D(N,vector<int>(N,10001));
  REP(i,M){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    G[a][b] = G[b][a] = D[a][b] = D[b][a]= c;
  }
  REP(i, N){
    G[i][i] = D[i][i] = 0;
  }

  REP(i, N){
    REP(j, N){
      REP(k, N){
        D[j][k] = min(D[j][k], D[j][i]+D[i][k]);
      }
    }
  }
  int ans = 0;
  REP(i, N){
    REP(j, N){
      if(G[i][j] != 0 && G[i][j] != D[i][j]){
        ans++;
      }
    }
  }
  cout << ans/2 << endl;
  // cout << "G" << endl;
  // REP(i, N){
  //   REP(j, N){
  //     cout << G[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << "D" << endl;

  // REP(i, N){
  //   REP(j, N){
  //     cout << D[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {

  int c,d;
  int i,j,k;
  int  m,n;
  

  while (1) {

    scanf("%d",&n);
    //   printf("n = %d\n",n);
    if(n  == 0) break;

    char a[n+1], b[n+1];

    for(i=0;i<n;i++) {
      scanf(" %c",&a[i]);
      scanf(" %c",&b[i]);
  
      //    printf("a = %c || b = %c\n",a[i],b[i]);      
    }
    
    scanf("%d",&m);
    // printf("m = %d\n",m);

    char str[m+1];

    for(i=0;i<m;i++) {
      scanf(" %c",&str[i]);
      // printf("str[%d] = %c\n",i,str[i]);

      for(j=0;j<n;j++){
	if(str[i] == a[j]){
	  //  printf("str[%d](%c) => b[%d](%c)\n",i,str[i],j,b[j]);
	  str[i] = b[j];
	  break;
	}
      }
    }

    for(i = 0;i<m;i++) printf("%c",str[i]);
   
    printf("\n");


  }
  

  return 0;

}

Measured memory_bytes: 668
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;


int main() {

	string p;
	cin >> p;
	
	if (p[0] == '9' || p[1] == '9')cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a[30],i;
    while(~scanf("%d",&n))
    {
        int acm=0;
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(i=2;i<=n-1;i++)
            if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))
                acm++;
                printf("%d\n",acm);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y,z;
    cin >>x>>y>>z;
    int temp = x;
    x = y;
    y = temp;
    temp = x;
    x = z;
    z =temp;
    cout<< x<<" "<< y<< " "<<z;

  	return 0;

}

Measured memory_bytes: 256
//1.read question_2.read I/O_3.read test cases_4.read constraints(to decide TC of solution)_5.decide method_6.dry run_
//7.code_8.test_9.submit
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define _READ freopen("input.txt","r", stdin);
#define pb push_back
#define MP make_pair
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{

   // freopen("input.txt","r", stdin);
    lli n,t,i,j,k,ans=0,flag=0,a,b,m,w;
    string s1,s2;
    cin>>s1>>s2;n=s1.size();m=s2.size();
    vector<vector<lli>>dp(n+1,vector<lli>(m+1,0));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(s1[i-1]==s2[j-1])
            {
                dp[i][j]=
                dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=
                    max(dp[i-1][j],dp[i][j-1]);
            }
            ans=max(ans,dp[i][j]);
        }
    }
    k=ans;
    i=n;j=m;
    string S;
    while(k!=0)
    {
        if(dp[i-1][j-1]+1==dp[i][j] && s1[i-1]==s2[j-1])
        {
            k--;
            S.push_back(s1[i-1]);
            i--;j--;
        }
        else if(dp[i-1][j]==dp[i][j])
            --i;
        else if(dp[i][j-1]==dp[i][j])
            --j;
    }
    reverse(S.begin(),S.end());
    cout<<S;
    return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			long[] a = cin.ArrayLong(n);

			long[] a2 = a.OrderBy(x => x).ToArray();
			var dic = new Dictionary<long, int>(n);
			for (int i = 0; i < n; i++) {
				dic[a2[i]] = i;
			}
			
			int ans = 0;
			for (int i = 0; i < n; i++) {
				if (dic[a[i]] % 2 != i % 2) {
					ans++;
				}
			}

			Console.WriteLine(ans / 2);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 25556
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

#define INF 1000000000000

using namespace std;

long a[1001], b[1001];
int ability[1001];
long dp[1001][8192];

int main(void)
{
    int N, M;
    cin >> N >> M;
    int argmax = 0;
    for (int i = 0; i < N; i++)
    {
        argmax |= 1 << i;
    }
    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        ability[i] = 0;
        for (int j = 0; j < b[i]; j++)
        {
            int c;
            cin >> c;
            ability[i] = ability[i] | (1 << (c - 1));
        }
    }
    for (int i = 0; i < M; i++)
    {
        for (int j = 1; j <= argmax; j++)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][ability[0]] = a[0];
    // write dp
    for (int i = 1; i < M; i++)
    {
        if (a[i] < dp[i-1][ability[i]])
            dp[i][ability[i]] = a[i];
        for (int j = 1; j <= argmax; j++)
        {
            if (dp[i-1][j] < dp[i][j])
            {
                dp[i][j] = dp[i-1][j];
            }
        }
        for (int j = 1; j <= argmax; j++)
        {
            if (dp[i - 1][j] != INF)
            {
                if (dp[i-1][j] + a[i] < dp[i][j | ability[i]])
                    dp[i][j | ability[i]] = dp[i-1][j] + a[i];
            }
        }
    }
    if (dp[M-1][argmax] == INF) dp[M-1][argmax] = -1;
    cout << dp[M-1][argmax] << endl;
    return 0;
}

Measured memory_bytes: 63104
k, n = map(int, input().split())
lis = list(map(int, input().split()))
dislis = []
num_pre = lis[-1]
for num in lis:
    dislis.append(min(k-abs(num - num_pre),abs(num - num_pre)))
    num_pre = num

print(k-max(dislis))


Measured memory_bytes: 86348
import sys
input=sys.stdin.readline

def main():
    K = int(input())
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            return i
    return -1
ans =main()
print(ans)

Measured memory_bytes: 9176
/*
挺难的一个贪心。
*/
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 1e6+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int n;
string s;
vector<pii_> Pa,Pb,Pc;
int main()
{
    fastio();
    cin>>n;
    rep(i,1,n){
        cin>>s;
        int l=0,r=0;
        for(auto x:s){
            if(x=='(') l++;
            else{
                if(l) l--;
                else r++;
            }
        }
        if(l>r) Pa.pb(mp_(l,r));
        else if (l<r)Pb.pb(mp_(l,r));
        else Pc.pb(mp_(l,r));
    }
    sort(Pa.begin(),Pa.end(),[](pii_ a,pii_ b){return a.se<b.se;});
    sort(Pb.begin(),Pb.end(),[](pii_ a,pii_ b){return a.fi>b.fi;});
    int sum = 0;
    int flag = 1;
    int sza = Pa.size(),szb=Pb.size(),szc=Pc.size();
    rep(i,0,sza-1){
        sum -= Pa[i].se;
        if(sum<0) flag=0;
        sum += Pa[i].fi;
    }
    rep(i,0,szc-1){
        sum -= Pc[i].se;
        if(sum<0) flag=0;
        sum += Pc[i].fi;
    }
    rep(i,0,szb-1){
        sum -= Pb[i].se;
        if(sum<0) flag=0;
        sum += Pb[i].fi;
    }
    if(sum) flag=0;
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 11260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const ll INF = 100000000000100;

struct edge {
  int to, cost;
};
int n;                            //頂点数
vector<vector<edge>> graph(100010); //重み付きグラフ
vector<ll> d(100010, INF);          //最短距離
vector<bool> used(100010, false); //すでに使われたかのフラグ


void dfs(int depth, int p, ll dist){
  d[depth] = dist;
  for(auto e : graph[depth]){
    if(e.to == p) continue;
    dfs(e.to, depth, dist + e.cost);
  }
}

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  d[s] = 0;
  que.push(P(0, s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0; i < graph[v].size(); ++i){
      edge e = graph[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  cin >> n;
  rep(i, n - 1){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--; 
    graph[a].push_back(edge{b, c});
    graph[b].push_back(edge{a, c});
  }

  int q, k;
  cin >> q >> k;
  k--;
  //dijkstra(k);
  dfs(k, -1, 0);
  rep(i, q){
    ll x, y;
    cin >> x >> y;
    x--; y--;
    ll ans = 0;
    ans = d[x] + d[y];
    cout << ans << endl;
    //cout << d[x[i]] + d[y[i]] << endl;;
  }
  
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
Int comb(Int x, Int y)
{
    if (y == 0) return 1;
    if (x - y < y) return comb(x, x - y);
    return comb(x-1, y-1) * x / y;
}
int main()
{
    int N, A, B; cin >> N >> A >> B;
    vector<Int> V(N);
    for(auto& i : V) cin >> i;
    sort(V.begin(), V.end(), [](Int x, Int y){ return x > y; });
    Int sum = 0;
    REP(i, A) sum += V[i];
    int cnt = 0, cntin = 0;
    REP(i, N) if (V[i] == V[A-1]) cnt++;
    REP(i, A) if (V[i] == V[A-1]) cntin++;
    if (cntin == A) {
        Int c = 0;
        for (int i = A; i <= min(B, cnt); i++) c += comb(cnt, i);
        cout << V[0] << '\n' << c << endl;
    } else {
        cout << setprecision(20) << (1.0 * sum / A) << '\n' << comb(cnt, cntin) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;

    int main(){
      int n,k;
      cin>>n>>k;
      VEC(int,x,n);
      int res = INF;
      rep(i,n-k+1)res = min(res,abs(x[i]-x[i+k-1])+min(abs(x[i]),abs(x[i+k-1])));
      cout<<res<<endl;
    }


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int a,b,c;cin>>a>>b>>c;
    if(c-b==b-a)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	
	int i, res = 1;
	for (i = 1; i <= n; i++)
	{
		if (res + k <= res * 2)
		{
			res += k;
		}
		
		else
		{
			res *= 2;
		}
	}
	
	printf("%d\n", res);
	
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
int a[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	a[n] = INT_MAX;
	int ans = 0, i = 0;
	while(i < n){
		int j = i;
		while(a[j] >= a[j+1]) j++;
		DEBUG("[%d, %d]\n", i, j);
		LAR(ans, j-i);
		i = j + 1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
const ll mod = 998244353;
#define int ll
int n, W;
int w[102], v[102], dp[100002][2];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>W;
    for(int i=1; i<=n; i++)cin>>w[i]>>v[i];
    for(int i=1; i<=100000; i++) dp[i][0]=1e18;
    for(int i=1; i<=n; i++){
        for(int xd=v[i]; xd<=100000; xd++){
            dp[xd][1]=min(dp[xd][0], dp[xd-v[i]][0]+w[i]);
        }
        for(int xd=v[i]; xd<=100000; xd++){
            dp[xd][0]=dp[xd][1];
        }
    }
    for(int i=100000; i>=0; i--){
        if(dp[i][0]<=W) return cout<<i, 0;
    }
}


Measured memory_bytes: 1792
import numpy as np

def bfs(s,reached):
    ret = 0
    for i in grid[s]:
        if all(reached)==True:
            return 1
        if reached[i]==True:
            continue
        else:
            reached[i]=True
            ret += bfs(i,reached)
            reached[i]=False
    return ret

N,M = map(int,input().split())
# N,M=3,3

grid = [[] for i in range(N)]
for _ in range(M):
    a,b = map((int),input().split())
    grid[b-1].append(a-1)
    grid[a-1].append(b-1)
# print(grid)

#リーチドを示す
reached = []
for _ in range(N):
    reached.append(False)

#視点
reached[0]=True
s=0
ret = bfs(s,reached)
print(ret)

Measured memory_bytes: 12500
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)
#define ll long long
#define scout cout << fixed << setprecision(20)
ll INF = 9e17;
ll mod = 1e9 + 7;

int main() {
	int n,k; cin >> n >> k;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	int ans = 0;
	rep(i,n) {
		ans += (min(x[i],abs(x[i]-k)))*2;
	}
	cout << ans << endl;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;

int main(){
    LL n, k;
    scanf("%lld %lld", &n, &k);
    if(k >= n)
        printf("%lld\n", min(n, k-n));
    else
        printf("%lld\n", min(n%k, k-n%k));
    
return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
li = list(map(int,input().split()))

c = collections.Counter(li)

#print(c)
# Counter({'a': 4, 'c': 2, 'b': 1})
#print(c.items())
# dict_items([('a', 4), ('b', 1), ('c', 2)])

if len(li) == 0:
    print(0)
    exit()

count = 0
for ci in c.items():
    a = ci[0]
    b = ci[1]
    if a<b:
        count += b-a
    elif a>b:
        count += b
print(count)

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


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

	vector<int> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	int s = pow(10,9), l = 1;
	for (size_t i = 0; i < N; i++)
	{
		s = min(s, A.at(i));
		l = max(l, A.at(i));
	}
	cout << l - s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>

typedef long long ll;

using namespace std;

bool is_atcg(char c) {
    return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}

int main(void) {
    string S;
    cin >> S;

    int max_len = 0;
    for (int i = 0; i < S.size(); i++) {
        if (is_atcg(S[i])) {
            int j = i + 1;
            while (is_atcg(S[j]))
                j++;
            // cout << "(" << i << "," << j << ")" << endl;
            max_len = max(max_len, j - i);
        }
    }
    cout << max_len << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  set<string> dic;
  for(int i=0; i<n; i++){
    string s;
    cin>>s;
    string key;
    cin>>key;
    if(s=="insert"){
      dic.insert(key);
    }else if(dic.count(key)){
      cout<<"yes"<<endl;
    }else{
      cout<<"no"<<endl;
    }
  }
}


Measured memory_bytes: 32152
#include <cstdio>

using namespace std;
int n,a,b,c,d,i;
long long st,dr;
bool ok;
int main()
{
    scanf ("%d %d %d %d %d", &n, &a, &b, &c, &d);
    ok=false;
    for (i=(n-1);i>=1;i--)
    {
        st=(0LL)+a-(1LL)*i*d+(1LL)*(n-1-i)*c;
        dr=(0LL)+a-(1LL)*i*c+(1LL)*(n-1-i)*d;
        if (st<=b && dr>=b)
            ok=true;
    }
    if (ok==true)
        printf ("YES\n");
    else
        printf ("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

typedef map<int, int> M;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int N, result = 0;
  cin >> N;
  vector<int> L(N);
  REP(i, N) cin >> L[i];
  sort(ALL(L));
  REP(i, N) {
    REP(j, N) {
      REP(k, N) {
        if (L[i] < L[j] && L[j] < L[k] && L[i] + L[j] > L[k]) {
          result++;
        }
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
def main():
    N, M, C = map(int, input().split())
    B = [int(b) for b in input().split()]

    count = 0
    for i in range(N):
        v = C
        A = temp = [int(a) for a in input().split()]
        for j in range(M):
            v += A[j] * B[j]
        if v > 0: count += 1
    return count

if __name__ == '__main__':
    print(main())

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

int main() {
  int N, N_;
  cin >> N;
  N_ = N;
  int f = 0;
  while (N_ > 0) {
    f += N_ % 10;
    N_ /= 10;
  }
  if (N % f == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int M = 1e9+7,N = 1e3+1;
 
int freq[N];
 
int main()
{
    int n;long div=1;
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        int x=i;
        for(int j=2;j*j<=x;j++)
        {
            while(x%j==0)
            {
            	x/=j;
                freq[j]++;
            }
        }
        if(x!=1)
          freq[x]++;
    }
    for(int i=2;i<=n;i++){
        div*=(freq[i]+1);
        div%=M;
    }
    printf("%ld\n",div);
    return 0;
}

Measured memory_bytes: 3796
#include<stdio.h>

int main(void){
  int a,b,ans;
  char op;
  scanf("%d %c %d",&a,&op,&b);
  if(op == '+'){
    ans = a+b;
  }
  if(op == '-'){
    ans = a-b;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
routes = gets.chomp

s_flag = routes.include?("S")
n_flag = routes.include?("N")
e_flag = routes.include?("E")
w_flag = routes.include?("W")

if (s_flag && n_flag && !e_flag && !w_flag) || (!s_flag && !n_flag && e_flag && w_flag) || (s_flag && n_flag && e_flag && w_flag) then
  puts "Yes"
else
  puts "No"
end

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

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

    int a[M], b[M];

    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
    }

    int roads[N]={};

    for( int i=0; i<M; i++ ){
        roads[ a[i]-1 ] +=1;
        roads[ b[i]-1 ] +=1;
    }

    for(int i=0; i<N; i++){
        cout << roads[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n+1][3];
    a[0][0]=0;a[0][1]=0;a[0][2]=0;
    for (int i=0; i<n; i++){
        cin >>a[i+1][0]>>a[i+1][1]>>a[i+1][2];
    }
    for (int i=0; i<n; i++){
        int dist=abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2]);
        if (dist<=a[i+1][0]-a[i][0] && (dist-a[i+1][0]+a[i][0])%2==0){
            continue;
        }else {
            cout << "No" <<endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
}
    

Measured memory_bytes: 1408
#include <iostream>

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

struct edge {
  ll to;
  ll money;
  ll time;
};

vector<pair<int, vector<edge>>> graph;
vector<vector<ll>> dp(50, vector<ll>(2451, INF));
//dp.at(i).at(j)は都市iに所持金jで到達するための最小時間

int main(){
  ll N, M, S;
  cin >> N >> M >> S;
  graph.resize(N);
  vector<ll> U(M), V(M), A(M), B(M);
  rep(i, M){
    cin >> U.at(i) >> V.at(i) >> A.at(i) >> B.at(i);
    U.at(i)--;
    V.at(i)--;
    graph.at(U.at(i)).first = U.at(i);
    graph.at(V.at(i)).first = V.at(i);
    graph.at(U.at(i)).second.push_back({V.at(i), A.at(i), B.at(i)});
    graph.at(V.at(i)).second.push_back({U.at(i), A.at(i), B.at(i)});
  }
  vector<ll> C(N), D(N);
  rep(i, N){
    cin >> C.at(i) >> D.at(i);
  }
  dp.at(0).at(min(2450LL, S)) = 0;
  priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>> q;
  q.push(make_tuple(0, 0, min(2450LL, S)));
  while(!q.empty()){
    tuple<ll, ll, ll> d = q.top();
    //cout << get<0>(d) << " " << get<1>(d) << " " << get<2>(d) << endl;
    q.pop();
    if(dp.at(get<1>(d)).at(get<2>(d)) < get<0>(d)){
      continue;
    }
    for(auto e : graph.at(get<1>(d)).second){
      //cout << "from " << get<1>(d) << " to " << e.to << endl;
      if(e.money > get<2>(d)){
        continue;
      }
      if(chmin(dp.at(e.to).at(get<2>(d)-e.money), get<0>(d)+e.time)){
        q.push(make_tuple(get<0>(d)+e.time, e.to, get<2>(d)-e.money));
        //cout << "push " << get<0>(d)+e.time << " " << e.to << " " << get<2>(d)-e.money << endl;
      }
    }
    if(chmin(dp.at(get<1>(d)).at(min(2450LL, get<2>(d)+C.at(get<1>(d)))), get<0>(d)+D.at(get<1>(d)))){
      q.push(make_tuple(get<0>(d)+D.at(get<1>(d)), get<1>(d), min(2450LL, get<2>(d)+C.at(get<1>(d)))));
      //cout << "push " << get<0>(d)+D.at(get<1>(d)) << " " << get<1>(d) << " " << min(2450LL, get<2>(d)+C.at(get<1>(d))) << endl;
    }
  }
  vector<ll> ans(N-1, INF);
  rep(i, N-1){
    rep(j, 2451){
      chmin(ans.at(i), dp.at(i+1).at(j));
    }
  }
  rep(i, N-1){
    cout << ans.at(i) << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<pair<ll,ll>,ll> P;

ll L;
vector<P> v;

int main(){
    cin >> L;
    bitset<19> bt(L);
    ll l = 0;
    while(L > 1){
        l++;
        L /= 2;
    }
    ll c = 0;
    for(int i=1;i<=l;i++){
        v.push_back({{i,i+1},0});
        v.push_back({{i,i+1},1<<(i-1)});
        if(bt[i-1]==1){
            v.push_back({{i,20},(1<<l)+c});
            c += 1 << (i-1);
        }
    }
    for(int i=l+1;i<20;i++){
        v.push_back({{i,i+1},0});
    }
    cout << 20 << " " << v.size() << endl;
    for(auto &e : v){
        cout << e.first.first << " " << e.first.second << " " << e.second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  //declare function

  //declare variable
  function search(array) {
    return allCards.filter(function(card) {
      return array.indexOf(card) === -1;
    });
  }
  var inputs = stdin.toString().trim().split('\n');
  var line = [].concat(inputs);
  var make13 = [];
  for (var i = 0; i < 13; i++) {
    make13.push(i + 1);
  }
  var allCards = ['S', 'H', 'C', 'D'].map(function(v) {
    return [].concat(make13).map(function(w) {
      return [v, parseInt(w)].join(' ');
    });
  }).reduce(function(a, b) {
    return a.concat(b);
  });
  //main

  //display
  if (inputs[0] < 52) {
    console.log(search(line).join('\n'));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 15536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int x; cin>>x;
	ll ans = (x/500)*(1000);
	x%=500;
	ans+=(x/5)*5;
	cout<<ans<<'\n';
}


Measured memory_bytes: 892
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[0]*(n+1)
l[1]=(p[0]+1)/2
for i in range(2,n+1):
  l[i]=l[i-1]+(p[i-1]+1)/2
ans=0
for i in range(n-k+1):
  if ans<l[i+k]-l[i]:
    ans=l[i+k]-l[i]
print(ans)

Measured memory_bytes: 71792
"""
C - Unification

どんな状況でも赤青両方のブロックが1つ以上存在しているなら赤青となりあう箇所が最低1か所存在する.
→ 赤青どちらかのブロックがなくなるまでブロックを2つずつ取り除くことができる.
"""


def solve():
    S = input()
    zero_num = S.count('0')
    one_num = S.count('1')
    ans = zero_num * 2 if zero_num < one_num else one_num * 2
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188