akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ h, w ] <- readInts
	board <- replicateM h getLine
	putStrLn $ replicate ( w + 2 ) '#'
	mapM_ ( printf "#%s#\n" ) board
	putStrLn $ replicate ( w + 2 ) '#'


Measured memory_bytes: 1404
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=x-1;i>=n;--i)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
void print(int arr[],int n){
	for(int i=0;i<n;++i)
	cout<<arr[i]<<" ";
	cout<<endl;
}
int32_t main()
{
	int n; cin>>n;
	int a[n],b[n];
	int s=0,t=0;
	f(i,0,n)
	{cin>>a[i];s+=a[i];}
	f(i,0,n)
	{cin>>b[i];t+=b[i];}
	if(s<t){
		cout<<"-1";
		return 0;
	}
	int ans=0,tb=0;
	int d[n];
	f(i,0,n)
	{d[i]=a[i]-b[i]; if(d[i]<0){tb-=d[i];} if(d[i]<0)ans++;}
	sort(d,d+n);
	rf(i,n,0){
		if(tb>0 && d[i]>0){
			ans++;
			tb-=d[i];
		}else break;
	}
	if(tb<=0){
		cout<<ans;
	}else cout<<"-1";
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=305;
int n;
char s[N][N];
int check(int A){
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (s[i][j]!=s[j][i])
				return 0;
	return 1;
}
void move(){
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			s[i-1][j]=s[i][j];
	for (int i=1;i<=n;i++)
		s[n][i]=s[0][i];
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	int ans=0;
	for (int i=0;i<n;i++){
		ans+=check(i)*n;
		move();
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
    char c;

    while (1) {
        scanf("%c", &c);
        if (isalpha(c)) {
            if (islower(c)) cout << (char)toupper(c);
            else cout << (char)tolower(c);
        } else cout << c;

        if (c == '\n') break;
    }
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    int n;
    cin>>n;
    ll a[n];
    ll sum=0;
  	ll m=1000000000+7;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        sum-=a[i];
        ans+=((a[i]%m)*(sum%m))%m;
    }
    cout<<ans%m;
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  string s;
  cin >> s;

  vector<int> brack(N+1, 0);
  REP(i, N) brack[i+1] += brack[i]+(s[i] == '#'? 1: 0);

  vector<int> white(N+1, 0);
  RREP(i, N) white[i] = white[i+1]+(s[i] == '.'? 1: 0);

  int ans = INF;
  REP(i, N) chmin(ans, brack[i]+white[i+1]);

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3732
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod =924844033;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int c[100006], d[100006];
signed main() {
	int a, b, m; cin >> a >> b >> m;
	rep(i, a)cin >> c[i];
	rep(i, b)cin >> d[i];
	int ans = inf;
	rep(i, m) {
		int x, y, e; cin >> x >> y >> e;
		ans = min(ans, c[x - 1] + d[y - 1] - e);
	}
	sort(c, c + a);
	sort(d, d + b);
	ans = min(ans, c[0] + d[0]);
	cout << ans << endl;
}

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

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

//vector<vector<ll> > comb(ll n, ll b){
void comb(vector<vector <ll> > &v, ll n){
  cout << v.size();
  rep(i, n){
    v[i][0] = 1;
    v[i][i] = 1;
  }

  rep(j, n) {
    rep(k,j) {
      v[j][k] = (v[j-1][k-1] + v[j-1][k]);
    }
  }
}


int main(){
  ll n;
  cin >> n;
  long double m = sqrt(n);
  ll nn = ll(m);

  ll tmp1 = 1; 
  ll tmp2 = n;
 
  for (ll i=nn+1; i>0; i--){
    if (n%i==0) {
      tmp1 = i;
      tmp2 = n/i;
      break;
    }
  }

  
  ll cnt = 1;
  while(tmp2/10>0){
      cnt++;
      tmp2 /= 10;	
    // else{
    //   break;
    // }
  }

  cout << cnt << endl;
  
  
}


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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for (int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

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

  if (n % 2 == 0) {
    p(0.5000000000);
  } else {
    float c = (n - 1) / 2;
    p((c + 1) / n);
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
A_LIST = np.array(list(map(int, input().split())))

x_list = np.zeros(N)
start_index = 0
x_list[start_index] = (A_LIST.sum() - 2 * A_LIST[1::2].sum()) / 2
tmp_index = start_index
for _ in range(N-1):
    next_index = (tmp_index+1) % N
    x_list[next_index] = A_LIST[tmp_index] - x_list[tmp_index]
    tmp_index = next_index
ans = ' '.join((x_list * 2).astype(int).astype(str))
print(ans)

Measured memory_bytes: 35744
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 1000000007

#define MAXR 100000
#define PI 3.14159265358979323846

int divisor(int64_t n) {
    vector<int64_t> ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret.size();
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

using namespace std;

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = n-1; i > 0; i--) {
        long long N;
        N = i;
        const auto &pf = prime_factorize(N);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ans += res;
    }

    
    cout << ans <<endl ;

    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i%2==1){
					if(j%2==1){
						printf("#");
					}
					else{
						printf(".");
					}
				}
				else{
					if(j%2==1){
						printf(".");
					}
					else{
						printf("#");
					}
				}
			}
			printf("\n");
			if(i==H){
				printf("\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 572
N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9 + 7

from collections import defaultdict
from itertools import combinations

d = defaultdict(int)

k = 0
K %= mod

for i,j in combinations(range(N),2):
    if A[i] > A[j]:
        k+=1
        d[A[j]]+=1
    elif A[j] > A[i]:
        d[A[i]]+=1

ans = (k * K) % mod

for k in d.keys():
    ans += d[k]*(K*(K-1)//2) % mod
    ans %= mod

print(ans)


Measured memory_bytes: 42204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    bool a = false;
    if(s[0] == 'A'){
        a = true;
    }
    int cnt = 0;
    for(int i = 2; i < s.size()-1;i++){
        if(s[i] == 'C'){
            cnt++;
        }
    }

    int k = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] >= 'a' && s[i] <= 'z'){
            k++;
        }
    }
    if(a && (cnt == 1) && (k == s.size()-2)){
        cout << "AC";
    }else{
        cout << "WA";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int main(){
ll a,b,x;
read(a),read(b),read(x);
ll ans=b/x-a/x+(a%x?0:1);
write(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int x[10];
int y[10];

bool isUsed[10];
int locPos[10];
double sum;
int totalCount;


double calcDist(double x1, double y1, double x2, double y2)
{
	double total = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
	return sqrt(total);
}

void doSearch(int d)
{
	if (d == n)
	{
		double curDist = 0;
//		printf("%d", locPos[0]);
		for (int i = 1 ; i < n ; i++)
		{
			int p1 = locPos[i - 1];
			int p2 = locPos[i];
			curDist = curDist + calcDist(x[p1], y[p1], x[p2], y[p2]);
//			printf(" %d", locPos[i]);
		}
		sum = sum + curDist;
//		printf("%lf\n", curDist);
		totalCount++;
	}
	else
	{
		for (int i = 0 ; i < n ; i++)
		{
			if (isUsed[i] == true)
				continue;
			isUsed[i] = true;
			locPos[d] = i;
			doSearch(d + 1);
			isUsed[i] = false;
		}
	}
}

int main()
{
	scanf("%d\n", &n);
	
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d%d", &(x[i]), &(y[i]));		
		isUsed[i] = false;
	}
	
	totalCount = 0;
	
	doSearch(0);	
	
		
	double average = sum / totalCount;
	
	printf("%.10lf\n", average);
	
			
	return 0;
}


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

using namespace std;

const int N = 2100, MOD = 1e9 + 7;
int n;
long long f[N];

int main () {
	cin >> n;
	for (int i = 3; i <= n; i ++ ) f[i] = 1;
	for (int i = 6; i <= n; i ++ ) {
		for (int j = i - 3; j >= 3; j -- ) {
			f[i] += f[j];
			f[i] %= MOD;
		}
	}
	cout << f[n] << endl;
	return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
ll X, Y;

int main() {
  cin >> X >> Y;
  ll ans = 0;
  ll a = X;
  while (a <= Y) {
    ++ans;
    a *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
ID: vamaddu1
LANG: C++11
TASK: cowfood
*/

#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <deque>
#include <string.h>
#include <sstream>
#include <bitset>
#include <math.h>
#include <assert.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define epsilon 1e-9
#define INF 5000000000000000000
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N;
string s;
long long dp [3010][3010], pref [3010], ret = 0;

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> s; s = '.'+s; dp[0][0] = 1;
    for(int i = 1; i < N; i++){
        for(int j = 0; j < i; j++) pref[j+1] = (pref[j]+dp[i-1][j])%MOD;
        for(int j = 0; j <= i; j++){
            if(s[i] == '<') dp[i][j] = pref[j];
            else dp[i][j] = (pref[i]-pref[j]+MOD)%MOD;
        }
    }
    for(int i = 0; i < N; i++) ret = (ret+dp[N-1][i])%MOD;
    cout << ret << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


Measured memory_bytes: 69248
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//int n = Integer.parseInt(br.readLine());
		//String[] arg = br.readLine().split(" ");
		//int[] inp = new int[arg.length];
		Solver s = new Solver();
		

		System.out.println(s.solve(br.readLine()));
	}

}

class Solver {

	String solve(String inp) {

		StringBuilder sb = new StringBuilder();
		for(int i = 0;i<inp.length();i++) {
			if(inp.charAt(i)=='B' && sb.length()==0) {
				continue;
			}
			if(inp.charAt(i)=='0'||inp.charAt(i)=='1') {
				sb.append(inp.charAt(i));
			}if(inp.charAt(i)=='B') {
				sb.deleteCharAt(sb.length()-1);
			}
		}
		return sb.toString();
	}

}

Measured memory_bytes: 21332
# coding: utf-8

class Caesar
  def initialize
    @hints = ["the", "this", "that"]
    @codes = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
  end

  def solve
    while line = gets do
      line.chomp!
      0.upto(25).each do |i|
        tmp = ""
        for j in 0..line.size - 1 do
          if line[j] =~ /[a-z]/ then
            tmp << @codes[(line[j].ord - "a".ord + i) % 26]
          else
            tmp << line[j]
          end
        end
        @hints.each do |hint|
          if tmp.include?(hint) then
            puts tmp
            break
          end
        end
      end
    end
  end
end

Caesar.new.solve

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int cnt = 1;
    char c = S[0];
    for (int i = 1; i < N; i++) {
        if (c != S[i]) {
            c = S[i];
            cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    vector<pair<int,int>> R;
    vector<pair<int,int>> B;
    rep(i,N){
        int a,b; cin >> a >> b;
        R.push_back(make_pair(a,b));
    }
    rep(i,N){
        int c,d; cin >> c >> d;
        B.push_back(make_pair(d,c));
    }
    sort(R.begin(),R.end());
    sort(B.begin(),B.end());
    int cnt=0;
    rep(i,N){
        for(int j=N-1;j>=0;j--){
            if(R[j].first<B[i].second && R[j].second<B[i].first){
                cnt++; R[j].first=999999999; R[j].second=999999999;
                break;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 12;

struct node {
	int c = 0;
	vector<int> N;
} G[maxN];

bool DFS(int v, int w) {
	bool win = false;
	for(int u : G[v].N) if(u != w) {
		bool s = DFS(u, v);
		if(G[u].c < G[v].c && !s)
			win = true;
	}
//	cout << v << " " << win << "\n";
	return win;
}

int main() {
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> G[i].c;
	for(int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].N.push_back(v);
		G[v].N.push_back(u);
	}
	for(int i = 0; i < n; i++) {
//		cout << i << "\n";
		if(DFS(i, -1)) cout << i + 1 << " ";
	}
}


Measured memory_bytes: 768
#include<iostream>
#include<cmath>
using namespace std;

const double EPS = 1e-9;

int main() {
  int n;
  double xa,ya,ra,xb,yb,rb;
  cin>>n;
  while(n--) {
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    double dist = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
    if(dist > ra+rb) {
      cout<<0<<endl;
    }else if(dist+ra < rb) {
      cout<<-2<<endl;
    }else if(dist+rb < ra) {
      cout<<2<<endl;
    }else{
      cout<<1<<endl;
    }
  }
}

Measured memory_bytes: 0
import copy

n = int(input())
s = input()

flag = False
begin_list = [["S", "S"], ["W", "S"], ["S", "W"], ["W", "W"]]

for i in range(4):
  sub = copy.deepcopy(begin_list[i])
  judge = True
  for j in range(2, n):
    if s[j-1] == "o":
      if sub[j-1] == "S":
        if sub[j-2] == "S":
          sub.append("S")
        else:
          sub.append("W")
      else:
        if sub[j-2] == "S":
          sub.append("W")
        else:
          sub.append("S")
    else:
      if sub[j-1] == "S":
        if sub[j-2] == "S":
          sub.append("W")
        else:
          sub.append("S")
      else:
        if sub[j-2] == "S":
          sub.append("S")
        else:
          sub.append("W")
  if s[-1] == "o":
    if (sub[-1] == "S" and sub[-2] != sub[0]) or (sub[-1] == "W" and sub[-2] == sub[0]):
      continue
  else:
    if (sub[-1] == "S" and sub[-2] == sub[0]) or (sub[-1] == "W" and sub[-2] != sub[0]):
      continue
  if s[0] == "o":
    if (sub[0] == "S" and sub[-1] != sub[1]) or (sub[0] == "W" and sub[-1] == sub[1]):
      continue
  else:
    if (sub[0] == "S" and sub[-1] == sub[1]) or (sub[0] == "W" and sub[-1] != sub[1]):
      continue
  flag = True
  break

if flag:
  print("".join(sub))
else:
  print(-1)

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

#define MAX 100000

int N;
long long A[MAX];
long long B[MAX];

long long X;
long long C[MAX];

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

	for( int i = 0; i < N; i++ ) {
		X -= B[i];
		C[i] = A[i] + B[i];
	}
	sort( C, C + N, greater<long long>() );
	long long ans = X;
	for( int i = 0; i < N; i++ ) {
		if( i % 2 == 0 ) {
			ans += C[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#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 nx,ny,gx,gy;
 cin>>nx>>ny>>gx>>gy;
 ll cnt=0;
 //startを0に合わせる
 gx-=nx;nx=0;
 gy-=ny;ny=0;
  
 string s;
 //1回目goalまで
 //x方向
 if(nx<gx){
  while(nx<gx){
   s+='R';nx++;
  }
 }
 else if(nx>gx){
  while(nx>gx){
   s+='L';nx--;
  }
 }
 //y方向
 if(ny<gy){
  while(ny<gy){
   s+='U';ny++;
  }
 }
 else if(ny>gy){
  while(ny>gy){
   s+='D';ny--;
  }
 }
 
 //1回目(0,0)まで
 ll len=s.length();
 rep(i,cnt,len){
  if(s[i]=='U')s+='D';
  if(s[i]=='D')s+='U';
  if(s[i]=='L')s+='R';
  if(s[i]=='R')s+='L';
 }
  cnt=len-1;
 nx=0;ny=0;
 //重複を避けるための移動
 if(gy>0){
  s+='D';ny--;
 }
 else{
  s+='U';ny++;
 }
   
 //2回目goalまで
 //x方向
 if(nx<gx){
  while(nx<gx+1){
   s+='R';nx++;
  }
 }
 else if(nx>gx){
  while(nx>gx-1){
   s+='L';nx--;
  }
 }
 //y方向
 if(ny<gy){
  while(ny<gy){
   s+='U';ny++;
  }
 }
 else if(ny>0){
  while(ny>0){
   s+='D';ny--;
  }
 }
 if(nx>gx){
  s+='L';nx--;
 }
 else if(nx<gx){
  s+='R';nx++;
 }
 cnt=(cnt+1)*2;
 //1回目(0,0)まで
 len=s.length();
 rep(i,cnt,len){
  if(s[i]=='U')s+='D';
  if(s[i]=='D')s+='U';
  if(s[i]=='L')s+='R';
  if(s[i]=='R')s+='L';
 }
 pr(s);
 return 0;}

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

namespace ABC127B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] RDX = CIN.IntArray();

            int r = RDX[0];
            int D = RDX[1];
            int X = RDX[2];

            int A = X;
            for (int i = 0; i < 10; i++)
            {
                A = r * A - D;
                Console.WriteLine(A);
            }
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11348
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
#include <queue>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N;
    scanf("%lld\n", &N);

    vector<ll> A(N);
    for (ll i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }

    sort(A.begin(), A.end());

    ll ans = 0;
    priority_queue<ll> circle;
    for (ll i = N - 1; i >= 0; i--)
    {
        if (i != N - 1)
        {
            ans += circle.top();
            circle.pop();
        }

        circle.push(A[i]);
        if (i != N - 1)
        {
            circle.push(A[i]);
        }
    }

    printf("%lld\n", ans);
}


Measured memory_bytes: 6920
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9+7
#main code here!
    n=I()
    lis=[I() for i in range(n)]
    
    class SegmentTree:#非再帰(こちらの方が速い) #1-indexed
        # 初期化処理
        # f : SegmentTreeにのせるモノイド
        # default : fに対する単位元
        def __init__(self, size, f=lambda x,y : max(x,y), default=-inf):
            self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
            self.default = default
            self.dat = [default]*(self.size*2) # 要素を単位元で初期化
            self.f = f
    
        def update(self, i, x):
            i += self.size
            self.dat[i] = x
            while i > 0:
                i >>= 1
                self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])
    
        def query(self, l, r):
            l += self.size
            r += self.size
            lres, rres = self.default, self.default
            while l < r:
                if l & 1:
                    lres = self.f(lres, self.dat[l])
                    l += 1
    
                if r & 1:
                    r -= 1
                    rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
                l >>= 1
                r >>= 1
            res = self.f(lres, rres)
            return res
    #Seg=SegmentTree(n,lambda x,y : max(x,y),-inf)
    Seg=SegmentTree(n)
    for i in range(n):
        Seg.update(i,lis[i])
    for i in range(n):
        Seg.update(i,-inf)
        print(Seg.query(0,n))
        Seg.update(i,lis[i])
    
    
                
                
if __name__=="__main__":
    main()



Measured memory_bytes: 93196
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		String s=sc.next();
		String t=sc.next();
		
		//p(t.substring(0,1)+" "+s.substring(2,3));
		boolean x=false;
		
		String ans=s+t;
		
		for(int i=0;i<N;i++) {
			
			String a=s.substring(i,N);
			String b=t.substring(0,N-i);
			//p(a+" "+b);
			if(a.equals(b)) {
				//p("aaaa");
				ans=s+t.substring(N-i,N);
				break;
			}
			
			
			
			
			
		}
		//p(ans);
		p(ans.length());
		
		
		
		
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
inf = float("inf")

S = input()



N = len(S)
bestP = [None for i in range(N)]
bestD = [None for i in range(N)]
if S[0] in ["?", "D"]:
    bestP[0] = 0
    bestD[0] = 1
else:
    bestP[0] = 0
    bestD[0] = 0
for i in range(1, N):
    bestP[i] = max(bestD[i - 1], bestP[i - 1])
    bestD[i] = max(bestD[i - 1] + 1, bestP[i - 1] + 2)
    if S[i] != "?":
        if S[i] == "P":
            bestD[i] = -inf
        else:
            assert S[i] == "D"
            bestP[i] = -inf

ans = [None for i in range(N)]
if bestP[-1] > bestD[-1]:
    ans[-1] = 'P'
else:
    ans[-1] = 'D'
for i in range(N - 2, -1, -1):
    if S[i] != '?':
        ans[i] = S[i]
    else:
        prev = ans[i + 1]
        if prev == 'D':
            if bestP[i] + 2 > bestD[i] + 1:
                ans[i] = 'P'
            else:
                ans[i] = 'D'
        else:
            if bestP[i] > bestD[i]:
                ans[i] = 'P'
            else:
                ans[i] = 'D'

print(''.join(ans))

Measured memory_bytes: 102176
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_048
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            bool firstWin = false;
            if (s[0] == s[s.Length - 1])
            {//奇数になるほうが負け
                firstWin = s.Length % 2 == 0;
            }
            else
            {
                firstWin = s.Length % 2 == 1;
            }
            if (firstWin)
            {
                Console.WriteLine("First");
            }
            else
            {
                Console.WriteLine("Second");
            }
        }

        static bool DFS(string s)//絶対に勝てるかどうか返す
        {
            bool canHandle = false;
            for(int i = 1; i < s.Length - 1;i++)
            {
                if (s[i - 1] == s[i + 1]) continue;

                canHandle = true;
                if (DFS(s.Remove(i,1)))
                {
                    return false;
                }
            }
            return canHandle;
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13280
#include <stdio.h>
#include <math.h>

int main(void){
  double a,b,x;
  double s,h,w;
  double rad,degree;

  scanf("%lf %lf %lf",&a,&b,&x );

  s=x/a;
  if(s>a*b/2){
    h=(a*b-s)*2/a;

    rad=atan(h/a);
  }else{
    w=s*2/b;
    rad=atan(b/w);
  }

  degree = rad*180/M_PI;

  printf("%f\n",degree );

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int tate[200005][2]={0},yoko[200005][2]={0};
int main(){
  int h,w,n;
  cin>>h>>w>>n;
  int sx,sy;
  cin>>sx>>sy;
  string s,t;
  cin>>s>>t;
  int lb=1,rb=w+1,ub=1,db=h+1;
  for(int i=n-1;i>=0;i--){
    if(t[i]=='L'){
      rb=min(rb+1,w+1);
    }
    if(t[i]=='R'){
      lb=max(lb-1,1);
    }
    if(lb>=rb){
      cout<<"NO"<<endl;
      return 0;
    }

    if(s[i]=='L'){
      lb++;
      if(lb>w){
        cout<<"NO"<<endl;
        return 0;
      }
    }
    if(s[i]=='R'){
      rb--;
      if(rb<1){
        cout<<"NO"<<endl;
        return 0;
      }
    }
   if(lb>=rb){
      cout<<"NO"<<endl;
      return 0;
    }

    if(t[i]=='U'){
      db=min(db+1,h+1);
    }
    if(t[i]=='D'){
      ub=max(ub-1,1);
    }
    if(ub>=db){
      cout<<"NO"<<endl;
      return 0;
    }

    if(s[i]=='U'){
      ub++;
      if(ub>h){
        cout<<"NO"<<endl;
        return 0;
      }
    }
    if(s[i]=='D'){
      db--;
      if(db<1){
        cout<<"NO"<<endl;
        return 0;
      }
    }
    if(ub>=db){
      cout<<"NO"<<endl;
      return 0;
    }
    //cout<<lb<<" "<<rb<<endl;
  }
  //cout<<lb<<" "<<rb<<" "<<ub<<" "<<db<<endl;
  if(lb<=sy&&sy<rb&&ub<=sx&&sx<db) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 776
#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() {
    cout<<fixed<<setprecision(12);
    int l;
    cin >> l;
    
    long double x = l / 3.0;
    
    long double ans = x * x * x;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a,b; cin >>a>>b;
  if(a == 'H') {
    if (b=='H') cout << 'H' << endl;
    else cout << 'D' << endl;
  } else {
    if (b=='H') cout << 'D' << endl;
    else cout << 'H' << endl;
  }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

void step(string& s) {
  string t(s.size()-1, '0');
  REP(i, s.size()-1) {
    t[i] += abs(s[i]-s[i+1]);
  }
  swap(s, t);
}

// 1-stepすすめると0, 1, 2だけになる
//

int comb_parity(int64 a, int64 b) {
  int64 ret = 1;
  while (a) {
    if (a%2 == 0 && b%2) ret = 0;
    a /= 2;
    b /= 2;
  }
  return ret;
}

bool is_palindrome(const string& s) {
  REP(i, s.size()/2) {
    if (s[i] != s[s.size()-i-1]) return 0;
  }
  return 1;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (is_palindrome(s) && is_palindrome(s.substr(0, s.size()/2)) && is_palindrome(s.substr(s.size()/2+1, s.size()/2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

long long x, y;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> x >> y;
    long long cur = x, ans = 1;

    while(x*2<=y) {
        x*=2;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
def main():
    X, N =  map(int, input().split())
    p = list(map(int, input().split()))
    if N > 0:
        P = deque(sorted(p))
        L = P.popleft()
    else:
        print(X)
        return
    diff = 101
    ans = 101

    for i in range(-102,102):
        if i == L:
            if len(P) > 0:
                L = P.popleft()
            else:
                L = 200
        else:
            diff = abs(X-i)
        if diff < ans:
            ans = min(diff, ans)
    if X-ans in p:
        print(X+ans)
    else:
        print(X-ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9464
import java.util.*;

class Main{

    int N,P;
    int[] p;

    void solve(){
	Scanner sc = new Scanner(System.in);

	int MAX = 200600;
	p = new int[MAX];
	for(int i=2; i<p.length; i++)p[i] = 1;
	for(int i=2; i<Math.sqrt(MAX)+1; i++){
	    for(int j=i*2; j<MAX; j+=i){
		p[j] = 0;
	    }
	}

	while(true){
	    N = sc.nextInt();
	    P = sc.nextInt();
	    if(N==-1 && P==-1) break;

	    int[] list = new int[10000];
	    Arrays.fill(list,Integer.MAX_VALUE);
	    int idx = 0;
	    for(int i=N+1; i<N+300; i++){
		if(p[i]==0) continue;
		for(int j=i; j<N+300; j++){
		    if(p[j]==0) continue;
		    list[idx] = i+j;
		    idx++;
		}
	    }

	    Arrays.sort(list);

	    System.out.println(list[P-1]);
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int a,b;
  cin>>a>>b;

  if((a+b)%3==0)cout<<"Possible"<<endl;
  else if(a%3==0)cout<<"Possible"<<endl;
  else if(b%3==0)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;





return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i(0);i<n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.txt","r",stdin) ; freopen("output.txt","w",stdout);
#define watch(x) cout<<(#x)<<" is "<<x<<"\n";
#define mod 1000000007

int32_t main(){
	
	fast;
	//open;

	int n,l,m=INT_MAX,ans;
	cin>>n>>l;
	for(int i(1);i<=n;i++){
		if(abs(l + i - 1)<abs(m))m = l+i-1;
	}
	ans = n*(n+1);
	ans/=2;
	ans+=n*(l-1);
	ans -= m;
	cout<<ans;



	return 0;
}

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

using namespace std;

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

struct Node {
    int p, chil, bro, dep;
};

Node u[100001];

void get_depth(int node, int depth){
    u[node].dep = depth;
    if(u[node].chil != -1)get_depth(u[node].chil, depth + 1);
    if(u[node].bro != -1)get_depth(u[node].bro, depth);
}

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

    rep(i,n)u[i].p = u[i].chil = u[i].bro = -1;

    rep(i,n){
        int id, chil_n, left, node;
        cin >> id >>  chil_n;
        rep(j,chil_n){
            cin >> node;
            if(j == 0)u[id].chil = node;
            else u[left].bro = node;
            left = node;
            u[node].p = id;
        }
    }
    //printf("cin end\n");
    int root;
    rep(i,n)if(u[i].p == -1)root = i;
    get_depth(root, 0);
    //printf("calclating end\n");

    rep(i,n){
        printf("node %d: parent = %d, depth = %d, ", i, u[i].p, u[i].dep);
        if(u[i].dep == 0)printf("root");
        else if(u[i].chil == -1)printf("leaf");
        else printf("internal node");
        printf(", [");
        int j, child;
        for(j = 0, child = u[i].chil; child != -1; j++, child= u[child].bro){
            if(j)printf(", ");
            cout << child;
        }
        printf("]\n");
    }

    return 0;
}


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

int main() {
	int range[3];
	cin >> range[0] >> range[1] >> range[2];

	int j, v;
	for (int i = 1; i < 3; i++) {
		v = range[i];
		j = i - 1;

		while (j >= 0 && range[j] > v) {
			range[j + 1] = range[j];
			j--;
		}

		range[j + 1] = v;
		


	}

	cout << range[0] << " " << range[1] << " " << range[2] << endl;

	
}


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

using namespace std;

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  for (int i = 0; i < a; i++) {
    if (s[i] < '0' || s[i] > '9') {
      puts("No");
      return 0;
    }
  }
  if (s[a] != '-') {
    puts("No");
    return 0;
  }
  for (int i = a + 1, j = 0; j < b; i++, j++) {
    if (s[i] < '0' || s[i] > '9') {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int res=1000000;
int main()
{
	int x,y;
	int a[10000],b[10000];
	cin>>x>>y;
	for(int i=0;i<x;i++)
	{
		cin>>a[i]>>b[i];
		if(b[i]<=y)res=min(res,a[i]);
	}
	if(res==1000000)
	{
		cout<<"TLE"<<endl;
		return 0;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int pid=0,pnum=0,rpid[NUM],cost[NUM],cpid[NUM],que[NUM];
int judge(int a,int b){if(pnum<b||b==1)return 0;return cpid[que[a]]>cpid[que[b]]?1:0;}
void push(int a,int n){int i=++pid,j=++pnum;rpid[i]=n,cpid[i]=a,que[j]=i;while(judge(j/2,j))que[j]=que[j/2],que[j/=2]=i;}
int pop(){int ans=rpid[que[1]],i=1,j,n=que[pnum--];que[1]=n;while(judge(i,j=i*2+judge(i*2,i*2+1)))que[i]=que[j],que[i=j]=n;return ans;}

int ans[NUM];
void calc(int v,int e,int* a,int* b){
  int i,num=0,ver=1,pre[v],last[v],ng[NUM]={0},flag[NUM]={0},col=1;
  FOR(i,1,v+1)last[i]=-1;
  FOR(i,0,e)pre[i]=last[a[i]],last[a[i]]=i;
  while(num<v){
    num++;
    for(i=last[ver];i+1;i=pre[i]){
      if(col==ng[ver])col++;
      ans[i]=col;
      ng[b[i]]=col++;
      push(b[i],b[i]);
    }
    col=1;
    ver=pop();
  }
}

int main(){
  int N,i,max=0;
  scanf("%d",&N);
  int a[N-1],b[N-1];
  FOR(i,0,N-1)scanf("%d%d",&a[i],&b[i]);
  calc(N,N-1,a,b);
  FOR(i,0,N-1)max=MAX(max,ans[i]);

  printf("%d\n",max);
  FOR(i,0,N-1)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

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

  if (A >= K) {
    A -= K;
  } else {
    K -= A;
    A = 0;
    if (B >= K) B -= K;
    else B = 0;
  }

  cout << A << " " << B << endl;
  return 0;
}


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


long long gcd(long long a, long long b){
  if(a < b){
    long long work = a;
    a = b;
    b = work;
  }
  if(b == 0)
    return a;
  
  return gcd(b, a%b);
}

int main(){
  int n, f=0;
  long long a;

  cin >> n;


  for(int i=0; i<n; ++i){
    cin >> a;
    f += a-1;
  }


  cout << f << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int n;
map<int, bool> ans;
int main(void) {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		auto itr = ans.find(a);
		if (itr == ans.end()) {
			ans[a] = true;
		}
		else {
			ans.erase(itr);
		}
	}
	cout << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 4864