akhauriyash/Code-Regression huggingface dataset:
class Graph(): #non-directed
    def __init__(self,n,edge):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.deg = [0 for _ in range(n)]
        for e in edge:
            self.graph[e[0]].append(e[1])
            self.graph[e[1]].append(e[0])
            self.deg[e[0]] += 1
            self.deg[e[1]] += 1

    def lowlink(self): #DFS木, ord, lowを計算
        self.ord = [None for _ in range(self.n)]
        self.low = [None for _ in range(self.n)]
        self.group = [None for _ in range(self.n)]
        self.prev = [None for _ in range(self.n)]
        self.tree = [[] for _ in range(self.n)]
        self.sorted = []
        order = 0
        count = 0
        low = [None for _ in range(self.n)]
        for s in range(self.n):
            if self.group[s] is None:
                stack = [(s, None)]
                while stack:
                    node, par = stack.pop()
                    if self.group[node] is None:
                        self.group[node] = count
                        self.ord[node] = order
                        self.sorted.append(node)
                        order += 1
                        if par is not None:
                            self.prev[node] = par
                            self.tree[par].append(node)
                        for adj in self.graph[node]:
                            if self.group[adj] is None:
                                stack.append((adj, node))
                count += 1
        for node in self.sorted[::-1]:
            self.low[node] = self.ord[node]
            for adj in self.graph[node]:
                if self.prev[adj]  == node:
                    self.low[node] = min(self.low[node], self.low[adj])
                elif self.prev[node] == adj:
                    continue
                else:
                    self.low[node] = min(self.low[node], self.ord[adj])

    def articulation(self):
        res = []
        for node in range(self.n):
            if self.prev[node] is None and len(self.tree[node]) > 1:
                res.append(node)
            if self.prev[node] is not None:
                for adj in self.tree[node]:
                    if self.ord[node] <= self.low[adj]:
                        res.append(node)
                        break
        return res

    def bridge(self):
        res = []
        for node in range(self.n):
            for adj in self.tree[node]:
                if self.ord[node] < self.low[adj]:
                    res.append((node, adj))
        return res


import sys
input = sys.stdin.readline

N, M = map(int, input().split())
E = [tuple(map(int, input().split())) for _ in range(M)]

g = Graph(N, E)
g.lowlink()
res = g.bridge()
res = list(map(lambda x: (min(x), max(x)), res))
res.sort()
if res:
    print('\n'.join(map(lambda x: ' '.join(map(str, x)), res)))


Measured memory_bytes: 18616
#include <cstdio>

using namespace std;

int a[200000];
int b[200000];

int main() {
    int n, x = -1, i;
    long long ans = 0, m = 1e18;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    
    for (i = 0; i < n; i++) {
        if (a[i] > b[i] && b[i] < m) {
            x = i;
            m = b[i];
        }
    }
    
    if (x >= 0) {
        for (i = 0; i < n; i++) {
            if (i != x) ans += b[i];
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

typedef long long ll;

int main(void){
    int N;
    cin>>N;
    
    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    sort(A.begin(),A.end(),greater<ll>());
    
    ll sum=1;
    ll check=false;
    for(int i=1;i<A.size();i++){
        if(A[i-1]==A[i]){
            if(check){sum*=A[i];break;}
            sum*=A[i];
            check=true;
            i++;
        }
    }
    
    if(check)cout<<sum<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	string w = "keyence";
	makes(s);
	int a = 0;
	int b = 0;
	while (a < w.size() && s[a] == w[a])a++;
	while (b < w.size() && s[s.size() - 1 - b] == w[w.size() - 1 - b])b++;
	YN(a + b >= w.size());
}

Measured memory_bytes: 256
#include <stdio.h>

#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 101

int n;
int a[N][N];
int d[N];

void dijkstra(int key);
int min(int a, int b);

int main()
{
  int i, j;
  int num, k;
  int v /* 頂点numに隣接する頂点の番号　*/, c /* 辺の重み　*/;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
    {
      for(j = 0; j < n; j++)
      {
	a[i][j] = INF;
      }
    }
  
  for(i = 0; i < n; i++)
    {     
      scanf("%d %d", &num, &k);
      
      for(j = 0; j < k; j++)
	{	  
	  scanf("%d %d", &v, &c);
	  a[num][v] = c;
	}
    }
  
  dijkstra(0);
  
  for(i = 0; i < n; i++)
    {
      printf("%d %d\n", i, d[i]);
    }
  
  return 0;  
}

void dijkstra(int key)
{
  int i, j;
  int color[N];
  int mincost, ver = -1;
  
  for(i = 0; i < n; i++)
    {
      d[i] = INF;
      color[i] = WHITE;
    }
  
  color[key] = GRAY;
  d[key] = 0;
  
  while(1)
    {
      mincost = INF;
      ver = -1;
      
      for(i = 0; i < n; i++)
	{
	  if(color[i] == GRAY && d[i] < mincost)
	    {
	      ver = i;
	      mincost = d[i];	      
	    }
	}
      
      if(ver == -1) break;
      
      color[ver] = BLACK;
      
      for(i = 0; i < n; i++)
	{
	  if(color[i] != BLACK && a[ver][i] != INF)
	    {	     
	      d[i] = min(d[i], d[ver] + a[ver][i]);
	      color[i] = GRAY;
	    }	
	}    
      
    }  
}

int min(int x, int y)
{
  if(x < y)return x;
  return y;
}



Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 1500

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {


	string a, b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	


	return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

#define MAX_X 100000
int x;
int dp[MAX_X + 1];
int val[] = { 100, 101, 102, 103, 104, 105 };

inline bool is_in_range(const int v) {
    return 0 <= v && v <= x;
}

int main() {
    cin >> x;
    REP(i, x + 1) {
        REP(j, 6) {
            if(i == 0 || (dp[i] > 0 && is_in_range(i + val[j]))) {
                dp[i + val[j]] = dp[i] + 1;
            }
        }
    }
    cout << (dp[x] > 0) << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PI_INT 3.14159265358979323846
#define PI acos(-1.0)
#define LL long long
#define N 100000007
#define MOD 10000007
#define MX numeric_limits<long long>::max();
#define MN numeric_limits<long long>::min();
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define FILL(v, n) fill(v.begin(), v.end(), n);
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define PRINT(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define SCAN(v) for(int i=0; i<n; i++) { int temp; cin>>temp; v.push_back(temp); }
#define SORT(v) sort(v.begin(), v.end());

using namespace std;

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

    string line;
    cin >> line;

    if(n%2!=0)
        printf("No\n");
    else
    {
        int temp=n/2;

        string a1="";
        string a2="";

        for(int i=0; i<temp; i++)
        {
            a1+=line[i];
        }

        for(int i=temp; i<n; i++)
        {
            a2+=line[i];
        }

        if(a1==a2)
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vi L(N);
    for (auto &i : L){
        cin >> i;
    }
    int max = *max_element(L.begin(), L.end());
    if(max*2 < accumulate(L.begin(), L.end(), 0)) cout << "Yes" << endl; else cout << "No" << endl;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
lst1 = [1,3,5,7,8,10,12]
lst2 = [4,6,9,11]
lst3 = [2]

if (x in lst1 and y in lst1) or (x in lst2 and y in lst2) or (x in lst3 and y in lst3):
    print('Yes')
else:
    print('No')
    

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    vec v(N); rep(i, N) cin >> v[i];
    int m = 0;
    int res = 0;
    rep(i, N){
        if(m <= v[i]){
            res++;
            m = v[i];
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut i:usize = 0;
    let mut j:usize = s.len()-1;
    let mut ans = 0;

    while i < j {
        if s[i] == s[j]{
            i += 1;
            j -= 1;
        }else if s[i] == 'x'{
            ans += 1;
            i += 1;
        }else if s[j] == 'x'{
            ans += 1;
            j -= 1;
        }else{
            ans = -1;
            break;
        }
    }

    println!("{}",ans);


}


Measured memory_bytes: 2704
#include<iostream>
//#include<complex>
//#include<cstring>
//#include<algorithm>
#include<cstdio>
//#include<sec_api/stdio_s.h>
//#include<structuredquerycondition.h>
//#include<uiautomationcoreapi.h>
//#include<threadpoollegacyapiset.h>
//#include<_mingw_print_pop.h>
//#include<windows.security.cryptography.h>
#define R register
#define A 10010
//#define maxn 100010
//#define ll long long
#pragma GCC optimize(2)

using namespace std;

inline char GETCHAR()
{
	static char buf[A],*p1=buf,*p2=buf;
	return p1==p2 and (p2=(p1=buf)+fread(buf,1,A,stdin),p1==p2)?EOF:*p1++;
}
template <class T> void read(T &x)
{
	x=0;
	int flag=0;
	char ch=GETCHAR();
	while(!isdigit(ch))
	{
		flag|=ch=='-';
		ch=GETCHAR();
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+(ch^48);
		ch=GETCHAR();
	}
	x=flag?-x:x;
	return;
}
inline void write(int x)
{
	if(x<0)
	{
		x=-x;
		putchar('-');
	}
	if(x>9)
	  write(x/10);
	putchar(x%10+48);
}
int a,b,c,x,cnt;

int main()
{
	read(a);
	read(b);
	read(c);
	for(R int i=1;i<=a;i++)
	{
		read(x);
		if(x<b or x>=c)
		  cnt++;
	}
	write(cnt);
	cout<<'\n';
}

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

int main() {

   char arr[3][3];
   
   for(int i=0;i<3;++i)
      for(int j=0;j<3;++j)
         cin>>arr[i][j];
         
         
         cout<<arr[0][0]<<arr[1][1]<<arr[2][2];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

vector <int> adj[MAX], go[2];
bool used[MAX];

bool dfs(int v, int i) {
    go[i].pb(v);
    used[v] = true;
    bool f = false;
    for (int n : adj[v]) {
        if (!used[n]) {
            f = f || dfs(n, i);
        }
        if (f) return true;
    }
    return true;
}

void solve(void){
    int N, M;
    cin >> N >> M;
    rep(M, meanimgless_) {
        int a, b;
        scanf("%d %d\n", &a, &b);
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int s = 1;
    dfs(s, 0);
    if (adj[s].size() == 1) {
        printf("%d\n", (int)go[0].size());
        for (int v : go[0]) printf("%d ", v);
        printf("\n");
        return;
    }
    dfs(s, 1);
    reverse(all(go[0]));
    printf("%d\n", (int)go[0].size() + (int)go[1].size() - 1);
    for (int v : go[0]) if(v != s) printf("%d ", v);
    for (int v : go[1]) printf("%d ", v);
    printf("\n");
}

int main(void){
  solve();
  return 0;
}


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

int main()
{

    int n,m;
    cin>>n>>m;
    if((n==1||n==3||n==5||n==7||n==8||n==10||n==12)&&(m==1||m==3||m==5||m==8||m==10||m==12))
        cout<<"Yes"<<endl;
    else if((n==4||n==6||n==9||n==11)&&(m==4||m==6||m==9||m==11))
        cout<<"Yes"<<endl;
    //else if(n==2&&m==2)
        //cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,l;
  cin>>a>>l;
  int t=a*2;
  int r=l-t;
  if(l%2!=0)
  cout<<"No";
  else
  {
     if(l>=t && r<=t)
     cout<<"Yes";
     else
     cout<<"No";
  }
}

Measured memory_bytes: 3076
import heapq

N, M = [int(i) for i in input().split()]
A = [-int(i) for i in input().split()]
#print(N, M)
#print(A)

heapq.heapify(A)
for i in range(M):
    a = -heapq.heappop(A)
    a = a//2
    heapq.heappush(A, -a)

print(-sum(A))

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

bool is_palin(string s)
{
	int n = s.length();
	int flag = 0;
	int k = (n-3)/2;
	
	for (int i = 0; i < (n-1)/2; ++i)
	{
		/* code */
		if(s[i]!=s[k-i])
		{
			flag = 1;
			break;
		}
	}
	// cout<<flag<<endl;
	if(flag)
		return false;
	else
		return true;
}

int main()
{
	string s;
	cin>>s;
	if(is_palin(s))
	{
		int n = s.length();
		int flag = 0;
		int k = (n+1)/2;
		for (int i = 0; i < (n-1)/2; ++i)
		{
			if(s[i]!=s[k+i])
			{
				flag = 1;
				break;
			}
		}
		if(flag)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}	
	else
		cout<<"No"<<endl;
}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            if(Kaibun(s)== false) {
                Console.WriteLine("No");

                Console.Out.Flush();
                return;
            }

            var ss = s.Substring(0, (s.Length) / 2);

            if (Kaibun(ss) == false) {
                Console.WriteLine("No");

                Console.Out.Flush();
                return;
            }

            var sss = s.Substring(((s.Length + 2) / 2), s.Length / 2);

            if (Kaibun(sss) == false) {
                Console.WriteLine("No");

                Console.Out.Flush();
                return;
            }

            Console.WriteLine("Yes");

            Console.Out.Flush();
        }

        public static bool Kaibun(string s)
        {
            var n = s.Length;
            var cn = s.Length / 2;

            for(int i = 0; i < cn; i++) {
                if(s[i].Equals(s[n - i- 1]) == false) {
                    return false;
                }
            }

            return true;
        }
    }
}



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

/*
  ll n , m ;
  cin >> n >> m ;
  ll a , b , c ;
  cin >> a >> b >> c ;
  vector<ll> A(n) ;
  cout << "Yes" << endl ;
  cout << "No"  << endl ;
*/

int main(){
  ll x ;
  cin >> x ; 
  for(ll a = -1000 ; a <= 1000 ; a++ ){
    for(ll b = -1000 ; b <= 1000 ; b++ ){
      if( a*a*a*a*a - b*b*b*b*b == x ){
        cout << a << ' ' << b << endl ;
        return 0 ;
      }
    }
  }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct Pos
{
	ll x = -1;
	ll y = -1;
	ll h = -1;
};

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	ll n; cin >> n;
	vector<Pos> p(n+1);
	for(int i = 1; i <= n; i++)
		cin >> p[i].x >> p[i].y >> p[i].h;

	Pos G;
	rep(i, n)
		if(p[i].h >= 1)
			G = p[i];

	Pos ans;
	for(int cx = 0; cx <= 100; cx++)
	{
		for(int cy = 0; cy <= 100; cy++)
		{
			ll v1 = G.h + abs(cx - G.x) + abs(cy - G.y);
			v1 = max(v1, 0LL);
			bool flg = true;
			for(int i = 1; i <= n; i++)
			{
				ll v2 = v1 - abs(cx - p[i].x) - abs(cy - p[i].y);
				v2 = max(v2, 0LL);
				if(p[i].h != v2)
					flg = false;
			}
			if(flg)
			{
				ans.x = cx;
				ans.y = cy;
				ans.h = v1;
			}
		}
	}

	printf("%lld %lld %lld\n", ans.x, ans.y, ans.h);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin>>n>>k;
	vector<array<ll,2>> jumps(k);
	for(ll x=0;x<k;x++){
		cin>>jumps[x][0]>>jumps[x][1];
	}
	ll ways[n+1]={0};
	ways[1]=1;
	ll pref[n+1]={0};
	pref[1]=1;
	for(ll x=2;x<=n;x++){
		for(ll y=0;y<k;y++){
			ll start=jumps[y][0],end=jumps[y][1];
			end=max(end,1ll);
			if(x-start>=1){
				ways[x]+=pref[x-start];
				if(x-end>=1){
					ways[x]-=pref[x-end-1];
					ways[x]+=mod1;
				}
			}
			ways[x]%=mod1;
		}
		pref[x]=pref[x-1]+ways[x];
		pref[x]%=mod1;
	}
	cout<<ways[n]<<endl;
	return 0;

}


Measured memory_bytes: 6692
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	min, max := inf, -inf
	for i := 0; i < n; i++ {
		a := ri()
		if a > max {
			max = a
		}
		if a < min {
			min = a
		}
	}

	fmt.Println(max - min)
}


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

struct node{
    int value;
    node *prev;
    node *next;
};

node *nil;
void init(){
    nil = (node*)malloc(sizeof(node));
    nil->prev = nil;
    nil->next = nil;
}


void insert(int key){
    node *newNode = (node *)malloc(sizeof(node));

    newNode->next = nil->next; //nilが先頭であるため、nilが指していたアドレスを代入。(最後尾のnextはnilを参照)
    newNode->value = key;
    nil->next->prev = newNode;
    nil->next = newNode;
    newNode->prev = nil;
}

void deleteNode(node * t){
    if(t == nil){
        return;
    }
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    // node *first = nil->next;
    // nil->next->prev = nil;
    // nil->next = nil->next->next;
    // free(first);
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

node *listSearch(int key){
    node *head = nil->next;

    while(head != nil){
        if(head->value == key){
            break;
        }
        head = head->next;
    }
    return head;
}

void printList(){
    node *last = nil->prev;
    node *head = nil->next;
    while(head != last){
        cout << head->value << " ";
        head = head->next;
    }
    cout << head->value << endl;
}
int main(){
    int n; cin >> n;
    string command;

    init();
    for(int i = 0; i < n; i++){
        cin >> command;
        if(command == "insert"){
            int x; cin >> x;
            insert(x);
        }else if(command == "delete"){
            int x; cin >> x;
            node *delete_node = listSearch(x);
            deleteNode(delete_node);
        }else if(command == "deleteFirst"){
            deleteFirst();
        }else if(command == "deleteLast"){
            deleteLast();
        }
    }

    node *head = nil->next;

    printList();
    return 0;
}




Measured memory_bytes: 34448
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, n-2) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
  int N,M,i,ans;
  scanf("%d %d",&N,&M);
  int L[M],R[M];
  int L_max = 1,R_min = N;
  for(i = 0;i < M;i++) {
    scanf("%d %d",&L[i],&R[i]);    
  }
  for(i = 0;i < M;i++) {
    if(L_max < L[i]) L_max = L[i];
    if(R_min > R[i]) R_min = R[i];
  }
  ans = R_min - L_max + 1;
  if(ans >= 0) printf("%d\n",ans);
  else printf("0\n");
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
int n,a[10000];
  cin>>n;
  rap(i,n) cin>>a[i];
  sort(a,a+n);
  cout<<abs(a[0]-a[n-1])<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  int X;cin>>X;
  int MAX = 1;
  for (int i = 1; i <= 1000; i++)
  {
    for (int j = 2; j < 1000; j++)
    { 
    if(pow(i,j) <= X)
      chmax(MAX,pow(i,j));
    }

  }
  cout<<MAX<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int min=Integer.MAX_VALUE;
    int max=Integer.MIN_VALUE;
    int tmp;
    for(int i=0;i<n;i++){
      tmp=sc.nextInt();
      min=Math.min(tmp,min);
      max=Math.max(tmp,max);
    }
    System.out.println(max-min);
  }
}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
 
int main() {
    
    int N;
    cin >> N;
    
    int sum=0 ;
    for (int i=0 ; i<N ; i++){
        int l,r;
        cin >> l >>r;
        sum += r-l+1 ;
    }
    
    cout << sum <<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=1e5+10;
ll a[maxn],sum[maxn];
int main(){
	int n=read();
	REP(i,1,n) a[i]=read();
	sort(a+1,a+n+1);
	REP(i,1,n) sum[i]=a[i]+sum[i-1];
	int Mid=(n>>1);
	if(n&1) printf("%lld\n",sum[n]*2+max(-sum[Mid+1]*3-sum[Mid-1],-sum[Mid+2]*2+a[Mid+2]+a[Mid+1]-sum[Mid]*2));
	else printf("%lld\n",sum[n]*2-sum[Mid+1]*2-sum[Mid-1]*2+a[Mid+1]-a[Mid]);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main(){

	int t = 1;
	//cin >> t;
	while(t--){
		int n, k;
		cin >> n >> k;
		long double a[n];
		for(int i = 0; i < n; ++i){
			cin >>a[i];
			a[i] += 1.0;
		}
		long double sum = 0.0;
		for(int i = 0; i < k; ++i){
			sum += a[i];
		}
		long double res = sum / 2.0;
		for(int i = k; i < n; ++i){
			sum += a[i] - a[i - k];
			res = max(sum / 2.0, res);
		}
		cout <<fixed << setprecision(12)<< res;
	}
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <set>
#include <bitset>
using namespace std;
enum dim{
    x = 0,
    y,
    z,
    size,
};
class Signs {
public:
    static size_t constexpr size = 2 * 2 * 2;
private:
    bitset<dim::size> signs[size];
public :
    Signs() {
        for (size_t i = 0; i < size; i++) signs[i] = i;
    }

    bitset<dim::size> const& operator[](size_t const i) const {
        return signs[i];
    }
};

class Point {
    int64_t p[dim::size];
public:
    Point(int64_t x, int64_t y, int64_t z) {
        p[dim::x] = x, p[dim::y] = y, p[dim::z] = z;
    }

    int64_t GetTotal(bitset<dim::size> const& sign) const {
        int64_t val = 0;
        for (size_t i = 0; i < dim::size; i++) { 
            val += sign[i] ? p[i]  : -p[i];
        }
        return val;
    }
};

class Bests {
    multiset<int64_t> bests;
public :
    void insert(uint64_t val) {
        bests.insert(val);
    } 

    int64_t GetTotal(size_t M) const {
        int64_t ret = 0;
        auto ite = bests.cend();
        ite--;

        for (size_t i = 0; i < M; i++, ite--) {
            ret += *ite;
        }

        return ret;
    }
};

int main() {
    size_t N, M;
    cin >> N >> M;
   
    Signs signs;
    Bests bests[signs.size];
    
    int64_t x, y, z;
    size_t last_idx = M - 1;
    for(size_t i = 0; i < N; i++) {
        cin >> x >> y >> z;
        Point p(x, y, z);
        for (size_t j = 0; j < signs.size; j++) {
            int64_t const total = p.GetTotal(signs[j]);
            bests[j].insert(total);
        }
    }
    
    int64_t ret = 0;
    for (Bests const& target : bests) {
        int64_t const val = target.GetTotal(M);
        ret = max<int64_t>(ret, val);
    }

    cout << (int64_t)ret << endl;
    return 0;
}



Measured memory_bytes: 640
from collections import Counter, defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)
for d in D:
    memo[d] += 1

for i in range(M):
    ti = T[i]
    if ti not in memo:
        print("NO")
        exit()
    if memo[ti] == 0:
        print("NO")
        exit()
    memo[ti] -= 1

print("YES")

Measured memory_bytes: 127572
#include <iostream>

int main()
{
  int N, X;
  std::cin >> N >> X;

  int m[N];
  for ( int i = 0; i < N; i++ ) std::cin >> m[i];

  int sum = m[0];
  int min = m[0];
  for ( int i = 1; i < N; i++ ) {
    sum += m[i];
    if ( min > m[i] ) min = m[i];
  }

  X -= sum;
  std::cout << N + int(X/min) << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
# AtCoder Grand Contest 006
# A - Prefix and Suffix

def f(word,N,S,T):
    if word[:N]==S and word[-N:]==T:
        return True
    else :
        return False


N=int(input())
S=input()
T=input()

ans = N*2

for i in range (N):
    t=T[N-i:]
    word=S+t

    if f(word,N,S,T):
        if ans>len(word):
            ans=len(word)
    else:
        pass

print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <iomanip>
#include <cassert>

#include <utility>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

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

constexpr int INF = numeric_limits<int>::max();

void Main()
{
	int H, W;
	cin >> H >> W;

	vector<string> S(H);
	rep(i, H)
	{
		cin >> S[i];
	}

	rep(i, W+2)
	{
		cout << '#';
	}
	cout << endl;

	rep(i, H)
	{
		cout << '#';
		cout << S[i];
		cout << '#';
		cout << endl;
	}

	rep(i, W+2)
	{
		cout << '#';
	}
	cout << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::f64::consts::PI;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: f64 = iterator.next().unwrap().parse().unwrap();
    let b: f64 = iterator.next().unwrap().parse().unwrap();
    let x: f64 = iterator.next().unwrap().parse().unwrap();

    let s = x / a;

    let ans = if s >= a * b / 2_f64 {
        let h = 2_f64 * (a * b - s) / a;
        h.atan2(a) * 360_f64 / (2_f64 * PI)
    } else {
        let w = 2_f64 * s / b;
        b.atan2(w) * 360_f64 / (2_f64 * PI)
    };

    return format!("{:.10}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b,c,d;
  cin >> a >> b>>c>>d;
 
  if (a+b>c+d)
    cout << "Left" << endl;
  else if (a+b==c+d)
    cout << "Balanced" <<endl;
  else
    cout << "Right" << endl;    
}

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

int Sizeof(ll s){
   string S=to_string(s);
   return S.size();
}

int main(){
   ll S;
   cin >> S;
   int s_size = Sizeof(S);
   int m = s_size - 1;
   ll sum = 0;

   for (int tmp = 0; tmp < (1 << m); tmp++){
      bitset<9> s(tmp);
      ll N = S;
      int w = 10;
      for(int i = 0; i < m; i++){
         if(s.test(i)){
            sum += N % w;
            N /= w;
            w = 10;
         }else{
            w *= 10;
         }
      }
      sum += N;
   }

   cout << sum << endl;

}

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define PI 3.14159265359
using namespace std;

int main() {
  int R;
  cin >> R;
  cout << R * PI * 2 << endl;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

struct Node_struct{
	Node_struct *l, *r, *p;
	int key;
};
Node_struct* Root;

void insert(int num){
	Node_struct *x = Root , *y = NULL, *z;
	z=(Node_struct*)malloc(sizeof(Node_struct));
	z->key = num;
	z->l = NULL, z->r = NULL;
	
	while(x != NULL){
		y = x;
		if(z->key > x->key) x = x->r;
		else x = x->l;
	}
	z->p = y;
	if(y == NULL) Root = z;
	else if(z->key > y->key) y->r = z;
	else y->l = z;
}

void in(Node_struct *cur){
	if(cur==NULL)	return;
	in(cur->l);
	printf(" %d",cur->key);
	in(cur->r);
}

void pre(Node_struct *cur){
	if(cur==NULL)	return;
	printf(" %d", cur->key);
	pre(cur->l);
	pre(cur->r);
}

void find(int num){
	bool flag = false;
	Node_struct *x = Root;
	
	while(x != NULL){
		if(num == x->key)flag = true;
		if(num > x->key) x = x->r;
		else x = x->l;
	}
	if(flag) printf("yes\n");
	else printf("no\n");
}

int main(){
	int i, n;
	int id;
	string s;
	scanf("%d", &n);
	
	for(i=0; i<n; ++i){
		cin >> s;
		if(s[0] == 'i'){
			scanf("%d", &id);
			insert(id);
		}
		else if(s[0] == 'p'){
			in(Root);
			printf("\n");
			pre(Root);
			printf("\n");
		}
		else if(s[0] == 'f'){
			scanf("%d", &id);
			find(id);
		}
	}
	
	return 0;
}


Measured memory_bytes: 22056
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;
typedef pair<double,int> P;

int main(){
    int N;
    for(;;){
        scanf("%d",&N);
        if(N==0) break;
        vector<pair<int,int> > bils(N);
        for(int i=0;i<N;i++){
            int b,x,y;
            scanf("%d%d%d",&b,&x,&y);
            bils[b-1]=make_pair(x,y);
        }
        vector<vector<double> > path(N,vector<double>(N));
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                int d2=(bils[i].first-bils[j].first)*(bils[i].first-bils[j].first)+(bils[i].second-bils[j].second)*(bils[i].second-bils[j].second);
                if(d2<=2500) path[i][j]=sqrt(d2);
                else path[i][j]=-1;
            }
        }
        int M;
        scanf("%d",&M);
        for(int i=0;i<M;i++){
            int st,go;
            scanf("%d%d",&st,&go);
            vector<double> dist(N,-1);
            vector<int> bef(N);
            dist[st-1]=0;
            bef[st-1]=st-1;
            priority_queue<P,vector<P>,greater<P> > que;
            que.push(make_pair(0,st-1));
            while(!que.empty()){
                P now=que.top();
                que.pop();
                int at=now.second;
                if(dist[at]<now.first) continue;
                for(int i=0;i<N;i++){
                    if(path[at][i]!=-1 && (dist[i]==-1 || dist[i]>dist[at]+path[at][i])){
                        dist[i]=dist[at]+path[at][i];
                        bef[i]=at;
                        que.push(make_pair(dist[i],i));
                    }
                }
            }
            if(dist[go-1]==-1) printf("NA\n");
            else{
                vector<int> ps;
                int now=go-1;
                for(;;){
                    ps.push_back(now);
                    if(bef[now]==now) break;
                    now=bef[now];
                }
                reverse(ALL(ps));
                for(int i=0;i<ps.size()-1;i++){
                    printf("%d ",ps[i]+1);
                }
                printf("%d\n",ps.back()+1);
            }
        }
    }
}

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

int main()
{
	int a,b,c;
	long long k,lim,in;
	lim = 1000000000000000000;
	cin>>a>>b>>c>>k;
	
	in = a-b;
	if(abs(in)>lim)
	{
		cout<<"Unfair";
		return 0;
	}
	if(k%2==0)
	{
		cout<<in;
	}
	else
	{
		cout<<0-in;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

typedef vector<int> vi;

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

	vi line(w);
	rep(i, w) line[i] = i+1;
	rep(i, n){
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(line[a-1], line[b-1]);
	}

	rep(i, w) printf("%d\n", line[i]);

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

long long K,a[100050];

int main()
{
	scanf("%lld",&K);
	for(int i = 1;i <= K; ++ i)
		scanf("%lld",&a[i]);
	if(a[K] != 2)
	{
		printf("-1\n");
		return 0;
	}
	long long t = 2,gp = 1;
	for(int i = K;i >= 1; -- i)
	{
		if(t % a[i] != 0)
			t = (t / a[i] + 1) * a[i];
	}
	long long tmpt = t;
	for(int i = 1;i <= K; ++ i)
		t = t / a[i] * a[i];
	if(t != 2)
	{
		printf("-1\n");
		return 0;
	}
	t = a[K] + (a[K] - 1);
	gp = 1;
	for(int i = K;i >= 1; -- i)
	{
		if(a[i] > t)
		{
			t = a[i] + a[i] - 1;
			gp = 1;	
		}
		else if(i != K)
			t = (gp * a[i + 1] + a[i + 1] - 1) / a[i] * a[i] + a[i] - 1,gp = t / a[i];
	}
	printf("%lld %lld\n",tmpt,t);
	return 0;
} 

Measured memory_bytes: 1024
def cul(x,X):
    dic={0:1}
    for i in range(len(x)):
        tmp={}
        for j in dic:
            tmp[j+x[i]]=1
            tmp[j-x[i]]=1
        dic=tmp
    if X in dic: return True
    else: return False

S=input()
s=list(S.split("T"))
X,Y=map(int,input().split())
x,y=[len(i) for i in s[::2]],[len(i) for i in s[1::2]]
if S[0]=="F": X=abs(X-x.pop(0))
Y=abs(Y)

dx=sorted(x,reverse=True)
dy=sorted(y,reverse=True)

print("Yes" if cul(dx,X) and cul(dy,Y) else "No")

Measured memory_bytes: 3936
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<3;i++){
	if(s[i]=='9'){
      s[i] = '1';
    }
    else{
      s[i] = '9';
    }
  }
  cout << s << "\n";
}


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


class UnionFindWeighted:
    """ポテンシャル付きUnionFind"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.weight = [0] * n
        self.cnt = n
        self.INF = 10 ** 18
       
    def root(self, x):
        """頂点xの根を求める"""
        if self.parent[x] < 0:
            return x
        rt = self.root(self.parent[x])
        self.weight[x] += self.weight[self.parent[x]]
        self.parent[x] = rt
        return rt

    def merge(self, x, y, weight):
        """頂点xを含む集合と頂点y含む集合を結合する
        weight: 頂点yに対する頂点xのポテンシャル(頂点xの方がweight高い)
        """
        root_x = self.root(x)
        root_y = self.root(y)
        if root_x == root_y:
            return
        if self.parent[root_x] < self.parent[root_y]:
            self.parent[root_x] += self.parent[root_y]
            self.parent[root_y] = root_x
            self.weight[root_y] = -weight + self.weight[x] - self.weight[y]
        else:
            self.parent[root_y] += self.parent[root_x]
            self.parent[root_x] = root_y
            self.weight[root_x] = weight - self.weight[x] + self.weight[y]
        self.cnt -= 1

    def is_same(self, x, y):
        """頂点x, yが同じ集合に属するかどうかを返す"""
        return self.root(x) == self.root(y)

    def diff(self, x, y):
        """頂点yに対する頂点xのポテンシャルを求める
        ただし、頂点x,y間にポテンシャルが定義されていない場合は INF を返す
        """
        if not self.is_same(x, y):
            return self.INF
        return self.weight[x] - self.weight[y]

    def get_size(self, x):
        """頂点xを含む集合の要素数を返す"""
        return -self.parent[self.root(x)]

    def get_cnt(self):
        """集合の個数を返す"""
        return self.cnt


def solve():
    n, q = list(map(int, input().split()))
    query = [list(map(int, input().split())) for i in range(q)]
    INF = 10 ** 18
    ufw = UnionFindWeighted(n)

    for i in range(q):
        if query[i][0] == 0:
            # クエリ1の場合
            _, x, y, weight = query[i]
            ufw.merge(x, y, weight)
        else:
            # クエリ2の場合
            _, x, y = query[i]
            ans = ufw.diff(x, y)
            if ans == INF:
                print("?")
            else:
                print(ans)


if __name__ == "__main__":
    solve()


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

int main(){
  long long n;
  while(cin >> n){
    if(n==0)break;

    long long sum = n==1?0:1;
    for(long long i=2;i*i<=n;i++){
      if(n%i == 0){
	sum += i;
	if(i*i!=n)sum += n/i;
      }
    }

    if(sum<n)cout << "deficient number" << endl;
    else if(sum>n)cout << "abundant number" << endl;
    else cout << "perfect number" << endl;
  }
}

Measured memory_bytes: 1152