akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())

int n;
int up[200005];
int a[200005];

int par[200005],ran[200005];
void init(){ for(int i=0;i<200005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	par[x] = y;
}
bool same(int x,int y){ return find(x)==find(y); }
//0の割合、unionfind上の根
set<pair<double,P1>,greater<pair<double,P1> > >S;
pair<double,P1>cur[200005];
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		int p; scanf("%d",&p); up[i] = p;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		S.insert(mp((double)(!a[i]),mp(mp(!a[i],a[i]),i)));
		cur[i] = mp((double)(!a[i]),mp(mp(!a[i],a[i]),i));
	}
	init();
	ll ans = 0;
	while(S.size() >= 2){
	    auto it = S.begin();
		//pair<double,P1>F = *S.begin(); S.erase(S.begin());
		while((*it).sc.sc == 1) it++;
		pair<double,P1>F = *it; S.erase(it);
		int x = find(up[F.sc.sc]);
		//xとFをマージ
		pair<double,P1>X = cur[x]; S.erase(S.find(cur[x]));
		ans += 1LL*X.sc.fi.sc*F.sc.fi.fi;
		int zero = X.sc.fi.fi+F.sc.fi.fi;
		int one = X.sc.fi.sc+F.sc.fi.sc;
		double ratio = (double)(zero) / (double)(zero+one);
		cur[x] = mp(ratio,mp(mp(zero,one),x)); //cout<<x<<" "<<ratio<<endl;
		S.insert(cur[x]);
		unite(F.sc.sc,x); //cout << F.sc.sc << " " << x << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 20608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
 
using namespace std;
 
int main(){
     
    int n;
    int w[500];
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
         
        for(int i = 0; i < n; i++){
            cin >> w[i];
        }
         
        int DP[500][500] = {};
         
        for(int i = 2; i <= n; i += 2){
            for(int j = 0; j <= n - i; j++){
                DP[j][j + i - 1] = DP[j + 1][j + i - 2];
                if((w[j] - w[j + i - 1]) * (w[j] - w[j + i - 1]) <= 1 && DP[j + 1][j + i - 2] == (i - 2) / 2){
                    DP[j][j + i - 1]++;
                }
                for(int k = j + 1; k < j + i - 1; k += 2){
                    DP[j][j + i - 1] = max(DP[j][j + i - 1], DP[j][k] + DP[k + 1][j + i - 1]);
                }
            }
        }
         
        if(n % 2 == 1){
            cout << max(DP[0][n - 2], DP[1][n - 1]) * 2 << endl;
        }else{
            cout << DP[0][n - 1] * 2 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4056
N = int(input())
B = list(map(int,input().split()))

ans = []
for i in range(N-1,-1,-1):
    for j in range(i,-1,-1):
        if B[j] == j+1:
            ans.append(B[j])
            del B[j]
            break

if len(ans) == N:
    print('\n'.join(map(str,ans[::-1])))
else:
    print(-1)

Measured memory_bytes: 3064
import java.util.Scanner;


public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=Integer.parseInt(sc.nextLine());
        for(int i=0;i<n;i++){
            String[] str= sc.nextLine().split(" ");
            double[] d = new double[6];
            for(int j=0;j<6;j++){
                d[j]=Double.parseDouble(str[j]);
            }
            double dist = Math.sqrt((d[0]-d[3])*(d[0]-d[3])+(d[1]-d[4])*(d[1]-d[4]));
            double big = d[2]+d[5];
            int ans=0;
            if(dist>big){
                ans=0;
            }else{
            
                if(d[2]>d[5]+dist){
                    ans=2;
                }else if(d[5]>d[2]+dist){
                    ans=-2;
                }else{
                    ans=1;
                }
                 
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 26100
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	ll n,m;
	cin>>n>>m;
	vector<ll> v(m),u(m - 1);
	for(int i = 0;i < v.size(); ++i)
	{
		scanf("%lld",&v[i]);
	}
	sort(v.begin(),v.end());
	for(int i = 0;i < v.size() - 1; ++i)
	{
		u[i] = v[i + 1] - v[i];
	}
	sort(u.rbegin(),u.rend());
	ll sum = 0;
	for(int i = 0;i < n - 1 && i < u.size(); ++i)
	{
		sum += u[i];
	}
	printf("%lld\n",v.back() - v.front() - sum);
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int N=Integer.parseInt(br.readLine());
        long sum=0;
        for(int i=1;i<=N;i++)
            if(i%3==0 || i%5==0) continue;
            else sum+=i;
        System.out.println(sum);
    }
}


Measured memory_bytes: 32612
#include<iostream>

using namespace std;

int main(){

	string str,qtr;	cin>>str>>qtr;

    int cnt =0;

  for(int i=0;i<str.size();i++){

  	if(str[i]==qtr[i]){

  		cnt++;

  	}

  }

  if(cnt==str.size()&&str.size()+1==qtr.size()){

  	 cout<<"Yes"<<endl;

  }

  else cout<<"No"<<endl;

    

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define N 300
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int G[N][N];
P SIRO[N];
int n,m,l,s,T;


int dijkstra(){
  vector<vector<int> >D(1<<l,vector<int>(n,T+1));   
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  Q.push(PP(0,P(0,s)));
  D[0][s] = 0;
  
  int res = 0;
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first;
    int bit = t.second.first;
    int pos = t.second.second;
    if(D[bit][pos]<cost)continue;
    if(cost + G[pos][s]<=T)res = max(res,__builtin_popcount(bit));

    
    for(int i=0;i<l;i++){
      int npos = SIRO[i].first;
      int ncost= cost+G[pos][npos]+SIRO[i].second;
      int nbit = bit|1<<i;
      if(bit==nbit||D[nbit][npos]<=ncost)continue;
      Q.push(PP(ncost,P(nbit,npos)));
      D[nbit][npos] = ncost;
    }
  }
  return res;
}

int main(){
  while(1){
    cin>>n>>m>>l>>s>>T;
    if(!n&&!m&&!l&&!s&&!T)return 0;
    s--;
    
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) G[i][j] = i==j? 0:T+1;

    for(int i=0,a,b,c;i<m;i++)cin>>a>>b>>c,G[a-1][b-1] = G[b-1][a-1] = c;
    for(int i=0,j,e;i<l;i++)cin>>j>>e,SIRO[i] = P(j-1,e);
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  G[i][j] = min(G[i][j],G[i][k]+G[k][j]);
    
    cout<< dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 92124
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int a[100002], N, L;
int dp[100002]; // おれる時間

int rec(int idx){
  if(~dp[idx]) return(dp[idx]);
  int ret = 0;
  if(a[idx - 1] >= a[idx]) ret = max( ret, rec(idx - 1));
  if(a[idx + 1] >= a[idx]) ret = max( ret, rec(idx + 1));
  return(dp[idx] = ret + L - a[idx]);
}

int main(){
  fill_n( dp, 100002, -1);

  cin >> N >> L;
  
  a[0] = -1;
  for(int i = 1; i <= N; i++){
    cin >> a[i];
  }
  a[N + 1] = -1;


  int ret = 0;
  for(int i = 1; i <= N; i++){
    ret = max( ret, rec(i));
  }
  cout << ret << endl;
}

Measured memory_bytes: 3300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		N = N % 10;

		if (N == 3) {
			System.out.println("bon");
		}else if(N == 0 || N == 1 || N == 6 || N == 8) {
			System.out.println("pon");
		}else {
			System.out.println("hon");
		}
	}
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  ll N, max, ans;
  cin >> N;
  for (ll i = 1; i <= sqrt(N); i++){
    if(N % i == 0){
      max = i;
    }
  }
  ans = max + N/max - 2;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())


def gcd(x, y):
    if x > y:
        x, y = y, x
    while y != 0:
        tmp = x % y
        x = y
        y = tmp
    return x
    
A = A - 1
lcm_CD = C * D // gcd(C, D)
cnt_B = B - (B//C + B//D) + (B//lcm_CD)
cnt_A = A - (A//C + A//D) + (A//lcm_CD)

ans = cnt_B - cnt_A
print(ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> vis(n + 1, false);
    vector<int> wa(n + 1, 0);
    int ac = 0;
    for (int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;
        if (!vis[p]) {
            if (s == "WA")
                wa[p]++;
            else if (s == "AC") {
                ac++;
                vis[p] = true;
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < wa.size(); i++) {
        if (vis[i]) cnt += wa[i];
    }
    cout << ac << " " << cnt << endl;
    return 0;
}

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

int main()
{
  int n,S;
  for(;cin>>n>>S,n;)    
    {
      int power[n];
      for(int i=0;i<n;i++)
	{
	  cin>>power[i];
	}
      int count=0;
      for(int i=0;i<n-1;i++)
	{
	  for(int j=i+1;j<n;j++)
	  {	    
	    if(power[i]+power[j]>S)
	      count++;
	  }
	}
      cout<<count<<endl;
    }
}

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

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int count = int.Parse(Console.ReadLine());
            var hash = new HashSet<string>();
            var output = new StringBuilder(4000000);
            for (int i = 0; i < count; ++i) {
                var input = Console.ReadLine();
                if(input[0] == 'i') {
                    hash.Add(input.Substring(7));
                }
                else {
                    output.AppendLine(hash.Contains(input.Substring(5)) ? "yes" : "no");
                }
            }
            Console.Write(output.ToString());
        }
    }
}

Measured memory_bytes: 44420
import sys
# input = sys.stdin.readline
inf = 10 ** 18

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

# https://qiita.com/maron8676/items/6010128f4ef5c268f719
class UFnode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.rank_ = 1

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        root = self.root()
        return root.group_id_

    def rank(self):
        root = self.root()
        return root.rank_

    def unite(self, unite_node):
        root = self.root()
        unite_root = unite_node.root()
        if root.group_id_ != unite_root.group_id_:
            if root.rank() > unite_root.rank():
                unite_root.parent_ = root
                root.rank_ = max(root.rank_, unite_root.rank_ + 1)
            else:
                root.parent_ = unite_root
                unite_root.rank_ = max(root.rank_ + 1, unite_root.rank_)

nodes = [UFnode(i) for i in range(N)]

for i, (Xi, Yi, Zi) in enumerate(XYZ):
    nodes[Xi - 1].unite(nodes[Yi - 1])

print(len(set([nodes[i].find() for i in range(N)])))

Measured memory_bytes: 64408
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int dp[2][100 + 1][100 * 100 + 1] = {};

int main() {
  
  int n, C; cin >> n >> C;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 100 + 1; j++) {
      for (int k = 0; k < 100 * 100 + 1; k++) {
        dp[i][j][k] = -1;
      }
    }
  }

  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

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

  // dp[i][費用][メインのヒロインの好感度] := サブヒロインの好感度の max
  dp[0][0][0] = 0;
  int cur = 0;
  int nxt = 1;

  int likeMax = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= C; j++) {
      for (int k = 0; k <= likeMax; k++) {
        if (dp[cur][j][k] == -1) continue;

        // 取らない
        dp[nxt][j][k] = max(dp[nxt][j][k], dp[cur][j][k]);

        // 普通にとる
        if (j + c[i] <= C) {
          chmax(dp[nxt][j + c[i]][k + a[i]], dp[cur][j][k] + b[i]);
        }

        // 逆でとる
        if (j + c[i] <= C) {
          chmax(dp[nxt][j + c[i]][k + b[i]], dp[cur][j][k] + a[i]);
        }
      }
    }

    likeMax += max(a[i], b[i]);
    swap(cur, nxt);
  }

  int ans = 0;
  for (int j = 0; j <= C; j++) {
    for (int k = 0; k <= likeMax; k++) {
      ans = max(ans, min(k, dp[cur][j][k]));
    }
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 10992
void main()
{
    long[] tmp = rdRow;
    long h = tmp[0], w = tmp[1];

    string[] a = new string[h];
    coord[] que;
    long[][] dist = new long[][](h, w);
    foreach (i; 0 .. h)
    {
        dist[i][] = -1;
    }
    foreach (i; 0 .. h)
    {
        a[i] = rdStr;
        foreach (j, c; a[i])
        {
            if (c == '#')
            {
                que ~= coord(i, j);
                dist[i][j] = 0;
            }
        }
    }

    long[] dy = [-1, 0, 1, 0], dx = [0, 1, 0, -1];
    long result;
    while (!que.empty)
    {
        long y = que[0].y, x = que[0].x;
        que.popFront;
        foreach (i; 0 .. 4)
        {
            long y1 = y + dy[i], x1 = x + dx[i];
            if (y1 < 0 || h <= y1 || x1 < 0 || w <= x1) continue;
            if (dist[y1][x1] >= 0) continue;

            dist[y1][x1] = dist[y][x] + 1;
            result = max(result, dist[y1][x1]);
            que ~= coord(y1, x1);
        }
    }

    result.writeln;
}

alias Tuple!(long, "y", long, "x") coord;

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 38908
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str;
        while(true){
        	int sum = 0;
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for(int i = 0; i < str.length(); i++){
                sum += str.charAt(i) - '0';
            }
            System.out.println(sum);
        }
    }
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    a.emplace_back(-1);
    int ans = 0, cnt = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] == a[i + 1]) cnt++;
        else ans += cnt / 2, cnt = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
a_list = list(map(int, input().split()))

if n%2 == 0:
    th = int(n/2)
else:
    th = int((n-1)/2)

count = 0
num_2 = 0
for a in a_list:
    if a%4 == 0:
        count += 1
    elif a%2 == 0:
        num_2 += 1

if n%2 == 0:
    if count >= th-int(num_2/2):
        print("Yes")
    else:
        print("No")
else:
    if count >= th-int(max((num_2-1), 0)/2):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14252
import sys

N, A, B = map(int, sys.stdin.readline().strip().split())
X = list(map(int, sys.stdin.readline().strip().split()))

ans = 0
for i in range(N-1):
    if (X[i+1] - X[i]) * A < B:
        ans +=  (X[i+1] - X[i]) * A
    else:
        ans += B

print(ans)

Measured memory_bytes: 62704
a = input()
count = 0

#文字列を配列にいれている
#奇数の場合、list_beforeの方に多く入る
list_before = []
list_after = []
for i in a:
	if count < len(a)/2:
		list_before.append(i)
	else:
		list_after.append(i)
	count += 1

#print(list_before)
#print(list_after)

l = int(len(a)/2)
count = 0
if len(list_before)-len(list_after) == 1:
	for i in range(l):
		if list_before[i] != list_after[l-1 - i]:
			list_before[i] = list_after[l-1 - i]
			count += 1
else: 
	for i in range(l):
		if list_before[i] != list_after[l-1 - i]:
			list_before[i] = list_after[l-1 - i]
			count += 1
		
#print(list_before)
#print(list_after)

print(count)

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

int main()
{
	int x, y;
	while(1) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
			if (x < y) {
				cout << x <<" "<< y<<endl;
			}
			else if (y <= x){
				cout << y <<" "<< x<<endl;
			}

	}
    return 0;
}




Measured memory_bytes: 2980
q, h, s, d = map(int, input().split())
n = int(input())
one = [q*4, h*2, s]
one.sort()
cost = 0
if one[0]*2>d:
    cost += d*(n//2)
    n %= 2
cost += one[0]*int(n)
n -= int(n)
if n==0:
    print(cost)
else:
    n *= 100
    x = []
    x.append(q*(n//25))
    x.append(s*(n//50)+q*((n%50)//25))
    print(min(x)+cost)

Measured memory_bytes: 9212
import copy
S = input()
ans = 0
cnt1 = 1
cnt = []
i = 0
if len(S)==1:
    print(1)
    exit()
before = S[0]
for i in range(1,len(S)):
    if S[i] == before:
        cnt1 += 1
    else:
        cnt.append([cnt1,before])
        before = S[i]
        cnt1 = 1
if cnt1 > 0:
    cnt.append([cnt1,S[i]])
cnt2 = copy.deepcopy(cnt)
for i in range(1,len(cnt)):
    if cnt2[i-1][1] == "<":
        if cnt2[i-1][0] < cnt2[i][0]:
            if cnt[i-1][0] > 0:
                cnt[i-1][0] -= 1
        else:
            if cnt[i][0] > 0:
                cnt[i][0] -= 1

for i in range(len(cnt)):
    ans += cnt[i][0]*(cnt[i][0]+1)//2
print(ans)

Measured memory_bytes: 84760
const val M = 1000006
fun main(args: Array<String>) {
    val n = readInt()
    val a = readListInt().sorted()
    val cnt = List<Int>(M){ 0 }.toMutableList()
    for (x in a) {
        if (cnt[x] != 0 ) {
            cnt[x] = 2
            continue
        }
        for (i in x until M step x) {
            cnt[i] ++
        }
    }
    var ans = 0
    for (x in a) {
        if (cnt[x] == 1) ans++
    }
    println(ans)


}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 76304
package main

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

func main() {
	N := getStdinInt()
	L := getStdinIntArr()

	hash := make(map[string]int, 0)
	var cnt int64 = 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			for k := 0; k < N; k++ {
				if L[i] < L[j] && L[j] < L[k] {
					if hash[strconv.Itoa(i)+"_"+strconv.Itoa(j)+"_"+strconv.Itoa(k)] == 0 {
						if L[i] != L[j] && L[j] != L[k] {
							if L[i]+L[j] > L[k] {
								cnt++
								hash[strconv.Itoa(i)+"_"+strconv.Itoa(j)+"_"+strconv.Itoa(k)]++
							}
						}
					}
				}
			}
		}
	}
	fmt.Printf("%d\n", cnt)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 18592
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


s = list(input())

t = list(input())
flag = -1
on = [[-1 for j in range(len(s))] for i in range(26)]

al = [-1 for i in range(26)]
alll = [0 for i in range(26)]
for i in range(len(s)):
    k = ord(s[i]) - 97
    on[k][i] = i
    if al[k] == -1:
        al[k] = i

for i in range(26):
    for j in range(len(s)-2,-1,-1):
        if on[i][j+1] != -1 and on[i][j] == -1:
            on[i][j] = on[i][j+1]
co = 0
ppp = 0
t = cl.deque(t)
while t:
    k = t.popleft()
    kkk = al[ord(k)-97]
    ppp = kkk+1
    if kkk == -1:
        print(kkk)
        exit()
    while t:
        kt = t.popleft()
        if k == kt:
            if kkk == len(s)-1:
                t.appendleft(kt)
                break
            else:
                kk = on[ord(kt)-97][kkk+1] 
                if kkk >= kk:
                    t.appendleft(kt)
                    break
                else:
                    ppp = kk+1
                    kkk = kk
                    k = kt
        else:
            kk = on[ord(kt)-97][kkk]
            if kkk >= kk:
                t.appendleft(kt)
                break
            else:
                ppp = kk+1
                kkk = kk
                k = kt
    if len(t) != 0:
        co += 1

print(len(s)*co + ppp)




Measured memory_bytes: 132888
def power(x, a):
    if a == 0:
        return 1
    elif a == 1:
        return x
    elif a % 2 == 0:
        return power(x, a//2) **2 % mod
    else:
        return power(x, a//2) **2 * x % mod


def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  
    denomi = 1  

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod

X,Y=map(int,input().split())
mod=10**9 + 7
if Y<=2*X and Y>=0.5*X and (X+Y)%3==0:
  print(binomial_coefficients((X+Y)//3,((X+Y)//3)*2-X))
else:
  print(0)

Measured memory_bytes: 3188
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

N = int(input())
A = [None]
info = [None] + [[] for _ in range(N)]
for i in range(N):
    a = int(input())
    A.append(a)
    for _ in range(a):
        x, y = map(int, input().split())
        info[i+1].append((x, y))
#print('info={}'.format(info))
    
ans_bit = 0
for num in range(2**N-1, -1, -1):
    bit_pre = bin(num)
    bit_pre = bit_pre[2:]
    l = len(bit_pre)
    bit = '0' * (N - l) + bit_pre


    status = [None] * (N + 1)
    #print('bit={}'.format(bit))
    contradict = False
    for i, n in enumerate(bit):
        i += 1
        n = int(n)
        #print('i={}, n={}'.format(i, n))
    
        if n == 1:
            for x, y in info[i]:
                if int(bit[x-1]) != y:
                    contradict = True
                    
                s = status[x]
                #print('s={}'.format(s))
                if s == None:
                    status[x] = y
                elif s != y:
                    contradict = True
                #print('status={}'.format(status))
        
    if not contradict:
        ans_bit = bit
        break



#print('ans_bit={}'.format(ans_bit))
ans = 0
for x in ans_bit:
    if x == '1':
        ans += 1
print(ans)

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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	bool good = true;
	cin >> s;
	for (LL i = 0; i < s.size(); i++){
		if ((i%2)){
			if (s[i] == 'R')
				good = false;
		}
		else{
			if (s[i] == 'L')
				good = false;
		}
	}
	if (good)
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            Dictionary<string, List<int>> indexData = new Dictionary<string, List<int>>();
            List<string> words = new List<string>();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                string word = temp[0];
                int index = int.Parse(temp[1]);

                if (!indexData.ContainsKey(word))
                {
                    indexData.Add(word, new List<int>());
                    words.Add(word);
                }

                indexData[word].Add(index);
            }

            words.Sort();

            foreach (var word in words)
            {
                indexData[word].Sort();

                sb.AppendLine(word);

                int len = indexData[word].Count - 1;

                for (int i = 0; i < len; i++)
                {
                    sb.Append(indexData[word][i] + " ");
                }
                sb.AppendLine(indexData[word][len].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10044
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n;
    cin >> n;
    vi L(n);
    rep(i,n) cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;

    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i < j && j < k){
                    if(i != j && j != k && k != i){
                        if(L[i] + L[j] > L[k] && L[k] + L[i] > L[j] && L[j] + L[k] > L[i] && L[i] != L[j] && L[j] != L[k]){
                            //cout << i << " " << j << " " << k << endl; 
                            ans++;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/*

*/

Measured memory_bytes: 3628
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n;
    	int ue,mae,migi,reg,sum;
    	String s;
    	for(;;){
    		sum=1;
    		ue=1;
    		mae=2;
    		migi=3;
    		n=sc.nextInt();
    		if(n==0){
    			return;
    		}
    		for(int i=0;i<n;i++){
    			s=sc.next();
    			switch(s){
    			    case "North":
    				    reg=ue;
    				    ue=mae;
    				    mae=7-reg;
    				    break;
    			    case "East":
    			    	reg=migi;
    			    	migi=ue;
    			    	ue=7-reg;
    			    	break;
    			    case "West":
    			    	reg=ue;
    			    	ue=migi;
    			    	migi=7-reg;
    			    	break;
    			    case "South":
    			    	reg=mae;
    			    	mae=ue;
    			    	ue=7-reg;
    			    	break;
    			    case "Right":
    			    	reg=mae;
    			    	mae=migi;
    			    	migi=7-reg;
    			    	break;
    			    case "Left":
    			    	reg=migi;
    			    	migi=mae;
    			    	mae=7-reg;
    			    	break;
    			}
    			sum+=ue;
    		}
    		System.out.println(sum);
    	}
    }
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll N;
  cin >> N;
  VLL A(N);
  VLL sum(N);

  rep(i,N){
    cin >> A[i];
    sum[i] = A[i];
  }

  sort(all(A));
  sort(all(sum));


  rep(i,N-1) sum[i+1] += sum[i];

  ll ans = 1;
  //rep(i,N) cout << sum[i] << " ";
  // cout << endl;
  // rep(i,N) cout << A[i] << " ";
  // cout << endl;
  rep(i,N-1) if(sum[i]*2 >= A[i+1]){
    ans++;
    //cout << i<< ":" << sum[i] << endl;
  }else{
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, k; cin >> n >> k;
  vector<int> h(n); rep(i, n) cin >> h[i];
  int dp[100010];
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; i++) {
    dp[i] = 1e9;
    for (int j = 1; j <= k; j++)
      if (0 <= i - j)
        dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]));
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100
 
int main(){
 
    char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
    int array[ARRAY_SIZE];
    int change_count = 0;
 
    for(int i = 0; i < n; i++){
        cin >> array[i];
    }
 
    int tmp = 0;
    for(int i = n-1;i > 0;i--){
        for(int j = 0; j < i;j++){
            if(array[j] > array[j+1]){
                tmp = array[j+1];
                array[j+1] = array[j];
                array[j] = tmp;
                change_count++;
            }
        }
    }
 
    for(int i = 0; i < n; i++){
        if(i != n-1){
            printf("%d ",array[i]);
        }else{
            printf("%d\n",array[i]);
        }
    }
    printf("%d\n",change_count);
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include<vector>
#include<unordered_map>
#define ll long long
const ll mx=1e5;
using namespace std;
ll mp[mx];
int main( ) {
 
     ll t=0,i,j,m ;
     ll k=0,n;
       ll a,b;
       ll cnt=0;
		    string str;
		    cin>>n>>str;
		     
		    bool ok=true;
		    for(i=n-1;i>=0;i--)
		    {
		    	if(str[i]=='R' ) cnt++;
		    	//if(str[i]=='W')cnt++;
			}
		///	cout<<cnt<<endl;
			for(i=0;i<cnt;i++)
			{
				if(str[i]=='R')k++;
			}
			cout<<cnt-k<<endl;
	  
	return 0;
}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    string s, t; cin >> s >> t;
    int n = s.length(), m = t.length();

    vector<VI> where(26);
    FOR(i, 0, n)where[s[i] - 'a'].push_back(i);
    int now = -1; ll ans = 0;
    FOR(i, 0, m) {
        if (where[t[i] - 'a'].empty()) {
            cout << "-1\n";
            return 0;
        }

        auto itr = upper_bound(all(where[t[i] - 'a']), now);
        if (itr == where[t[i] - 'a'].end()) {
            ans += n;
            itr = where[t[i] - 'a'].begin();
        }
        now = *itr;
    }
    cout << ans + now + 1 << "\n";
}

Measured memory_bytes: 1228
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1000
int main(){
    int n,n2,n3;
    while(cin>>n>>n2>>n3){
        int cnt=0;
        for(int i=1;i<=10;i++){
            if(i!=n&&i!=n2&&i!=n3){
                if(i+n2+n<=20)cnt++;
            }
        }
        if(cnt>3.5)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 2996
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print("ABC" if S == "ARC" else "ARC")

Measured memory_bytes: 9872
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
#define d read()
ll n,k;
ll ans;
int main(){
	scanf("%lld %lld",&n,&k);
	printf("%lld",min(n-n/k*k,-(n-n/k*k-k)));
	return 0;
}

Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)  cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 300005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll  b) {
    return (ceil(1.0 * a / b * 1.0));
}
ll binexp(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinvfermat(ll a, ll m)
{
    return binexp(a, m - 2, m);
}
void task(bool flag)
{
    if (flag)
        cout << "YES\n";
    else
        cout << "NO\n";
}
ll lcm(ll a, ll b)
{
    return ((1LL * a * b) / (__gcd(a, b)));
}



signed main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    fast
    ll n;
    cin >> n;
    if (n < 2)
        cout << 0 << END;
    else
    {
        ll ans = 0;
        ans = binexp(10, n, MOD);
        ll val = (2 * binexp(9, n, MOD)) % MOD;
        ll val2 = binexp(8, n, MOD);
        ans = (ans + val2) % MOD;
        ans = (ans - val + MOD) % MOD;
        cout << ans << END;
    }


// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
    return 0;
}



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

int main() {
	// your code goes here
	ll n;
	cin >> n;
	vector<ll> v;
	ll temp;
	ll ans=0;
	for(int i=0;i<n;i++){
	    cin >> temp;
	    v.push_back(temp);
	    ans=ans^temp;
	}
	for(int i=0;i<n;i++){
	    temp = ans^v[i];
	    cout << temp << " ";
	}
	return 0;
}


Measured memory_bytes: 5364
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,m;
    cin >> n >> m;
    if(abs(n-m) > 1){
        cout << 0 << endl;;
        return 0;
    }
    ll answer=1;
    FOR(i,1,n+1){
        answer = answer*i%MOD;
    }
    FOR(i,1,m+1){
        answer = answer*i%MOD;
    }
    if(n == m){
        answer = answer*2%MOD;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3030;

int main() {
    int N;
    cin >> N;
    vector<double> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
     // dp[i][j] : i 枚目まで投げた時に表が j 枚出る確率
    double dp[MAX_N][MAX_N];
    dp[0][0] = 1;
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp[i+1][j] += dp[i][j] * (1.0 - A[i]);
            dp[i+1][j+1] += dp[i][j] * A[i];
        }
    }
    
    double ans = 0;
    for (int i = (N + 1) / 2; i <= N; i++) ans += dp[N][i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 71808
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll ans = 1;
    rp(i,n){
        ans = (ans*(i+1))%MOD;
    }
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007

using namespace std;
int main()
{    
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,k,n,m;
     ll t;
     ll a,b;
     cin>>n;
     a=100;
     ll ans=0;
     while(a<n)
     {
         ans++;
         a=a+(a/100);
     }
     cout<<ans;
}  



Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    vector<int> a(4);
    rep(i, 4) cin >> a[i];
    sort(all(a));
    int ans=0;
    if(a[0]==1) ans++;
    if(a[1]==4) ans++;
    if(a[3]==9) ans++;
    if(a[2]==7) ans++;
    if(ans==4) cout<<"YES"<<endl;
    else{
        cout<<"NO"<<endl;
    }
}

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if(N*A >= B)
	{
	
	cout << B << endl;
	
	}
	else if (N*A < B)
	{
	
	cout << N*A << endl;
	
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  string S; 
  bool flg = false;
 
  for(int i = 0; i < N; i++){
    cin >> S;
    
    if (S == "Y"){
      flg = true;
      break;
    }
  }
  
  if (flg== true){
    cout << "Four" << endl;
  }
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 256