akhauriyash/Code-Regression huggingface dataset:
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
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<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

//pow(a,b) → aのb乗を求める

//s1.erase(n) 文字列s1の、n文字目以降削除

int a = 0, b = 0, c = 0, d = 0, x = 0, y = 0
   , z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> s;
	for (int i = 3; i <= s.size() - 1; i++) {
		if (s[i-1] == 'C')cnt++;
	}
	rep(i, s.size()) {
		if ((int)s[i] < 93)sum++;
	}
	if (s[0] != 'A') cout << "WA" << rt;
	else {
		if (cnt != 1)cout << "WA" << rt;
		else {
			if (sum != 2)cout << "WA" << rt;
			else cout << "AC" << rt;
		}
	}
	please AC;
}

Measured memory_bytes: 256
input = [int(i) for i in input().split()]
 
N = input[0]
Y = input[1]
 
ans = False
total = 0
 
for i in range(0,N+1):
    for j in range(0,(N+1-i)):
        total = 10000 * i + 5000 * j + (N-i-j) * 1000
        if Y == total:
            print(i,j,(N-i-j))
            ans = True
            break
    else:
        continue
    break
if ans == False:
 
    print(-1,-1,-1)

Measured memory_bytes: 3064
import java.io.*;
import java.nio.file.WatchEvent;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
    private static int A, B, C;

    private static String solver(int length, String hats) {

        int redNum = length - hats.replace("R", "").length();

        if (redNum*2 > length) {
            return "Yes";
        } else {
            return "No";
        }
    }


    public static void main(String[] args) {

        int length = 0;
        String hats = "";
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        try {
            String[] inputArray = br.readLine().split(" ");
            length = Integer.parseInt(inputArray[0]);
            hats = br.readLine().split(" ")[0];
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println(solver(length, hats));

    }
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#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 pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

ll modpow(int a, int r)
{
    if(r == 0)return 1;
    if(r % 2 == 1){
        return modpow(a, r-1) * a % MOD;
    }else{
        ll x = modpow(a, r / 2);
        return x * x % MOD;
    }
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    ll aCnt[n];
    ll leftQcnt[n];
    ll cCnt[n];
    ll rightQcnt[n];
    aCnt[0] = 0;
    leftQcnt[0] = 0;
    FOR(i,1,n){
        aCnt[i] = aCnt[i-1];
        leftQcnt[i] = leftQcnt[i-1];
        if(s[i-1] == 'A'){
            aCnt[i]++;
        }else if(s[i-1] == '?'){
            leftQcnt[i]++;
        }
    }
    cCnt[n-1] = 0;
    rightQcnt[n-1] = 0;
    FORR(i,n-2,0){
        cCnt[i] = cCnt[i+1];
        rightQcnt[i] = rightQcnt[i+1];
        if(s[i+1] == 'C'){
            cCnt[i]++;
        }else if(s[i+1] == '?'){
            rightQcnt[i]++;
        }
    }
    ll ans = 0;
    FOR(i,0,n){
        if(s[i] == 'B' || s[i] == '?'){
            ans += (ll)aCnt[i] * cCnt[i] % MOD * modpow(3, leftQcnt[i]) % MOD * modpow(3, rightQcnt[i]) % MOD;
            ans %= MOD;
            ans += (ll)leftQcnt[i] * cCnt[i] % MOD * modpow(3, leftQcnt[i] - 1) % MOD * modpow(3, rightQcnt[i]) % MOD;
            ans %= MOD;
            ans += (ll)aCnt[i] * rightQcnt[i] % MOD * modpow(3, leftQcnt[i]) % MOD * modpow(3, rightQcnt[i] - 1) % MOD;
            ans %= MOD;
            ans += (ll)leftQcnt[i] * rightQcnt[i] % MOD * modpow(3, leftQcnt[i] - 1) % MOD * modpow(3, rightQcnt[i] - 1) % MOD;
            ans %= MOD;
        }
    }
    ANS(ans);
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               int n,k;
               cin>>n>>k;
               int a[n];
               for(int i=0;i<n;++i)
                    cin>>a[i];
               sort(a,a+n);
               int ans=0;
               for(int i=0;i<k;++i)
                    ans+=a[i];
               cout<<ans;
       }
}


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

using namespace std;

int main(){
	int k  ,l , r;
	cin>>k>>l>>r;
	if(l % k == 0) cout<<"OK"<<endl;
	else if(r % k == 0) cout<<"OK"<<endl;
	else{
		if(l / k == r / k) cout<<"NG"<<endl;
		else cout<<"OK"<<endl;
	}
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String line = sc.nextLine();
        String[] lines = line.split(" ");
        int A = Integer.parseInt(lines[0]);
        int B = Integer.parseInt(lines[1]);

        if(A < 9 && B < 9){
            System.out.println("Yay!");
        }else{
            System.out.println(":(");
        }
    }
}


Measured memory_bytes: 21844
# https://drken1215.hatenablog.com/entry/2020/01/26/164200
# bit_pathの参考にした
# https://atcoder.jp/contests/abc152/submissions/9619555
# popcnt

def main():
    from collections import namedtuple
    from functools import reduce
    from itertools import combinations
    from operator import or_

    Edge = namedtuple('Edge', 'to edge_id')

    def bit_path(curr, goal, par=-1):
        if curr == goal:
            return 0
        for e in g[curr]:
            if e.to == par: continue
            res = bit_path(curr=e.to, goal=goal, par=curr)
            if ~res:  # -1以外
                return res | (1 << e.edge_id)
        return -1

    def popcnt(n):
        """https://atcoder.jp/contests/abc152/submissions/9619555"""
        c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
        c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
        c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
        c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
        c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
        c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
        return c

    N = int(input())

    g = tuple(set() for _ in range(N))
    for edge_id in range(N - 1):
        a, b = (int(x) - 1 for x in input().split())
        g[a].add(Edge(to=b, edge_id=edge_id))
        g[b].add(Edge(to=a, edge_id=edge_id))

    M = int(input())

    cons = []
    for _ in range(M):
        u, v = (int(x) - 1 for x in input().split())
        b = bit_path(u, v)
        cons.append(b)

    ans = 1 << (N - 1)
    for k in range(1, M + 1):
        for comb in combinations(cons, r=k):
            b = reduce(or_, comb)
            ans += ((-1) ** k) * (1 << (N - 1 - popcnt(b)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3940
#include "stdio.h"
int main(){
    int n,m,i,j=0;
	scanf("%d %d",&n,&m);
	scanf("%d",&i);
	if(m>n){
		j=i/m;
		if(i%m>0){
			j++;
			
		}
		
	}
	else {
		j=i/n;
		if(i%n>0){
			j++;
		}
	}
	printf("%d",j);
	
	return 0;
} 

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

int main(){
  int n, p;
  string s;
  cin >> n;
  
  tuple<string, int, int>r[110];
  for(int i=0;i<n;i++){  
    cin >> s >> p;
    r[i]=make_tuple(s,-p,i+1);
  }
   for(int i=0;i<n;i++){  
	sort(r, r+n);
    cout << get<2>(r[i]) << endl;
  }
}

Measured memory_bytes: 256
l = int(input())
s = bin(l)[2:]
n = len(s)
m = 0
ans = []
for i in range(n-1):
    ans.append([i+1, i+2, 0])
    ans.append([i+1, i+2, 2**(n-2-i)])
    m += 2
imp = 2**(n-1)
for i in range(n-1, 0, -1):
    if s[i] == '1':
        ans.append([1, i+1, imp])
        m += 1
        imp += 2 ** (n-1-i)
print(n, m)
for x in ans:
    print(' '.join(list(map(str, x))))

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int moun[10];
	int height[10001] = {0};
	int sub = 3;
	int i;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &moun[i]);
		height[moun[i]]++;
	}
	for (i = 10000; i >= 0; i--){
		if (height[i] > 0){
			while (height[i] > 0){
				printf("%d\n", i);
				height[i]--;
				sub--;
				if (sub == 0)break;
			}
			
			if (sub == 0)break;
		}
	}
	
	return (0);
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    long long t = n/k;
    long long ans = t*t*t;
    if (k%2 == 0){
        if(n%k >= k/2) t++;
        ans += t*t*t;
	}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String y = sc.next();

        char [] c = y.toCharArray();
        int count =0;
        int kotae = 0;
        int countA =0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                for (int k = i; k < n; k++) {
                    if(c[j] == c[k]){
                        count++;
                    }
                    for (int l = 0; l < j; l++) {
                        if(c[j] == c[l]){
                                count=0;
                        }
                    }
                }
                if(count > 0){
                    countA++;
                }
                count =0;
            }
            kotae = Math.max(kotae,countA);
            countA = 0;
        }

        System.out.println(kotae);
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
string str;
bool jud;
int n;
const ll mod = 1000000007;
vector<int> vec;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> str;
	n = str.length();
	if (str[n - 1] == '1' || str[0] == '0')
	{
		cout << -1 << endl;
		return 0;
	}
	jud = true;
	for (int i = 0; i < n - 1; i++)
	{
		if (str[i] != str[n - 2 - i])
		{
			jud = false;
		}
	}
	if (!jud)
	{
		cout << -1 << endl;
		return 0;
	}
	for (int i = n / 2; i > 0; i--)
	{
		if (str[i - 1] == '1')
		{
			vec.push_back(i);
		}
	}
	for (int i = vec[0] + 2; i <= n; i++)
	{
		cout << vec[0] + 1 << ' ' << i << endl;
	}
	cout << vec[0] << ' ' << vec[0] + 1 << endl;
	int root = vec[0];
	for (int i = vec[0] - 1; i > 0; i--)
	{
		cout << i << ' ' << root << endl;
		if (str[i - 1] == '1')
		{
			root = i;
		}
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 1916
public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var N = sc.nextInt();

		long count = 0;
		for (int A = 1; A <= N-1; A++) {
				count+=(N-1)/A;
		}
		System.out.println(count);
	}
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int count = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == t[i]) {
      ++count;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int len,i,j,lenp,lenr,end=0;
  char ring[201],p[101];
  char *lr=ring;
  char *lp=p;
  scanf("%s",ring);
  scanf("%s",p);
  lenr=strlen(lr);
  lenp=strlen(lp);
  //printf("A");
  for(i=0;i<lenr;i++){
    ring[i+lenr]=ring[i];
  }
  for(i=0;i<lenr;i++){
    j=0;
    while(p[j]==ring[i+j]){
      j++;
      if(j==lenp){
	end=1;
	break;
      }
    }
    if(end) break;
  }
  if(end)printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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 INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    ll sum = 0;
    rep(i,N)sum ^= A[i];
    rep(i,N){
        cout << (sum ^ A[i]) << endl;
    }
}

Measured memory_bytes: 4776
import java.io.*;
import java.util.*;

public class Main{
	
	static int mod=(int)1e9+7;
	
	public static void main(String[] args) throws IOException {
		Writer out=new Writer(System.out);
		Reader in=new Reader(System.in);
		int ts=1;
		
		outer: while(ts-->0) {	
			
			long a[]=in.readLongArray(2);
			long b[]=in.readLongArray(2);
			long ans=Long.MIN_VALUE;
			for(long i: a) {
				for(long j: b) ans=max(ans,i*j);
			}
			out.println(ans);
		}
		out.close();		
		
	}

	
	
/*********************************** UTILITY CODE BELOW **************************************/	
		
	static int abs(int a) {
		return a>0 ? a : -a;
	}
	
	static long max(long a, long b) {
		return a>b ? a : b;
	}
	
	static int pow(int n, int m) {
		if(m==0) return 1;
		int temp=pow(n,m/2);
		long res=(((long)temp*temp)%mod);
		if(m%2==0) return (int)res;
		return (int)((res*n)%mod);
	}
	
	static class Pair{
		int u, v;
		
		Pair(int u, int v){this.u=u; this.v=v;}
		
		static void sort(Pair [] coll) {		
			List<Pair> al=new ArrayList<>(Arrays.asList(coll));
			Collections.sort(al,new Comparator<Pair>() {
				public int compare(Pair p1, Pair p2) {
					return p1.u-p2.u;
				}	
			});
			for(int i=0; i<al.size(); i++) {
				coll[i]=al.get(i);
			}
		}
		
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static int [] array(int n, int value) {	
		int a[]=new int[n];
		for(int i=0; i<n; i++) a[i]=value;
		return a;
	}
	
	static class Reader{
		
		BufferedReader br;
		StringTokenizer to;
		
		Reader(InputStream stream){
			br=new BufferedReader(new InputStreamReader(stream));
			to=new StringTokenizer("");
		}
		
		String next() {
			while(!to.hasMoreTokens()) {
				try {
					to=new StringTokenizer(br.readLine());	
				}catch(IOException e) {}
				
			}
			return to.nextToken();
			
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0; i<n ;i++) a[i]=nextInt();
			return a;
		}
		long [] readLongArray(int n) {
			long a[]=new long[n];
			for(int i=0; i<n ;i++) a[i]=nextLong();
			return a;
		}
		
	}
	
	static class Writer extends PrintWriter{
		Writer(OutputStream stream){
			super(stream);
		}
		void println(int [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
		void println(long [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
	}
	
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<29)//INF
#define F first
#define S second
#define VS vector<string>
#define VI vector<int>
#define REPI(i,s,n) for(int i=s;i<n;i++)//sからn未満の間iを回す
#define REPJ(j,s,n) for(int j=s;j<n;j++)//sからn未満の間iを回す
#define RREPI(i,s,n) for(int i=s;i>=n;i--)//sからn以下の間iを回す
#define RREPJ(j,s,n) for(int j=s;j>=n;j--)//sからn以下の間jを回す
#define ALL(a) a.begin(),a.end()//ソートとかに使える sort(ALL(vec))のように
#define SET(a,c) memset(a,c,sizeof(a));//aをc（0or1）で初期化する
#define DEBUGONE(x) cout<<#x<<" : "<<x<<endl;//デバックで一つの変数を表示
#define DEBUGTWO(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;//デバックで二つの変数を表示
#define DEBUGTHREE(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl;//デバックで三つの変数を表示
#define OUTONE(x) cout<<x<<endl;//一つの変数を表示
#define OUTTWO(x,y) cout<<x<<" "<<y<<endl;//二つの変数を表示
#define OUTTHREE(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;//三つの変数を表示
typedef long long int64;
typedef pair<string,int> Psi;
typedef pair<int,int> Pii;
map<Psi,int64> mem;
string num[15];
int n,k;
int64 ans=0;
int64 bitdfs(int now,string nows,int bits);
main(){
  while(cin>>n>>k,n||k){
    ans=0;
    mem.clear();
    REPI(i,0,n){
      cin>>num[i];
    }
    cout<<bitdfs(0,"",0)<<endl;
  }
}
int64 bitdfs(int now,string nows,int bits){
  if(now>=k){
    if(mem[Psi(nows,now)]==0){
      mem[Psi(nows,now)]=-1;
      return 1;
    }
    else{
      return 0;
    }
  }
  else{
    int64 cnt=0;
    int bitst=1;
    REPI(i,0,n){
      int b=bitst&bits;
      if(b==0){
	cnt+=bitdfs(now+1,nows+num[i],bits|bitst);
      }
      bitst=bitst<<1;
    }
    return mem[Psi(nows,now)]=cnt;
  }
}

Measured memory_bytes: 1564
N = int(input())
a = [int(input()) for i in range(N)]
i=0
j=0
cnt=0
while True:
    if a[j]==2:
        cnt+=1
        print(cnt)
        break
    elif cnt>N:
        print(-1)
        break
    else:
        cnt+=1
        i+=1
        j=a[j]-1

Measured memory_bytes: 7084
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;



int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	ll ans = -9e18;
	
	vector<pair<ll,ll>> s1,s2;
	
	s1.push_back({a,min(-1LL,b)});
	if(a<=0 && 0<=b) s1.push_back({0,0});
	s1.push_back({max(1LL,a),b});
	
	s2.push_back({c,min(-1LL,d)});
	if(c<=0 && 0<=d) s2.push_back({0,0});
	s2.push_back({max(1LL,c),d});
	
	
	for(auto [l1,r1] : s1) if(l1<=r1)
	for(auto [l2,r2] : s2) if(l2<=r2){
		ans = max(ans, l1*l2);
		ans = max(ans, l1*r2);
		ans = max(ans, r1*r2);
		ans = max(ans, r1*l2);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3652
N = int(input())
B = list(map(int,input().split()))
score = B[0] + B[N-2]

for i in range(N-2):
    t = B[i+1] - B[i]
    if t >0:
        score += B[i]
    else:
        score += B[i+1]
print(score)

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

X,K,D = map(int, input().split())

if X+K*D<=0:
  answer = -X-K*D
elif X-K*D>=0:
  answer = X-K*D
else:
  r = (X+K*D)%(2*D)
  if r>=2*D-r:
    answer = 2*D-r
  else:
    answer = r

print(answer)

Measured memory_bytes: 9180
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	short w, h;
	short[][] map;
	short sx, sy;
	short gx, gy;
	P[] nodes;
	LinkedList<E>[] edge;
	int size;
	
	@SuppressWarnings("unchecked")
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			w = sc.nextShort();
			h = sc.nextShort();
			if( (w|h) == 0 ) break;
			
			map = new short[h+2][w+2];
			LinkedList<P> foods = new LinkedList<P>();
			for(short i=1;i<=h;i++) for(short j=1;j<=w;j++) {
				map[i][j] = sc.nextShort();
				if(map[i][j] == 2) {
					map[i][j] = 1;
					sx = j; sy = i;
				}
				if(map[i][j] == 3) {
					map[i][j] = 1;
					gx = j; gy = i;
				}
				if(map[i][j] == 4) {
					map[i][j] = 1;
					foods.add(new P(j, i));
				}
			}
			
			size = foods.size() + 2;
			nodes = new P[size];
			
			nodes[0] = new P(sx, sy);
			for(int i=1;i<size-1;i++) nodes[i] = foods.remove();
			nodes[size-1] = new P(gx, gy);
			
			edge = new LinkedList[size];
			for(int i=0;i<size;i++) edge[i] = new LinkedList<E>();
			for(int i=0;i<size;i++) for(int j=i+1;j<size;j++) {
				int d = bfs(nodes[i], nodes[j]);
				if( d<0 ) continue;
				edge[i].add(new E(j, d));
				edge[j].add(new E(i, d));
			}
			
			System.out.println(dijkstra());
		}
	}
	
	int dijkstra() {
		boolean visited[] = new boolean[size];
		PriorityQueue<E> que = new PriorityQueue<E>();
		que.add(new E(0, 0));
		for(;!que.isEmpty();) {
			E now = que.remove();
			if( visited[now.t] ) continue;
			if( now.t == size-1 ) return now.c;
			visited[now.t] = true;
			for(E next: edge[now.t]) {
				que.add(new E(next.t, now.c+next.c));
			}
		}
		return -1;
	}
	
	short dx[] = {-1,0,1,0};
	short dy[] = {0,-1,0,1};
	
	int bfs(P f, P t) {
		boolean[][] visited = new boolean[h+2][w+2];
		
		LinkedList<P> que = new LinkedList<P>();
		que.add(f);
		visited[f.y][f.x]= true; 
		
		for(;!que.isEmpty();) {
			P now = que.remove();
			if(now.c == 0) continue;
			if( now.x == t.x && now.y == t.y ) return 6-now.c;
			for(int i=0;i<4;i++) if( map[now.y+dy[i]][now.x+dx[i]] == 1  && !visited[now.y+dy[i]][now.x+dx[i]] ) {
				visited[now.y+dy[i]][now.x+dx[i]] = true;
				que.addLast(new P((short)(now.x+dx[i]), (short)(now.y+dy[i]), (short)(now.c-1)));
			}
		}
		
		return -1;
	}
	
	class E implements Comparable<E>{
		int t, c;
		E (int t, int c) {
			this.t = t;
			this.c = c;
		}
		@Override
		public int compareTo(E o) {
			// TODO 自動生成されたメソッド・スタブ
			return c-o.c;
		}
	}
	
	class P {
		short x, y, c;
		P(short x, short y) {
			this.x = x;
			this.y = y;
			c = 6;
		}
		P(short x, short y, short c) {
			this.x = x;
			this.y = y;
			this.c = c;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

void mult(ll a[matmax][matmax], ll b[matmax][matmax], ll c[matmax][matmax], int m, int n, int p)
{
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= p; j++)
		{
			c[i][j] = 0;
			for (int k = 1; k <= n; k++)
			{
				c[i][j] += (a[i][k]*b[k][j])%mod;
				c[i][j] %= mod;
			}
		}
	}
}

void mat_pow(ll a[matmax][matmax], ll c[matmax][matmax], int n, ll p)
{
	if (p == 0)
	{
		for (int i = 1; i <= n; i++)
			c[i][i] = 1;
	}
	else if (p == 1)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
				c[i][j] = a[i][j];
		}
	}
	else
	{
		ll d[matmax][matmax];
		mat_pow(a, d, n, p/2);
		if (p % 2)
		{
			ll e[matmax][matmax];
			mult(d, d, e, n, n, n);
			mult(e, a, c, n, n, n);
		}
		else
		{
			mult(d, d, c, n, n, n);
		}
	}
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}
ll n, a[11000], ans = 0;
int main()
{
	fastio;		
	cin>>n;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i];
		ll temp = a[i];
		while (temp % 2 == 0)
		{
			temp /= 2;
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 384
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut count = 0;
    for a in a.iter() {
        if *a - 1 == count {
            count += 1;
        }
    }
    let ans = if count == 0 { -1 } else { (n - count) as i64 };
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 998244353;

int main(){
    int N;
    while(cin >> N){
        vector<int> cnt(N, 0);
        bool ok = true;
        for(int i=0;i<N;i++){
            int d; cin >> d;
            if(i==0 && d != 0) ok = false;
            if(i!=0 && d == 0) ok = false;
            cnt[d]++;
        }
        long long res = 1;
        if(!ok) res = 0;
        int sum = cnt[0];
        for(int i=1;i<N;i++){
            if(cnt[i] == 0) break;
            sum += cnt[i];
            for(int j=0;j<cnt[i];j++) res = (res*cnt[i-1])%MOD;
        }
        if(sum != N) res = 0;
        cout << res << endl;
    }
}

Measured memory_bytes: 640
// Vicfred
// https://atcoder.jp/contests/abc043/tasks/arc059_a
// brute force
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.map!(to!int).array;

    long minima = long.max;
    for(int i = -100; i <= 100; i++) {
        long cost = 0;
        foreach(item; a)
            cost += (item - i)^^2;
        minima = min(minima, cost);
    }

    minima.writeln;
}



Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int th, td, ah, ad;
  cin >> th >> td >> ah >> ad;
  while (th > 0 || ah > 0)
  {
    if (ah - td <= 0){
      printf("Yes");
      ah -= td;
      break;
    }
    else
    {
      ah -= td;
    }
    if (th - ad <= 0)
    {
      printf("No");
      th -= ad;
      break;
    }
    else
    {
      th -= ad;
    }
  }
}

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


int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string s;
    cin>>s;
    int n = s.length();
    map<int, int> m;
    int num = 0;
    m[num]++;
    int tp = 1;
    int ans = 0;
    for (int i=n-1; i>=0; i--){
        int digit = s[i]-'0';
        num = (tp*digit + num)%2019;
        tp = (10*tp)%2019;
        ans += m[num];
        m[num]++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3708
class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.root(self.parent[x])

    def size(self, x):
        return -self.parent[self.root(x)]


N, K, L = map(int, input().split())

uf_tree1 = UnionFind(N)
uf_tree2 = UnionFind(N)

for _ in range(K):
    p, q = map(int, input().split())
    p -= 1; q -= 1;
    uf_tree1.unite(p, q)

for _ in range(L):
    r, s = map(int, input().split())
    r -= 1; s -= 1;
    uf_tree2.unite(r, s)

d = {}
for i in range(N):
    pair = (uf_tree1.root(i), uf_tree2.root(i))
    d[pair] = d.get(pair, 0) + 1

for i in range(N):
    pair = (uf_tree1.root(i), uf_tree2.root(i))
    print(d[pair], end = "")
    print("\n" if i == N-1 else " ", end = "")

Measured memory_bytes: 41244
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

map<ll, ll> m;

ll solve(ll x) {
  if (m.find(x) != m.end()) return m[x];
  ll y = x / 2;
  ll ans = 1 + 2 * solve(y);
  m[x] = ans;
  return ans;
}

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

  ll h;
  cin >> h;
  m[1] = 1;
  ll ans = solve(h);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b; cin >> a >> b;
    if(b %a == 0) dunk(a+b);
    else dunk(b-a);
}
    

Measured memory_bytes: 256
from itertools import product
N=list(input())
for i in range(4):
    N[i]=int(N[i])



for op1, op2, op3 in product([1,-1],[1,-1],[1,-1]):
    if N[0] + N[1]*op1 + N[2]*op2 + N[3]*op3 == 7:
        print("{}{}{}{}{}{}{}=7".format(
            N[0],"+" if op1==1 else "-",
            N[1],"+" if op2==1 else "-",
            N[2],"+" if op3==1 else "-",
            N[3]))
        break



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

using namespace std;
using ll = long long;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(j, k) ans += p[j];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
n, k = map(int, input().split())
aes = list(map(int, input().split()))

bottom, top = 0, max(aes)

def ok(l):
  cnt = 0
  for a in aes:
    if a % l == 0:
      cnt += a // l - 1
    else:
      cnt += a // l
  return cnt <= k

while top - bottom > 1:
  mid = (bottom + top) // 2
  if ok(mid):
    top = mid
  else:
    bottom = mid

print(top)
    




Measured memory_bytes: 104180
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=1e5+10;
LL n,m;
char s[N],t[N];
void main() {
    R(n,m,s,t);
    REP(i,n) {
        if ( m*i%n!=0 ) continue;
        LL j=m*i/n;
        if ( j>=0 && j<m && s[i]!=t[j] ) {
            dump(i,j,s[i],t[j]);
            W(-1);
            return;
        }
    }
    LL ans=n*m/__gcd(n,m);
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::set<int> s;
    for (int i = 0; i < 3; i++) {
        int a; std::cin >> a;
        s.insert(a);
    }
    std::cout << (s.size() == 2 ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (A, B, K) = get!(usize, usize, usize);

    let mut a = A;
    let mut b = B;
    for i in 0..K {
        if i % 2 == 0 {
            if a % 2 == 1 {
                a -= 1;
            }
            a /= 2;
            b += a;
        } else {
            if b % 2 == 1 {
                b -= 1;
            }
            b /= 2;
            a += b;
        }
    }

    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
S = list(input())
"""
if(len(S) == 1):
  print(S[0])
  exit()
cnt = 0
for i in range(1 << len(S)-1):
  f = S[0]
  for j, b in enumerate(format(i, 'b').zfill(len(S)-1)):
    if(b == '1'):
      f += '+'
    f += S[j+1]
  cnt += sum(map(int,f.split('+')))
print(cnt)

"""

cnt = 0
for i in range(1 << len(S)-1):
  f = S[0]
  for j in range(len(S)-1):
    if(((i >> j) & 1)== 1):
      f += '+'
    f += S[j+1]
  cnt += sum(map(int, f.split('+')))
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int N;
unordered_map<string, int> mp;
ll ans;
int main(){
  cin >> N;
  rep(i, N){
    string s;
    cin >> s;
    sort(all(s));
    if(mp.count(s)){
      ans = ans + mp.at(s);
      mp.at(s)++;
    }else{
      mp[s] = 1;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> ans(n);

    rep(i,n){
        ans.at(a.at(i)-1) = i+1;
    }
    rep(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;

}

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

Measured memory_bytes: 37052
#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>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    string s;
    int n;
    cin >> s >> n;
    for(int i = 0; i < s.size(); i++){
        if('z' - s[i] + 1 <= n && s[i] != 'a'){
            n -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
    }
    int c = s[s.size() - 1] - 'a';
//    cout << c << endl;
    c = (c + n) % 26;
//    cout << c << endl;

    s[s.size() - 1] = c + 'a';
    cout << s << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<string, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

// BIT
// initialize : FenwickTree(n)
// add(pos, n): data[pos] += n;
// sum(l, r)  : sum [l, r)
template <typename T>
class FenwickTree
{
    const int n;
    vector<T> data;

  public:
    FenwickTree(int count) : n(count), data(count, 0) { ; }

    void add(int pos, const T &value)
    {
        assert(0 <= pos && pos < n);
        for (int i = pos; i < n; i |= i + 1)
            data[i] += value;
    }

    T sum(int pos) const
    {
        assert(0 <= pos && pos <= n);
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += data[i];
        }
        return res;
    }

    T sum(int l, int r) const
    {
        assert(0 <= l && l <= r && r <= n);
        return sum(r) + (-sum(l));
    }
    using value_type = T;
    using update_type = T;
};

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

    ll N;
    cin >> N;
    vector<int> a(N), xs;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        xs.push_back(a[i]);
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    for (int i = 0; i < N; i++)
    {
        a[i] = lower_bound(xs.begin(), xs.end(), a[i]) - xs.begin();
    }
    ll res = 0;
    FenwickTree<ll> ft(N + 1);
    for (int i = 0; i < N; i++)
    {
        res += ft.sum(a[i]);
        ft.add(a[i], 1);
    }
    cout << N * (N - 1) / 2 - res << endl;
}



Measured memory_bytes: 5960
/**
 *   author: sahushivam
 *   created: 01 September 2019 (Sunday)  17:36:13
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,a,b) for(ll i = a; i<b; i++)
#define MOD 1000000009
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll a,ans,b;
    cin>>a>>b;
    cout<<1+ceil(ld(b-a)/(a-1));

return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  vector<string> s(n);int ans=0;
  rep(i,n){
    string t;cin >> t;
    vsort(t);s[i]=t;
  }
  vsort(s);int cnt=1;
//  rep(i,n)cout << s[i] << endl;
  for(int i=1;i<n;++i){
    if(s[i]==s[i-1]){
      cnt++;
    }else{
      ans+=(cnt*(cnt-1))/2;
      cnt=1;
    }
  }
  ans+=(cnt*(cnt-1))/2;
  cout << ans << endl;

}


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

using namespace std;

int main() {
	double dist, t, speed;

	// D meters away. T mins.	
	cin >> dist >> t >> speed;
	
	double tr = dist/speed, te = t;
	if (tr <= te)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}


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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    rep(i,n){
        cin>>p.at(i);
    }
    sort(p.begin(),p.end());
    int ans=0;
    rep(i,k){
        ans+=p.at(i);
    }
    fin(ans);


    return 0;
}




Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    C[A[i]]++;
  }

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }

  printf("%d",B[n]);

  printf("\n");



  return 0;
}



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

int N, K;
int x[100005], y[100005];
int sW[1005][1005], sB[1005][1005];
bool isB[100005];

int qry(int A[][1005], int x1, int y1, int x2, int y2) {
	if (x2 < x1 || y2 < y1) return 0;
	return A[x2][y2] - (x1?A[x1-1][y2]:0) - (y1?A[x2][y1-1]:0) + (x1&&y1?A[x1-1][y1-1]:0);
}

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

	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		char c;
		cin >> x[i] >> y[i] >> c;
		isB[i] = c == 'B';
		x[i] %= 2*K; y[i] %= 2*K;
		if (x[i] >= K) isB[i] = !isB[i], x[i] -= K;
		if (y[i] >= K) isB[i] = !isB[i], y[i] -= K;

		if (isB[i]) sB[x[i]][y[i]]++;
		else sW[x[i]][y[i]]++;
	}

	for (int i = 0; i < K; ++i) for (int j = 1; j < K; ++j) sW[i][j] += sW[i][j-1], sB[i][j] += sB[i][j-1];
	for (int j = 0; j < K; ++j) for (int i = 1; i < K; ++i) sW[i][j] += sW[i-1][j], sB[i][j] += sB[i-1][j];

	int mx = 0;
	for (int dx = 0; dx < K; ++dx) {
		for (int dy = 0; dy < K; ++dy) {
			int v = qry(sW, dx, dy, K-1, K-1) + qry(sW, 0, 0, dx-1, dy-1)
				  + qry(sB, dx, 0, K-1, dy-1) + qry(sB, 0, dy, dx-1, K-1);
			mx = max(mx, max(v, N-v));
		}
	}

	cout << mx << endl;
}

Measured memory_bytes: 9088