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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


#define ABYSS -1
#define TO_BE_FILLED 0

vi solve(int N, int A, int B) {
    vi ans;
    if (A+B > N+1) return ans;
    if ((ll)A*B < (ll)N) return ans;
    if (A < B) {
        vi rev = solve(N, B, A);
        rep(i,N) rev[i] = (N+1)-rev[i];
        return rev;
    }
    // A >= B
    // A+B <= N+1
    // A*B >= N
    ans.assign(N, -1);
    if (B == 1) {
        rep(i,N) ans[i] = 1+i;
        return ans;
    }

    int rest = N-A, q = rest/(B-1), r = rest%(B-1), _r = (B-1)-r;
    int label=0;
    // for (int i=0;i<A;++i) {
#ifdef DEBUG
    fprintf(stderr, "N=%d,A=%d,B=%d; q=%d,r=%d|%d\n", N,A,B,q,r,_r);
#endif
    for (int a=0; a<A; ++a) {
        int bmax = 0;
        if (a < q) bmax = B-1;
        if (r != 0 && a == q) bmax = 1+r;
        for (int b=0; b<=bmax; ++b) {
            int fill_index = -1;

            int _b = (B-1)-b; //0...B-1
            if (_b < _r) {
                if (q <= a) continue;
                fill_index = _b*q + a;
            } else if (r != 0 && _b < B-1) {
                if (q+1 <= a) continue;
                fill_index = _r*q + (_b-_r)*(q+1) + a;
            } else {
                fill_index = rest + a;
            }
#ifdef DEBUG
            fprintf(stderr, "%d | (%d,%d|%d) -> %d\n", i, a,b,_b, fill_index);
#endif
            if (fill_index >= 0) {
                ans[fill_index] = ++label;
                if (label == N) goto done;
            }
        }
    }
 done:
    return ans;
}

int main() {
    int N,A,B; cin >> N >> A>> B;
    vi ans = solve(N,A,B);
    if (ans.size() != N) {
        cout << -1 << endl;
    } else {
        rep(i,N) {
            if (i != 0) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
n, l = map(int, input().split())
tast = []
for i in range(n):
  tast.append(l + i)
ans = 0
if 0 in tast:
  ans = sum(tast)
elif tast[0] > 0 and tast[-1] > 0:
  ans = sum(tast) - tast[0]
elif tast[0] < 0 and tast[-1] < 0:
  ans = sum(tast) - tast[-1]
print(ans)

Measured memory_bytes: 3064
def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    Ch, Cw = (int(i)-1 for i in input().split())
    Dh, Dw = (int(i)-1 for i in input().split())
    A = [input() for i in range(H)]
    V = [[-1]*W for i in range(H)]  # V[h][w]を頂点iとする
    d = ((1, 0), (0, 1), (-1, 0), (0, -1))

    def bfs_2d(sy, sx, v):
        que = deque()
        V[sy][sx] = v
        que.append((sy, sx))
        while que:
            uh, uw = que.popleft()
            for dy, dx in d:
                next_h = uh + dy
                next_w = uw + dx
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if V[next_h][next_w] != -1:
                    continue
                if A[next_h][next_w] == '#':
                    continue
                V[next_h][next_w] = v
                que.append((next_h, next_w))

    # グループ分け
    vertex = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#" or V[h][w] != -1:
                continue
            bfs_2d(h, w, vertex)
            vertex += 1

    # グラフを作成、全てのマスで5*5の範囲を走査
    G = [[] for _ in range(vertex)]
    used = [set() for _ in range(vertex)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                continue
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    if h + dh < 0 or H <= h + dh or w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        continue
                    if V[h][w] == V[h+dh][w+dw]:
                        continue
                    if V[h+dh][w+dw] in used[V[h][w]]:
                        continue
                    G[V[h][w]].append((V[h+dh][w+dw]))
                    used[V[h][w]].add((V[h+dh][w+dw]))

    # for h in range(H):
    #     print(V[h])

    # for i in range(vertex):
    #     print(G[i])

    # スタートからゴールまでbfsして最短距離を求める
    s = V[Ch][Cw]
    g = V[Dh][Dw]
    que = deque([0])

    dist = [-1 for _ in range(vertex)]
    par = [-1]*vertex
    que = deque()
    dist[s] = 0
    par[s] = -2  # rootは親なし
    que.append(s)
    while que:
        u = que.popleft()
        for v in G[u]:
            if par[v] != -1:
                continue
            par[v] = u
            dist[v] = dist[u] + 1
            que.append(v)
    print(dist[g])


if __name__ == '__main__':
    main()


Measured memory_bytes: 162932
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;
int N=1e7+1;
vi sieve(N,0);
void filsieve(int n)
{
    int i,j;
    sieve[1]=1;
    for(i=2;i<=n;i++)
    {
        if(sieve[i]==0)
        {
           for(j=i;j<=n;j+=i)
           {
               if(sieve[j]==0)
               sieve[j]=i;
           }
        }
    }
}
int fnd(int n)
{
    int prod=1,prev,sum=0;
    while(n!=1)
    {
        sum=0,prev=sieve[n];
        while(sieve[n]==prev)
        {
            n/=sieve[n];
            sum++;
        }
        prod*=(sum+1);
    }
    return prod;
}

int32_t main() {
	// your code goes here
int n,m,k,i;
cin>>n;
filsieve(n);
int sum=0;
for(i=1;i<=n;i++)
sum+=i*fnd(i);
cout<<sum<<"\n";

}


Measured memory_bytes: 81296
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool isPrime[100010];

void set_prime() {
    rep(i, 100010) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    REP(i, 2, 1000) {
        int j = 2;
        while(i * j <= 100000) {
            isPrime[i * j] = false;
            j++;
        }
    }
}
int sum[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    set_prime();
    int Q; cin >> Q;
    for(int i = 1; i < 100001; i++) {
        if (isPrime[i] && isPrime[(i + 1) / 2]) {
            sum[i] = 1;
        }
    }
    rep(i, 100000) sum[i + 1] += sum[i];
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1152
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

H, W = get_ints
A = []
H.times do |i|
  A[i] = gets.chomp
end

ax = A.filter do |a|
  a != '.'*W
end

list = []
W.times do |i|
  if ax.all? { |a| a[i] == '.'}
    list << i
  end
end

while list.length > 0
  index = list.pop
  ax = ax.map do |a|
    test = a.split('')
    test.delete_at(index)
    test.join
  end
end

ax.each do |a|
  puts a
end


Measured memory_bytes: 14548
N = int(input())
h = list(map(int, input().split()))
low = 0
ans = 0
for i in range(N-1):
    if h[i+1] >= h[i]:
        continue
    else:
        ans += h[i] - low
        low = h[i+1]
ans += max(0, h[-1] - low)
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    vector<vector<pair<int, int>>> statements(N);
    REP(n, N) {
        int a;
        cin >> a;
        REP(i, a) {
            int x, y;
            cin >> x >> y;
            --x;
            statements[n].pb(mp(x, y));
        }
    }

    int ans = 0;
    REP(i, 1 << N) {
        bool ok = true;

        // bitパターンから正直者・不親切を生成
        // 1: 正直者  0: 不親切
        vector<int> truth(N);
        int man = 0;
        REP(j, N) {
            if ((1 << j) & i) {
                truth[j] = 1;
                ++man;
            }
            else {
                truth[j] = 0;
            }
        }

        // 証言から集めた結果
        // 1: 正直者  0: 不親切  -1: any
        vector<int> res(N, -1);
        REP(j, N) {
            if (truth[j]) {
                for(auto xy: statements[j]) {
                    auto x = xy.first;
                    auto y = xy.second;
                    if (res[x] == -1) {
                        res[x] = y;
                    }
                    else {
                        if (res[x] != y) ok = false;
                    }
                }
            }
        }
        // 証言に矛盾が出た場合は終わり
        if (!ok) continue;

        // 証言から集めた結果と、真の結果が一致するか
        REP(j, N) {
            if (res[j] == -1) continue;
            if (res[j] != truth[j]) ok = false;
        }

        // 一致しなければ終わり
        if (!ok) continue;

        ans = max(ans, man);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

const int MAXN = 20024;

bool dp[MAXN][MAXN];
int dx[MAXN];
int dy[MAXN];

vector<string> split(string s, string delim) {
    vector<string> res;
    int pos = 0;
    while(true) {
        int found = s.find(delim, pos);
        if(found >= 0) {
            res.push_back(s.substr(pos, found - pos));
        }
        else {
            res.push_back(s.substr(pos));
            break;
        }
        pos = found + delim.size();
    }
    return res;
}

ll conv(string num) { stringstream ss; ss << num << flush; ll n; ss>>n; return n; }
string conv(ll n) { stringstream ss; ss << n << flush; return ss.str(); }

int main() {
    string s; cin>>s;
    int x,y; cin>>x>>y;
    x += 8000;
    y += 8000;

    vector<string> v = split(s, "T");
    int ix = 0;
    int iy = 0;
    for(int i = 0; i < (int)v.size(); ++i) {
        if(i % 2 == 0) {
            dx[ix++] = v[i].size();
        }
        else {
            dy[iy++] = v[i].size();
        }
    }

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

    fill((bool*)dp, (bool*)(dp + MAXN), false);

    dp[iy][y] = true;

    for(int i = iy - 1; i >= 0; --i) {
        for(int j = 0; j < MAXN; ++j) {
            if(j + dy[i] < MAXN) {
                dp[i][j] = (dp[i][j] || dp[i+1][j + dy[i]]);
            }
            if(j - dy[i] >= 0) {
                dp[i][j] = (dp[i][j] || dp[i+1][j - dy[i]]);
            }
        }
    }

    if(!dp[0][8000]) {
        cout << "No" << endl;
        return 0;
    }

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

    fill((bool*)dp, (bool*)(dp + MAXN), false);

    dp[ix][x] = true;

    for(int i = ix - 1; i >= 0; --i) {
        for(int j = 0; j < MAXN; ++j) {
            if(j + dx[i] < MAXN) {
                dp[i][j] = (dp[i][j] || dp[i+1][j + dx[i]]);
            }
            if(j - dx[i] >= 0 && i > 0) {
                dp[i][j] = (dp[i][j] || dp[i+1][j - dx[i]]);
            }
        }
    }

    if(!dp[0][8000]) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 392064
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
  long long int A,B,C;
  cin>>A>>B>>C;
  long long int var1,var2,var3,var4,var5,var6;
  long long int diff1,diff2,diff3;
  long long int less;
 if(A>=2&&B>=2&&C>=2&&A<=1000000000&&B<=1000000000&&C<=1000000000){
  var1=A*B*(C/2);
  var2=A*B*(C-(C/2));
  var3=A*C*(B/2);
  var4=A*C*(B-(B/2));
  var5=B*C*(A/2);
  var6=B*C*(A-(A/2));
  diff1=abs(var1-var2);
  diff2=abs(var3-var4);
  diff3=abs(var5-var6);
  less=min(diff1,diff2);
  cout<<min(less,diff3);
 }
  return 0;
}


Measured memory_bytes: 3568
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i=i+2)
	{
		cout<<s[i]; 
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference, debug statements can also cause TLE.
//priority_queue implements max heap by default

double dp[305][305][305];

int main(){
    fastio;
    // think about edge cases like n=1(especially graph questions).
    int n;
    cin>>n;
    int cnt[4] = {};
    dp[0][0][0] = 0.0;
    forn(i,0,n){
        int a;
        cin>>a;
        cnt[a]++;
    }
    for(int three = 0;three<=n;three++){
        for(int two = 0;two<=n;two++){
            for(int one = 0;one<=n;one++){
                if(one+two+three == 0){
                    continue;
                }
                if(one+two+three>n){
                    continue;
                }
                int zero = n-one-two-three;
                // cerr<<zero<<" "<<one<<" "<<two<<" "<<three<<endl;
                double val = 1.0;
                if(three)
                    val += (1.0*three/n)*dp[three-1][two+1][one];
                if(two)
                    val += (1.0*two/n)*dp[three][two-1][one+1];
                if(one)
                    val += (1.0*one/n)*dp[three][two][one-1];
                assert(zero!=n);
                val = val/(1.0-(1.0*zero/n));
                dp[three][two][one] = val;
            }
        }
    }
    cout<<fixed<<setprecision(12)<<dp[cnt[3]][cnt[2]][cnt[1]]<<endl;
    return 0;
}

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

int main(void) {
    string s;
    int cnt = 0;
    cin >> s;
    for(int i=0;i<3;i++) {
        if(s[i] == 'o')cnt++;
    }
    cout << cnt * 100 + 700<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) (i%(ll)(1e9 + 7))


int main(){
	string a,b;
	cin >> a >>b;
	if(a.size() > b.size()){
		cout << "GREATER" << endl;
		return 0;
	
	}else if(a.size() < b.size()){
		cout << "LESS" << endl;
		return 0;
	}else{
		rep(i,0,a.size()){
			if(a[i] > b[i]){
				cout << "GREATER" << endl;
				return 0;
			}else if(a[i] < b[i]){
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int h , w , m;
    cin >> h >> w >> m;
    set<pair<int,int>> points;
    vector<int> row(h+1 , 0) , col(w+1 , 0);
    for(int i = 1; i <= m; i++) {
        int x , y;
        cin >> x >> y;
        points.insert({x,y});
        row[x]++ , col[y]++;
    }
    int r = 0 , c = 0;
    for(int i = 1; i <= h; i++) r = max(r , row[i]);
    for(int i = 1; i <= w; i++) c = max(c , col[i]);
    int ans = r + c - 1;
    vector<int> a , b;
    for(int i = 1; i <= h; i++) if(row[i] == r) a.push_back(i);
    for(int i = 1; i <= w; i++) if(col[i] == c) b.push_back(i);
    for(int i = 0; i < (int)a.size(); i++) {
        for(int j = 0; j < (int)b.size(); j++) {
            if(!points.count({a[i] , b[j]})) {
                cout << ans+1 << "\n"; 
                return 0;
            }
        }
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 35024
from collections import deque
import sys
input = sys.stdin.readline

H,W = map(int, input().split())
table = []
b_count = 0

for i in range(H):
    s = list(input())
    b_count += s.count("#")
    table.append(s)

Q = deque()
Q.append((0,0))
dist = [[-1]*W for i in range(H)]
dist[0][0] = 0
dx = [1,0,-1,0]
dy = [0,-1,0,1]

while Q:
    y,x = Q.popleft()
    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if 0<=ny<H and 0<=nx<W and table[ny][nx] == "." and dist[ny][nx] == -1:
            dist[ny][nx] = dist[y][x]+1
            Q.append((ny,nx))

if dist[-1][-1] == -1:
    print(-1)
else:
    ans = H*W-b_count-(dist[-1][-1]+1)
    print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a;
  int b;
  int c = -1;
  cin >> a >> b;
  for(int i = 0;i < 1001;i++){
    if(i * 2 / 25 == a && i / 10 == b){
      c = i;
      break;}
    }
    cout << c << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	ll A, B;
	cin >> A >> B;
	if (A == B) {
		cout << 0 << endl;
	}
	else if ((A + B) % 2 == 0) {
		cout << (A + B) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#define MAX_N 1000
#define MAX_INT 2147483647
 
using namespace std;
 
typedef pair<int, int> P;
long long int N, T, A,result;
long long int H[MAX_N];
int solve() {
  int ans = 0;
  result = MAX_INT;
  scanf("%lld %lld %lld", &N, &T, &A);	
  for(int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  for(int i = 0; i < N; i++) {
    long long int tmp = abs((A * 1000) - ((T * 1000) - H[i] *6));
    if(result > tmp) {
      result = tmp;
      ans = (i + 1);
    }
  }
  printf("%d\n", ans);
}
 
int main(int args, char* argv[]) {
  solve();
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define id(i,j) ((i-1)*m+j)
const int N=110,inf=1e9;
struct fk{int to,nxt,w;}e[N*N*N*4];
int head[N*N*2],cnt=1;
int dis[N*N*2],n,m,Sx,Sy,Tx,Ty,mp[N][N],S,T,ans,tot;
char s[N];
queue<int> q;
void add(int u,int v,int w){e[++cnt].to=v;e[cnt].nxt=head[u];e[cnt].w=w;head[u]=cnt;}
bool bfs(){
    memset(dis,63,sizeof(dis));
    dis[S]=0;q.push(S);
    while(!q.empty()){
        int u=q.front();q.pop();
        for(int i=head[u],v;i;i=e[i].nxt)
            if(e[i].w&&dis[v=e[i].to]>dis[u]+1)
                dis[v]=dis[u]+1,q.push(v);
    }
    return dis[T]<inf;
}
int dfs(int u,int flow){
    if(u==T||!flow)return flow;
    int now=0;
    for(int i=head[u],v;i;i=e[i].nxt)
        if(e[i].w&&dis[v=e[i].to]==dis[u]+1){
            int f=dfs(v,min(flow-now,e[i].w));
            e[i].w-=f;e[i^1].w+=f;now+=f;
        }
    if(!now)dis[u]=-1;
    return now;
}
void dinic(){for(;bfs();ans+=dfs(S,inf));}
int main(){
    scanf("%d%d",&n,&m);tot=n*m;
    S=0;T=tot*2+1;
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
            if(s[j]!='.'){
                if(s[j]=='o'){
                    mp[i][j]=1;
                    add(id(i,j),id(i,j)+tot,1);
                    add(id(i,j)+tot,id(i,j),0);
                }
                else{
                    if(s[j]=='S')mp[i][j]=1,Sx=i,Sy=j;
                    if(s[j]=='T')mp[i][j]=1,Tx=i,Ty=j;
                    add(id(i,j),id(i,j)+tot,inf);
                    add(id(i,j)+tot,id(i,j),0);
                }
            }
    }
    add(S,id(Sx,Sy),inf);
    add(id(Sx,Sy),S,0);
    add(id(Tx,Ty)+tot,T,inf);
    add(T,id(Tx,Ty)+tot,0);
    if(Sx==Tx||Sy==Ty){puts("-1");return 0;}
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(mp[i][j]){
                for(int k=1;k<=n;k++)
                    if(k!=i&&mp[k][j])
                        add(id(i,j)+tot,id(k,j),inf),add(id(k,j),id(i,j)+tot,0);
                for(int k=1;k<=m;k++)
                    if(k!=j&&mp[i][k])
                        add(id(i,j)+tot,id(i,k),inf),add(id(i,k),id(i,j)+tot,0);
            }
        }
    dinic();
    printf("%d\n",ans);
}


Measured memory_bytes: 47360
#include <stdio.h>

int main(int argc, char *argv[])
{
    static int status[100000], list[100000];
    int i, N, n = 1;
    scanf("%d", &N);
    for ( i = 0; i < N; i++ ){
        scanf("%d", &list[i]);
    }
    status[0] = 1;
    for ( i = 1, n = list[n-1]; n != 2; n = list[n-1], i++ ){
        if ( status[n-1] != 0 ){
            printf("-1\n");
            return 0;
        }
        status[n-1] = 1;
    }
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;

void solve() {
	cin >> S;
	N = sz(S);
	ll res = 0;
	int cnt = 0;
	rep(i, 0, N) {
		if(S[i] == 'W') {
			res += i - cnt;
			cnt++;
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 720
n, y = map(int, input().split())
ans = 0
for i in range(n+1):
    for j in range(n+1-i):
        if y == 10000*i + 5000*j + 1000*(n-i-j):
            print(i, j, n-i-j)
            ans += 1
            exit()
if ans == 0:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#while 1:
    #n=map(int,raw_input().split())

def chang(x):
    h = x / 100
    m= x%100
    return h * 60 + m

while 1:
    (ch,st,en) = map(int, raw_input().split())
    if(ch==0 and st ==0 and en ==0):break
    hours = [0]*(chang(2400)+1)
    for i in range(ch):
        line = raw_input()
        tms = map(int, raw_input().split())
        for ti in tms[0::2]:
            hours[chang(ti)] += 1
            #print ti,hours[chang(ti)]            
        for tim in tms[1::2]:
            hours[chang(tim)] -=1
            #print tim,hours[chang(tim)]
    #end imos
    spn = 0
    checker = 0
    maxspn = 0
    for t in range(chang(st),chang(en)):
        if(checker < ch and hours[t] + checker >= ch):
            if(spn > maxspn):maxspn = spn
            spn=0
        checker += hours[t]
        if(checker < ch):spn+=1
    if(spn > maxspn):maxspn = spn
    
    print maxspn
            

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

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++)
  {
    cout << s[i];
  }
  if (s.at(n - 1) == 's')
  {
    cout << "es" << endl;
  }
  else
  {
    cout << 's' << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,k,l,dsu1[200010],dsu2[200010],x,y;
map< pair<int, int>, int> mp;
int find1(int s){
    if (s == dsu1[s]) return s;
    else return (dsu1[s] = find1(dsu1[s]));
}
int find2(int s){
    if (s == dsu2[s]) return s;
    else return (dsu2[s] = find2(dsu2[s]));
}
int main(){
    cin>>n>>k>>l;
    for(int i=1; i<=n; i++){
        dsu1[i] = i;
        dsu2[i] = i;
    }
    for(int i=1; i<=k; i++){
        cin>>x>>y;
        dsu1[find1(x)] = find1(y);
    }
    for(int i=1; i<=l; i++){
        cin>>x>>y;
        dsu2[find2(x)] = find2(y);
    } 
    for(int i=1; i<=n; i++){
        mp[make_pair(find1(i),find2(i))]++; 
    }
    for(int i=1; i<n; i++){
        cout<<mp[make_pair(find1(i), find2(i))]<<' ';
    }
    cout<<mp[make_pair(find1(n), find2(n))]<<endl;;
    return 0;
}

Measured memory_bytes: 16352
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int N,M,Q;
#define fi first
#define se second
vector<int> point(11);
vector<pair<pair<int,int>,pair<int,int>>> points;

void print_list(vector<int> a)
{
    int n=a.size();
    for (int i=0;i<n;i++) cout << a[i] << " " ;
    cout << endl;
}

int ans()
{
    int score=0,a,b,c,d;
    for (int i=0;i<Q;i++)
    {
        a=points[i].fi.fi;
        b=points[i].fi.se;
        c=points[i].se.fi;
        d=points[i].se.se;
        if (point[b]-point[a]==c) score+=d;
    }
    return score;
}
void dfs(int s,int v,vector<int> &point,int &answer)
{
    if (s==N+1) 
    {
        answer=max(answer,ans());
        //print_list(point);
        return;
    }
    point[s]=v;
    for (int i=v;i<M+1;i++) 
    {
        //cout << "loop" << endl;
        dfs(s+1,i,point,answer);
    }
}

int main()
{
    cin >> N >> M >>Q;
    int a,b,c,d;
    for (int i=0;i<Q;i++)
    {
        cin >> a>> b >>c >>d;
        points.push_back(make_pair(make_pair(a,b),make_pair(c,d)));
    }
    int answer=0;
    dfs(1,1,point,answer);
    cout << answer << endl;
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
   x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node x;
  Node y;
  if(z->left==NIL||z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->left;
  }
  else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }
  else{
    if(y==y->parent->left){
      y->parent->left=x;
    }
    else{
      y->parent->right=x;
    }
  }
  if(y!=z){
    z->key=y->key;
}
}

void insert(int k){
  Node x = root;
  Node y = NIL;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int i,n,x;
  char com[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      Node t = treeSearch(root,x);
      if(t!=NIL)
    printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] ==  'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0] ==  'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }
  return 0;
}



Measured memory_bytes: 25240
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    a, b, c = lr()
    if a+b-c > 0:
        print('No')
    elif (a+b-c)**2 > 4*a*b:
        print('Yes')
    else:
        print('No')
resolve()

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define int long long

const int MOD = 2019;
int a, b;
int ans = 2019;

signed main()
{
	IOS;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		for (int j = i+1; j <= b; j++) {
			ans = min(ans, (i%MOD * j%MOD)%MOD);
			if (!ans) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
 
using namespace std;
 
int main(){
 
    int n,q;
    string s;
    cin >> n >> q;
    cin >> s;
    int check[100000] = {};
    int check100[1000] = {};
 
    for(int i = 0; i < n - 1; i++){
        if(s[i] == 'A' && s[i + 1] == 'C') check[i] = 1;
    }
 
    for(int i = 0; i < n; i++){
        if(check[i] == 1) check100[i/100]++;
    }
 
 
    for(int i = 0; i < q; i++){
        int l,r;
        int cnt = 0;
        cin >> l >> r;
        l--;
        r--;
 
        for(int j = l / 100 + 1; j < r / 100; j++){
            cnt = cnt + check100[j];
        }
 
        for(int j = l; j < (l / 100 + 1) * 100 && j < r; j++){
            cnt = cnt + check[j];
        }
 
        if(l / 100 != r / 100){
            for(int j = r / 100 * 100; j < r; j++){
                cnt = cnt + check[j];
            }
        }
 
        printf("%d\n",cnt);
 
    }
 
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int i,a,b;
    int n,m;
    int r,l;
    int rr,ll;
    string s;
    int u, v, w;
    cin >>n>>m;
    long long int ans=0;
    std::cin >> l>>r;
    for (i=1;i<m;i++){
        std::cin >> ll>>rr;
        if (ll>l) l=ll;
        if(rr<r) r=rr;
  }
  if (r>=l)
  std::cout << r-l+1 << std::endl;
  else 
  std::cout << 0 << std::endl;
 //   for (i=0;i<n;i++){
  //      std::cin >> u>>v>>w;
//        if (w%2==0)ans[v-1]=ans[u-1];
 //       else if(ans[u-1]==0)ans[v-1]=1;
  //      else ans[v-1]=0;
//    }
 //   for(i=0;i<n;i++)
// if (a>=13) ans=b;
// else if(a>5)ans=b/2;
    //std::cout << ans << std::endl;
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T,class V> ostream& operator<<(ostream &s,pair<T,V> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n;
        cin>>n;
        vii v(n);
        for(int i=0;i<n;i++){
            cin>>v[i].fi;
            v[i].fi--;
            v[i].se=i+1;
        }
        sort(v.begin(),v.end());
        vi ans;
        vi done;
        ll l1=0,l2=0,d=0;
        while(ans.size()<n*n){
            while(l1<n&&v[l1].se==d+1)l1++,d=0;
            if(l2<n&&ans.size()==v[l2].fi){
                if(l1<=l2)break;
                ans.push_back(v[l2].se);
                for(int i=v[l2].se;i<n;i++)done.push_back(v[l2].se);
                l2++;
                continue;
            }
            if(l1<n)ans.push_back(v[l1].se),d++;
            else if(done.empty())break;
            else ans.push_back(done.back()),done.pop_back();
        }
        if(ans.size()==n*n){
            cout<<"Yes"<<endl;
            for(int i=0;i<n*n;i++)cout<<ans[i]<<(i==n*n-1?'\n':' ');
        }
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4208
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	
	
	public static long A;
	public static long answer = 0;
	

 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd(long a, long b) {
		if (b == 0) {
			return a;			
		}
		return gcd(b, a % b);
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	public static void ans(String n) {
		if(Long.valueOf(n)>A) {
			return;
		}else if(n.contains("3")&&n.contains("5")&&n.contains("7")){
			answer++;
		}
		ans(n+"3");
		ans(n+"5");
		ans(n+"7");
	}

	
    
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 A=sc.nextLong();
     ans("0");
	 System.out.println(answer);
}
}

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

using namespace std;

int main(){
    string s;
    string p;

    getline(cin, s);
    getline(cin, p);

    s.append(s);

    if(s.find(p) == -1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, d, x; cin >> n >> d >> x;
  vector<int> a(n);
  for(int &c : a) {
    cin >> c;
  }
  int allchocoes = 0;
  for(int c : a) {
    int dates = 1, eachchocoes = 0;
    while(dates <= d) {
      eachchocoes++;
      dates += c;
    }
    allchocoes += eachchocoes;
  }
  cout << allchocoes + x << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int l=s.size();
    if(s[0]==s[l-1]){
        if(l%2==0){
            cout<<"First"<<endl;
        }
        else{
            cout<<"Second"<<endl;
        }
    }
    else{
        if(l%2==0){
            cout<<"Second"<<endl;
        }
        else{
            cout<<"First"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 512
S = input()

moved = {"N": False, "W": False, "S": False, "E": False}
for s in S:
    if not moved[s]:
        moved[s] = True

if (moved["N"] and moved["S"]) or not (moved["N"] or moved["S"]):
    if (moved["W"] and moved["E"]) or not (moved["W"] or moved["E"]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 9036
import java.util.*;
class Main{
    
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
            int a = s.nextInt() , b = s.nextInt() ;
            int ans = Math.max(a+b,a-b);
            
            ans = Math.max(ans,a*b);
            
            System.out.println(ans);
    }
}

Measured memory_bytes: 20820
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
using namespace std;
int main(){
string s;
int l;
int a[26]={0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0};

while(cin>>s && s!="#"){
l=s.length();
int ans=0;
if(l!=1){
for(int i=0;i<l-1;i++){
if(a[s[i]-'a']+a[s[i+1]-'a']==1) ans++;
}
}
cout<<ans<<endl;
}

return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

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

using namespace std;
using ll = long long;

const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D;
  A--;B--;C--;D--;
  cin >> S;
  
  vector<bool> dp1(200005, false);
  dp1[A] = true;
  for(int i = 0; i < 200005; i++) {
    if(dp1[i]) {
      if(i + 1 < 200005 && S[i + 1] == '.') dp1[i + 1] = true;
      if(i + 2 < 200005 && S[i + 2] == '.') dp1[i + 2] = true;
    }
  }
  // for(int i = 0; i < N; i++) //cerr << dp1[i] <<" "; cerr << endl;

  vector<bool> dp2(200005, false);
  dp2[B] = true;
  for(int i = 0; i < 200005; i++) {
    if(dp2[i]) {
      if(i + 1 < 200005 && S[i + 1] == '.') dp2[i + 1] = true;
      if(i + 2 < 200005 && S[i + 2] == '.') dp2[i + 2] = true;
    }
  }
  
  // for(int i = 0; i < N; i++) //cerr << dp2[i] <<" "; cerr << endl;
  if(D < C) {
    bool ok = false;
    for(int i = B; i <= D; i++) {
      if(dp1[i - 1] && dp2[i] && dp1[i + 1]) ok = true;
    }
    
    if(!ok) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  if(dp1[C] && dp2[D]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first<<"\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    REP(i,n){
        cin >> a[i];
        a[i]--;
    }
    REP(i,n){
        cin >> b[i];
    }
    REP(i,n-1){
        cin >> c[i];
    }
    int res = 0;
    REP(i,n){
        if(i<n-1){
            if(a[i]+1==a[i+1]){
                res+=c[a[i]];
            }
        }
        res+=b[i];
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int,int> P;

int dy[4]={0,0,1,-1};
int dx[4]={1,-1,0,0};
int main(){
	long long M=0,A=0,R=0,C=0,H=0;
	int N;
	cin>>N;
	REP(i,N){
		string s;
		cin>>s;
		if(s[0]=='M')M++;
		if(s[0]=='A')A++;
		if(s[0]=='R')R++;
		if(s[0]=='C')C++;
		if(s[0]=='H')H++;
	}
	long long ans=0;
	ans=M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    a = list(map(lambda x: int(x)-1, input().split()))
    event = [[] for _ in [0]*m]
    for j, i in enumerate(a):
        if j < n-1:
            A = m-a[j+1]
            if A < m:
                event[A].append((True, j))
        B = m-i
        if B < m:
            event[B].append((False, j))
    leader = 1
    now = a[-1]
    for i in range(n-1):
        if a[i] > a[i+1]:
            leader += 1
            now += a[i]
    s = a[0]
    ans = 10**20
    for i in range(m):
        for e, j in event[i]:
            if e:
                leader += 1
                now += ((a[j]+i) % m)
            else:
                now -= m
                if j != n-1:
                    leader -= 1
        now += leader
        ans = min(ans, now-1-(s+i) % m)
    print(ans)


main()

Measured memory_bytes: 33472