akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
int N,K,h[100001];
int i,j;
int dp[100101];
inline void solve(){
  IN2(N,K);
  UP(i,1,N){
    IN(h[i]);
  }
  dp[1]=0;
  UP(i,2,100101)dp[i]=INT_MAX;
  UP(i,1,N-1){
    UP(j,1,K){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  OUT(dp[N]);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    int cnt  =0;
    for(int i = 0; i < s.size()/2; i++){
        if(s[i] != s[s.size() - i-1]) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const long double PI = 3.14159265358979323846l;
const long double Moon_T = 41666.666666666667l;
const long double Moon_S = 1800.0000000000000l;
const long double Kaguya_S = 1900.00000000000l;
const long double Kaguya_T = 120.000000000000l;
const long double Dist = 380000.0000000000000l;
long double start, times;

struct Point { long double x, y, z; };
long double SIN(long double r) { return sin(r*PI / 180.0l); }
long double COS(long double r) { return cos(r*PI / 180.0l); }
Point getpoint(long double r, long double t) {
	Point mn = Point{ Dist*COS(r), Dist*SIN(r), 0.0l };
	Point Kgy = { mn.x - Kaguya_S*SIN(t / Kaguya_T*360.0l),mn.y, mn.z + Kaguya_S*COS(t / Kaguya_T*360.0l) };
	return Kgy;
}
long double dist(Point a, Point b) {
	long double a1 = (a.x - b.x)*(a.x - b.x);
	long double a2 = (a.y - b.y)*(a.y - b.y);
	long double a3 = (a.z - b.z)*(a.z - b.z);
	return sqrtl(a1 + a2 + a3);
}
long double dst(Point a, Point b) {
	long double L1 = 375000, R1 = 385000, c1, c2;
	long double A1 = dist(Point{ 0,0,0 }, b);
	R1 = A1;
	long double Ax1 = b.x / A1;
	long double Ay1 = b.y / A1;
	long double Az1 = b.z / A1;
	long double minx = 1000000000.0l;
	for (int i = 0; i < 60; i++) {
		c1 = (L1 + L1 + R1) / 3.0l;
		c2 = (L1 + R1 + R1) / 3.0l;
		Point RR1 = { Ax1*c1,Ay1*c1,Az1*c1 };
		Point RR2 = { Ax1*c2,Ay1*c2,Az1*c2 };
		long double d1 = dist(a, RR1);
		long double d2 = dist(a, RR2);
		if (d1 < d2)R1 = c2;
		if (d1 > d2)L1 = c1;
		minx = min(minx, min(d1, d2));
	}
	return minx;
}
long double solve(long double t) {
	long double rr = (start / 360.0l + (t / Moon_T))*360.0l;
	Point PP1 = getpoint(rr, t);
	Point PP2 = Point{ Dist*COS(rr), Dist*SIN(rr), 0.0l };
	long double ans = dst(PP2, PP1);
	return ans;
}
int main() {
	cin >> start >> times; long double cnt = 0.0l;
	for (long double i = 0.0l; i < times; i += 0.005l) {
		if (solve(i) < Moon_S)cnt += 0.005l;
	}
	printf("%.12Lf\n", cnt);
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,t=0; cin >> n;
    vector<pair<long,long>> v(n);
    for(int i=0;i<n;i++){
        long a,b; cin >> a >> b;
        v[i] = make_pair(b,a);
    }
    bool B = true;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        long a,b; tie(b,a) = v[i];
        t += a;
        if(t > b){
            cout << "No" << endl;
            B = false;
            break;
        }
    }
    if(B)cout << "Yes" << endl;
}

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

const int M = 1000005;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi cnt(M);
    for (int x : a) {
        if (cnt[x] > 0) {
            cnt[x]++;
            continue;
        }
        for (int i=x; i<M; i+=x) cnt[i]++;
    }
    int ans = 0;
    rep(i, n) if (cnt[a[i]] == 1) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8008
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

typedef struct N_t
{
  vector<int> b; // branches
  int value;
} N;

int main()
{
  int n;
  cin >> n;
  int i, j;
  N* node = new N[n + 1];
  N* temp = new N[n + 1];
  vector<int> c(n);
  for (i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    node[a].b.push_back(b);
    node[b].b.push_back(a);
  }
  for (i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(c.begin(), c.end());
  vector<int> f(n + 1, -1);
  queue<int> q;
  int ci = n - 1;
  node[1].value = c[ci--];
  node[node[1].b[0]].value = c[ci--];
  // for (i = 1; i <= n; i++) {
  //   cout << i << ":" << node[i].value << endl;
  // }
  q.push(1);
  while (!q.empty()) {
    int j;
    j = q.front();
    q.pop();
    if (f[j] != -1)
      continue;
    for (i = 0; i < node[j].b.size(); i++) {
      q.push(node[j].b[i]);
      if (node[node[j].b[i]].value == 0) {
        node[node[j].b[i]].value = c[ci--];
      }
    }
    f[j] = 0;
  }
  // cout << ci << endl;
  int ans;
  ans = 0;
  for (i = 0; i < n - 1; i++) {
    ans += c[i];
  }
  cout << ans << endl;
  for (i = 1; i <= n; i++) {
    cout << node[i].value << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <utility>
using namespace std;

class Dice{
  int T,S,E,W,N,D;

  public:
  Dice(int T, int S, int E,
      int W, int N, int D)
    : T(T), S(S), E(E),
    W(W), N(N), D(D) {}

  Dice(){}

  int get_top() { return T; }
  int get_south(){ return S; }
  int get_east() { return E; }
  int get_west() { return W; }
  int get_down() { return D; }

  void rot(char c){
    int tmp;
    tmp = T;
    switch(c){
      case 'N':
        T = S; S = D; D = N; N = tmp;
        break;
      case 'S':
        T = N; N = D; D= S; S = tmp;
        break;
      case 'E':
        T = W; W = D; D = E; E = tmp;
        break;
      case 'W':
        T = E; E = D; D = W; W = tmp;
        break;
    }
  }

  void twist(char c){
    int tmp;
    tmp = S;
    switch(c){
      case 'R':
        S = E; E = N; N=W; W=tmp;
        break;
      case 'L':
        S = W; W = N; N=E; E=tmp;
        break;
    }
  }

  bool equal(Dice &other)
  {
    if(T==other.T &&
        S==other.S &&
        E==other.E &&
        W==other.W &&
        N==other.N &&
        D==other.D)
    {
      return true;
    }else
    {
      return false;
    }
  }

  bool operator==(Dice &other)
  {
    return equal(other);
  }

  bool equaldice(Dice &other)
  {
    bool flag = false;
    for(int i=0;i<4;i++)
    {
      for(int j=0;j<4;j++)
      {
        other.rot('E');
        if(equal(other)) flag=true;
      }
      other.rot('S');  
    } 
    for(int i=0;i<4;i++)
    {
      for(int j=0;j<4;j++)
      {
        other.rot('E');
        if(equal(other)) flag=true;
      }
      other.twist('R');
    }
    return flag;
  }
};

Dice load_dice(){
  Dice d;
  int num[6];
  for(int i=0;i<6;i++) cin>>num[i];
  d = Dice(num[0],num[1],num[2],num[3],num[4],num[5]);
  return d;
}

int main(){
  int n;
  bool find=false;
  cin>>n;
  Dice *d = new Dice[100];
  d[0] = load_dice();
  for(int i=1;i<n;i++)
  {
    d[i] = load_dice();
    for(int j=0;j<i;j++)
    {
      if(d[j].equaldice(d[i])){
        find=true;
        break;
      }
    }
    if(find) break;
  }

  if(find){ 
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }

  return 0;

}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b,c;
    cin >> a;
    if(a == 1){
        cout << "Hello World" << endl;
    }else{
        cin >> b >> c;
        cout << b+c << endl;
    }
}

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

int main()
{
    int64_t n;
    cin >> n;
    int64_t dp[n + 1];
    fill(dp, dp + n + 1, (1ll << 60));
    dp[0] = 0;
    for (int64_t i = 0; i < n; i++)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        for (int64_t j = 6; i + j <= n; j *= 6)
        {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
        for (int64_t j = 9; i + j <= n; j *= 9)
        {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

const int N = 110;
int n, ans;
int a[N], b[N], s1[N], s2[N];

int main() {
	int i;
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]);
	rep(i, 1, n) scanf("%d", &b[i]);
	rep(i, 1, n) s1[i] = s1[i-1] + a[i];
	dep(i, n, 1) s2[i] = s2[i+1] + b[i];
	rep(i, 1, n) ans = max(s1[i]+s2[i], ans);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll n,a=0;
    cin >> n;
    vector<ll> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    ll min = 1e5*2;
    for(int i=0;i<n;i++){
        if(min >= p[i]){
            min = p[i];
            a++;
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int NMAX = 100;
const int AMAX = 2001;
int A[NMAX][NMAX];
int C[NMAX];
int n;

int MST(int a) {
	C[a] = 1;
	int sum, minv, mina;
	sum = 0;

	while (true) {
		minv = AMAX;
		mina = -1;
		for (int i = 0; i < n; i++) {
			if (C[i] == 0) {
				continue;
			}
			for (int j = 0; j < n; j++) {
				if (C[j] == 1 || A[i][j] == AMAX) {
					continue;
				}
				minv = min(A[i][j], minv);
				if (A[i][j] == minv) {
					mina = j;
				}
			}
		}
		if (minv == AMAX || mina == -1) {
			break;
		}
		C[mina] = 1;
		sum += minv;
	}

	return sum;
}

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

	for (int i = 0; i < n; i++) {
		C[i] = 0;
		for (int j = 0; j < n; j++) {
			scanf("%d", &A[i][j]);
			if (A[i][j] == -1) {
				A[i][j] = AMAX;
			}
		}
	}

	printf("%d\n", MST(0));

	return 0;
}



Measured memory_bytes: 3240
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String s;
        int m;
        int h;
        int i;
        while(!(s=sc.next()).equals("-")){
            m=sc.nextInt();
            for(i=0;i<m;i++){
                h=sc.nextInt();
                s=s.substring(h,s.length())+s.substring(0,h);
            }
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 26180
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1e4 + 4;

int n, h;
int a[N], b[N];
int dp[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> h >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	MMS(dp, '?');
	dp[0] = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 0; j < n; j++) {
			dp[i] = min(dp[i], dp[max(0, i - a[j])] + b[j]);
		}
	}
	cout << dp[h] << endl;
	return 0;
}


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

using namespace std;

int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  while (x || y) {
    x <= y ? printf("%d %d\n", x, y) : printf("%d %d\n", y, x);
    scanf("%d %d", &x, &y);
  }
  return 0;
}



Measured memory_bytes: 3124
// D - AtCoder Express 2
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int l,r,N,M,Q; cin>>N>>M>>Q;
	vvi X(N+1, vi(N+1, 0));
	rep(i, M){cin>>l>>r; X[l][r]++; }
	rep(l, N) rep(r, N) X[l+1][r+1] += X[l+1][r];
	rep(r, N) rep(l, N) X[l+1][r+1] += X[l][r+1];
	while(Q--){ cin>>l>>r; cout<< X[N][r] - X[l-1][r] <<endl; }
}

Measured memory_bytes: 1920
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>

using namespace std;



int main(void){
	int N;
	int i,j;
  	long long int sum=0;
	unsigned int A[100001];
	unsigned int B[100000];
	//int tmp,success=0;

	cin >> N;

	for (i = 0; i < N+1; i++){
		cin >> A[i];
	}
	for (i = 0; i < N; i++){
		cin >> B[i];
	}

	for (i = 0; i < N; i++){
		if (B[i] <= A[i]){
			sum += B[i];
		}
		else if (B[i] > A[i]){
			if ((A[i] + A[i + 1]) >= B[i]){
				sum += B[i];
				A[i + 1] = A[i + 1] - (B[i] - A[i]);
			}
			else if ((A[i] + A[i + 1]) < B[i]){
				sum += (A[i] + A[i + 1]);
				A[i + 1] = 0;
			}

		}
	}
	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(long long i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    long N = S.size();
    vector<pair<long, long> > face;
    long long down = 0, up = 0;
    bool flag = false;
    REP(i,N){
        if (S[i] == '>'){
            if (flag) {
                face.push_back(make_pair(down, up));
                down = 0;
                up = 0;
                flag = false;
            }
            ++down;
        } else{
            flag = true;
            ++up;
        }
    }
    face.push_back(make_pair(down, up));
    long L = face.size();
    // REP(i, L) cout << face[i].first << ' ' << face[i].second << endl;
    long long ans = 0;
    REP(i,L){
        down = face[i].first;
        up = face[i].second;
        ans += (up*(up+1) + down*(down+1))*1/2;
    }
    REP(i, L-1){
        long long up1 = face[i].second;
        long long down2 = face[i+1].first;
        ans -= min(up1, down2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3352
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

const ll MAX = 5000001;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    vll elast(MAX, 0);
    for (ll i = 2; i < MAX; i++) {
        if (elast[i] == 0) {
            for (ll j = 2 * i; j < MAX; j += i) {
                elast[j] = 1;
            }
        }
    }

    for (ll i = x; i < MAX; i++) {
        if (elast[i] == 0) {
            cout << i << '\n';
            break;
        }
    }
    return 0;
}


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

int main(){
    int p,q,r; cin >> p >> q >> r;
    int ans = p+q;
    ans = min(ans,p+r);
    ans = min(ans,q+r);
    cout << ans << endl;
}

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

using namespace std;

int main(){
	map<string, int> m;
    int n; cin >> n;
    while(n--){
        string s;
        cin >> s;
        if(!m.count(s))m[s] = 1;
        else m[s]++;
    }
    int maxC = -1;
    vector<string> vec;
    for(auto &v : m){
        maxC = max(maxC, v.second);
    }
    for(auto &v : m){
        if(v.second == maxC)vec.emplace_back(v.first);
    }
    sort(vec.begin(), vec.end());
    for(auto s:vec){
        cout << s << endl;
    }
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<ll> A;
    rep(i, n) {
        ll a; 
        cin >>a;
        A.push_back(a);
    }
    
    ll sum_xor = 0; 
    rep(i, n) {
        sum_xor ^= A[i];
    }

    rep(i, n) {
        int ans = sum_xor ^ A[i];
        cout << ans << " ";  
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
int t;
long long n,w,ans;
inline long long Mx(long long x,long long y){return x>y?x:y;}
inline long long Mi(long long x,long long y){return x<y?x:y;}
inline long long read()
{
    long long x=0;char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x;
}
void exgcd(long long x,long long y)
{
    if(x%y==0) ans+=((x/y-1)<<1|1)*y;
    else
    {
        ans+=((x/y)<<1)*y;
        exgcd(y,x%y);
    }
}
int main()
{
 
        n=read(),w=read();ans=0;
        ans+=n;exgcd(Mx(w,n-w),Mi(w,n-w));
        printf("%lld\n",ans);
    
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a, int b ){
    int r, tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
vector<int> prime(1000000,0);
int amax = 1000001;
vector<bool> isPrime(amax+1, true);
void pr(){
    int p = 0;
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i<=amax; ++i){
        if(isPrime[i]){
            prime[p] = i;
            ++p;
            for(int j=i*2;j<=amax;j+=i) isPrime[j]=false;
        }
    }
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint a(n);
    REP(i,n) cin >> a[i];
    pr();
    vector<bool> used(1000001, false);
    int x = a[0];
    bool f = true;
    REP(i,n){
        x = gcd(x, a[i]);
        int t = a[i];
        for(int j=0;prime[j]*prime[j]<=a[i];++j){
            if(t%prime[j]==0){
                if(used[prime[j]]==true){
                    f = false;
                }
                while(t%prime[j]==0){
                    t/=prime[j];
                }
                used[prime[j]]=true;
            }            
        }
        if(t>1){
            if(used[t]==true){
                f = false;
            }
            used[t]=true;
        }
    }
    if(f){
        cout << "pairwise coprime" << endl;
    }else if(x==1){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }

    return 0;
}

Measured memory_bytes: 11404
import sys
import bisect
sys.setrecursionlimit(10**7)
N = int(input())
L = list(map(int, input().split()))
L.sort()

cnt = 0
lenL = len(L)
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L[i+1:]):
        sumll = l1 + l2
        pos = bisect.bisect_left(L, sumll)
        add = pos - i - j - 2
        cnt += add
print(cnt)

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

	long int n,a[10000000];
	int main(){
		long int MIN = 10000000,MAX =-100000000,total = 0;

		cin >> n;
		for(int i = 0; i<n;i++){

			cin >> a[i];
			total +=a[i];
			MIN = min (MIN,a[i]);
			MAX = max (MAX,a[i]);

		}
		cout << MIN << " " << MAX << " " << total << endl;

		return 0;

	}

Measured memory_bytes: 1244
parseInts :: String -> [Int]
parseInts line = map (\x -> read x :: Int) $ words line

sortInts :: [Int] -> [Int]
sortInts [] = []
sortInts (x:xs) =
    sortInts lower ++ [x] ++ sortInts upper
    where
        lower = [l | l <- xs, l <= x]
        upper = [u | u <- xs, x <  u]

intsToString :: [Int] -> String
intsToString = unwords.map show

main :: IO ()
main = do
    line <- getLine
    let
        nums = sortInts $ parseInts line
    putStrLn $ intsToString nums

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

vector<int> graph[100];
int d[100], f[100];
int visited = 1;

void dfs(int id){
    d[id] = visited++;
    for(int i = 0; i < graph[id].size(); i++)
	{
        if(graph[id][i] != id && !d[graph[id][i]] && !f[graph[id][i]])
		{
			dfs(graph[id][i]);
		}
    }
    f[id] = visited++;
}

int main(){
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
	{
        int u, k;
        cin >> u >> k;
        for(int j = 0;j < k;j++)
		{
            int v;
            cin >> v;
            graph[u - 1].push_back(v - 1);
        }
    }
    dfs(0);
    for(int i = 0;i < n;i++)
	{
        if(!f[i]) 
		{
			dfs(i);
		}
    }
    for(int i = 0;i < n;i++)
	{
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <complex>
using namespace std;

int main()
{
    long n,k;
    string s;
    cin  >> s;

    vector <char> a;
    vector <bool> a_bol;
    for(char i ='a';i<='z';i++){
        a.push_back(i);
        a_bol.push_back(false);
    }

    bool isfind=false;
    char ans;

    for(int i=0;i<a.size();i++){
        bool isNone=true;
        if (a_bol[i]==true)continue;
        for(int j=0;j<s.size();j++){
            if (s[j]==a[i]){
                a_bol[i]=true;
                isNone=false;
                break;
            }
        }
        if (isNone){
            isfind = true;
            ans = a[i];
            break;
        }

    }

    if (isfind){
        cout << ans;
    }else{
        cout << "None";
    }

    // cout << (isfind==true) ? (char)ans :"None" ;
    
    return 0;
}






Measured memory_bytes: 512
// Making chalk mark on generator: $1
// Knowing where to make mark: $9,999
#include <bits/stdc++.h>
#define when(...) fprintf(stderr,__VA_ARGS__)
typedef long long ll;
ll read() {
   static char c;
   static ll x;
   int flag = 1;
   while (c = getchar(), !isdigit(c))
      if (c == '-') flag = 0;
   x = c - '0';
   while (c = getchar(), isdigit(c))
      x = x * 10 + c - '0';
   return flag ? x : -x;
}

struct edge   {
   int pre,to;
} gs[200200];
int head[200200],gc;
void add(int x,int y){
   gs[++gc]={head[x],y};
   head[x]=gc;
}

const ll mod=1e9+7;
ll ksm(ll x,ll y=mod-2){
   ll ans=1;
   for(;y;x=x*x%mod,y>>=1)
      if (y&1)
         ans=ans*x%mod;
   return ans;        
}

int n;
int dep[200200],indep[200200],maxdep[200200],son[200200],h[200200];
ll *ans[200200][3],_ans[20020002],*now=_ans;
void preprocess(int x){
   indep[dep[x]]++;
   for(int i=head[x];i;i=gs[i].pre){
      maxdep[gs[i].to]=dep[gs[i].to]=dep[x]+1;
      preprocess(gs[i].to);
      maxdep[x]=std::max(maxdep[x],maxdep[gs[i].to]);
   }
   for(int i=head[x];i;i=gs[i].pre)
      if (maxdep[gs[i].to]==maxdep[x]) 
         son[x]=gs[i].to;
}

void split(int x,int d=0){
   h[x]=d;
   if (son[x]) split(son[x],d+1);
   for(int i=head[x];i;i=gs[i].pre)
      if (gs[i].to!=son[x]) 
         split(gs[i].to,0);
   
   if (son[x]) for(int i=0;i<3;++i) ans[x][i]=ans[son[x]][i]-1;
   else for(int i=0;i<3;++i) now+=(h[x]+5),ans[x][i]=now;
}

void solve(int x){
   ans[x][0][0]=1;
   ans[x][1][0]=1;
//   printf("%d %lld %lld\n",x,ans[x][0][0],ans[x][1][0]);
   if (son[x]==0) return;
   
   solve(son[x]);
   int length=0;
   for(int i=head[x];i;i=gs[i].pre){
      if (gs[i].to==son[x]) continue;  
      length=std::max(length,maxdep[gs[i].to]-dep[gs[i].to]+1);
   }
   for(int i=0;i<=length;++i) ans[x][2][i]=0;
   
   for(int i=head[x];i;i=gs[i].pre){
      int y=gs[i].to;
      if (y==son[x]) continue;
      solve(y);
      int len=maxdep[y]-dep[y]+1;
      for(int j=1;j<=len;++j){
         ll t0=ans[x][0][j],t1=ans[x][1][j],t2=ans[x][2][j];
         ans[x][0][j]=t0*ans[y][0][j-1]%mod;
         ans[x][1][j]=(t0*ans[y][1][j-1]+t1*ans[y][0][j-1])%mod;
         ans[x][2][j]=(t1*ans[y][1][j-1]+t2*(ans[y][0][j-1]+ans[y][1][j-1]))%mod;
      }
   }
   for(int i=0;i<=length;++i) ans[x][0][i]=(ans[x][0][i]+ans[x][2][i])%mod;
}

signed main() {
   n=read();
   for(int i=1;i<=n;++i){
      int p=read();
      add(p,i);   
   }
   preprocess(0);
   split(0);
   solve(0);
   
   ll sum=0;
//   for(int i=0;i<=maxdep[0];++i) when("%lld %lld\n",&ans[0][0][i]-_ans,&ans[0][1][i]-_ans);
//   for(int i=0;i<=maxdep[0];++i) when("%lld %lld\n",&ans[son[0]][0][i]-_ans,&ans[son[0]][1][i]-_ans);
   for(int i=0;i<=maxdep[0];++i) sum=(sum+ans[0][1][i]*ksm(2,n+1-indep[i]))%mod;
   printf("%lld\n",sum);
}



Measured memory_bytes: 36864
#include<stdio.h>

void bubbleSort(int A[] , int n){
  int i,j,temp,num=0;
  for(i = 0;i < n; i++){
    for(j = n - 1; j >= 1; j--){
      if(A[j] < A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	num++;
      }
    }
  }
   for(i = 0; i < n; i++){
    printf("%d", A[i]);
    if(i== n-1)  break;
      printf(" ");
   }
   printf("\n%d\n", num);
}
int main(){
  int i,j,N,temp,num=0;
  scanf("%d", &N);
  int A[N];
  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  bubbleSort(A,N);
  return 0;
}

Measured memory_bytes: 604
package main

import (
  "fmt"
  "sort"
  )

func main() {
  var N int
  var A []int

  fmt.Scan(&N)

  for i := 0; i < N; i++ {
    tmp := 0
    fmt.Scan(&tmp)
    A = append(A, tmp)
  }
  sort.Sort(sort.Reverse(sort.IntSlice(A)))

  bob := 0
  alice := 0
  for i := 0; i < N; i++ {
    if i%2 == 0 {
      alice += A[i]
    } else {
      bob += A[i]
    }
  }
  fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include <iostream>

long long gcd(long long x_g, long long y_g)
{
    long long tmp_small;
    long long tmp_big;
    long long tmp;
    if (x_g < y_g) {
        tmp_big = y_g;
        tmp_small = x_g;
    } else {
        tmp_big = x_g;
        tmp_small = y_g;
    }

    while (true) {
        tmp = (tmp_big % tmp_small);
        if (tmp == 0) {
            return tmp_small;
            break;
        }
        tmp_big = tmp_small;
        tmp_small = tmp;
    }
    return tmp_small;
}


long long lcm(long long x, long long y)
{
    return x * y / gcd(x, y);
}

long long A, B, C, D;
int main()
{
    std::cin >> A >> B >> C >> D;
    long long E = lcm(C, D);
    if (false)
        std::cout << "E:" << E << "\n";

    long long ans = B - A + 1;
    ans -= (B / D) - ((A - 1) / D);
    if (false)
        std::cout << "D:" << D << " " << (B / D) - ((A - 1) / D) << "\n";

    ans -= (B / C) - ((A - 1) / C);
    if (false)
        std::cout << (B / C) - ((A - 1) / C) << "\n";

    ans += (B / E) - ((A - 1) / E);

    if (false)
        std::cout << (B / E) - ((A - 1) / E) << "\n";

    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>

int main() {
    int N, K;
    std::cin >> N >> K;
    std::unordered_set<int> received;
    for (int i=0; i<K; i++) {
        int di;
        std::cin >> di;
        for (int j=0; j<di; j++) {
            int Aij;
            std::cin >> Aij;
            received.insert(Aij);
        }
    }
    int tricked = 0;
    for (int i=1; i<=N; i++) {
        if (received.count(i) == 0) {
            tricked++;
        }
    }
    std::cout << tricked << std::endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;


int main() {
    ll A, B;
    cin >> A >> B;

    ll C_b = A / 0.08;
    while (C_b * 0.08 < A) {
      C_b ++;
    }
    ll C_u = (A + 1)/ 0.08;
    while (C_u * 0.08 < A + 1) {
      C_u ++;
    }
    ll D_b = B / 0.1;
    while (D_b * 0.1 < B) {
      D_b ++;
    }
    ll D_u = (B + 1)/ 0.1;
    while (D_u * 0.1 < B + 1) {
      D_u ++;
    }
    
    if (C_b >= D_b) {
      if (C_b < D_u) {
        cout << C_b << endl;
      } else {
        cout << -1 << endl;
      }
      return 0;
    }
    if (D_b < C_u) {
      cout << D_b << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

vi adj[100001];
int n, mod;

int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int dp[100001];

int dfs(int x, int p = -1)
{
    if (dp[x] != -1) return dp[x];
    int sol = 1;
    for (int y : adj[x])
        if (y != p)
            muls(sol, add(1, dfs(y, x)));
    return dp[x] = sol;
}

int dp2[100001];

void dfs2(int x, int p = -1, int f = 0)
{
    int sz = adj[x].size() - int(p != -1), i = 0;
    vi pref(sz), suff(sz);
    for (int y : adj[x])
        if (y != p)
            pref[i] = suff[i] = add(1, dp[y]), ++i;
    for (int i = 1; i < sz; ++i)
        muls(pref[i], pref[i - 1]);
    for (int i = sz - 2; i >= 0; --i)
        muls(suff[i], suff[i + 1]);

    i = 0;
    for (int y : adj[x])
    {
        if (y == p) continue;
        int g = add(f, 1);
        if (i != 0) muls(g, pref[i - 1]);
        if (i != sz - 1) muls(g, suff[i + 1]);
        dfs2(y, x, g);
        ++i;
    }
    dp2[x] = mul(add(f, 1), dp[x]);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> mod;
    for (int i = 0; i < n - 1; ++i)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    memset(dp, -1, sizeof dp);
    dfs(1);
    dfs2(1);
    for (int i = 1; i <= n; ++i)
        cout << dp2[i] << '\n';
}


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

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

int main() {
	string s;
	cin >> s;
	int q;
	cin >> q;
	string t;
	rep(i, q){
		int ty;
		cin >> ty;
		if(ty == 1){
			swap(s,t);
		}
		else{
			int f; char c;
			cin >> f >> c;
			if (f ==1){
				t += c;
			}
			else {
				s += c;
			}
		}
	}
	reverse(t.begin(), t.end());
	t += s;
	cout << t << endl;



}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

vector <vl> adj(200005);
vl vis(200005, 0);

void dfs(ll i, ll &c) {
	for (auto j : adj[i]) {
		if (!vis[j]) {
			vis[j] = 1;
			c++;
			dfs(j, c);
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m;
	cin >> n >> m;
	//map <pair<ll,ll>,ll> mp;
	for (ll i = 0; i < m; i++) {
		ll u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	ll ans = 1;
	for (ll i = 0; i < n; i++) {
		if (!vis[i]) {
			vis[i] = 1;
			ll c = 1;
			dfs(i, c);
			ans = max(ans, c);
		}
	}
	cout << ans << "\n";

}


Measured memory_bytes: 25076
/**
 * author: BueVonHun 🐼🎋
 * More Info: https://github.com/Bue-von-hon
**/

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>

typedef long long ll;
using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define m_p make_pair
#define pii pair<int,int>
#define piii pair<int,pii>
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define X first
#define Y second
#define rep(i, n) for (int i = 0; i < (n); i++)

template <class T> T _min(T a,T b){return (a<b ? a : b);}
template <class T> T _max(T a,T b){return (a>b ? a : b);}
template<class T> void read(T& x) {cin >> x;}

int tc;
int main(void) {
    fast_cin();

    ll n;
    read(n);
    vt<ll> s(n);
    ll sol = 0, mod = 1e9+7;
    for (ll i = 0; i < n; i++) {
        ll temp;
        read(temp);
        s[i]=temp;
    }
    int ans = 0, x = 0;
    rep(i, n) {
        ans = (ans+(s[i]*x))%mod;
        x = (x+(s[i]))%mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4780
#include<cstdio>
long long a,b,c,h,w,k[]={0,0,-1,1,0,0},i;
char s[405][405];
void d(int x,int y){
  char t;
  ((t=s[x][y])-'#'?a:b)++;
  s[x][y]=0;
  for(int i=0;i<4;++i)if(s[x+k[i]][y+k[i+2]]+t==81)d(x+k[i],y+k[i+2]);
}
int main(){
  scanf("%d%d",&h,&w);
  for(;i<=h;)scanf("%s",s[++i]+1);
  for(;h;--h)for(i=w;i;--i)if(s[h][i])a=b=0,d(h,i),c+=a*b;
  printf("%lld\n",c);
}

Measured memory_bytes: 12800
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int f(vector<int>& v) {
	int carry = 1;
	int r = 0;
	for (int i = 0; i < v.size(); i++) {
		v[i] += carry;
		if (v[i] == 2) {
			v[i] = 0;
			carry = 1;
		}
		else if (v[i] == 1) {
			r++;
			carry = 0;
		}
		else {
			carry = 0;
		}
	}
	return r;
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> v;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		vector<pair<int, int>> vv;
		for (int j = 0; j < a; j++) {
			int x, y;
			cin >> x >> y;
			vv.push_back(make_pair(x, y));
		}
		v.push_back(vv);
	}

	vector<int> c = vector<int> (n, 0);
	int r = 0;
	for (int i = 0; i < pow(2, n); i++) {
		int flag = 1;
		for (int j = 0; j < c.size(); j++) {
			if (c[j] == 0) continue;
			for (auto p : v[j]) {
				if (c[p.first - 1] != p.second) {
					flag = 0;
					break;
				}
			}
		}
		if (flag == 1) {
			res = max(res, r);
		}

		r = f(c);
	}
	cout << res << endl;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemC solver = new ProblemC();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			char[] s = in.next().toCharArray();
			List<Integer>[] adj = new List[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<>();
			}
			int[][] deg = new int[2][n];
			for (int i = 0; i < m; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
				++deg[s[a] - 'A'][b];
				++deg[s[b] - 'A'][a];
			}

			int[] q = new int[n];
			boolean[] was = new boolean[n];
			int qt = 0;
			int qh = 0;
			for (int i = 0; i < n; i++) {
				if (deg[0][i] == 0 || deg[1][i] == 0) {
					was[i] = true;
					q[qh++] = i;
				}
			}
			while (qt < qh) {
				int v = q[qt++];
				for (int u : adj[v]) {
					--deg[s[v] - 'A'][u];
					if (was[u]) {
						continue;
					}
					if (deg[0][u] == 0 || deg[1][u] == 0) {
						was[u] = true;
						q[qh++] = u;
					}
				}
			}
			out.println(qt < n ? "Yes" : "No");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 82176
H, W, D = map(int, input().split())
xy = {}
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        xy[A[j]] = (i + 1, j + 1)

d = [0] * (H * W + 1)
for i in range(D + 1, H * W + 1):
    x1, y1 = xy[i]
    x2, y2 = xy[i - D]
    d[i] = d[i - D] + abs(x1 - x2) + abs(y1 - y2)

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = d[R] - d[L]
    print(ans)

Measured memory_bytes: 22980
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include<bitset>
#include<iomanip>
using namespace std;
#define ri register int
#define il inline
#define pb push_back
#define LL long long
#define pairint pair<int,int>
#define fi first
#define se second
#define mp make_pair

namespace i207M
{

template<class T>il void in(T &x)
{
    x=0; bool f=0; char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=1;
        c=getchar();
    }
    while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
    if(f) x=-x;
}

#define N 100005
int n;
int a[N],b[N],c[N],d[N];
int f[N];
int findfa(int x)
{
	return x==f[x]?x:f[x]=findfa(f[x]);
}
int cu,cnt,rems;
bool app[N];
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
#endif
	in(n);
	int s=0;
	for(ri i=1;i<=n;++i) in(a[i]),s^=a[i],c[i]=a[i];
	c[n+1]=rems=s;
	s=0;
	for(ri i=1;i<=n;++i) in(b[i]),s^=b[i],d[i]=b[i];
	d[n+1]=s;
	sort(c+1,c+n+2); sort(d+1,d+n+2);
	for(ri i=1;i<=n+1;++i)
		if(c[i]!=d[i]) 
		{
			puts("-1");
			return 0;
		}
	cu=unique(c+1,c+n+2)-c-1;
	for(ri i=1;i<=cu;++i) f[i]=i;
	for(ri i=1;i<=n;++i)
		if(a[i]!=b[i])
		{
			a[i]=lower_bound(c+1,c+cu+1,a[i])-c;
			b[i]=lower_bound(c+1,c+cu+1,b[i])-c;
			f[findfa(a[i])]=findfa(b[i]);
			app[a[i]]=app[b[i]]=1;
			++cnt;
		}
	rems=lower_bound(c+1,c+1+cu,rems)-c;
	if(!app[rems]) ++cnt;
	for(ri i=1;i<=cu;++i)
		if(app[i]&&f[i]==i) ++cnt;
	printf("%d",--cnt);
    return 0;
}

}

int main()
{
    i207M::main();
    return 0;
}
//566

Measured memory_bytes: 3840
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a[5],C;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cin >> C;
	
	if (a[4]-a[0]<=C)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

const int MAXN = 100000 + 10;

ll H, W;
vector<vector<ll>> g(10, vector<ll>(10));

int main() {
    cin >> H >> W;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> g[i][j];
        }
    }
    vector<vector<ll>> dp(g);
    for (int k = 0; k < 10; ++k) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    ll x;
    ll ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> x;
            if (x == -1 || x == 1) continue;
            ans += dp[x][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
A = [[0], [W], [0], [H]]

for i in range(N):
    x, y, a = map(int, input().split())
    a -= 1
    if a <= 1:
        A[a].append(x)
    else:
        A[a].append(y)

x1 = max(A[0])
x2 = min(A[1])
y1 = max(A[2])
y2 = min(A[3])

X = max(0, x2 - x1)
Y = max(0, y2 - y1)
print(X * Y)


Measured memory_bytes: 3064
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);

//番号ズレ注意！！
int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    print((H - h) * (W - w));
}


Measured memory_bytes: 256
fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  let nm = s.trim().split_whitespace().map(|e| e.parse::<u32>().unwrap()).collect::<Vec<u32>>();
  let left = *nm.first().unwrap();
  let right = *nm.last().unwrap();
  let str1 = make_str(std::char::from_digit(left, 10).unwrap(), right);
  let str2 = make_str(std::char::from_digit(right, 10).unwrap(), left);
  let mut for_sort = vec!(str1, str2);
  for_sort.sort();
  println!("{}",for_sort.first().unwrap().as_str());
}

fn make_str(c: char, num: u32) -> String {
  let mut chars = vec!();
  for i in 0..num {
    chars.push(c)
  }
  use std::iter::FromIterator;
  
  String::from_iter(chars)
}

Measured memory_bytes: 4352