akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int x;
	cin >> x;
	for (int i = -2000; i <= 2000; ++i) {
		for (int j = -2000; j <= 2000; ++j) {
			if (1LL * i * i * i * i * i - 1LL * j * j * j * j * j == x) {
				cout << i << " " << j;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3652
from sys import stdin

N = int(stdin.readline().rstrip())
wit = [[] for _ in range(N)]
A = []

for i in range(N):
    A = int(stdin.readline().rstrip())
    for n in range(A):
        wit[i].append([int(x) for x in stdin.readline().rstrip().split()])

ans = 0

for i in range(2 ** N):
    s = bin(i)[2:].zfill(N)
    one_cnt = 0
    tmp = 0
    for j in range(N):
        if s[j] == '1':
            one_cnt += 1
            cnt = 0
            for k in wit[j]:
                if k[1] == 1:
                    if s[k[0] - 1] == '1':
                        cnt += 1
                elif k[1] == 0:
                    if s[k[0] - 1] == '0':
                        cnt += 1
            if cnt == len(wit[j]):
                tmp += 1
    if tmp == one_cnt:
        ans = max(ans, one_cnt)

print(ans)

Measured memory_bytes: 45404
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    int buss[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1};

    while(--n >= 0){
        int a, b;
        cin >> a >> b;

        int i[2], j[2];
        i[0] = find(buss, buss+15, a) - buss;
        i[1] = find(buss+i[0]+1, buss+15, a) - buss;
        j[0] = find(buss, buss+15, b) - buss;
        j[1] = find(buss+j[0]+1, buss+15, b) - buss;

        int x, y;
        int len = INT_MAX;
        for(int k=0; k<2; ++k){
            for(int l=0; l<2; ++l){
                if(i[k] == 15 || j[l] == 15)
                    continue;
                int tmp = (j[l] - i[k] + 15) % 15;
                if(tmp < len){
                    len = tmp;
                    x = i[k];
                    y = j[l];
                }
            }
        }

        cout << buss[x];
        do{
            ++ x;
            x %= 15;
            cout << ' ' << buss[x];
        }while(x != y);

        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;
 
ll powmod(ll a, ll b, ll mod = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (mod - 1ll), a %= mod;
	while(b){
		if(b%2 == 1)	res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}

 
int main(){	

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);
 
	string a, b, c;
	int n;
	cin >> n >> a >> b >> c;
	int cnt[30];
	int ans = 0;
	for(int i = 0; i < n; i++){
		memset(cnt, 0, sizeof(cnt));
		cnt[a[i] - 'a']++, cnt[b[i] - 'a']++, cnt[c[i] - 'a']++;
		ans += 3 - max({cnt[a[i] - 'a'], cnt[b[i] - 'a'], cnt[c[i] - 'a']});
	}

	cout << ans;
}

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

//#define int long long
//#define ll int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(vec) (vec).begin(),(vec).end()
#define vint vector<int>
#define pint pair<int,int>
#define vpint vector<pint>

int par[100002];
int rnk[100002];
void init(int n){REP(i,n){par[i]=i;rnk[i]=0;}}
int find(int x){if(par[x]==x){return x;}else{return par[x]=find(par[x]);}}
void unite(int x,int y){x=find(x);y=find(y);if(x==y)return;if(rnk[x]<rnk[y]){par[x]=y;}else{par[y]=x;if(rnk[x]==rnk[y])rnk[x]++;}}
bool same(int x,int y){return find(x)==find(y);}

int n,a[10002];

signed main(){
    cin>>n;
    REP(i,n)cin>>a[i];
    int ans=0;
    REP(i,n){
        int ntz=0;
        while((a[i]&1)==0)ntz++,a[i]>>=1;
        ans+=ntz;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        if (x < a){
            System.out.println("0");
        }else {
            System.out.println("10");
        }

    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    ll a,b;
    cin >>a>>b;
    bool ans = false;

    if (a<10 && b<10)ans=true;

    ll num = 0;
    if (ans){
        num = a*b;
    }

    cout << (ans? num:-1);


}


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

#define MAX 100005
#define NIL -1

struct Node {
    int parent;
    int brother;
    int child;
};

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

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("depth = %d, ", D[u]);

    if(T[u].parent == NIL) printf("root, ");
    else if(T[u].child == NIL) printf("leaf, ");
    else printf("internal node, ");

    printf("[");    
    int x = T[u].child;
    while(x != NIL){
        printf("%d", x);
        x = T[x].brother;
        if(x != NIL) printf(", ");
    }
    printf("]\n");
}

int rec(int u, int p){
    D[u] = p;
    if(T[u].brother != NIL) rec(T[u].brother, p);
    if(T[u].child != NIL) rec(T[u].child, p + 1);
}

int main(){
    cin >> n;

    rep(i,n) T[i].parent = T[i].child = T[i].brother = NIL;
    
    rep(i,n){
        int v, c, cn, bro;
        cin >> v >> cn;
        rep(j, cn){
            cin >> c;
            T[c].parent = v;
            if(j == 0) T[v].child = c;
            else T[bro].brother = c;
            bro = c;
        }
    }

    int root;
    rep(i,n){
        if(T[i].parent == NIL) root = i;
    }
    rec(root, 0);

    rep(i,n) print(i);

    return 0;
}


Measured memory_bytes: 7908
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int a; cin >> a;
    string s; cin >> s;
    if (a >= 3200) {
        cout << s << "\n";
    } else {
        cout << "red\n";
    }
}


Measured memory_bytes: 256
s = input()
f = s[0]
ans = "AC"

if "C" in s[2:-1] and f == "A" and s[2:-1].count("C") == 1:
    pass
else:
    ans = "WA"

for i in s:
    if i.isupper():
        if i == "A" or i == "C":
            continue
        else:
            ans = "WA"

print(ans)

Measured memory_bytes: 9052
import sys

readline = sys.stdin.buffer.readline

n, m = map(int, readline().split())

es = []
for _ in range(m):
    a, b = map(int, readline().split())
    es.append((a, b))


def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def same(x, y):
    return find(x) == find(y)


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y


ans = 0
for i in range(m):
    par = [_ for _ in range(n + 1)]
    for j, k in enumerate(es):
        if i == j:
            continue
        a, b = k
        unite(a, b)
    a, b = es[i]
    if not same(a, b):
        ans += 1
print(ans)


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

int main() {
  int H, W;
  cin >> H >> W;
  vector <vector<char>> fig(H, vector<char>(W));
  for (int i=0;i<H;i++) {
    for (int j=0;j<W;j++) {
      cin >> fig.at(i).at(j);
    }
  }
  for (int i=0;i<W+2;i++) {
    cout << "#";  
  }
  cout << endl;
  for (int i=0;i<H;i++) {
    cout << "#";
    for (int j=0;j<W;j++) {
      cout << fig.at(i).at(j);
    }
    cout << "#" << endl;
  }
  for (int i=0;i<W+2;i++) {
    cout << "#";  
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[][] field = new boolean[n][n];
		for (int i = 0; i < n; i++) {
		    int from = sc.nextInt() - 1;
		    int count = sc.nextInt();
		    for (int j = 0; j < count; j++) {
		        field[from][sc.nextInt() - 1] = true;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < n; j++) {
		        if (j > 0) {
		            sb.append(" ");
		        }
		        if (field[i][j]) {
		            sb.append("1");
		        } else {
		            sb.append("0");
		        }
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 28916
// inputに入力データ全体が入る
function Main(input) {
  	// まずメインの入力の値をとる
	var a = input.split("\n")[1].split(" ");
  	var counter = 0;
  	while(a.every(e=> {return e%2 === 0})){
    	counter++;
      	a = a.map(e=>{
        	return e = e/2
        })
    }
	//出力
	console.log(counter);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    char input;
    char ch[128];
    ch['A'] = 'T';
    ch['T'] = 'A';
    ch['C'] = 'G';
    ch['G'] = 'C';

    cin >> input;
    cout << ch[(int)input] << endl;

    return 0;
}

Measured memory_bytes: 256
(* O(|s| 2^|s|) *)
let s = read_line () in
let slen = String.length s in
let f bits =
  let m = slen - 1 in
  let rec split acc i j =
    let aux () = int_of_string (String.sub s i (j - i)) :: acc in
    if j > m then aux ()
    else if bits lsr (m - j) land 1 = 1 then
      split (aux ()) j (j + 1)
    else split acc i (j + 1) in
  split [] 0 1 |> List.fold_left (+) 0 in
let sum = ref 0 in
for i = 0 to 1 lsl (slen - 1) - 1 do
  sum := !sum + f i
done;
Printf.printf "%d\n" !sum

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll h1, m1, h2, m2, k;
    cin>>h1>>m1>>h2>>m2>>k;
    if(h2 == 0 && h1!=0){
        h2+=24;
    }
    ll tot = (h2*60 + m2) - (h1*60 + m1);
    cout<<tot - k<<endl;
}

Measured memory_bytes: 3620
S = input()
ans1 = 0 # 101010101...
ans2 = 0 # 010101010...
for i, s in enumerate(S):
    if s == '0' and i % 2 == 0:
        ans1 += 1
    elif s == '0' and i % 2 == 1:
        ans2 += 1
    elif s == '1' and i % 2 == 0:
        ans2 += 1
    else:
        ans1 += 1
print(min(ans1, ans2))

Measured memory_bytes: 3188
#include <iostream>
#include <bits/stdc++.h>
#define loop(N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(v.size()){
        pt<T>(v[i]);
    }
}



/*********************************asserting****************************/

template <class T>
void asserty(T in,T out){

    if(in != out){
        ps("Test not passed:");
        pt<T>(in);
        ps("expected :");
        pt<T>(out);
    }
}

void assertv(vi in,vi out){
    bool equals = true;
    if( in.size()!=out.size()){
        equals = false;
    }else{
        loop(in.size()){
            if(in[i]!=out[i]){
                equals = false;
                break;
            }

        }

    }

    if(!equals){
        ps("Test not passed:");
        pv<int>(in);
        ps("expected :");
        pv<int>(in);
    }
}

/*********************************reused****************************/

int main()
{
    string s;
    cin>>s;
    if((s[0]==s[1] && s[1]==s[2]) ||(s[1]==s[2] && s[2]==s[3]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    if(judge_parin(s)) {
      System.out.println("NO");
    } else {
      System.out.println("YES");
    }
  }
  public static boolean judge_parin(String s) {
    int[] count = new int[3];
    int gap = 0;
    char[] list = s.toCharArray();
    Arrays.fill(count, 0);
    for(int i = 0; i < list.length; i++) {
      if(list[i] == 'a') {
        count[0]++;
      } else if(list[i] == 'b') {
        count[1]++;
      } else {
        count[2]++;
      }
    }
    Arrays.sort(count);
    gap = count[2] - count[0];
    if(gap > 1) {
      return true;
    } else {
      return false;
    }
  }
}


Measured memory_bytes: 27948
#include <stdio.h>

int main()
{
	int num, sum;
	int x, y, z;
	int judge = 0;
	int val[3] = {10000, 5000, 1000};
	scanf("%d %d", &num, &sum);

	for (x = 0; x <= num; x++) {
		for (y = 0; x + y <= num; y++) {
			z = num - (x + y);
			int count = x * val[0] + y * val[1] + z * val[2];
			if (count == sum) {
				judge = 1;
				goto RESULT;
			}
		}
	}

	RESULT:if (judge == 0) {
		printf("-1 -1 -1\n");
	} else {
		printf("%d %d %d\n", x, y, z);
	}
	return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  ll h, w;
  cin >> h >> w;

  ll ans1=1e12;
  REP(i,1,h){
    ll j = w/2;
    ll s1 = (h-i)*j;
    ll s2 = (h-i)*(w-j);
    ll s3 = i*w;
    ll smax = max(s1, max(s2, s3));
    ll smin = min(s1, min(s2, s3));
    //prt3(s1,s2,s3);
    chmin(ans1, smax-smin);
  }
  REP(i,1,w){
    ll j = h/2;
    ll s1 = (w-i)*j;
    ll s2 = (w-i)*(h-j);
    ll s3 = i*h;
    ll smax = max(s1, max(s2, s3));
    ll smin = min(s1, min(s2, s3));
    //prt3(s1,s2,s3);
    chmin(ans1, smax-smin);
  }

  ll ans2=1e12;
  REP(i,1,h){
    ll j = (h-i)/2;
    ll s1 = j*w;
    ll s2 = (h-i-j)*w;
    ll s3 = i*w;
    ll smax = max(s1, max(s2, s3));
    ll smin = min(s1, min(s2, s3));
    chmin(ans2, smax-smin);
  }
  REP(i,1,w){
    ll j = (w-i)/2;
    ll s1 = j*h;
    ll s2 = (w-i-j)*h;
    ll s3 = i*h;
    ll smax = max(s1, max(s2, s3));
    ll smin = min(s1, min(s2, s3));
    chmin(ans2, smax-smin);
  }

  prt(min(ans1, ans2));

}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]
print('Yes' if c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2] and
      c[2][0] - c[1][0] == c[2][1] - c[1][1] == c[2][2] - c[1][2] else 'No')


Measured memory_bytes: 3060
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define in insert
#define er erase
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}


//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

vector<int> a;
vector< pair<pii , pii> > qu;
int n,m;
int maxscore = INT_MIN;

void gen(int idx , int val){
    // cout << idx << " " << val << endc;
    if(idx == n){
        int score = 0;
        for(auto i : qu){
            if(a[i.fi.se - 1] - a[i.fi.fi - 1] == i.se.fi)
                score += i.se.se;
        }

        maxscore = max(maxscore , score);
        return;
    }

    for(int j = val; j <= m; j++){
        a[idx] = j;
        gen(idx + 1 , j);
    }
}

int32_t main(){
    init;
    int q,i,j,k,l,p;
    cin >> n >> m >> q;
    qu.resize(q);
    a.resize(n);

    for(i = 0; i < q; i++){
        cin >> qu[i].fi.fi >> qu[i].fi.se >> qu[i].se.fi >> qu[i].se.se;
    }

    gen(0 , 1);
    cout << maxscore << endc;
    return 0;
}

Measured memory_bytes: 3628
import sys
from collections import deque
readline = sys.stdin.readline
N, M = map(int, readline().split())
Col = [1 if s == 'A' else 0 for s in readline().strip()]

Edge = [[] for _ in range(N)]
Dim = [[0, 0] for _ in range(N)]
for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a][Col[b]] += 1
    Dim[b][Col[a]] += 1

Q = deque([i for i in range(N) if not min(Dim[i])])
used = set(Q)

while Q:
    vn = Q.pop()
    c = Col[vn]
    for vf in Edge[vn]:
        if vf in used:
            continue
        Dim[vf][c] -= 1
        if not Dim[vf][c]:
            used.add(vf)
            Q.appendleft(vf)

print('Yes' if len(used) < N else 'No')

Measured memory_bytes: 105112
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// スペース区切りの整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		//最大数
		System.out.print(Math.min(a, b));
		
		//半角スペース
		System.out.print(" ");
		
		//最小数
		System.out.print((a + b - n) < 0 ? 0 : (a + b - n));
		
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
    using namespace std;
     
     
    #define ll long long
    #define pb push_back
    #define mp make_pair
    #define loop(i, a, b) for(int i = (a); i < (b); i++)
    #define loopb(i, a, b) for(int i = (a); i > (b); --i)
     
    typedef pair <int,int> ii;
    typedef vector <int> vi;
    typedef vector <ii> vii;
    typedef vector <ll> vl;
     
    const int mod = 1e9+7;
    const ll inf = 2e18+5;
     
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int n,k;
        cin>>n>>k;

        vector <bool> dp(k+1); //dp[i] is true if player who moves now wins when there are i stones remaining

        vi a(n);
        loop(i,0,n) cin>>a[i];
        
        for(int stones=0; stones<=k; stones++){
            for(int x:a){
                if(stones>=x && dp[stones-x]==false)
                    dp[stones] = true;
            }
        }
      
		if(dp[k]==true)
        	cout<<"First";
        else
          	cout<<"Second";
        
        return 0;
    } 

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    string              com;
    priority_queue<int> pq;

    while (true) {
        cin >> com;
        if (com[0] == 'i') {
            int key;
            cin >> key;
            pq.push(key);

        } else if (com[1] == 'x') {
            cout << pq.top() << endl;
            pq.pop();
        } else if (com[0] == 'e') {
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 6940
import sys
arr=[]
for _ in range(int(raw_input())):
	arr.append(map(int,raw_input().split(' ')))
temp1,temp2,temp3,ans=0,0,0,True
for temp,x,y in arr:
	x_d = abs(x-temp1);y_d = abs(y-temp2);t_d=temp-temp3;
	if t_d >= x_d + y_d:
		if t_d%2 == ((x_d+y_d)%2):
			flag = True
		else:
			flag = False
			print "No"
			sys.exit()
	else:
		flag = False
		print "No"
		sys.exit()
print "Yes"


Measured memory_bytes: 21508
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;


int main()
{
    int n;
    cin >> n;
    int m = n;
    int d = 1e9;
    int a = 0;
    while(m > 0)
    {
        a += m/d;
        m = m%d;
        d /= 10;
    }

    if(n%a == 0)
        cout << "Yes" << endl;
    else
        cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main() {
	int i, j, n, minj, tmp, a[100], count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (a[j] < a[minj])minj = j;
		}
		if (a[i] != a[minj]) {
			count++;
		}
		tmp = a[i];
		a[i] = a[minj];
		a[minj] = tmp;
	}
	printf("%d", a[0]);
	for (i = 1; i < n; i++) {
		printf(" %d", a[i]);
	}
	printf("\n%d\n", count);
	return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b;
  cin>>a>>b;
  if(a==0){
    if(b>0)
      cout<<b<<endl;
    else
      cout<<1-b<<endl;
  }
  else if(b==0){
    if(a>0)
      cout<<1+a<<endl;
    else
      cout<<abs(a)<<endl;
  }
  else{
  if(a<=b){
    if((a>=0&&b>=0)||(a<=0&&b<=0))
      cout<<b-a<<endl;
    else
      cout<<1+abs(abs(a)-b)<<endl;
  }
  else{
    if((a>=0&&b>=0)||(a<=0&&b<=0))
      cout<<2+abs(a-b)<<endl;
    else
      cout<<1+abs(abs(b)-a)<<endl;
  }
  }
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
que = [getList() for i in range(N)]

# マンハッタン距離
# 分けて考える?
# NlogNまでいけそう

# 愚直?
# ソートして考える?

# リストして各点についてO(1)で答える
# xが小さい順にソート

minus = []
plus = []
for x, y in que:
    minus.append(x - y)
    plus.append(x + y)
minus.sort()
plus.sort()
m = minus[-1] - minus[0]
p = plus[-1] - plus[0]
print(max(abs(m), abs(p)))

Measured memory_bytes: 135664
/**
 *    author:  RM07
 *    created: August 15, 2020 7:00 PM
 *    motto: Knowledge is Power, Strive for Excellence
**/
#include<bits/stdc++.h>
using namespace std;
const int maxn=3009;
 
int n,m,K;
 
int a[maxn][maxn];
 
long long f[maxn][maxn][4];
 
int main(){
	cin>>n>>m>>K;
	while(K--){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		a[x][y]=z;
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			for(int k=0;k<=3;++k){
				long long t=max(max(f[i-1][j][0],f[i-1][j][1]),max(f[i-1][j][2],f[i-1][j][3]));
				f[i][j][k]=max(f[i][j-1][k],t);
				if(k)f[i][j][k]=max(f[i][j-1][k-1]+a[i][j],f[i][j][k]);
				if(k)f[i][j][k]=max(f[i][j][k],t+a[i][j]);
			}
		}
	}
	printf("%lld\n",max(max(f[n][m][0],f[n][m][1]),max(f[n][m][2],f[n][m][3])));
	return 0;
}

Measured memory_bytes: 321080
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,i,j,k,x,y,nx,ny,qx[405],qy[405],bg,ed,f[10][5]={{-1,0},{1,0},{0,-1},{0,1}},dis[25][25],ans;
char s[25][25];
bool v[25][25];
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	for(i=1;i<=n;++i)
		for(j=1;j<=m;++j)
			if(s[i][j]=='.')
			{
				for(x=1;x<=n;++x)
					for(y=1;y<=m;++y)
						v[x][y]=false;
				bg=ed=1;
				qx[1]=i,qy[1]=j,dis[i][j]=0;
				v[i][j]=true;
				while(bg<=ed)
				{
					for(k=0;k<4;++k)
					{
						nx=qx[bg]+f[k][0],ny=qy[bg]+f[k][1];
						if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&s[nx][ny]=='.'&&!v[nx][ny])
						{
							++ed;
							qx[ed]=nx,qy[ed]=ny;
							v[nx][ny]=true;
							dis[nx][ny]=dis[qx[bg]][qy[bg]]+1;
						}
					}
					++bg;
				}
				for(x=1;x<=n;++x)
					for(y=1;y<=m;++y)
						if(v[x][y])
							ans=max(ans,dis[x][y]);
			}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;



int main(){
    int a,b,c;
    string s="Yes";
    cin>>a>>b>>c;
    if(a+b<c){
    	s="No";
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a=[];
  for ($i=0; $i<$n; $i++) {
    list($a[]) = explode(" ", trim(fgets(STDIN)));    
  }

  $b=1;
  for($i=0;$i<$n;$i++){
    if($b==2){
      echo $i;
      exit;
    }
    $b=$a[$b-1];
  }
  echo "-1";

Measured memory_bytes: 22788
a = gets.chomp.split("")
for i in 0..a.length-1
  if a[i] == a[i+1]
    puts "#{i+1} #{i+2}"
    exit
  elsif a[i] == a[i+2]
    puts "#{i+1} #{i+3}"
    exit
  end
end
puts "-1 -1"
  

Measured memory_bytes: 6908
from calendar import isleap

f = True
while True:
    a, b = map(int, input().split())
    if a == b == 0: break
    leap = [str(i) for i in range(a, b+1) if isleap(i)]
    if f:
        f = False
    else:
        print()
    if not leap:
        print('NA')
    else:
        print('\n'.join(leap))




Measured memory_bytes: 7312
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

string add0(int n){
    int k = 0, s = 1;
    while(n >= s){
        s *= 10;
        k++;
    }
    string S = to_string(n);
    REP(i, 6 - k) S = '0' + S;
    return S;
}

signed main(){

    int N, M;
    cin >> N >> M;
    vec P(M), Y(M);
    REP(i, M) cin >> P[i] >> Y[i];

    map<int, vector<Pii>> m;
    set<int> s;
    REP(i, M){
        m[P[i]].push_back(Pii(Y[i], i));
        s.insert(P[i]);
    }
    for(int n: s) SORT(m[n]);

    vec ans(M);
    for(int n: s){
        REP(i, m[n].size()) ans[m[n][i].second] = i + 1;
    }

    REP(i, M){
        cout << add0(P[i]) << add0(ans[i]) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 7/6/2020

 9:09-

 */

const int MAX_N=1e6+1;
LL A[MAX_N],L;
int N;

void solve() {
  int st=-1;
  REP(i,N-1) if(A[i]+A[i+1]>=L) {
    st=i;
    break;
  }
  dump(st);
  if(st==-1) {
    cout<<"Impossible"<<endl;
    return;
  }

  VI left,right;
  FOR(i,st,N-1) right.push_back(i);
  REP(i,st) left.push_back(i);
  /*reverse(ALL(left)),*/reverse(ALL(right));

  assert(SZ(left)+SZ(right)==N-1);
  /*
  vector<LL> cum(N+1);
  REP(i,N) cum[i+1]=cum[i]+A[i];
  int l=0,r=N;
  FORR(i,left) l=i,assert(cum[r]-cum[l]>=L);
  FORR(i,)*/

  cout<<"Possible"<<endl;
  FORR(i,left) cout<<i+1<<endl;
  FORR(i,right) cout<<i+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>L;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 4744
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();      
            Console.WriteLine(new string(s.Take(3).ToArray()));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

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

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

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

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


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

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 26580
#include <iostream>
using namespace std;
int a,b,c,k;
int sum=0,MAX=0,cnt;
int main()
{
	cnt=1;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	sum=a+b+c;
	for(int i=1;i<=k;i++)
	{
		cnt=2*cnt;
	}
	MAX=max(a,max(b,c));
	sum=sum+MAX*(cnt-1);
	cout<<sum;
	return 0;
}

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

const int MOD = 1000000007;

int a[110];
long dp_sum[110][110000];
long dp[110][110000];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	dp[0][0] = 1;
	for (int i = 0; i <= k; i++)
		dp_sum[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			dp[i][j] = dp_sum[i - 1][j];
			if (j - a[i] - 1 >= 0) dp[i][j] -= dp_sum[i - 1][j - a[i] - 1];
			if (j - 1 >= 0)
				dp_sum[i][j] = dp_sum[i][j - 1] + dp[i][j];
			else
				dp_sum[i][j] = dp[i][j];
			dp[i][j] %= MOD;
			dp_sum[i][j] %= MOD;
		}
	}
	if (dp[n][k] < 0) dp[n][k] += MOD;
	cout << dp[n][k] << endl;
}

Measured memory_bytes: 175488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
long long int func(long  int x){
 long  int ans = x*(x+1)/2;
  return ans;
}
int main(){
   int n;
  cin>>n;
 long long int sum=0;
  for(int i= 1;i<=n;i++){
     sum += func(n/i)*i;
  }
  cout<<sum;
  
  
 
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cmath>
#include <sstream>
 
using namespace std;
 
typedef long long Long;

int WWLR[2010][2010];
int WBLR[2010][2010];
int BWLR[2010][2010];
int BBLR[2010][2010];
int WP[2010], BP[2010];
int N;
int mem[2010][2010];
int dp(int wid, int bid) {
	if (wid == N && bid == N) return 0;
	if (mem[wid][bid] != -1) return mem[wid][bid];
	int w = 1000000000;
	if (wid < N) {// use white
		int pos = WP[wid] + WWLR[wid][wid] + WBLR[wid][bid];
		w = min(w, dp(wid+1, bid) + pos - (bid + wid));
	}
	if (bid < N) {
		int pos = BP[bid] + BWLR[bid][wid] + BBLR[bid][bid];
		w = min(w, dp(wid, bid+1) + pos - (bid + wid));
	}
	return mem[wid][bid] = w;
}

int main(int argc, char *argv[]) {
	memset(mem, -1, sizeof(mem));
	cin >> N;
	vector<int> V(2*N);
	vector<string> C(2*N);
	for (int i = 0; i < 2*N; ++i) {
		cin >> C[i] >> V[i];
		V[i]--;
	}
	for (int i = 0; i < 2*N; ++i) {
		if (C[i] == "W") {
			WP[ V[i] ] = i;
			for (int j = i+1; j < 2*N; ++j) {
				if (C[j] == "W") {
					WWLR[ V[i] ][ V[j] ]++;
				} else {
					WBLR[ V[i] ][ V[j] ]++;
				}
			}
		} else {
			BP[ V[i] ] = i;
			for (int j = i+1; j < 2*N; ++j) {
				if (C[j] == "W") {
					BWLR[ V[i] ][ V[j] ]++;
				} else {
					BBLR[ V[i] ][ V[j] ]++;
				}
			}
		}
	}
	
	for (int i = 0; i < N; ++i) {
		{
			int s = 0;
			for (int j = 0; j <= N; ++j) {
				int t = WWLR[i][j];
				WWLR[i][j] = s;
				s += t;
			}
		}
		{
			int s = 0;
			for (int j = 0; j <= N; ++j) {
				int t = BWLR[i][j];
				BWLR[i][j] = s;
				s += t;
			}
		}
		{
			int s = 0;
			for (int j = 0; j <= N; ++j) {
				int t = WBLR[i][j];
				WBLR[i][j] = s;
				s += t;
			}
		}
		{
			int s = 0;
			for (int j = 0; j <= N; ++j) {
				int t = BBLR[i][j];
				BBLR[i][j] = s;
				s += t;
			}
		}
	}
	cout << dp(0,0) << endl;
}
 
/*
 
gautambishal
5
3 0
2 0 5
3 1
4 0 0
4 3 0

 */
 


Measured memory_bytes: 79616
num=input().rstrip().split(" ")
N=int(num[0])
M=int(num[1])
date=input().rstrip().split(" ")
sum=0
for i in range(N):
  sum+=int(date[i])
for j in range(len(date)):
  date[j]=int(date[j])
date=sorted(date,reverse=True)
if (sum/4)/M<=int(date[M-1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

#define INF 1000000

void dijkstra(int **, int, int);

int main(){

  int i, j;
  int n, u, k, v, c;
  int **a;

  scanf("%d", &n);

  a = (int **)malloc(sizeof(int *) * n);

  for(i = 0; i < n; i++){
    a[i] = (int *)malloc(sizeof(int) * n);

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

  }

  for(i = 0; i< n; i++){
    scanf("%d%d", &u, &k);

    for(j = 0; j < k; j++){
      scanf("%d%d", &v, &c);

      a[u][v] = c;
    }

  }

  dijkstra(a, n, 0);

  return 0;
}

void dijkstra(int **a, int n, int r){

  int i;
  int *d;
  int *pi;
  int *color;
  int min, u;
  
  d = (int *)malloc(sizeof(int) * n);
  pi = (int *)malloc(sizeof(int) * n);
  color = (int *)malloc(sizeof(int) * n);
  
  for(i = 0; i < n; i++){
    d[i] = INF;
    pi[i] = -1;
    color[i] = 0;
  }

  d[r] = 0;

  while(1){

    min = INF;

    for(i = 0; i < n; i++){
      if(color[i] != 1 && d[i] < min){
	min = d[i];
	u = i;

      }

    }

    if(min == INF) break;

    color[u] = 1;

    for(i = 0; i < n; i++){
      if(a[u][i] != -1){
	if(color[i] != 1 && d[u] + a[u][i] < d[i]){
	  pi[i] = u;
	  d[i] = d[u] + a[u][i];
	}
	
      }

    }

  }

  for(i = 0; i < n; i++){
    printf("%d %d\n", i, d[i]);
  }
  
}

Measured memory_bytes: 640
n = int(input())
c = [0] * (n+1)

c[0], c[1] = map(int, input().split())

for i in range(2, n+1):
    c[i] = int(input().split()[1])
 
array = [[10**7]*(n+1) for i in range(n+1)]
 
for i in range(1, n+1):
    array[i][i] = 0
 
for l in range(2, n+1):
    for i in range(1, n-l+2):
        j = i+l-1
        for k in range(i, j):
            array[i][j] = min(array[i][j], array[i][k] + array[k+1][j] + c[i-1]*c[k]*c[j])
 
print(array[1][n])


Measured memory_bytes: 5664
m, d = list(map(int, input().split()))
count = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        d1 = j // 10
        d2 = j % 10
        if (d1 >= 2) and (d2 >= 2) and i == d1 * d2:
            count += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
	string s;cin>>s;
	if((s[5]==s[4])&&(s[3]==s[2]))cout<<"Yes";
	else cout<<"No";


}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)

ll x[100001];
int n,k;
ll ans = LLONG_MAX;

int main(){
  cin >> n >> k;
  REP(i,n) cin >> x[i];
  REP(i,n-k+1){
    ll tmp = 0;
    if(x[i]*x[i+k-1]>=0ll) tmp = max(abs(x[i]),abs(x[i+k-1]));
    else tmp = min(abs(x[i]),abs(x[i+k-1])) * 2ll + max(abs(x[i]),abs(x[i+k-1]));
    ans = min(ans,tmp);
  }
  cout << ans <<endl;
}


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

int x[4], y[4];

int main()
{
    while(cin >> x[0] >> y[0] >> x[1] >> y[1])
    {
        for(int i = 2; i < 4; i++)
        {
            if(x[i - 1] >= x[i - 2] && y[i - 1] >= y[i - 2])
            {
                x[i] = x[i - 1] - (y[i - 1] - y[i - 2]);
                y[i] = y[i - 1] + (x[i - 1] - x[i - 2]);
            }
            else if(x[i - 1] <= x[i - 2] && y[i - 1] >= y[i - 2])
            {
                x[i] = x[i - 1] - (y[i - 1] - y[i - 2]);
                y[i] = y[i - 1] - (x[i - 2] - x[i - 1]);
            }
            else if(x[i - 1] >= x[i - 2] && y[i - 1] <= y[i - 2])
            {
                x[i] = x[i - 1] + (y[i - 2] - y[i - 1]);
                y[i] = y[i - 1] + (x[i - 1] - x[i - 2]);
            }
            else
            {
                x[i] = x[i - 1] + (y[i - 2] - y[i - 1]);
                y[i] = y[i - 1] - (x[i - 2] - x[i - 1]);
            }
        }

        /*
        if(x[0] == x[1])
        {
            y[2] = y[1], y[3] = y[0];
            int sign = 1;
            if(y[0] < y[1])
            sign = -1;
            x[2] = x[3] = x[0] + sign * abs(y[1] - y[0]);

        }
        else if(y[0] == y[1])
        {
            x[2] = x[1], x[3] = x[0];
            int sh = 1;
            if(x[0] > x[1])
                sh = -1;
            y[2] = y[3] = y[0] + sh * abs(x[1] - x[0]);
        }
        else
        {
            x[2] =
        }
*/
        cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
    }
    return 0;
}


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

int main()
{
  int n;
  cin>>n;
  double x,s=0;
  string y;
  for (int i=1;i<=n;i++)
  {
    cin>>x>>y;
    if (y=="JPY")
      s+=x;
    else
      s+=x*380000.0;
  }
  cout<<s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int ans=0;
  for(int i=0;i<n;i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3920