akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 ll a,b;
 sc(a);sc(b);
 if(a>b||(n==1&&a!=b)){
  puts("0");return 0;
 }
 if(n==1&&a==b){
  puts("1");return 0;
 }
 ans=0;
 ans=(b-a)*(n-2)+1;
  pr(ans);
 return 0; }


Measured memory_bytes: 3580
(* O(k^2) (k = max n m) *)
let n = read_int () in
let ss = Array.init n @@ fun _ -> read_line () in
let m = read_int () in
let ts = Array.init m @@ fun _ -> read_line () in
let f acc s =
  let c = Array.fold_left (fun c s' -> if s' = s then c + 1 else c) 0 ss in
  max acc @@ Array.fold_left (fun c t -> if t = s then c - 1 else c) c ts in
Array.fold_left f 0 ss |> Printf.printf "%d\n"

Measured memory_bytes: 384
import itertools
import math
def dist(x1,y1,x2,y2):
    r = math.sqrt( (x1-x2)**2 + (y1-y2)**2 )
    return r

n = int(input())
r = [ list(map(int, input().split())) for i in range(n) ]
id = range(n)
idlst = list(itertools.permutations(id))
N = math.factorial(n)
distance = 0
for i in range(N):
    for j in range(1,n):
        pre = idlst[i][j-1]
        now = idlst[i][j]
        distance += dist(r[pre][0],r[pre][1],r[now][0],r[now][1])

ans = distance / N
print(ans)




Measured memory_bytes: 7996
#include<bits/stdc++.h>
#include<array>
#define nguyendz the_best


#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
#define setpre(x) fixed<<setprecision(x)
#define PI 3.14159265358979323846

using namespace std;
const ll maxn=1e6+100;
vector<ll> adj[maxn];
ll a[maxn];
 bool dd[maxn];
 ll par[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  /*  if (fopen("A.INP","r"))
    {
         freopen("A.INP","r",stdin);
        freopen("A.OUT","w", stdout);
    }*/
    ll n, m;
    cin>> n>>m ;
    for (int i=1;i<=n;i++)
    {
        dd[i]=0;
        par[i]=-1;
    }
    for (int i=1;i<=m;i++)
    {
        ll x, y;
         cin>> x>>y ;
         adj[x].pb(y);
         adj[y].pb(x);
    }
    queue<ll> q;
    q.push(1);
    while (!q.empty())
    {
        auto p =q.front();
        q.pop();
        dd[p]=1;
        for (auto to:adj[p])
        {
            if (!dd[to])
            {
                dd[to]=1;
                par[to]=p;
                q.push(to);
            }
        }
    }
    bool x=true;
    for (int i=2;i<=n;i++)
    {
        if (par[i]==-1) x=false;
    }
    if (!x)
    {
        cout <<"No";
    }
    else
    {
        cout <<"Yes"<<endl;
        for (int i=2;i<=n;i++)
        {
            cout <<par[i]<<endl;
        }
    }



}


Measured memory_bytes: 34156
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
 }

bool sorter(ll a, ll b){
    if(a>b)return 1;
    return 0;
}
const int mx = 2e5+3;
ll fact[mx];
ll invfact[mx];


ll cal(ll n ){
    if( n<=1)return 0;
    ll ans = fact[n];
    ll den = invfact[n-2]*invfact[2];
    den %= mod;
    ans *= den;
    ans %= mod;
    return ans;


}


ll ans[mx];
ll a[mx];

int main(){

   ios_base :: sync_with_stdio(0);
   cin.tie(0);
    fact[0] = invfact[0] = 1;
   fact[1] = invfact[1] = 1;

   for(int i =2 ; i<mx;i++){
        fact[i] = i*fact[i-1];
        fact[i] %= mod;
        invfact[i] = pow(fact[i] , mod-2);
   }


   ll n;
   cin>>n;

   map<ll,ll> mp;

   rep(i ,0 , n){
    cin>>a[i];
    mp[ a[i] ]++;

   }
    ll total = 0;
    for(auto i : mp){
        ll t = i.second;
        total += ((i.second)*(i.second-1))/2;
     //   total =
    }
    for(auto i : mp){

        ll t = i.second;
        ll t1 = ((i.second)*(i.second-1))/2;
        ll d = total;
        d -= t1;
        //d %= mod;
        d += ((i.second-1)*(i.second-2))/2;
        //d %= mod;
        ans[i.first] = d;
    }
    rep(i ,0 , n){
        cout<<ans[ a[i] ]<<"\n";
    }
}


Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S; cin >> S;
  for(int i = 0; i < 3; i++){
    if(S[i] == S[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    long long int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    long long int ans1,ans2,ans3;
    if(x>y){
        ans1=2*c*y+a*(x-y);
    }else{
        ans1=2*c*x+b*(y-x);
    }
    ans2=a*x+b*y;
    ans3=2*c*max(x,y);
    cout<<min(ans1,min(ans2,ans3))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;

int main()
{
    int x, a;
    cin >> x >> a;
    if (x < a)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 10 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define double long double
#define stp setprecision
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define initi(a,r) memset(a,r,sizeof(a))
#define inp(a) for(auto&i:a) cin>>i;
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bi back_inserter
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define mpii map<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
#define matrix vector<vector<int>>
#define mxe *max_element
#define mne *min_element
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=2e5+7;
void a_b_l(){
    int x;
    cin>>x;
    if(x==0){
        cn(1);
    }
    else
        cn(0);
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    while(t--)
    	a_b_l();
}

Measured memory_bytes: 3600
import java.util.Scanner;


//AtCoder Beginner Contest 117
//D	Restore the Tree
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double T = sc.nextDouble();
		double X =sc.nextDouble();
		System.out.println(T / X);

		sc.close();
	}
}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
#define Re real()
#define Im imag()
using namespace std;

const double eps = 1e-9;
typedef complex<double> Point;
typedef Point Vector;
typedef vector<Point> Polygon;

Point P[50050], s;
int n, k, m;
vector<Point> qs;

bool cmp(Point a, Point b)
{
    if(fabs(a.Re - b.Re) < eps) return a.Im < b.Im;
    else return a.Re < b.Re;
}

double cross(const Point& a, const Point& b)
{
    return (conj(a) * b).Im;
}

double dot(const Point& a, const Point& b)
{
    return (conj(a) * b).Re;
}

int check(const Point& t)
{
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        Vector v1 = P[i] - t, v2 = P[(i + 1) % n] - t;
        if(v1.Im > v2.Im) swap(v1, v2);
        if(v1.Im <= 0 && v2.Im > 0 && cross(v1, v2) < 0) cnt ^= 1;
        if(cross(v1, v2) == 0 && dot(v1, v2) <= 0) return 1;
    }
    return cnt ? 2 : 0;
}

int main()
{
    while(~scanf("%d", &n))
    {
        for(int i = 0; i < n; i++)
        {
            double tx, ty;
            scanf("%lf%lf", &tx, &ty);
            P[i] = complex<double>(tx, ty);
        }
        scanf("%d", &m);
        for(int i = 0; i < m; i++)
        {
            double tx, ty;
            scanf("%lf%lf", &tx, &ty);
            s = Point(tx, ty);
            printf("%d\n", check(s));
        }
    }
    return 0;
}

/*

5
0 0
2 0
2 2
0 2
1 1

4
0 0
3 1
3 3
0 3
16
1 1
2 1
1 2
2 2
3 1
3 2
0 3
0 2
2 0
4 1
-1 1
0 -1
1 4
3 4
4 3
-2 3

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1128



#include <iostream>
#include <complex>
#include <vector>
using namespace std;

typedef complex<double> point;
double cross(const point& a, const point& b) {
    return imag(conj(a)*b);
}
double dot(const point& a, const point& b) {
    return real(conj(a)*b);
}

typedef vector<point> polygon;
enum { OUT, ON, IN };
int contains(const polygon& P, const point& p) {
    bool in = false;
    for (int i = 0; i < P.size(); ++i) {
        point a = P[i] - p, b = P[(i+1)%P.size()] - p;
        if (imag(a) > imag(b)) swap(a, b);
        if (imag(a) <= 0 && 0 < imag(b))
            if (cross(a, b) < 0) in = !in;
        if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
    }
    return in ? IN : OUT;
}

int main() {
    int n;
    while (cin >> n) {
        polygon pol(n);
        for (auto& p : pol) {
            int x, y;
            cin >> x >> y;
            p = point(x, y);
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; i++) {
            int x, y;
            cin >> x >> y;
            cout << contains(pol, point(x, y)) << endl;
        }
    }
    return 0;
}

*/

Measured memory_bytes: 2008
n = gets().to_i
a = gets().split(' ').map(&:to_i)

def swappable(big, small,a ,n)

    if (a[big - 1] < a[small] || big == 0) && a[small] < a[big + 1] &&
      a[small - 1] < a[big] && (small == n - 1 || a[big] < a[small + 1])
return true
    end
  return false
 
end


def swappable1(big,a,n)
  if (a[big - 1] < a[big + 1] || big == 0) && (a[big] < a[big + 2] || big == n-1)
    return true
  end
  return false
end

big = -1
small = -1
s = 0
for i in 0..(n-1)
  if i < n - 1
    if a[i] > a[i + 1]
      case s
      when 0 then
        s = 1
        big = i
      when 1 then
        s = 2
        small = i + 1
      when 2 then
        s = 3
        break # impossible
      end
    end
  end
end
  
  case s
when 0 then
  puts 'YES'
when 1 then
  if swappable1(big,a,n)
    puts 'YES'
  else
    puts 'NO'
  end
when 2 then
  if swappable(big, small,a,n)
    puts 'YES'
  else
    puts 'NO'
  end
else
  puts 'NO'
end
    

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

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

signed main() {
  int n;
  cin >> n;
  int s = 0;
  rep(i,n) s += i;
  cout << s << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

// #define DEBUG

const int maxint = 1e9;
struct timestamp;
vector<int> shortest;
vector<vector<pair<int, int>>> connective;

void djkstra(int x)
{
    vector<int> search = {x};
    vector<int> new_search;
    shortest[x] = 0;
    int v, d;
    while (!search.empty())
    {
        for (auto itr = search.begin(); itr != search.end(); itr++)
        {
            for (auto itr2 = connective[*itr].begin(); itr2 != connective[*itr].end(); itr2++)
            {
                v = itr2->first, d = itr2->second;
                if (shortest[v] > d + shortest[*itr])
                {
                    shortest[v] = d + shortest[*itr];
                    new_search.push_back(v);
                }
            }
        }
        search.clear();
        search = new_search;
        new_search.clear();
    }
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, v, k, x, c;
    cin >> n;
    connective.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v >> k;
        shortest.push_back(maxint);
        for (int j = 0; j < k; j++)
        {
            cin >> x >> c;
            connective[i].push_back(make_pair(x, c));
        }
    }
    djkstra(0);
    for (int i = 0; i < n; i++)
    {
        cout << i << " " << shortest[i] << endl;
    }

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)
// for (int j = 0; j < m; j++)


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

const int MAXN = 20005;

int n, x, y;
char str[MAXN];

int a[2][MAXN];
int tmp = 0;
bitset<20000> bt;

int abv = 0;
bool check(int id, int x)
{
	if (x < 0) x = -x;
	int sum = 0;
	for (int i = 1; i <= a[id][0]; i++) sum += a[id][i];
	if (sum < x) return 0;
	int sub = sum-x;
	bt.reset();
	// cerr << sub << endl;
	bt[0] = 1;
	for (int i = 1; i <= a[id][0]; i++) bt = bt|(bt<<(2*a[id][i]));
	return bt[sub];
}

int main()
{
	scanf("%s", str+1);
	n = strlen(str+1);
	scanf("%d%d", &x, &y);
	int cur = 0, flag = 0;
	for (int i = 1; i <= n; i++) {
		if (str[i] == 'T') {
		        if (flag == 0) x -= tmp;
			else a[cur][++a[cur][0]] = tmp;
			cur ^= 1, tmp = 0;
			flag = 1;
		}
		else tmp++, abv = max(abv, tmp);
	}
	if (tmp) {
	        if (flag == 0) x -= tmp;
		else a[cur][++a[cur][0]] = tmp;
	}
	if (check(0, x) && check(1, y)) puts("Yes");
	else puts("No");
	return 0;
}


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

#define rep(N) for(int i=0;i<N;i++)


  void run(){
    long n,r;
    cin >> n;
    long max_profit = -1000000000;
    long min_r;

    cin >> min_r; //初期値は１回目の読み込み

    rep(n-1){// n-1回読み込み
      cin >> r;
      max_profit  = max(max_profit,r-min_r); //max_profitを更新
      min_r = min(min_r,r); //ここまでの最小値を保存
    }

    cout << max_profit << endl;

  }


int main(){
  run();
  return 0;
}



Measured memory_bytes: 3096
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int x = arr[0];
    int a = arr[1];
    int b = arr[2];
    int t = b - a;
    if (t <= 0) Console.WriteLine("delicious");
    else if (t <= x) Console.WriteLine("safe");
    else Console.WriteLine("dangerous");
  }
}

Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 111111

vector<pll> edge[MAX];
queue<ll> que;
ll point[MAX];

void bfs(ll start) {
  que.push(start);
  point[start] = 0;

  while (!que.empty()) {
	temp = que.front();
	que.pop();

	FOR(i, 0, edge[temp].size()) {
	  ll k = edge[temp][i].F;
	  if (point[k] == INF) {
		que.push(k);
		point[k] = point[temp] + edge[temp][i].S;
	  } else {
		if (point[temp] + edge[temp][i].S != point[k]) {
		  cout << "No" << endl;
		  exit(0);
		}
	  }
	}
  }
}

int main(void) {
  ll a, b, c;
  cin >> n >> m;
  FOR(i, 0, m) {
	cin >> a >> b >> c;	a--; b--;
	edge[a].pb(pll(b, c));
	edge[b].pb(pll(a, -c));
  }

  FOR(i, 0, n) point[i] = INF;

  FOR(i, 0, n) if (point[i] == INF) bfs(i);

  cout << "Yes" << endl;

  return 0;
}

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

int main() {
 UL N,M; cin>>N>>M;
 UL ans[200]; rep(i,2*N) ans[i]=i+1;
 UL buf[200];
 rep(i,M){
  UL k; cin>>k;
  if(k==0){
   rep(i,N) buf[i+i] = ans[i];
   rep(i,N) buf[i+i+1] = ans[i+N];
  }
  else{
   rep(i,2*N) buf[i] = ans[(i+k)%(2*N)];
  }
  rep(i,2*N) ans[i]=buf[i];
 }
 rep(i,2*N) cout<<buf[i]<<endl;
}



Measured memory_bytes: 3084
a = gets.chomp.to_i
b = []
b = gets.chomp.split("")
c = ["S", "W"]
for i in 0..1
for k in 0..1
  d = Array.new
  #puts d.join("")
  d[0] = c[i]
  d.push(c[k])
  for j in 1..a-2
    if d[j-1] == "S" && d[j] == "S"
      if b[j] == "o"
        d.push("S")
      else
        d.push("W")
      end
    elsif d[j-1] == "S" && d[j] == "W"
      if b[j] == "o"
        d.push("W")
      else
        d.push("S")
      end
    elsif d[j-1] == "W" && d[j] =="S"
      if b[j] == "o"
        d.push("W")
      else
        d.push("S")
      end
    elsif d[j-1] == "W" && d[j] =="W"
      if b[j] == "o"
        d.push("S")
      else
        d.push("W")
      end
    end
  end
  #puts d.join("")
    if d[-2] == d[0]
      if d[-1] == "S" && b[-1] == "o"
        if d[-1] == d[1]
          if d[0] =="S" && b[0] =="o"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "x"
            puts d.join("")
            exit
          end
        elsif d[-1] != d[1]
          if d[0] == "S" && b[0] == "x"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "o"
            puts d.join("")
            exit
          end
        end
      elsif d[-1] == "W" && b[-1] == "x"
        if d[-1] == d[1]
          if d[0] =="S" && b[0] =="o"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "x"
            puts d.join("")
            exit
          end
        elsif d[-1] != d[1]
          if d[0] == "S" && b[0] == "x"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "o"
            puts d.join("")
            exit
          end
        end
      end
    elsif d[-2] != d[0]
      if d[-1] == "S" && b[-1] == "x"
        if d[-1] == d[1]
          if d[0] =="S" && b[0] =="o"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "x"
            puts d.join("")
            exit
          end
        elsif d[-1] != d[1]
          if d[0] == "S" && b[0] == "x"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "o"
            puts d.join("")
            exit
          end
        end
      elsif d[-1] == "W" && b[-1] == "o"
        if d[-1] == d[1]
          if d[0] =="S" && b[0] =="o"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "x"
            puts d.join("")
            exit
          end
        elsif d[-1] != d[1]
          if d[0] == "S" && b[0] == "x"
            puts d.join("")
            exit
          elsif d[0] == "W" && b[0] == "o"
            puts d.join("")
            exit
          end
        end
      end
    end
end
end
puts "-1"

Measured memory_bytes: 44540
import java.math.BigDecimal
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    for (i in 1..n) {
        val (x1, y1, x2, y2) = Array(4, { BigDecimal(sc.next()) })
        val (x3, y3, x4, y4) = Array(4, { BigDecimal(sc.next()) })
        val (dx1, dx2) = Pair(x2-x1, x4-x3)
        val (dy1, dy2) = Pair(y2-y1, y4-y3)
        println(if ((dx1*dy2).compareTo(dx2*dy1) == 0) "YES" else "NO")
    }
}


Measured memory_bytes: 26244
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int x = -1;
  int cnt = 0;
  rep(i,sz(s)){
    if(x == -1 && s[i] == '1')cnt++;
    if(s[i] != '1'){
      if(x == -1) x = s[i]-'0';
    }
  }
  if(cnt>=k)cout<<1<<endl;
  else cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int counter = 0;
    for (int i = A; i <= B; i++){
        int reverse = 0;
        int tmp = i;
        while (tmp > 0){
            int rem = tmp % 10;
            reverse = reverse * 10 + rem;
            tmp /= 10;
        }
        if (i == reverse) counter++;
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ed = [[] for _ in range(n)]  # グラフ
v = [None] * n
for _ in range(m):
  l, r, d = map(int, input().split())
  ed[l-1].append((r-1, d))  # l -> r
  ed[r-1].append((l-1, -d))  # r -> l

visited = [False] * n  # 訪問フラグ（非連結の可能性の為）

def dfs(start):
  s = [start]
  v[start] = 0
  while s:
    label = s.pop()
    if visited[label] == False:
      visited[label] = True
      for to, dist in ed[label]:
        if v[to] is None:
          v[to] = v[label] + dist
          s.append(to)
        else:
          if v[to] != v[label] + dist:
            return False
  return True

is_exist = True
for i in range(n):
  if v[i] is None:
    if not dfs(i):
      print('No')
      is_exist = False
      break
if is_exist:
  print("Yes")


Measured memory_bytes: 66736
raw_input = []
while (n = gets.to_i) != 0 do
  raw_input << n
end

input = raw_input[1..-1]
size = raw_input[0] - 1
max_v = input[1] - input[0]
min_v = input[0]

for j in 1..size do
  margin = input[j] - min_v
  max_v = (max_v > margin) ? max_v : margin
  min_v = (min_v < input[j]) ? min_v : input[j]
end
p max_v



Measured memory_bytes: 9236
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAX = 100;

struct Trump {
	char mark;
	int value;
};

void selectionSort(Trump C[], int N);
void bubbleSort(Trump C[], int N);
void checkStable(Trump C1[], Trump C2[],int N);
void output(Trump C[], int N);


int main() {

	int N;
	char card[10];
	Trump T1[MAX],T2[MAX];

	//input
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> card;
		T1[i].mark = card[0];
		T1[i].value = (int)(card[1]-'0');
		T2[i].mark = card[0];
		T2[i].value = (int)(card[1] - '0');
	}
	bubbleSort(T1, N);
	selectionSort(T2, N);
	checkStable(T1, T2, N);
	return 0;
}

void bubbleSort(Trump C[], int N) {
	Trump tmp;
	for (int i = 0; i < N; i++)
	{
		for (int j = N-1; j >= i+1; j--)
		{
			if (C[j].value < C[j - 1].value) {
				tmp = C[j];
				C[j] = C[j - 1];
				C[j - 1] = tmp;
			}
		}
	}
	output(C, N);
	cout << "Stable" << endl;
}

void selectionSort(Trump C[], int N) {
	int minj;
	int flag=0;
	Trump tmp;
	for (int i = 0; i < N; i++)
	{
		minj = i;
		for (int j = i; j < N; j++)
		{
			if (C[j].value < C[minj].value) {
				minj = j;
				flag = 1;
			}
		}
		if (flag == 1) {
			tmp = C[i];
			C[i] = C[minj];
			C[minj] = tmp;
		}
		flag = 0;
	}
	output(C, N);
}

void output(Trump C[], int N) {
	for (int i = 0; i < N - 1; i++)
	{
		cout << C[i].mark << C[i].value<<" " << flush;
	}
	cout << C[N - 1].mark <<C[N-1].value <<endl;
}

void checkStable(Trump C1[],Trump C2[],int N) {
	for (int i = 0; i < N; i++)
	{
		if (C1[i].mark!= C2[i].mark || C1[i].value != C2[i].value) {
			cout << "Not stable" << endl;
			return;
		}
	}
	cout << "Stable" << endl;
}


Measured memory_bytes: 3080
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

int main(){
	string A,B;
	cin>>A>>B;
	int Na = A.size(), Nb = B.size();
	if(Na>Nb){
		ote("GREATER");
		return 0;
	}
	else if(Na<Nb){
		ote("LESS");
		return 0;
	}

	rp(i,Na){
		if(A[i]>B[i]){
			ote("GREATER");
			return 0;
		}
		else if(A[i]<B[i]){
			ote("LESS");
			return 0;
		}
	}
	ote("EQUAL");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> VI;
typedef vector<VI> VVI;

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    int x,y;
    x = s1.size(); y = s2.size();
    VVI dp(y+1,vector<long long>(x+1,0));
    REP(i,y){
        REP(j,x){
            if (s1[j] == s2[i]){
                dp[i+1][j+1] = dp[i][j] +1;
            }
            else{
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    int ii = y, jj = x;
    vector<char> str(dp[y][x]);
    while ( ii != 0 && jj != 0){
        if ( dp[ii-1][jj] == dp[ii][jj]) {
            ii--;
        }
        else if (dp[ii][jj-1] == dp[ii][jj]){
            jj--;
        }
        else {
            str[dp[ii][jj]-1] = s2[ii-1];
            ii--;jj--;
        }
    }
    for (char c : str) {
        cout << c;
    }

    return 0;
}
   


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

using namespace std;

const int Mod1 = 1e9 + 7, Mod2 = 1e9 + 9, Nmax = 5e5 + 5, Pow = 666013;
typedef long long ll;

int sP[Nmax], i, n, P;
ll ans = 0;
map< pair<int,int> , int> mp;
char a[Nmax];

ll power(ll a, int b, int Mod)
{
    ll ans = 1;
    while(b)
    {
        if(b&1) ans = ans * a % Mod;
        b >>= 1; a = a*a%Mod;
    }
    return ans;
}

struct number
{
    int x, y;
};

number Pw[Nmax], E[Nmax], R[Nmax], Inv, InvP[Nmax], target;

number operator - (number a, number b)
{
    a.x -= b.x;
    a.y -= b.y;
    if(a.x<0) a.x += Mod1;
    if(a.y<0) a.y += Mod2;
    return a;
}

number operator + (number a, number b)
{
    a.x += b.x;
    a.y += b.y;
    if(a.x>=Mod1) a.x -= Mod1;
    if(a.y>=Mod2) a.y -= Mod2;
    return a;
}

number operator * (number a, number b)
{
    return {(ll)a.x*b.x%Mod1, (ll)a.y*b.y%Mod2};
}

number operator * (number a, int b)
{
    return {(ll)a.x*b%Mod1, (ll)a.y*b%Mod2};
}

int main()
{
 //   freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> (a+1);

    for(i=1; i<=n; ++i) sP[i] = sP[i-1] - (a[i] == '<') + (a[i] == '>');

    Inv.x = power(Pow, Mod1-2, Mod1);
    Inv.y = power(Pow, Mod2-2, Mod2);

    Pw[0] = {1,1}; InvP[0] = {1,1};
    for(i=1; i<=2*n; ++i) Pw[i] = Pw[i-1] * Pow, InvP[i] = InvP[i-1] * Inv;

    P = n;
    for(i=1; i<=n; ++i) /// for 1..,i
    {
        E[i] = E[i-1];
        if(a[i] == '<')
        {
            --P;
            continue;
        }

        if(a[i] == '>')
        {
            ++P;
            continue;
        }

        if(a[i] == '-')
            E[i] = E[i] - Pw[P];
        else E[i] = E[i] + Pw[P];
    }

    for(i=1; i<=n; ++i) /// reverse operations for 1...i, not signs
    {
        if(a[i] == '<')
        {
            R[i] = R[i-1] * Pow;
            continue;
        }

        if(a[i] == '>')
        {
            R[i] = Inv * R[i-1];
            continue;
        }

        if(a[i] == '+') R[i] = R[i-1] + Pw[n];
            else R[i] = R[i-1] - Pw[n];
    }

    for(i=n; i; --i)
    {
        ++mp[{ E[i].x, E[i].y }]; /// i becomes active

        target = E[n] + R[i-1];
        if(sP[i-1] >= 0) target = target * Pw[sP[i-1]];
            else target = target * InvP[-sP[i-1]];

        ans += mp[{ target.x, target.y }];
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 48640
from collections import Counter
n = int(input())
s = input().rstrip()
front = s[:n]
back = s[n:]
back = list(reversed(back))
front_cnt = Counter()
back_cnt = Counter()
for i in range(2**n):
    fred = fblue = bred = bblue = "" 
    for j in range(n):
        if(i & 1 << j):
            fred += front[j]
            bred += back[j]
        else:
            fblue += front[j]
            bblue += back[j]
    front_cnt[fred + "_" + fblue] += 1
    back_cnt[bred + "_" + bblue] += 1

ans = 0
for key in front_cnt.keys():
    ans += front_cnt[key] * back_cnt[key]
print(ans)

Measured memory_bytes: 125532
import java.util.Scanner;

public class Main {
	public static int MAXN = 200000;
	public static long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int i1 = h - 1 - a;
		int j1 = b;
		long ans = 0;

		while(i1 >= 0 && j1 < w) {
			int i2 = h - 1 - i1;
			int j2 = w - 1 - j1;
			ans += comb(i1+j1,i1) * comb(i2+j2,i2) % MOD;
			if (ans >= MOD) ans -= MOD;
			i1 -= 1;
			j1 += 1;
		}
		
		System.out.println(ans);
	}
	
	static long[] fact = factorialArray(MAXN, MOD);
	static long[] factInv = factorialInverseArray(MAXN, MOD, inverseArray(MAXN, MOD));
	public static long comb(int n,int r) {
		return fact[n] * factInv[r] % MOD * factInv[n-r] % MOD;
	}
	
	public static long[] inverseArray(int maxN,long modP) {
		long[] inv = new long[maxN+1];
		inv[1] = 1;
		for(int i=2;i<=maxN;i++) {
			inv[i] = modP - (modP / i) * inv[(int) (modP%i)] % modP;
		}
		return inv;
	}
	public static long[] factorialArray(int maxN,long mod) {
		long[] fact = new long[maxN+1];
		fact[0] = 1 % mod;
		for(int i=1;i<=maxN;i++) {
			fact[i] = fact[i-1] * i % mod;
		}
		return fact;
	}
	public static long[] factorialInverseArray(int maxN,long modP,long[] inverseArray) {
		long[] factInv = new long[maxN+1];
		factInv[0] = 1;
		for(int i=1;i<=maxN;i++) {
			factInv[i] = factInv[i-1] * inverseArray[i] % modP;
		}
		return factInv;
	}
}


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

using namespace std;

int main()
{
    int n,i,j,k,x;
    cin>>n;
    int arr[n+1];
    memset(arr,0,(n+1)*sizeof(int));
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){ // with these 3 for loops you try all possible combinations
                x=i*i+j*j+k*k+i*j+j*k+i*k;
                if(x>n) // if you reach a number > n then you need to change y i.e j
                    break;
                else // if the number is included in the range then increase the values of it's index in the array
                    arr[x]++; 
            }
        }
    }
    for(i=1;i<=n;i++)
        cout<<arr[i]<<endl;
    return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}


  

int main()
{
    boost
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif
    string s;
    ll l;
    cin>>l;
    cin>>s;
    ll i;
    //ll l=s.length();
    string s1=s;
    ll ans=0;
    REP(i,l)
    {
        if(s[i]=='R')
        ans++;
    } 
    ll ans1=0;
    REP(i,ans)
    {
        if(s1[i]=='R')
        {
            ans1++;
        }
    }
    cout<<ans-ans1;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n, m, s;
    cin >> n >> m >> s;
    s = min(s, MAX - 1);

    vector<vector<P>> edge(n * MAX);
    for (int i = 0; i < m; i++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        for (int j = a; j < MAX; j++) {
            edge[u * MAX + j].push_back({v * MAX + j - a, b});
            edge[v * MAX + j].push_back({u * MAX + j - a, b});
        }
    }

    for (int i = 0; i < n; i++) {
        ll c, d;
        cin >> c >> d;
        for (int j = 0; j < MAX; j++) {
            edge[i * MAX + j].push_back({i * MAX + min(j + c, MAX - 1), d});
        }
    }

    vector <ll> ans(n * MAX, 1LL << 60);
    priority_queue <P, vector<P>, greater<P>> q;
    ans[s] = 0;
    q.push({0, s});

    while (!q.empty()) {
        P p = q.top();
        q.pop();
        ll time = p.first;
        int cur = p.second;
        if (ans[cur] < time) continue;
        for (P nxt : edge[cur]) {
            int next_node = nxt.first;
            ll total_time = time + nxt.second;
            if (ans[next_node] > total_time) {
                ans[next_node] = total_time;
                q.push({total_time, next_node});
            }
        }
    }

    for (int i = 1; i < n; i++) {
        ll mn = 1LL << 60;
        for (int j = 0; j < MAX; j++) mn = min(mn, ans[i * MAX + j]);
        cout << mn << '\n';
    }
    return 0;
}


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

int main () {
  int N;
  cin >> N;
  long long sum = 0;
  vector<long long>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  long long ans = 0;
  
  for (int i = 0; i < N; i++) {
    long long B = ((sum-A.at(i)) % 1000000007) * A.at(i);
    ans += B;
    ans %= 1000000007;
  }
  if (ans % 2 == 0){
    cout << ans/2 << endl;
  }
  else {
    cout << (ans + 1000000007)/2 << endl;
  }
}
  
    

Measured memory_bytes: 4756
#include <stdio.h>

int main(void) {
	int a,b,x,y;
	scanf("%d%d",&a,&b);
	x=a+b;
	if(x%2==1){
		printf("IMPOSSIBLE");
	}else{
	printf("%d",x/2);
	}
	// your code goes here
	return 0;
}


Measured memory_bytes: 128
class Integer
  def combination(k)
    return 1 if k.zero?
    (self - k + 1..self).inject(:*) / k.factorial
  end

  def permutation(k)
    return 1 if k.zero?
    (self - k + 1..self).inject(:*)
  end

  def factorial
    return 1 if self.zero?
    (1..self).inject(:*)
  end
end

n, m = gets.split.map(&:to_i)
candies = gets.split.map(&:to_i)
tmp = 0
hash = Hash.new(0)
candies.each_with_index do |c, i|
  mod = (tmp + c) % m
  hash[mod] += 1
  tmp = mod
end
sum = 0
hash.values.each { |v| sum += v.combination(2) }
sum += hash[0]
puts sum


Measured memory_bytes: 15244
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      List<int[]>[] arr = new List[n];
      for(int i = 0; i < n; i++) {
        int aNum = sc.nextInt();
        List<int[]> list = new ArrayList<>();
        for(int j = 0; j < aNum; j++) {
          list.add(new int[]{ sc.nextInt() - 1, sc.nextInt() });
        }
        arr[i] = list;
      }
      int maxCnt = 0;
      loop:
      for(int i = 0; i < (1 << n); i++) {
        int curCnt = 0;
        for(int j = 0; j < n; j++) {
          if(((i >> j) & 1) == 1) { // j番めの人がtrue
            curCnt++;
            for(int[] t : arr[j]) {
              if(((i >> t[0]) & 1) != t[1])
                continue loop;
            }
          }
        }
        maxCnt = Math.max(maxCnt, curCnt);
      }
      System.out.println(maxCnt);
  }
}

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

int main(){
	ll n,m,j=0;
    ll ans[50];
	while(cin>>n>>m){
		if(n==0&&m==0)break;
		ll d[n],v[n];
		vector<pair<ll,ll>>dv(n);
		for(ll i=0;i<n;i++){
			cin>>d[i]>>v[i];
			dv[i] = make_pair(d[i],v[i]);
		}
		sort(dv.begin(),dv.end());
		//for(int i=0;i<n;i++)cout<<dv[i].first<<endl;
		ll res = 0;
		for(ll i=0;i<n-1;i++){
			if(dv[i].first!=dv[i+1].first){
				res += dv[i].second;
			}else if(dv[i].first==m){
				break;
			}
		}
		res += dv[n-1].second;
//		cout<<dv[n-1].second<<endl;
		ans[j]=res;
		j++;
		//cout<<res<<endl;
	}

	for(int i=0;i<50;i++){
		if(i==j)break;
		cout<<ans[i]<<endl;
	}
}



Measured memory_bytes: 3060
// abc059_b
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) {
    cout << "GREATER" << endl;
  } else if (a.size() < b.size()) {
    cout << "LESS" << endl;
  } else {
    if (a == b) {
      cout << "EQUAL" << endl;
    } else {
      if (a > b) {
        cout << "GREATER" << endl;
      } else {
        cout << "LESS" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
from math import sqrt
n = int(input())
sqn_int = int(sqrt(n))
a = [0] * n
for x in range(1, 1 + sqn_int):
    for y in range(1, 1 + sqn_int):
        for z in range(1, 1 + sqn_int):
            left = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if left <= n:
                a[left - 1] += 1
for i in a[:n]:
    print(i)


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

int main() {
  double a,b;
  cin >> a >> b;
  int ans=-1;
  int aa=0, bb=0;
  for(int n=1;n<10001;n++){
    aa=n*0.08;//(int)(n*0.08);
    bb=n*0.1;//(int)(n*0.1);
    if(a==aa&&b==bb){
      ans=n;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

T=0
if H==1 & W==1:
	print("No")
	T=1


D=0
Numlist = []
for i in range(H):
	D+=100
	I=0
	RawList = []
	RawList = list(input())

	for j in range(W):
		CheckNum = RawList[j]
		I+=1

		if CheckNum == "#":
			Numlist.append(D+I)

N=0
for k in range(len(Numlist)):
	A = Numlist[k]
#	print(A)

	OK=0

	if (A+1) in Numlist:
		OK+=1
	if (A-1) in Numlist:
		OK+=1
	if (A+100) in Numlist:
		OK+=1
	if (A-100) in Numlist:
		OK+=1

	if OK == 0 and T==0:
		print("No")
		N=1
		break
#	print(OK)

if N==0 and T==0:
	print("Yes")




Measured memory_bytes: 3064
def main():
    n, m, k = map(int, input().split())
    mod = 998244353
    ans = 0
    m1 = [None]*(n+1)
    kaizyo = [None]*(n+1)
    nm1 = 1
    kai = 1
    for i in range(n+1):
        m1[i] = nm1
        nm1 *= m-1
        nm1 %= mod
        kaizyo[i] = kai
        kai *= i+1
        kai %= mod
    
    def comb(a, b):
        return (kaizyo[a]*fermat(kaizyo[a-b]*kaizyo[b], mod))%mod

    for i in range(k+1):
        ans += m*m1[n-i-1]*comb(n-1, i)
        ans %= mod
    
    print(ans)

def fermat(x, p):
    """
    1/x (mod p) を返す
        x**(p-1) ≡ 1    [if gcd(x, p) == 1]
        x**(p-2) ≡ 1/x
        繰返し二乗法 
            ex: x**50  = (x**25)**2
                x**25  = (x**12)**2 * x
                x**12  = (x**6)**2
                x**6   = (x**3)**2
    """
    times = []
    mod = p
    p -= 2
    while p > 1:
        times.append(p%2)
        p //= 2
    x %= mod
    out = x
    for i in times[::-1]:
        if i:
            out = (x*pow(out, 2, mod))%mod
        else:
            out = pow(out, 2, mod)
    return out



if __name__ == "__main__":
    main()

Measured memory_bytes: 83216
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, k; cin >> n >> k;
    vector<int> used(n, 0);
    for(int i = 0; i < k; i++)
    {
        int d; cin >> d;
        for(int j = 0; j < d; j++)
        {
            int x; cin >> x; x--;
            used[x] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(used[i]) continue;
        ans++;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
int N, M;
vint memo(100001, -1);
vvint graph;
ll solve(int i)
{
    if (memo[i] != -1)
    {
        return memo[i];
    }
    if (graph[i].size() == 0)
    {
        memo[i] = 0;
        return 0;
    }
    ll tmp = 0;
    for (auto j : graph[i])
    {
        tmp = max(tmp, solve(j));
    }
    memo[i] = tmp + 1;
    return memo[i];
}
int main()
{

    cin >> N >> M;
    graph.resize(N);
    int a, b;
    rep(i, M)
    {
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
    }
    ll ans = 0;
    rep(i, N)
    {
        ans = max(ans, solve(i));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std; 
    using ll = long long;
    using P = pair<int,int>; 
    
    int main() {
     double r;
     cin >> r;
     
     const double pi = 3.14159265;
     	cout << 2*r*pi << '\n';
     
     return 0;
    }
    

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;


vector<int> par;
vector<int> rnk;
vector<int> X;
vector<int> Y;
vector<int> Z;

void init(int N){
  rep(i,N){
    par[i] = i;
    rnk[i] = 0;
  }
}

int root(int x){
  return par[x] == x? x : par[x] = root(par[x]);
}

bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x==y) return;
  if(rnk[x] < rnk[y]){
    par[x] = y;
  }
  else{
    par[y] = x;
    if(rnk[x]==rnk[y]) rnk[x]++;
  }
}

int main(){
  int N, M; cin >> N >> M;
  par.resize(N);
  rnk.resize(N);
  X.resize(M);
  Y.resize(M);
  Z.resize(M);
  rep(i,M){
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--; Y[i]--; Z[i] %= 2;
  }
  init(N);
  rep(i,M){
    unite(X[i], Y[i]);
  }
  set<int> st;
  rep(i,N){
    st.insert(par[root(i)]);
  }
  cout << (int)st.size() << endl;
  return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int n;
    cin >> n;
    vector<int> p(n),q(n), v(n);

    for(int i = 0;i < n;++i)    cin >> p[i];
    for(int i = 0;i < n;++i)    cin >> q[i];
    for(int i = 0;i < n;++i)    v[i] = i+1;


    int a = 0, b = 0;

    int num = 0;
    do{
        num++;
        if(v == p){
            a = num;
        }
        if(v == q){
            b = num;
        }

        if(a > 0 && b > 0){
            break;
        }

    }while(next_permutation(v.begin(), v.end()));
    cout << abs(a-b) << endl;

    return 0;
}

Measured memory_bytes: 888