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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N;
  cin >> N;
  double tmp = 0.0;
  REP(n,N) {
    int m; cin >> m;
    tmp += (double)1/m;
  }
  printf("%.10f\n", 1.0/tmp);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        int N = 0;
        N = sc.nextInt();
        int[] ar = new int[N];

        for (int i = 0; i < N; i++) {
            ar[i] = sc.nextInt();
        }

        int KisuFlag = 0;
        int count = 0;
        while (KisuFlag == 0) {
            for (int i = 0; i < N; i++) {
                if (ar[i] % 2 != 0) {
                    KisuFlag = 1;
                }
            }
            if(KisuFlag==1){
                break;
            }
            for(int i=0;i<N;i++){
                ar[i]=ar[i]/2;
            }
            count++;
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 21844
a = {1:300000,2:200000,3:100000}

x,y = map(int,input().split())

if x == 1 and y == 1:
	print(a[x] + a[y] + 400000)
else:
	if x > 3 and y <= 3:
		print(a[y])
	elif x <= 3 and y > 3:
		print(a[x])
	elif x>3 and y >3:
		print(0)
	else:
		print(a[x] + a[y])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> array(N);
    REP(i, N) cin >> array.at(i);
    sort(ALL(array));//昇順

    int crrval=0;
    int cnt=0;
    REP(i,N){

        if(i==0){
            crrval=array.at(i);
            cnt++;
        }
        else if(crrval!=array.at(i)){
            crrval=array.at(i);
            cnt++;
        }

    }

    cout << cnt << endl;




    return 0;
}

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

int main() {
    string s;
    cin>>s;
    int S=s.size(), cnt=0;
    
    for(int i=0; i<S/2; i++){
        if(s.at(i)!=s.at(S-i-1)) cnt++;
    }

    cout<<cnt<<endl;
}


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



int main(void){
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3) ){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);

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

  int ans[N];
  for (int i = 0; i < N; i++) {
    ans[i] = 0;
  }

  int ball = 0;
  for (int i = N; i >= 1; i--) {
    if(i == 1){
      if(ball%2 != a[i-1]){
        ans[i-1] = 1;
        ball++;
      }
      break;
    }
    int count = 0;
    for (int j = 1; ; j++) {
      if(i*j-1 >= N) break;
      count += ans[i*j-1];
    }
    if(count%2 != a[i-1]){
      ans[i-1] = 1;
      ball++;
    }
  }

  printf("%d\n", ball);
  for (int i = 0; i < N; i++) {
    if(ans[i] == 1){
      ball--;
      printf("%d", i+1);
      if(ball == 0) printf("\n");
      else printf(" ");
    }
  }

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

  return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string s[3];
	scan(N);
	rep(i,3) scan(s[i]);
	int ans=0;
	rep(i,N){
		if(s[0][i]==s[1][i]&&s[0][i]==s[2][i]){

		}
		else if(s[0][i]==s[1][i]||s[0][i]==s[2][i]||s[1][i]==s[2][i]){
			ans++;
		}
		else ans+=2;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define ff first
#define ss second
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
*/
int n, m, t, k, mod = 1e9 + 7;
vector<vector<int>> mul(vector<vector<int>> &a, vector<vector<int>> &b)
{
    vector<vector<int>> c(n, vector<int>(n));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int k = 0; k < n; k++)
                c[i][j] = (c[i][j] + (a[i][k] * b[k][j]) % mod) % mod;
    return c;
}

int32_t main()
{
    ios;
    cin >> n >> k;
    vector<vector<int>> ans(n, vector<int>(n)), arr(n, vector<int>(n));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> arr[i][j], (i == j) ? ans[i][i] = 1 : ans[i][j] = 0;

    while (k)
    {
        if (k % 2)
        {
            ans = mul(arr, ans);
        }
        arr = mul(arr, arr);
        k /= 2;
    }
    int c = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            c = (c + ans[i][j]) % mod;

    cout << c << endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << -1 << endl;
    exit(0);
}

int main() {
    sonic();
    vector<ll> cnt(26, 0);
    string s;
    R s;
    ll ans=s.size()*(s.size()-1)/2+1;
    rep(i, s.size())cnt[s[i]-'a']++;
    rep(i, 26)ans-=cnt[i]*(cnt[i]-1)/2;
    co(ans);
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	cout << n*n*n << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = int64_t; // T = vector<int>
template<class T> ll sum(const T& a){ return accumulate(a.begin(), a.end(), 0ll);}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for(auto& i : h) cin >> i;
    vector good(n,true);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(h[a] <= h[b]) good[a] = 0;
        if(h[b] <= h[a]) good[b] = 0;

    }
    cout << sum(good) << endl;
}


Measured memory_bytes: 3760
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int d = s.nextInt();
		int ctr = 0;
		while(n--!=0) {
			int a = s.nextInt();
			int b = s.nextInt();
			
			if((Math.sqrt(Math.pow(a, 2)+Math.pow(b,2)))<=d) {
				ctr++;
			}
		}
		System.out.println(ctr);
	}

}

Measured memory_bytes: 60884
#include <bits/stdc++.h>
using namespace std;
int a[100010];

int main() {
    int n;
    while(~scanf("%d", &n)) {
        for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
        map<int, int> mp;
        for(int i = 1; i <= n; i++) {
            mp[a[i]]++;
        }
        int cnt = 0;
        map<int, int>::iterator it;
        for(it = mp.begin(); it != mp.end(); it++) {
            pair<int, int> x = *it;
            if(x.second % 2 != 0) cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 5376
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	var num int
	var values []int
	for i := 0; i < n; i++ {
		fmt.Scan(&num)
		values = append(values, num)
	}
	var costs []int
	for i := 0; i < n; i++ {
		var num int
		fmt.Scan(&num)
		costs = append(costs, num)
	}

	var realValues []int
	for i := 0; i < n; i++ {
		realValues = append(realValues, values[i]-costs[i])
	}
	var sum = 0
	sort.Sort(sort.Reverse(sort.IntSlice(realValues)))
	for _, realValue := range realValues {
		if realValue > 0 {
			sum += realValue
		} else {
			break
		}
	}

	fmt.Println(sum)
}


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

int main() {
    int n;
    
    cin >> n;
    
    for (int i = 0; i <= n; i++) {
        if (i * 108 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << ":(" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
s_split = s.split(", ")
print(s_split[int(input())-1])


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec w(n);
    double sum=0.0;
    rep(i,n){
        cin>>w[i];
        sum += w[i];
    }
    ll t = 0;
    double diff = 100000.0;
    rep(i,n){
        t += w[i];
        if(abs(t-sum/2)<diff){
            diff = abs(t-sum/2);
        }
//        dbg(t);
//        dbg(diff);
    }
    ll ans= diff*2;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 1000000;

typedef long long int ll;

using namespace std;

int memo[N];


int main(){
    int n;
    cin>>n;
    string val;cin>>val;
    int ans = 0;
    fore(i,0,10){
        fore(j,0,10){
            fore(k,0,10){
                bool c1 = false;
                bool c2 = false;
                bool c3 = false;
                fore(pos,0,SZ(val)){
                    if(val[pos]-48 == i && !c1){
                        c1 = true;
                    }else if(val[pos]-48 == j && !c2 && c1){
                        c2 = true;
                    }else if(val[pos]-48 == k && !c3 && c2 && c1){
                        c3 = true;
                    }
                }
                if(c1 && c2 && c3){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int x = 0,tmp = 0;
	int h, m, s;
	cin >> x;
	
	h = x / 3600;
	tmp = x % 3600;
	m = tmp / 60;
	tmp = x % 60;
	s = tmp / 1;
	cout <<h<<":"<<m<< ":" << s<<endl;

	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);CIN(M);CIN(X);CIN(Y);
    I hoge,huge;
    REP(A,N){
        CIN(b);
        hoge.pb(b);
    }
    REP(a,M){
        CIN(b);
        huge.pb(b);
    }
    hoge.push_back(X);
    huge.push_back(Y);
    if(*max_element(ALL(hoge)) < *min_element(ALL(huge))){
        COUT("No War");
    }else{
        COUT("War");
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++)
    {
    cin >> A.at(i);
    }
    int ans = 1 << 30;
    int temp = 0;
    for (int i = 1; i <= 100; i++)
    {
        temp = 0;
        for (int j = 0; j < N; j++)
        {
            temp += pow(A.at(j) - i,2);
        }
        ans = min(ans,temp);
    }
    cout << ans << endl;
  

    return 0;
}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-

t, x, y = 0, 0, 0

N = int(input())
for _ in range(N):
    t_next, x_next, y_next = map(int, input().split())

    diff_kyori = abs(x - x_next) + abs(y - y_next)
    diff_time = t_next - t

    if diff_kyori > diff_time:  # 距離が時間より大きい
        print('No')
        exit(0)
    if (diff_kyori - diff_time) % 2 == 1:  # 距離と時間の差
        print('No')
        exit(0)

    t, x, y = t_next, x_next, y_next

print('Yes')


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

using CP = complex<long double>;
#define X real()
#define Y imag()
const long double PI = acos(-1);
const long double EPS = 1e-10;
// conj(x) : complex conjugate,(0,1)->(0,-1)
// abs(x) : dist between(0,0) and x
// norm(x) : abs(x) * abs(x)
// arg(x) : argment
long double dot(CP a, CP b) { return (a * conj(b)).X; }
long double cross(CP a, CP b) { return (a * conj(b)).Y; }
long double corner(CP a, CP b) {
    //[0,pi]
    return acos(dot(a, b) / (abs(a) * abs(b)));
}

struct data{
    CP p;
    long double r;
};
struct dijk{
    int p;
    long double  dis;
};
bool operator<(const dijk &l, const dijk &r){
    if(l.dis != r.dis)return l.dis > r.dis;
    return l.p < r.p;
}

long long n;
data s,t;
vector<data> v;
vector<vector<long double>> memo;
vector<long double> dist;
priority_queue<dijk> pq;

long double solve();

int main(){
    cout << fixed << setprecision(10);
    int x,y;
    cin >> x >> y;
    s.p = CP(x,y);
    cin >> x >> y;
    t.p = CP(x,y);
    s.r = t.r = 0;
    cin >> n;
    v.resize(n + 2);
    v[0] = s;
    v[n + 1] = t;
    for(int i = 0;i < n;++i){
        cin >> x >> y;
        v[i + 1].p = CP(x,y);
        cin >> v[i + 1].r;
    }
    cout << solve() << endl;
    return 0;
}

long double solve(){
    n += 2;
    memo.assign(n,vector<long double>(n,0));
    for(int i = 0;i  < n;++i)
        for(int j = 0;j < n;++j)
            memo[i][j] = max((long double)0,abs(v[i].p-v[j].p) - v[i].r - v[j].r);
    dist.assign(n,1e13);
    dist[0] = 0;
    pq.push({0,0});
    while(!pq.empty()){
        dijk now = pq.top();
        pq.pop();
        if(now.dis != dist[now.p])continue;
        for(int i = 0;i < n;++i)
            if(now.p != i){
                dijk nextp = now;
                nextp.p = i;
                nextp.dis += memo[now.p][i];
                if(nextp.dis < dist[i]){
                    dist[i] = nextp.dis;
                    pq.push(nextp);
                }
            }
    }
    return dist[n-1];
}


Measured memory_bytes: 25964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

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

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll a,b;
    while(cin >> a >> b){
        ll GCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD = gcd(a,b);
        cout << GCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD << " " << a/GCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD*b<< endl;
    }
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <vector>
#include <math.h>


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


int main(){
	long long int N,ans;
	cin >> N;

	ans = N + N * N + N * N * N;

	cout << ans << endl;
	
return 0;
}


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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i <= _##i poi i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i < _##i poi i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i >= _##i poi i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i > _##i poi i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

int main(){
	vector<int> pyon(10) poi
    times(10, i) cin >> pyon[i] poi
    sort(pyon.begin(), pyon.end(), greater<int>()) poi
    times(3, i) cout << pyon[i] poipoi poi
    return 0 poi
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RSET(s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
typedef long long int ll;
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a&&c<=a+b)
	cout<<"YES";
        else
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
from collections import*
z,v,a=input,range,print
h,w,k=map(int,z().split());r,s,t,u=map(lambda x:int(x)-1,z().split());b=[z()for _ in v(h)];l=[[-1]*w for _ in v(h)];l[r][s]=0;d=deque([(r,s)])
while d:
  x,y=d.popleft();j=l[x][y]
  if(x==t)&(y==u):exit(a(j))
  for e,f in[[1,0],[-1,0],[0,-1],[0,1]]:
    for i in v(1,k+1):
      p,q=x+e*i,y+f*i
      if not((0<=p<h)&(0<=q<w))or b[p][q]=="@" or 0<=l[p][q]<=j:break
      if l[p][q]<0:d+=[(p,q)];l[p][q]=j+1
a(-1)

Measured memory_bytes: 36792
# ABC 119 C

N, A, B, C = map(int, input().split())

l = [int(input()) for i in range(N)]

INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        # 延長・縮小を行う
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10 # A の材料にする
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10 # B の材料にする
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10 # C の材料にする
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ans = INT_MAX;
    for (int i = 1; i <= n-2; ++i) {
        int tmp,tmp2;
        tmp = k-(a[i]-a[i-1]);
        tmp2 = k-(a[i+1]-a[i]);
        tmp = min(tmp,tmp2);
        ans = min(ans,tmp);
    }
    int tmp,tmp2;
    tmp = k-(a[1]-a[0]);
    tmp2 = a[n-1]-a[0];
    tmp = min(tmp,tmp2);
    ans = min(ans,tmp);

    tmp = k-(a[n-1]-a[n-2]);
    tmp2 = a[n-1]-a[0];
    tmp = min(tmp,tmp2);
    ans = min(ans,tmp);

    cout << ans << endl;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    int elements = 0;
    rep(i,n){
        cin >> x.at(i);
        elements += x.at(i);
    }
    int p = (elements + x.size() / 2) / x.size();
    int q = (elements - x.size() / 2)/ x.size();
    int SumofMin1 = 0;
    int SumofMin2 = 0;
    rep(i,n){
        int distance1 = abs(x.at(i) - p);
        int distance2 = abs(x.at(i) - q);
        SumofMin1 += distance1 * distance1;
        SumofMin2 += distance2 * distance2;
    }
    cout << min(SumofMin1, SumofMin2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct b{
  int u,l,r,d;
}BOX;

int main(void)
{
  int i;
  int n;
  int pos,dir;
  int h,w;
  BOX box[200];
  int maxu,maxl,maxr,maxd;


  while(1){
    scanf("%d",&n);
    if(n==0)break;

    maxu=0;maxl=0;maxr=0;maxd=0;
    for(i=0;i<n;i++){
      if(i==0){
	box[0].u=0;
	box[0].l=0;
	box[0].r=0;
	box[0].d=0;
      }else{
	scanf("%d %d",&pos,&dir);
	if(dir==0){
	  box[i].u=box[pos].u;
	  box[i].l=box[pos].l+1;
	  box[i].r=box[pos].r-1;
	  box[i].d=box[pos].d;
	  if(maxl<box[i].l)maxl=box[i].l;
	}else if(dir==1){
	  box[i].u=box[pos].u-1;
	  box[i].l=box[pos].l;
	  box[i].r=box[pos].r;
	  box[i].d=box[pos].d+1;
	  if(maxd<box[i].d)maxd=box[i].d;
	}else if(dir==2){
	  box[i].u=box[pos].u;
	  box[i].l=box[pos].l-1;
	  box[i].r=box[pos].r+1;
	  box[i].d=box[pos].d;
	  if(maxr<box[i].r)maxr=box[i].r;
	}else{
	  box[i].u=box[pos].u+1;
	  box[i].l=box[pos].l;
	  box[i].r=box[pos].r;
	  box[i].d=box[pos].d-1;
	  if(maxu<box[i].u)maxu=box[i].u;
	}
      }
    }

    w=maxl+maxr+1;
    h=maxu+maxd+1;

    printf("%d %d\n",w,h);
  }

  return 0;
}

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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(){
	int n;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	while(ifs >> n){
#else
	while(std::cin >> n){
#endif
		std::cout << 1 + n * (n + 1) / 2 << std::endl;
	}

#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}


Measured memory_bytes: 3004
#include <iostream>

class Node {
public:
	int key;
	Node* left;
	Node* right;
	Node* parent;
	Node() {left = right = parent = NULL;}
	Node(int key) { this->key = key; left = right = parent = NULL;}
	~Node(){}
};

void insert(Node** T, Node* z)
{	
	Node* y = NULL;
	Node* x = *T; // address of root
	while ( x != NULL ) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;
	
	if ( y == NULL ) *T = z; // T is empty
	else {
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void deleteKey(Node* T, int key)
{
	Node *y = NULL; // parent of x
	Node *x = T;
	while (x != NULL && x->key != key) {
		y = x;
		if (key < x->key) x = x->left;
		else if (key > x->key) x = x->right;
	}
	
	if (x != NULL && key == x->key) {
		if (x->left == NULL && x->right == NULL) {
			if (key < y->key) y->left = NULL;
			else y->right = NULL;
			delete x;
		}
		else if (x->left != NULL && x->right == NULL) {
			if (key < y->key) y->left = x->left;
			else y->right = x->left;
			delete x;
		}
		else if (x->left == NULL && x->right != NULL) {
			if (key < y->key) y->left = x->right;
			else y->right = x->right;
			delete x;
		}
		else {
			Node* zp = x;
			Node* z = x->right;
			while (z->left != NULL) {zp = z; z = z->left;}
			x->key = z->key;
			if (x == zp) zp->right = z->right;
			else zp->left = z->right;
			delete z;
		}
	}
}

bool find(Node* z, int key)
{
	if (z == NULL) return false;
	
	if (key == z->key) return true;
	if (key < z->key) return find(z->left, key);
	else return find(z->right, key);
}

void walk_preorder(Node* T)
{
	std::cout << " " << T->key;
	if (T->left != NULL) walk_preorder(T->left);
	if (T->right != NULL) walk_preorder(T->right);
}

void walk_inorder(Node* T)
{
	if (T->left != NULL) walk_inorder(T->left);
	std::cout << " " << T->key;
	if (T->right != NULL) walk_inorder(T->right);
}

void deleteNodes(Node* x)
{
	if (x->left != NULL) deleteNodes(x->left);
	if (x->right != NULL) deleteNodes(x->right);
	delete x;
}
	
int main()
{
	std::string strn;
	getline(std::cin, strn);
	
	int n = std::stoi(strn);
	
	Node* BST = NULL;
	
	for (int i=0; i<n; i++) {
		std::string buf;
		getline(std::cin, buf);
		int pos = buf.find(' ', 0);
		if (pos == std::string::npos) {
			// print
			walk_inorder(BST); std::cout << std::endl;
			walk_preorder(BST); std::cout << std::endl;
		}
		else {
			std::string op = buf.substr(0, pos);
			int key = std::stoi(buf.substr(pos+1));
			if ( op == "insert") {
				Node* z = new Node(key);
				insert(&BST, z);
			}
			else if ( op == "find" ) {
				if (find(BST, key)) std::cout << "yes" << std::endl;
				else std::cout << "no" << std::endl;
			}
			else if ( op == "delete" ) {
				deleteKey(BST, key);
			}
		}
	}
	
	deleteNodes(BST);
	
	return 0;
}



Measured memory_bytes: 21856
H, W = map(int, input().split())
S = [['.' for _ in range(W + 2)]]
for i in range(H):
    S.append(['.'] + list(input()) + ['.'])
S.append(['.' for _ in range(W + 2)])
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == '#':
            if S[i - 1][j] == '.' and S[i][j - 1] == '.' and S[i][j + 1] == '.' and S[i + 1][j] == '.':
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
	
		int x=0,y=0,a=0,b=0,c=0;
		Scanner sc=new Scanner(System.in);
		x=sc.nextInt();
		for(int i=0;i<x;i++){
			a=sc.nextInt();
			b=sc.nextInt();
			c=sc.nextInt();
			if(a>=b && a>=c);
			else if(b>=c){
				y=c;
				c=a;
				a=b;
				b=y;
			}
			else if(c>=b){
				y=b;
				b=a;
				a=c;
				c=y;
			}
			if(a*a==b*b+c*c)System.out.println("YES");
			else System.out.println("NO");
		}
	
	}
	}
		

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    ll ans = 0;
    map<int, int> m;
    FOR(i, 0, n) {
        ans += m[i - a[i]];
        ++m[i + a[i]];
    }
    m.clear();
    rFOR(i, 0, n) {
        ans += m[i - a[i]];
        ++m[i + a[i]];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 21100
#include <stdio.h>

int main( void ) {

  while( 1 ) {
    int i, n;
    int jiro[ 25 ];
    int ohjk = 32; 
    int j_command = 0;

    scanf( "%d", &n );
    if( !n ) break;

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

    while( 1 ) {
      ohjk -= ( ohjk - 1 ) % 5;
      if( ohjk <= 0 ) { printf( "0\n" ); break; }
      printf( "%d\n", ohjk );

      ohjk -= jiro[ j_command++ ];
      j_command %= n;
      if( ohjk <= 0 ) { printf( "0\n" ); break; }
      printf( "%d\n", ohjk );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef unsigned int uint;
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

const int MX = 100055;
const int MM = 1000000007;

vector<t3> G;

int main()
{
	int L, M = 1;
	scanf("%d", &L); L--;
	int n = 1;
	for(; (1<<n)-1 <= L; n++); n--;
	for(int i = 1; i <= n; i++){
		G.emplace_back(i, i+1, 0);
		G.emplace_back(i, i+1, 1<<i-1);
	}
	L -= (1<<n)-1; M += (1<<n) - 1;
	for(int i = n; i >= 0; i--){
		if(L >= (1<<i)){
			G.emplace_back(i+1, n+1, M);
			L -= 1<<i;
			M += 1<<i;
		}
	}
	printf("%d %d\n", n+1, G.size());
	for(t3 e : G){
		int a, b, c;
		tie(a, b, c) = e;
		printf("%d %d %d\n", a, b, c);
	}
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()
lamps = [[x-1 for x in i_l()[1:]] for _ in range(M)]
p = i_l()
ans = 0

for bit in range(1<<N):
    flag = True
    for i in range(M):
        cnt = 0
        for j in range(N):
            if bit & 1 << j and j in lamps[i]:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = False
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int l[1000], r[1000];

    long long ans = 0;
    rep(i, n){
        cin >> l[i] >> r[i];
        ans += (long long) ((r[i] -l[i]) + 1);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200010
using namespace std;
long long n,a[N],m=0;
vector<long long> ans;
bool book[N]={};
void make(long long x)
{
	long long i,tem=0;
	if(x==1)
	{
		if(m%2!=a[x])
		{
			m++;
			ans.push_back(x);
			book[x]=true;
		}
		return;
	}
	for(i=x;i<=n;i+=x)
	{
		if(book[i])
		{
			tem++;
		}
	}
	if(tem%2!=a[x])
	{
		m++;
		book[x]=true;
		ans.push_back(x);
	}
	return;
}
int main(){
	long long i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=n;i>0;i--)
	{
		make(i);
	}
	cout<<m<<endl;
	for(i=0;i<m;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

int main() {
    int q;
    cin >> q;
    int n=100000;
    int p[100005];
    int a[100005];
    int s[100005];
    p[1]=0;
    p[2]=1;
    for(int i=3; i<=n; i +=2){
        p[i]=1;
        p[i+1]=0;
        for(int j=3; j*j<=i; j+=2){
            if(p[j]==1 & i%j == 0){
                p[i]=0;
                break;
            }
        }
    }
    a[1]=0;
    a[2]=0;
    for(int i=3; i<=n; i +=2){
        if(p[i]==1 & p[(i+1)/2]==1) a[i]=1;
        else a[i]=0;
        a[i+1]=0;
    }
    s[1]=0;
    for(int i=2; i<=n; i +=1){
        s[i] = s[i-1]+a[i];
    }

    for(int i=0; i<q; i++){
        int x,y;
        cin >> x >> y;
        cout << s[y]-s[x-1] << endl;
    }
}

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

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

	sort(arr,arr+n);
	long long tuh=0;
	for(int i=0;i<n;i++){
	    tuh+=(long long) abs(arr[i]-arr[n/2]);
	}
	printf("%lld", tuh);
	return 0;
}


Measured memory_bytes: 1024
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

x,k,d = na()
x = abs(x)

y = x%d
yy = abs(y-d)

c = x//d

if c > k:
    print(x-d*k)
    exit()

if c%2 == k%2:
    print(y)
else:
    print(yy)

Measured memory_bytes: 9200
#include <cstdio>
#include <queue>
#include <set>

char str[200005];

std::set<int> edges[200005];
int cnt[2][200005];
int size;
bool gone[200005];

void remove(int v){
  std::queue<int> frontier;
  frontier.push(v);
  while(!frontier.empty()){
    int v=frontier.front();
    frontier.pop();
    if(gone[v]) continue;
    //printf("%d checked: %d,%d\n",v+1,cnt[0][v],cnt[1][v]);
    if(cnt[0][v]&&cnt[1][v]) continue;
    for(int adj:edges[v]){
      edges[adj].erase(v);
      if(--cnt[str[v]-'A'][adj]==0){
	frontier.push(adj);
      }
    }
    edges[v].clear();
    size--;
    //printf("%d removed\n",v+1);
    gone[v]=true;
  }
}

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  scanf("%s",str);
  for(int i=0;i<M;i++){
    int U,V;
    scanf("%d %d",&U,&V);
    U--,V--;
    edges[U].insert(V);
    edges[V].insert(U);
  }
  for(int i=0;i<N;i++){
    for(int adj:edges[i]){
      cnt[str[i]-'A'][adj]++;
    }
  }
  size=N;
  for(int i=0;i<N;i++){
    remove(i);
  }
  if(size>0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 29440
chomp($n=<>);
chomp($a=<>);
@ary=split/ /,$a;

for($i=0;$i<$n;$i++){
    if($i%2==0){
        push @even,$ary[$i];
    } else{
        push @odd,$ary[$i];
    }
}

%hashe=();
foreach (@even){
    $hashe{$_}++;
}
$num=0;
$num2=0;
foreach (sort {$hashe{$b} <=> $hashe{$a}} keys %hashe){
    if($num==0){
        $num=$hashe{$_};
        $tope=$_;
    }elsif($num2==0){
        $num2=$hashe{$_};
    }
}
$cnt = @even - $num;
$cnt2 = @even - $num2;
%hasho=();
foreach (@odd){
    $hasho{$_}++;
}
$num=0;
$num2=0;
foreach (sort {$hasho{$b} <=> $hasho{$a}} keys %hasho){
    if($num==0){
        $num=$hasho{$_};
        $topo=$_;
    }elsif($num2==0){
        $num2=$hasho{$_};
    }
}
if($tope == $topo){
    $cnt+= @odd - $num2;
    $cnt2+=@odd - $num;
    if($cnt <= $cnt2){
        $ans = $cnt;
    }else{
        $ans = $cnt2;
    }
}else{
    $cnt+= @odd - $num;
    $ans =$cnt;
}
print $ans;

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

int main()
{
  std::string s;
  
  std::cin>>s;
  
  if(s=="RRR")
  {
    std::cout<<3;
  }
  else if(s=="SRR"||s=="RRS")
  {
    std::cout<<2;
  }
  else if(s=="SSS")
  {
    std::cout<<0;
  }
  else
  {
    std::cout<<1;
  }
  
  std::cout<<std::endl;
  
  return 0;
}

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


int main (){
    string s, t;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s){
        a--;
    }
    else{
        b--;
    }

    cout << a <<" "<< b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define N_MAX 1000
#define M 1000000007
using namespace std;
typedef long long ll;
 
ll func(int);
 
int N,s,t;
string n[N_MAX];
vector<int> edge[N_MAX];
 
int main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>n[i];
  for(int i=0;i<N-1;i++) cin>>s>>t,edge[s-1].push_back(t-1);
  cout<<func(0)%M<<endl;
  return 0;
}
 
ll func(int x){
  ll res=0,res2=1;
  if(!edge[x].size()){
    if(n[x]=="E") return 1;
    if(n[x]=="E?") return 2;
    return 0;
  }
  if(n[x]=="E"){
    for(int i=0;i<edge[x].size();i++) res2*=func(edge[x][i]);
    return res2%M;
  }
  if(n[x]=="E?"){
    for(int i=0;i<edge[x].size();i++) res2*=func(edge[x][i]);
    return (res2+1)%M;
  }
  if(n[x]=="A"){
    for(int i=0;i<edge[x].size();i++) res+=func(edge[x][i]);
    return res%M;
  }
  if(n[x]=="A?"){
    for(int i=0;i<edge[x].size();i++) res+=func(edge[x][i]);
    return (res+1)%M;
  }
  if(n[x]=="R?"){
    for(int i=0;i<edge[x].size();i++) res2*=(1+func(edge[x][i]));
    return res2%M;
  }
  if(n[x]=="R"){
    for(int i=0;i<edge[x].size();i++) res2*=(1+func(edge[x][i]));
    return (res2-1)%M;
  }
}

Measured memory_bytes: 1340
n, m = input().split()
n, m = int(n), int(m)

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

ans = 0

s = 0

for j in range(n):
    s += a[j]

for i in range(n):
    if a[i] >= (s / (4 * m)):
        ans += 1

if ans >= m:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
int a,b;
cin >> a >> b;
if(a%3==0||b%3==0||(a+b)%3==0){
  cout << "Possible" << endl;
}
else{
  cout << "Impossible" << endl;
}


  return 0;
}


Measured memory_bytes: 256
w=[]
while True:
    try:
        s,n=input().split()
    except:
        break
    ch=True
    for i in range(len(w)):
        if w[i][0]==s:
            w[i].append(int(n))
            ch=False
            break
    if ch:
        w.append([s,int(n)])
w.sort()
for i in range(len(w)):
    print(w[i][0])
    p=sorted(w[i][1:])
    print(*p)


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   char S[150];
   string H = "Three";
   cin >> N;
   for(int i=0; i<N; i++){
        cin >> S[i];
        if(S[i] =='Y'){
            H = "Four";
        }
   }
   cout << H << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}
 
int main() {
    ll n,k;
    cin >> n >> k;
    ll ans=Pow(k,n);
    vector<ll> a(k+1,1);
    for(ll i=2;i<=k;i++){
        ll y=k/i,x=i;
        ll c=(MOD+i-a[i])%MOD;
        ans=(ans+Pow(y,n)*c%MOD)%MOD;
        while(true){
            if (x>k) break;
            a[x]+=c;
            x+=i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#define llint long long
#define inf 100000000000000000

using namespace std;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

int N, M;
vector<edge> G[1005];
llint dist[1005];

int main(void)
{
	cin >> N >> M;
	llint a, b, c;
	for(int i = 0; i < M; i++){
		cin >> a >> b >> c;
		G[a].push_back(edge(b, -c));
	}
	
	for(int i = 1; i <= N; i++) dist[i] = inf;
	dist[1] = 0;
	
	int cnt = 0; llint prev;
	bool update = true;
	while(update){
		update = false;
		for(int i = 1; i <= N; i++){
			for(int j = 0; j < G[i].size(); j++){
				if(dist[i] < inf && dist[G[i][j].to] > dist[i] + G[i][j].cost){
					dist[G[i][j].to] = dist[i] + G[i][j].cost;
					update = true;
				}
			}
		}
		cnt++;
		if(cnt == N+1) prev = dist[N];
		if(cnt >= 2*N){
			if(prev > dist[N]){
				cout << "inf" << endl;
				return 0;
			}
			else break;
		}
	}
	cout << -dist[N] << endl;
	return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll A, B, C;
  scanf("%lld %lld %lld", &A, &B, &C);

  ll K;
  scanf("%lld", &K);

  for (ll i = 0; i < K; i++) {
    if (B <= A) {
      B *= 2;
      continue;
    }
    if (C <= B) {
      C *= 2;
      continue;
    }
  }

  // cout << A << " " << B << " " << C << endl;

  if (C > B && B > A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5;
int cnt[30];
char str[N];
int main() {
	//freopen("in.txt","r",stdin);
	memset(cnt, 0, sizeof(cnt));
	cin>>str;
	int len = strlen(str);
	for(int i=0;i<len;i++) {
		cnt[str[i] - 'a'] ++;
	}
	int sum = 0;
	for(int i=0;i<26;i++)sum += cnt[i];
	ll ans = 1;
	for(int i=0;i<25;i++) {
		sum -= cnt[i];
		ans += (ll)sum * (ll)cnt[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main () {
	int n, w;
	cin >> n >> w;
	pair<int, int> items[n+1];
	for (int i=1; i<=n; i++) {
		cin >> items[i].first >> items[i].second;
	}
	long long dp[n+1][w+1];
	for (int i=0; i<=w; i++) {
		dp[0][i] = 0;
	}
	for (int i=1; i<=n; i++) {
		for (int j=0; j<items[i].first; j++) {
			dp[i][j] = dp[i-1][j];
		}
		for (int j=items[i].first; j<=w; j++) {
			dp[i][j] = max(dp[i-1][j], dp[i-1][j-items[i].first]+items[i].second);
		}
	}
	cout << dp[n][w] << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 2005;
vector<int> g[N];
int dist[N][N];

void dfs(int v, int p, int __dist, int rt){
	dist[rt][v] = __dist;
	for(auto u : g[v]){
		if(u != p)dfs(u, v, __dist + 1, rt);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	for(int i = 1; i < n; i++){
		int u, v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i = 1; i <= n; i++){
		dfs(i, 0, 0, i);
	}
	int ans = n;
	if(k&1){
		for(int rt = 1; rt <= n; rt++){
			for(int rrt : g[rt]){
				int tmp = n;
				for(int v = 1; v <= n; v++){
					if(dist[rt][v] <= k/2 || dist[rrt][v] <= k/2)tmp--;
				}
				ans = min(ans, tmp);
			}
		}
	}else{
		for(int rt = 1; rt <= n; rt++){
			int tmp = n;
			for(int v = 1; v <= n; v++){
				if(dist[rt][v] <= k/2)tmp--;
			}
			ans = min(ans, tmp);
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 16128
N=int(input())
flag=False

if N%4==0 or N%7==0:
    flag=True

maximum=N//4
minimum=N//7

for i in range(N//4):
    for j in range(N//7):
        if 4*(i+1)+7*(j+1)==N:
            flag=True
        else:
            continue

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060