akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<stack>
using namespace std;

int main(){

    int n, q;
    cin >> n >> q;

    vector<stack<int>> st(n);
    for(int i = 0; i < q; ++i){
        int com, t;
        cin >> com >> t;
        if(com == 0){
            int x;
            cin >> x;
            st[t].push(x);
        }
        else if(com == 1){
            if(!st[t].empty()){
                cout << st[t].top() << endl;
            }
        }
        else if(com == 2){
            if(!st[t].empty()){
                st[t].pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4324
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	int k, x;
	cin >> k >> x;
	k--;
	for (int i = max(-1000000, x - k); i <= min(1000000, x + k); i++) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

char buffer[4 * 1024 * 1024];
int pos = 0;
int end = 0;

int mygetchar(){
  if(pos == end){
    end = read(0, buffer, sizeof(buffer));
    pos = 0;
  }
  return buffer[pos++];
}

#define ISDIGIT(x) ((x) >= '0') 

__attribute__((always_inline)) int getInt(){
  int ret = 0, c;
  c = mygetchar();
  while(!ISDIGIT(c)) c = mygetchar();
  while(ISDIGIT(c)){
    ret *= 10;
    ret += c - '0';
    c = mygetchar();
  }
  return ret;
}

#define mask (0x7F)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

    for(i = 0; i < n; i++){
      int a = getInt();

      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }
    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 4452
#include <algorithm>
#include <bitset>
#include <complex>
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

#define ll int
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

vector<ll> find_ans(ll c,vector<ll> bits){
	vector<ll> ans,tmp;
	if(bits.size()==1){
		ans.pb(0);
		ans.pb(c);
		return ans;
	}
	if(__builtin_popcount(c)==1){
		ll sef;
		for(auto e:bits){
			if(((c>>e)&1)==0){
				sef=e;
				break;
			}
		}
		for(auto e:bits){
			if((c>>e)&1){
				vector<ll> bits2;
				for(auto ee:bits){
					if(ee!=e){
						bits2.pb(ee);
					}
				}
				ans=find_ans(1<<sef,bits2);
				tmp=ans;
				ll base=(1<<e)^(1<<sef);
				for(auto r:tmp){
					ans.pb(r^base);	
				}
				return ans;
			}
		}	
	}else{
		for(ll i=0;i<bits.size();i++){
			ll a=bits[i];
			if((c>>a)&1){
				for(ll j=i+1;j<bits.size();j++){
					ll b=bits[j];
					if((c>>b)&1){
						vector<ll> bits2;
						for(auto e:bits){
							if(e!=a){
								bits2.pb(e);
							}
						}
						ll cc=(c^(1<<a)^(1<<b));

						ans=find_ans(cc,bits2);
						ll base=ans.back()^(1<<a);
						tmp=find_ans((1<<b),bits2);
						for(auto e:tmp){
							ans.pb(e^base);
						}
						return ans;
					}
				}
			}
		}
	
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n,a,b;
	cin>>n>>a>>b;
	ll c=(a^b);
	ll m=(1<<n);
	ll move=m-1;
	if(__builtin_popcount(c)%2!=move%2){
		cout<<"NO";
		return 0;
	}
	cout<<"YES\n";
	vector<ll> bi;
	for(ll i=0;i<n;i++){
		bi.pb(i);
	}			
	vector<ll> ans=find_ans(c,bi);
	for(auto r:ans){
		cout<<(r^a)<<' ';
	}
}




















Measured memory_bytes: 1840
from sys import stdin
n = int(stdin.readline())
p = list(map(float,stdin.readline().split()))
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n+1):
    for j in range(n+1):
        if i>j:
            continue
        dp[i][j] += (0 if i==0 or j==0 else dp[i-1][j-1]*p[j-1])
        dp[i][j] += (0 if j==0 else dp[i][j-1]*(1-p[j-1]))
x = (n+1)//2
ans = 0
while x != n+1:
    ans += dp[x][-1]
    x += 1
print(ans)

Measured memory_bytes: 201912
# -*- coding: utf-8 -*-

n,y = map(int,input().split())

r = y - 1000 * n

for i in range(0,n+1):
    temp = r - 9000 * i
    if temp % 4000 == 0:
        j = temp / 4000
        k = n - i - j
        if j >= 0 and k >= 0:
            print(int(i),int(j),int(k))
            break
else:
    print(-1,-1,-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;
int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double rad;
    double s = x / a;
    if(s >= a*b/2) {
        double h = (a*b - s) * 2/a;
        rad = atan2(h, a);
    }
    else {
        double w = 2*s / b;
        rad = atan2(b, w);
    }
    double PI = acos(-1);
    double deg = rad/(2*PI)*360;
    printf("%.10f\n", deg);
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	A, _ := strconv.Atoi(read())
	B, _ := strconv.Atoi(read())
	if (A+B)%2 != 0 {
		fmt.Printf("%s\n", "IMPOSSIBLE")
		return
	}
	fmt.Printf("%d\n", (A+B)/2)
}


Measured memory_bytes: 640
fn main() {
    let (a, b) = {
        let tmp = read_vec::<i32>();
        (tmp[0], tmp[1])
    };

    if a < b {
        for _ in 0..b {
            print!("{:?}", a);
        }
        println!("");
    } else {
        for _ in 0..a {
            print!("{:?}", b);
        }
        println!("");
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin>>s;
  if(s=="AAA"){
    cout<<"No"<<endl;
  }else if(s=="BBB"){
    cout<<"No"<<endl;
  }else cout<<"Yes"<<endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e5+5;
struct EE{
    int v,c,d;
};
struct QQ{
    int x,y,op,id;
};
vector<EE>g[maxm];
vector<QQ>Q[maxm];
const int maxd=20;
int f[maxm][25];
int d[maxm];
int ans[maxm];
int n,q;
void dfs1(int x,int fa){
    for(int j=1;j<=maxd;j++){
        f[x][j]=f[f[x][j-1]][j-1];
    }
    for(auto i:g[x]){
        int v=i.v;
        if(v==fa)continue;
        d[v]=d[x]+1;
        f[v][0]=x;
        dfs1(v,x);
    }
}
int lca(int a,int b){
    if(d[a]<d[b])swap(a,b);
    for(int i=maxd;i>=0;i--){
        if(d[f[a][i]]>=d[b]){
            a=f[a][i];
        }
    }
    if(a==b)return a;
    for(int i=maxd;i>=0;i--){
        if(f[a][i]!=f[b][i]){
            a=f[a][i];
            b=f[b][i];
        }
    }
    return f[a][0];
}
//
int sum[maxm];
int cnt[maxm];
//
void dfs(int x,int fa,int dist){
    for(auto i:Q[x]){
        int x=i.x,y=i.y;
        ans[i.id]+=i.op*(dist-sum[x]+cnt[x]*y);
    }
    for(auto i:g[x]){
        int v=i.v;
        if(v==fa)continue;
        cnt[i.c]++;
        sum[i.c]+=i.d;
        dfs(v,x,dist+i.d);
        cnt[i.c]--;
        sum[i.c]-=i.d;
    }
}
signed main(){
    ios::sync_with_stdio(0);
    cin>>n>>q;
    for(int i=1;i<n;i++){
        int a,b,c,d;cin>>a>>b>>c>>d;
        g[a].push_back({b,c,d});
        g[b].push_back({a,c,d});
    }
    dfs1(1,1);
    for(int i=1;i<=q;i++){
        int x,y,u,v;cin>>x>>y>>u>>v;
        int lc=lca(u,v);
        Q[u].push_back({x,y,1,i});
        Q[v].push_back({x,y,1,i});
        Q[lc].push_back({x,y,-2,i});
    }
    dfs(1,1,0);
    for(int i=1;i<=q;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}
/*
在线做法:
树上距离可以用lca做,
边权替换操作只需要计算u和v之间有多少个颜色为x的边以及其边权和,
是在树上建可持久化线段树,直接维护就行了,
(或者树剖转序列再建树)

离线做法:
将询问拆分为u,v,lca三个点的询问,
每个询问查询当前点到根的距离-颜色为x的边权和+cnt[x]*y
颜色为x的边权和、cnt[x]直接用数组就可以维护了,
最后答案就是ans[u]+ans[v]-2*ans[lca].
*/


Measured memory_bytes: 54984
//object B {
object Main {
  import InOut._
  def main(args: Array[String]): Unit = {

    val n = nextInt
    val ls = nextInts(n).sorted

    var res = 0L
    var i = 0
    while (i < n) {
      var j = i + 1
      while (j < n) {
        if (ls(j) != ls(i)) {
          var k = j + 1
          while (k < n) {
            if (ls(k) != ls(j) && ls(i) + ls(j) > ls(k)) {
              res += 1
            }
            k += 1
          }
        }
        j += 1
      }
      i += 1
    }

    out.println(res)

    out.flush()
  }
 
  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}


Measured memory_bytes: 54764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <set>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

string line;

inline bool is0p(char c){
  return c == '+' || c == '-' || c == '/' || c == '*';
}

set<int> rec(int l,int r){
  vector<int> v;
  for(int i = l , j = 0 ; i < r ; i ++){
    if(line[i] == '(') j ++;
    if(line[i] == ')') j --;
    if(j == 0 && is0p(line[i]))v.push_back(i);
  }
  if(v.size() == 0){
    if(line[l] == '(')return rec(l+1,r-1);
    set<int> res;
    res.insert(atoi(line.substr(l,r-l).c_str()));
    return res;
  }

  set<int> res;
  for(int i = 0 ; i < v.size() ; i ++){
    set<int> a,b;
    a = rec(l,v[i]);
    b = rec(v[i]+1,r);
    for(set<int>::iterator p=a.begin();p!=a.end();p++){
      for(set<int>::iterator q=b.begin();q!=b.end();q++){
	if(line[v[i]]=='+'){
	  res.insert(*p + *q);
	}else if(line[v[i]]=='-'){
	  res.insert(*p - *q);
	}else if(line[v[i]]=='*'){
	  res.insert(*p * *q);
	}else if(line[v[i]]=='/'){
	  if(*q != 0)res.insert(*p / *q);
	}
      }
    }
  }
  return res;
}

int main(void){
  while(getline(cin,line)&&line !="#"){
    cout<<rec(0,line.size()).size()<<endl;
  }
}

Measured memory_bytes: 1300
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    int a[26] = {};
    for (int i = 0; i < s.length(); i++) {
        a[s[i]-'a'+0] = 1;
    }
    
    string al = "abcdefghijklmnopqrstuvwxyz";
    string ans = "-1";
    if (s.length() < 26) {
        for (int i = 0; i < 26; i++) {
            if (a[i] == 0) {
                ans = s + al[i];
                break;
            }
        }
    }else{
        string origin = s;
        bool flag = false;
        for (int i = 0; i < origin.length() && !flag; i++) {
            a[s[s.length()-1]-'a'+0] = 0;
            s.pop_back();
            for (int j = 0; j < 26 && !flag; j++) {
                if (a[j] == 0 && origin < s + al[j]) {
                    ans = s + al[j];
                    flag = true;
                }
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class Task {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int k = in.nextInt();
            int s = in.nextInt();

            int ans = 0;
            for (int i = 0; i <= k; i++)
                for (int j = 0; j <= k && i + j <= s; j++)
                    if (s - i - j <= k)
                        ans++;

            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    string s;
    cin>>s;

    ll l=0;
    for(ll i=0; i<s.size(); i++){
        l+=(s[i]-'0');
    }
    if(l%9==0)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 3744
while True:
	try:
		n = int(raw_input())
	except EOFError:
		break
	
	if n < 39:
		if n < 10:
			print "3C0" + str(n)
		else:
			print "3C" + str(n)
	elif n % 39 == 0:
		print "3C39"
	else:
		x = n % 39
		if x < 10:
			print "3C0" + str(x)
		else:
			print "3C" + str(x)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

ll mygcd(ll a, ll b)
{
	if (a < b) mygcd(b, a);
	ll r;
	while ((r=a%b)){
		a = b;
		b = r;
	}
	return b;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	vll a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	vll d(n), d2(n);
	d[0] = a[0];
	rep(i, n-1){
		d[i+1] = mygcd(a[i+1], d[i]);
	}
	reverse(all(a));
	d2[0] = a[0];
	rep(i, n-1){
		d2[i+1] = mygcd(a[i+1], d2[i]);
	}


	ll ans = d[n-1];
	rep(i, n){
		if (i == 0){
			ans = max(ans, d2[n-2]);
		}else if(i == n-1){
			ans = max(ans, d[n-2]);
		}else{
			ans = max(ans, mygcd(d[i-1], d2[n-2-i]));
		}
	}

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


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long
#define W V<L>
L E=70;W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}for(L i;i<2;i++){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=Q+1;}if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p);A[0]--;return A;}int main(){L M=2e17,n,a,b;cin>>n;V<W>p(n);while(n--){cin>>a>>b;p[n]={a+M,b+M};}W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    a[0] = 0;
    repi(i,1,n+1)cin >> a[i];
    bool b[n+1];
    m0(b);
    intl cnt = 0;
    rrepi(i,n,0){
        intl num = 0;
        for(intl j = 1; j * i <= n; j++){
            num += b[i * j];
        }
        //cout << i << ":" << " " << num << endl;
        if((num%2) != a[i]){
            b[i] = true;
            cnt++;
        }
    }
    cout << cnt << endl;
    repi(i,1,n+1){
        if(b[i])cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 2688
Module _20190519

    Sub Main()

        Dim sRead As String = Console.ReadLine()

        Dim arrChar() As Char = sRead.ToCharArray()

        Dim sUe As Integer = CInt(arrChar(0) & arrChar(1))
        Dim sSita As Integer = CInt(arrChar(2) & arrChar(3))

        '1=年のみ 2=両方OK
        Dim iUeFlg As Integer = 0
        Dim iSitaFlg As Integer = 0

        If sUe > 12 OrElse sUe = 0 Then

            iUeFlg = 1

        Else

            iUeFlg = 2

        End If

        If sSita > 12 OrElse sSita = 0 Then

            iSitaFlg = 1

        Else

            iSitaFlg = 2

        End If

        If iUeFlg = 2 AndAlso iSitaFlg = 2 Then

            Console.WriteLine("AMBIGUOUS")

        ElseIf iUeFlg = 1 AndAlso iSitaFlg = 2 Then

            Console.WriteLine("YYMM")

        ElseIf iUeFlg = 2 AndAlso iSitaFlg = 1 Then

            Console.WriteLine("MMYY")

        Else

            Console.WriteLine("NA")

        End If

    End Sub

End Module


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

using namespace std;

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int a,b,c;
	a=n+m;
	b=n-m;
	c=n*m;
	int t=a;
	if(b>t)t=b;
	if(c>t)t=c;
	printf("%d\n",t);
	return 0;
 } 

Measured memory_bytes: 256
from collections import deque

a = input()
q = int(input())
rflag = 0
b = []
for i in range(q):
    b.append(input())
# print(b)
# print(len(b[0]))
ans = deque(list(a))

for i in range(len(b)):
    if len(b[i]) == 1:
        rflag = (rflag ^ 1)
    else:
        c = int(b[i][2])
        # print("c="+b[i][2])

        if not rflag:

            if c == 1:
                # print("extend={}".format(b[i][4]))
                extend = b[i][4]
                ans.appendleft(extend)
            else:
                # print('ll')
                ans.append(b[i][4])
        else:
            if c == 1:
                ans.append(b[i][4])
            else:
                # print("extend={}".format(b[i][4]))
                extend = b[i][4]
                ans.appendleft(extend)
        # print(ans,rflag)

if not rflag:
    print("".join(ans))
else:
    h="".join(ans)
    print(h[::-1])


Measured memory_bytes: 99800
#include <iostream>
#include <vector>
 
using namespace std;
 
void sieve(vector<int> &primes) {
  primes.resize(55556, 1);
  primes[0] = primes[1] = 0;
  for(int i = 2; i < 55556; i++) {
    if (primes[i]) {
      for(int j = i + i; j < 55556; j += i) {
        primes[j] = 0;
      }
    }
  }
}
 
int main() {
  vector<int> primes;
  sieve(primes);
  int N;
  cin >> N;
  int now = 0;
  vector<int> ans;
  for(int i = 0; i < 55556; i++) {
    if (!primes[i]) continue;
    if (i % 5 == 1) {
      now++;
      ans.push_back(i);
      if (now == N) break;
    }
  }
  for(int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..m)
        .map(|_| itr.next().unwrap().parse::<usize>().unwrap() - 1)
        .collect();
    a.sort_by(|a, b| b.cmp(a));
    let b = [2, 5, 5, 4, 5, 6, 3, 7, 6].to_vec();
    let mut dp = vec![-1; n + 1];
    let mut prv = vec![0; n + 1];

    dp[0] = 0;
    for i in 1..=n {
        for j in 0..m {
            if i >= b[a[j]] {
                let tmp = dp[i - b[a[j]]] + 1;
                if tmp > dp[i] {
                    dp[i] = tmp;
                    prv[i] = a[j];
                }
            }
        }
    }

    let mut ans = Vec::new();
    let mut i = n;
    while i > 0 {
        ans.push((49 + prv[i] as u8) as char);
        i -= b[prv[i]];
    }
    println!("{}", ans.into_iter().collect::<String>());
}


Measured memory_bytes: 2228
while True:
    n, q = map(int, input().split())
    if n == 0:
        break

    data = [list(map(int, input().split())) for i in range(n)]
    for li in data:
        if li[0] > 0:
            del(li[0])

    q -= 1
    day = 0
    for d in range(1,100):
        cnt = 0
        for li in data:
            if d in li:
                cnt += 1
        if cnt > q:
            q = cnt
            day = d

    print(day)


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

int main() {
  int K, S;
  cin >> K >> S;
  
  int N = 0;
  
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int l = S - i - j ;
      if (l >= 0 && l <= K) {
        N = N + 1;
      }
      else {
      }
    }
  }
  
  cout << N << endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long  long a[405];
long long f[405][405],s[405];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	    scanf("%lld",&a[i]),s[i]=s[i-1]+a[i];
	for(int i=2;i<=n;++i)
	{
		int c=n-i+1;
		for(int j=1;j<=c;++j)
		{
			int l=j+i-1; 
			f[j][l]=f[j][j] + f[j+1][l];
			for(int k=j+1;k<=l;++k)
			  	f[j][l]=min(f[j][l],f[j][k]+f[k+1][l]);
			f[j][l]+=s[l]-s[j-1];
			//cout<<f[j][l]<<endl;
		} 
	}
	printf("%lld",f[1][n]);
	return 0;
}

Measured memory_bytes: 5044
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans = 1;
  for(int i = 0; i < s.length()-1; i++){
    if(s[i]!=s[i+1]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(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 VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;template<typename TypeInt>TypeInt G_C_D(TypeInt a, TypeInt b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename TypeInt>
TypeInt G_C_D(const std::vector<TypeInt> &list){TypeInt a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename TypeInt>TypeInt L_C_M(TypeInt a, TypeInt b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename TypeInt>TypeInt L_C_M(const std::vector<TypeInt> &list){TypeInt a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	string S;
	cin>>S;
    if(S.at(0)!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    
	int sum=0;
	int N=S.size();
	for(int i=2; i<N-1;i++){
		if(S[i]=='C'){
			sum++;
		}
	}   
	if(sum!=1){
        cout<<"WA"<<endl;
        return 0;		
	}
	sum=0;
	for(int i=0; i<N;i++){
		if('a'<=S[i]&&S[i]<='z'){
			sum++;
		}
	}
	if(sum!=N-2){
        cout<<"WA"<<endl;
        return 0;		
	}
	else{
		cout<<"AC"<<endl;
	}
}

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

int main() {
    int n;
    long long k;
    cin>>n>>k;
    
    long long a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    if(k<=n) {
        long long p=1;

        for(int i=0;i<k;i++) {
            p = a[p-1];
        }
        
        cout << p << endl;
        return 0;
    }
    vector<long long > v;
    long long count[500006]={0};
    
    long long t=1;
    long long target;
    
    while(1) {
        if(count[t] == 1){
            target = t;
            break;
        }
        
        else {
            count[t]++;
            v.push_back(t);
            t = a[t-1];
        }
    }
    
    bool check = true;
    long long curr = 0;
    vector<long long> ans;
    
    for(int i=0;i<v.size();i++) {
        if(v[i]!=target && check)
        curr++;
        
        else {
            check = false;
            ans.push_back(v[i]);
            
        }
    }
    
    k = k - curr;
    k = k%ans.size();
    cout << ans[k] << endl;
	return 0;
}

Measured memory_bytes: 11620
N = int(input())
ans = 0
array = []
d = {}
for tmp in range(N):
    a = int(input())
    array.append(a)
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
array = list(set(array))
for tmp in range(len(array)):
    if d[array[tmp]]%2 == 1:
        ans += 1
    else:
        pass
print(ans)

Measured memory_bytes: 19848
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	a := ParseInt64(sc.Bytes())
	b := ParseInt64(sc.Bytes())
	fmt.Println(a * b / 100)
}

func ParseInt64(b []byte) (n int64) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		if '0' <= b[i] && b[i] <= '9' {
			n *= 10
			n += int64(b[i] - '0')
		}
	}
	if b[0] == '-' {
		return -n
	}
	return
}

// generated by https://github.com/murosan/gollect

type Scanner struct{ *bufio.Scanner }

func NewScanner(r io.Reader) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &Scanner{Scanner: s}
}

func (s *Scanner) Bytes() []byte { s.Scan(); return s.Scanner.Bytes() }


Measured memory_bytes: 1756
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (a > 5) cout << b / 2 << endl;
    else            cout << 0 << endl;
    return 0;
}


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

int main() 
{
	int n;
	cin >> n;
	int a[n + 1], sum[n + 1] = {};
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	
	int ans = 1e9;
	for (int i = 1; i < n; i++)
		ans = min(ans, abs((sum[n] - sum[i]) - sum[i]));
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
  cerr << ' ' << head;
  debug_cerr(tail...);
}
void chmax(int &a, int b) { if (a < b) a = b; }
void chmin(lint &a, lint b) { if (a > b) a = b; }
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} iosetup;

int main() {
  int n, m;
  cin >> n;
  map<string, int> mp;
  string s;
  vector <string> vec(n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i];
  }
  cin >> m;
  int ans = 0;
  map<string, int> secMp;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    if (secMp.count(s)) {
      ++secMp[s];
    } else {
      secMp[s] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    s = vec[i];
    if (mp.count(s)) {
      ++mp[s];
    } else {
      mp[s] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    int tmp = mp[vec[i]] - secMp[vec[i]];
    if (tmp < 0) tmp = 0;
    if (ans < tmp) ans = tmp;
  }
  cout << ans << '\n';
}


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

ll MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;

  bool dir[2 * N];
  dir[0] = true;
  for(int i = 1; i < 2 * N; i++){
    if(s[i] != s[i-1]) dir[i] = dir[i-1];
    else dir[i] = !dir[i-1];
  }

  if(s[0] == 'W'){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1LL;
  ll cnt = 0;
  for(int i = 0; i < 2 * N; i++){
    if(dir[i]) cnt++;
    else{
      ans *= cnt;
      cnt--;
      ans %= MOD;
    }
  }

  for(ll i = 1; i <= N; i++){
    ans *= i;
    ans %= MOD;
  }

  if(cnt == 0){
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 772
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c = sc.nextInt
    var ans = 0
    for (i <- a to b; if c % i == 0) {
      ans += 1
    }
    println(ans)
  }
}

Measured memory_bytes: 45292
N, T = map(int, input().split())
t = list(map(int, input().split()))

res = 0
pre_t = 0
for i in range(N):
    cur_t = t[i]

    if i==0:
        res+=T
    elif cur_t - pre_t >= T:
        res += T
    else:
        res += cur_t - pre_t

    pre_t = cur_t

print(res)

Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,x;
ll a[100100];
ll ans=0;
int main(){
	cin>>n>>x;
	REP(i,n)
		cin>>a[i];
	
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			if(a[i]<=x){
				ans+=(a[i+1]+a[i]-x);
				a[i+1]-=(a[i+1]+a[i]-x);
			}else{
				ans+=(a[i+1]+a[i]-x);
				a[i+1]=0;
				a[i]=x;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MAX = 10;
bool graph[MAX][MAX];
bool visited[MAX];

int N;

int dfs(int v){
    int ret = 0;
    visited[v] = true;

    bool all_visited = true;
    for(int i=1; i<=N; i++) if(visited[i] == false) all_visited = false;
    if(all_visited){
        visited[v] = false;
        return 1;
    } 

    for(int v2=1; v2<=N; v2++){
        if(graph[v][v2] == true && visited[v2] == false){
            ret += dfs(v2);
        }
    }

    visited[v] = false;
    return ret;
}

int main(void){
    int M; cin >> N >> M;

    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        graph[a][b] = graph[b][a] = true;
    }

    for(int i=1; i<=N; i++) visited[i] = false;

    cout << dfs(1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    for(ll i = 0; i < 4; i++){
        vector<string> vp;
        if(i==0){vp.push_back("S"); vp.push_back("S");}
        if(i==1){vp.push_back("S"); vp.push_back("W");}
        if(i==2){vp.push_back("W"); vp.push_back("S");}
        if(i==3){vp.push_back("W"); vp.push_back("W");}
        for(ll j = 0; j < s.length()-1; j++){
            if(s[j]=='o' && vp[j]=="S" && vp[j+1]=="S") vp.push_back("S");
            if(s[j]=='o' && vp[j]=="W" && vp[j+1]=="S") vp.push_back("W");
            if(s[j]=='o' && vp[j]=="S" && vp[j+1]=="W") vp.push_back("W");
            if(s[j]=='o' && vp[j]=="W" && vp[j+1]=="W") vp.push_back("S");
            if(s[j]=='x' && vp[j]=="S" && vp[j+1]=="S") vp.push_back("W");
            if(s[j]=='x' && vp[j]=="W" && vp[j+1]=="S") vp.push_back("S");
            if(s[j]=='x' && vp[j]=="S" && vp[j+1]=="W") vp.push_back("S");
            if(s[j]=='x' && vp[j]=="W" && vp[j+1]=="W") vp.push_back("W");
            //cout << vp << endl;
        }
        vp.push_back(vp[1]);
        bool ok = true;
        /*for(ll j = 0; j < vp.size(); j++)
            cout << vp[j];
        cout << endl;*/
        //if(vp[0]!=vp[vp.size()-1]) ok = false;
        for(ll j = 1; j < vp.size()-1; j++){
            if(vp[j]=="S" && s[j-1]=='o' && vp[j-1]!=vp[j+1])
                ok = false;
            if(vp[j]=="S" && s[j-1]=='x' && vp[j-1]==vp[j+1])
                ok = false;
            if(vp[j]=="W" && s[j-1]=='o' && vp[j-1]==vp[j+1])
                ok = false;
            if(vp[j]=="W" && s[j-1]=='x' && vp[j-1]!=vp[j+1])
                ok = false;
        }
        if(vp[0]!=vp[vp.size()-2]) ok = false;
        //if(s.begin()!=s.end()) ok = false;
        if(ok==true){
            for(ll i = 1; i < vp.size()-1; i++)
                cout << vp[i];
            cout << endl;
            break;
        }
        if(ok==false && i==3)
            cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 6116
#include<iostream>
using namespace std;
int main(){
int n,maxv=-1;
cin>>n;
int num[2][n];
for(int i=0;i<n;i++)cin>>num[0][i];
for(int i=0;i<n;i++)cin>>num[1][i];
for(int i=0;i<n;i++){
int sum=0;
for(int j=0;j<=i;j++)
sum+=num[0][j];
for(int j=i;j<n;j++)
sum+=num[1][j];
maxv=max(sum,maxv);
}
cout<<maxv;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    #include<vector>
    #include<queue>
    #include<algorithm>
    #include<functional>
    #define INF 999999
     
    using namespace std;
    typedef pair<int,long long int> P;
     
    long long int dist[100050];
    vector<P>edge[100050];
     
    void bfs(int s)
    {
    	queue<P> que;
    	que.push(P(s,0));
    	dist[s]=0;
     
    	while(que.size()!=0){
    		P p=que.front(); que.pop();
    		int from=p.first;
    		for(int i=0;i<edge[from].size();i++){
    			int to=edge[from][i].first;
    			long long int distance=p.second+edge[from][i].second;
    			if(dist[to]==INF){
    				dist[to]=distance;
    				que.push(P(to,distance));
    			}
    		}
    	}
    }
     
     
     
    int main()
    {
    	int n;
    	cin>>n;
     
    	int a[100050],b[100050];
    	long long int c[100050];
    	
    	for(int i=0;i<n;i++){
    		dist[i]=INF;
    	}
     
    	for(int i=0;i<n-1;i++){
    		cin>>a[i]>>b[i]>>c[i];
    		a[i]--;b[i]--;
    		edge[a[i]].push_back(P(b[i],c[i]));
    		edge[b[i]].push_back(P(a[i],c[i]));
    	}
     
    	
    	int q,k;
    	cin>>q>>k;
    	bfs(k-1);
     
    	int x[100050];
    	int y[100050];
    	for(int i=0;i<q;i++){
    		cin>>x[i]>>y[i];
    	}
    	for(int i=0;i<q;i++){
    		cout<<dist[x[i]-1]+dist[y[i]-1]<<endl;
    	}
    	return 0;
    }

Measured memory_bytes: 13168
fun main(arg: Array<String>) {
    val S = next()
    val N = S.length
    for (n in 0 until N - 1) {
        if (S[n] == S[n + 1]) {
            return println("${n + 1} ${n + 2}")
        }
    }
    for (n in 0 until N - 2) {
        if (S[n] == S[n + 2]) {
            return println("${n + 1} ${n + 3}")
        }
    }
    println("-1 -1")
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }



Measured memory_bytes: 34568
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

s = sinput()
ans = "A" if s.isupper() else "a"
print(ans)


Measured memory_bytes: 37796
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

const int C = 410;
const int infty = 1000000007;

int N, Ma, Mb;
int a[100], b[100], c[100];

int DP[410][410];

int main () {
  cin >> N >> Ma >> Mb;
  for (auto i = 0; i < N; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (auto i = 0; i < C; ++i) {
    for (auto j = 0; j < C; ++j) {
      DP[i][j] = infty;
    }
  }
  DP[0][0] = 0;
  for (auto t = 0; t < N; ++t) {
    for (auto i = C-1; i >= 0; --i) {
      for (auto j = C-1; j >= 0; --j) {
        if (DP[i][j] < infty) {
          int newi = i + a[t];
          int newj = j + b[t];
          if (newi < C && newj < C) {
            DP[newi][newj] = min(DP[newi][newj], DP[i][j] + c[t]);
          }
        }
      }
    }
  }
  int ans = infty;
  for (auto i = 1; i < C; ++i) {
    for (auto j = 1; j < C; ++j) {
      if (i * Mb == j * Ma) {
        ans = min(ans, DP[i][j]);
      }
    }
  }
  for (auto i = 0; i < 40; ++i) {
    for (auto j = 0; j < 40; ++j) {
      cerr << DP[i][j] << " "; 
    }
    cerr << endl;
  }
  if (ans == infty) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 896
#include <cstdio>
using namespace std;

int main(){
    double x1, y1, x2, y2, xq, yq;
    while( scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF ){
        double l = ((xq-x1)*(x2-x1)+(yq-y1)*(y2-y1))
                                    /
                   ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
        printf("%.6lf %.6lf\n", 2*(l*(x2-x1)+x1)-xq, 2*(l*(y2-y1)+y1)-yq); 
    }
    return 0;
}

Measured memory_bytes: 1084
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
    double r;
    cin >> r;
    double area = r * r * M_PI;
    double circumference = 2 * r * M_PI;
    cout << fixed << setprecision(6) << area << " "  << circumference << endl;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;


#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];

	multiset<int>s;
	int ans = 0;
	for(int i = 0; i < n; i++){
		s.insert(a[i]);
		if(*s.begin() == a[i]) ans++;
	}

	cout << ans << endl;

	
 
return 0;
}

Measured memory_bytes: 11264