akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using CompLib.Util;
using System.Threading;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        long n = sc.NextLong();
        long ans = 0;
        for (long a = 1; a < n; a++)
        {
            for (long b = a; a * b < n; b++)
            {
                // Console.WriteLine($"{a} {b}");
                if (a == b) ans++;
                else ans += 2;
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27516
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N;
string ans;

int main(){
    cin >> N;

    if(N<1200){
        ans="ABC";
    }else if(N<2800){
        ans="ARC";
    }else{
        ans = "AGC";
    }

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




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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i != r; ++i)
#define DF(i, l, r) for(auto i = l; i != r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair <int, int> pii;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int) 1e9 + 7;
const dbl eps = (dbl) 1e-8;
const int maxn = (int) 1e5 + 5;
const dbl pi = acos(-1);

ll a[maxn], b[maxn];
ll ans = 0, n, k;

void check(ll mask)
{
	ll o = 0;
	F(i, 0, n)
	{
		if ((a[i] & mask) == a[i])
			o += b[i];
	}
	ans = max(ans, o);
}

int main()
{
//    fin("t.in");
    sync;
    cin >> n >> k;
    F(i, 0, n)
    {
    	cin >> a[i] >> b[i];
    }
    ans = 0;
    for (int i = 30; i >= 0; --i)
    {
    	if (k & (1 << i))
    	{
    		check((k ^ (1 << i)) | ((1 << i) - 1));
    	}
    }
    check(k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

int main(){
  int ans = 0;
  int N, M;
  cin >> N >> M;
  vector<llong> H(N);
  for(int i=0; i<N; ++i) cin >> H[i];
  vector<int> appear(N, 0);
  vector<int> loose(N, 0);
  for(int i=0; i<M; ++i){
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    appear[a] = 1;
    appear[b] = 1;
    if(H[a] > H[b]) loose[b] = 1;
    else if(H[b] > H[a]) loose[a] = 1;
    else{
      loose[a] = 1;
      loose[b] = 1;
    }
  }
  for(int i=0; i<N; ++i){
    if(appear[i] == 0) ++ans;
    else if(loose[i] == 0) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    string s;
    cin >> s;
    
    lint n = s.length();
    static vector<lint> rem(n+1);
    rem[0] = 0;

    reverse(s.begin(), s.end());
    lint pow10 = 1;
    for(lint i=0; i<n; i++) {
        rem[i+1] = rem[i] + pow10 * (s[i]-'0');
        rem[i+1] %= 2019;
        pow10 *= 10;
        pow10 %= 2019;
    }

    map<lint, lint> counter;
    for(auto& e : rem) counter[e]++;

    lint ans = 0;
    for(auto& e : counter) ans += (e.second) * (e.second-1) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 5232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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

int main() {
	int n;
	cin >> n;
	int fish[n+1];
	rep(i,n) {
		int a, v;
		cin >> a >> v;
		fish[a] = v;
	}
	int mi = 1;
	for(int i=2; i<=n; i++) {
		if(fish[mi] < fish[i]) mi = i;
	}
	cout << mi << ' ' << fish[mi] << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {
    int N, tmp;
    cin >> N;
    vector<int> A(N);
    for (int i = 1; i < N; i++) {
        cin >> tmp;
        A.at(tmp-1) += 1;
    }

    for (int a : A) {
        cout << a << endl;
    }
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	ll int a,b,n;
	cin>>a>>b>>n;
	ll int x=min(b-1,n);
	
	ll int val=floor(a*x/b);
	cout<<val;
}




Measured memory_bytes: 3640
#include<stdio.h>
 
int main()
{
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    long A[n][m],B[m][l],C[n][l];
    //A scanf　関数化したい
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            scanf("%ld",&A[i][j]);
        }
    }
    //B scanf 関数化したい
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<l;j++)
        {
            scanf("%ld",&B[i][j]);
        }
    }
    //C printf
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<l;j++)
        {
            C[i][j] = 0;
            for(int x=0;x<m;x++)
            {
                C[i][j] += A[i][x] * B[x][j];
            }
            if(j != l-1){
                printf("%ld ",C[i][j]);
            }else {
                printf("%ld",C[i][j]);
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2112
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
clock_t start=clock();
inline void ck(){
    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
}
char s[205];int n;
int main(){
	scanf("%d%s",&n,s+1);
	if(n&1)return puts("No"),0;
	fp(i,1,n>>1)if(s[i]!=s[i+(n>>1)])return puts("No"),0;
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;

int N;
vector<lli> H;


int main() {
  cin >> N;
  lli h, last = 0;
  rep(i,N) {
    cin >> h;
    if ( h < last ) {
      cout << "No" << endl;
      return 0;
    } else if ( h >= last + 1 ) h--;

    // H.push_back(h);
    last = h;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
s = input()
len_s = len(s)
a = [int(s[i]) for i in range(len_s)]
sum_list = []


def f(pos,one_sum,block):
    if pos == len_s - 1:
        one_sum += block
        sum_list.append(one_sum)
    else:
        f(pos+1,one_sum+block,a[pos+1])
        f(pos+1,one_sum,10*block+a[pos+1])
    

f(0,0,a[0])
print(sum(sum_list))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int i, j, h, w;
  scanf("%d%d", &h, &w);
  char s[w + 10];
  for(i = 0; i < w + 2; ++i) printf("#");
  printf("\n");
  for(i = 0; i < h; ++i) {
    scanf("%s", s);
    printf("#%s#\n", s);
  }
  for(i = 0; i < w + 2; ++i) printf("#");
  return 0;
}

Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        var xyz = Console.ReadLine().Split(' ');
        var x = int.Parse(xyz[0]);
        var y = int.Parse(xyz[1]);
        var z = int.Parse(xyz[2]);
        Console.WriteLine((x - z) / (y + z));
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n;
    cin>>n;
    int flg=1;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0){flg=0;}
        }
    }
    if(flg==1){cout<<"APPROVED"<<endl;}
    else{cout<<"DENIED"<<endl;}
    return 0;
}

Measured memory_bytes: 256
V_, E_ = map(int, input().split())
A = input().split()
E = [[] for _ in range(V_)]
Used = [[False]*26 for _ in range(V_)]
for _ in range(E_):
    s, t = map(int, input().split())
    As, At = A[s], A[t]
    if As != "?":
        Used[t][ord(As)-97] = True
    if At != "?":
        Used[s][ord(At)-97] = True
    E[s].append(t)
    E[t].append(s)

for i, a in enumerate(A):
    if a == "?":
        for j in range(26):
            if not Used[i][j]:
                A[i] = chr(j + 97)
                for u in E[i]:
                    Used[u][j] = True
                break

print("".join(A))



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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  int maxv = 0;
  int ans = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if (h < maxv) continue;
    chmax(maxv, h);
    ++ans;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
import math

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))

def check(L):
    return sum(math.ceil(a / L)-1 for a in A) <= K

answer=max(A)
lo = 1
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if ok: 
        answer=min(m, answer)
        hi=m
    else:
        lo=m+1
print(answer)




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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

int main()
{
    FastIO 
    ll n;
    cin >> n;
    if(n == 2)
    {
        cout << 1 << "\n";
        return 0;
    }
    ll ans = 2;
    ll num = n-1;
    for(ll i=2; i*i<=num; i++)
    {
        if(num%i == 0)
        {
            ans++;
            if(num/i != i) ans++;
        }
    }
    num = n;
    for(ll i=2; i*i<=num; i++)
    {
        if(num%i == 0)
        {
            ll divisor = i;
            ll num_copy = num;
            while(num_copy%divisor == 0) num_copy /= divisor;
            if(num_copy%divisor == 1) ans++;
            divisor = num/i;
            if(divisor != i)
            {
                ll num_copy = num;
                while(num_copy%divisor == 0) num_copy /= divisor;
                if(num_copy%divisor == 1) ans++;
            }
        }
    }
    cout << ans << "\n";  
    return 0;
}

Measured memory_bytes: 384
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from collections import Counter


def factorize(n: int):
    d = Counter()
    m = 2

    while m * m <= n:
        while n % m == 0:
            n //= m
            d[m] += 1

        m += 1

    if n > 1:
        d[n] += 1

    return d

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b, a%b)

a, b = li()

g = gcd(a, b)
print(len(factorize(g)) + 1)

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        // 変数宣言
        String[][] cardNumber = {{"","",""},{"","",""},{"","",""}};
        String judge = "No";

        // Scannerインスタンス化
        Scanner sc = new Scanner(System.in);
        
        // ビンゴカード数字設定入力
        for( int index=0; index < cardNumber.length; index++ ){
            for( int innerIndex=0; innerIndex<cardNumber[index].length; innerIndex++){
                cardNumber[index][innerIndex] = sc.next();
            }
        }

        // 数字選択化数入力
        int choiceCounter = sc.nextInt();
        String[] selectNumber = new String[choiceCounter + 1];

        // ビンゴ選択入力
        for( int index=0; index <= choiceCounter ; index++ ){
            selectNumber[index] = sc.nextLine();
        }

        sc.close();

        // ビンゴ選択処理（当てた個所には×を入力）
        for( int index=0; index < cardNumber.length; index++ ){
            for( int innerIndex=0; innerIndex<cardNumber[index].length; innerIndex++){
                for(int j=0; j <= choiceCounter; j++){
                    if( cardNumber[index][innerIndex].equals(selectNumber[j]) ){
                        cardNumber[index][innerIndex] = "×";
                    }
                }
            }
        }

        // ビンゴ判定(行)
        for( int index=0; index < cardNumber.length; index++ ){
            if(cardNumber[index][0].equals("×") && cardNumber[index][1].equals("×") && cardNumber[index][2].equals("×")){
                judge = "Yes";
            }
        }

        // ビンゴ判定(列)
        for( int index=0; index < cardNumber.length; index++ ){
            if(cardNumber[0][index].equals("×") && cardNumber[1][index].equals("×") && cardNumber[2][index].equals("×")){
                judge = "Yes";
            }
        }

        // ビンゴ判定（斜め）
        if(cardNumber[1][1].equals("×")){
            if( cardNumber[0][0].equals("×")  && cardNumber[2][2].equals("×") ){
                judge = "Yes";
            }

            if( cardNumber[0][2].equals("×")  && cardNumber[2][0].equals("×") ){
                judge = "Yes";
            }
        }

        // 出力
        System.out.println(judge);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],mn=2e9,mx;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)mn=min(mn,a[i]);
	for(int i=1;i<=n;i++)mx=max(mx,a[i]);
	printf("%d",mx-mn);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int N;
vector<int> tree[200010];

signed main()
{
	cin >> N;
	for (int i = 2; i <= N; i++)
	{
		int a;
		cin >> a;
		tree[a].push_back(i);
	}

	for (int i = 1; i <= N; i++)
	{
		cout << tree[i].size() << endl;
	}
}




Measured memory_bytes: 14520
#include<cstdio>

using namespace std;

int main()
{
	int p,n,k=0,sum=0,nsum=0;
	while(~scanf("%d,%d",&p,&n)){
		sum+=p*n;
		nsum+=n;
		k++;
	}
	printf("%d\n%d\n",sum,(int)((double)nsum/k+0.5));
	return 0;
}

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

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int num = int.Parse(Reader.ReadLine());
        int max = GetMax(1, num, num);
        List<int> ans = GetAns(max, num);
        ans.Reverse();
        StringBuilder str = new StringBuilder();
        ans.ForEach(a => str.AppendLine(a.ToString()));
        Console.Write(str);
    }

    private List<int> GetAns(int num, int total)
    {
        List<int> ans = new List<int>();
        int remain = total;
        for (int i = num; i >= 1; i--)
        {
            if (i >= remain)
            {
                ans.Add(remain);
                break;
            }
            ans.Add(i);
            remain -= i;
        }
        return ans;
    }

    private int GetMax(int min, int max, int target)
    {
        int mid = (min + max) / 2;
        if (IsCorrect(mid, target))
        {
            if (mid - min <= 1)
            {
                return mid;
            }
            return GetMax(min, mid, target);
        }
        else
        {
            if (max - mid <= 1)
            {
                return max;
            }
            return GetMax(mid, max, target);
        }
    }


    private bool IsCorrect(long num, int remain)
    {
        if (num >= remain)
        {
            return true;
        }
        if (num * (num + 1) / 2 < remain)
        {
            return false;
        }
        return IsCorrect(num - 1, (int)(remain - num));
    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

7



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3160
w_arr = Array.new(10) { |i| i=0 }
k_arr = Array.new(10) { |i| i=0 }

10.times do |i|
  w_arr[i] = gets.to_i
end

10.times do |i|
  k_arr[i] = gets.to_i
end

puts "#{w_arr.sort.reverse[0..2].inject(:+)} #{k_arr.sort.reverse[0..2].inject(:+)}"

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

using namespace std;
#define mx 100000
int ar[mx+2];
int DP[mx+2];
  int n,m;
int dp(int pos){
//cout<<pos<<endl;
   if(pos==n)return 1;
  // cout<<pos<<endl;
   if(pos>n)return 0;

   int &ret=DP[pos];
   if(ret!=-1)return ret;
   ret= 0;
   if(ar[pos+1]!=1)ret+=dp(pos+1);
   if(ar[pos+2]!=1)ret+=dp(pos+2);
   if(ret>=1000000007)ret-=1000000007;
  // cout<<ret<<endl;
   return ret;
}
int main(){


   cin>>n>>m;
   for(int i=1;i<=m;i++){
   int x;
     cin>>x;
     ar[x] =1;
   }
   memset(DP,-1,sizeof DP);
   int ans =dp(0);
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int h[100000];
  int ans=0;
  rep(i,n){
    cin>>h[i];
    if(h[i]>=k) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())

l = []
for i in range(n):
    s,p = map(str,input().split())
    p = int(p)
    l.append([s,p,i+1])

# print(l)
l = sorted(l, key=lambda x: x[1],reverse=True)
# print(l)
l = sorted(l, key=lambda x: x[0])
# print(l)

for i in range(len(l)):
    print(l[i][2])




Measured memory_bytes: 38256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    int main() {
      // #ifndef ONLINE_JUDGE
      //  // for getting input from input.txt
      //  freopen("input.txt", "r", stdin);
      //  // for writing output to output.txt
      //  freopen("output.txt", "w", stdout);
      // #endif
      string s;
      cin>>s;
      if(s.at(1) == 'B'){
        cout<<"ARC"<<"\n";
      }
      else{
        cout<<"ABC"<<"\n";
      }
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main(){
  int i,j,n,m,A[100],key;
  scanf("%d",&j);
  for(i=0 ; i<j ; i++){
    scanf("%d",&A[i]);
  }
  for(i=0 ; i<j-1 ;i++){
  printf("%d ",A[i]);
  }
  printf("%d",A[i]);
  printf("\n");
  for(n=1 ; n<j ; n++){
    key = A[n];
    m = n-1;
    while (m>=0 && A[m]>key){
      A[m+1] = A[m];
      m--;
      A[m+1] = key;
    }
    for(m=0 ; m<j-1 ; m++){
	printf("%d ",A[m]);
    }
    printf("%d",A[m]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	size_t N;
	cin >> N;
	string s;
	vector<string> w;
	
	cin >> s;
	w.push_back(s);
	for (size_t i = 1; i <N; ++i) {
		string k;

		cin >> k;
		w.push_back(k);
		if (s[s.size()-1] != k[0]) {
			cout << "No" << endl;
			return 0;
		}
		s = k;

	}
	SORT(w);
	w.erase(unique(w.begin(), w.end()),w.end());
	if (w.size() != N) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
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; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N; cin >> N;
  string S; cin >> S;
  //main
  
  
  // output
  if(N%2 != 0){cout << "No" << endl;}
  else{
    for(int i=0; i<N/2; i++){
      if(S[i] != S[i+N/2]){cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
  res = X - i * 500
  if res < 0:
    break
  for j in range(B+1):
    res =  X - i * 500 - j * 100
    if res < 0:
      break
    if res % 50 == 0 and res / 50 <= C:
      ans += 1
print(ans)

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

long long int N, A, B;
char S[100001];
int na, nb;

int main(){
    cin >> N >> A >> B;
    scanf("%s", S);
    int le = strlen(S);
    for(int i = 0; i < N; i++){
        if(na >= A + B){
            printf("No\n");
            continue;
        }
        if(S[i] == 99){
            printf("No\n");
            continue;
        }
        if(S[i] == 97){
            printf("Yes\n");
            na++;
            continue;
        }
        if(nb < B){
            printf("Yes\n");
            na++;
            nb++;
            continue;
        }else{
            printf("No\n");
            continue;
        }
    }
    return 0;
}


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

int main(){
  int N,T,M=10000;cin>>N>>T;
  for(int i=0;i<N;i++){
    int c,t;cin>>c>>t;
    if(t<=T){
      M=min(c,M);
    }
  }
  if(M<10000){
    cout<<M<<endl;
  }else{
    cout<<"TLE"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100

int a[N];
int count;

void init(){
    count = 0;
}

int pop(){
    return a[--count];
}

void push(int v){
    a[count++] = v;
}

int main(void){
    char s[11];
    int i;
    int v1,v2;

    init();

    while( scanf("%s", s) != EOF) {

        if(s[0] == '+'){
            v1 = pop();
            v2 = pop();
            push(v2+v1);
        }

        else if(s[0] == '-'){
            v1 = pop();
            v2 = pop();
            push(v2-v1);
        }

        else if(s[0] == '*'){
            v1 = pop();
            v2 = pop();
            push(v2*v1);
        }

        else push(atoi(s));
    }

    printf("%d\n", a[0]);

    return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // dist[n] = ノードnまでのの重み
  vector<ll> parent;

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    d.resize(N); //Node情報,ans
    parent.resize(N);
    rep(i,N){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    G[s].emplace_back((edge){t, cost});
  }

  void dijkstra(ll s){
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que; //ansが小さい順に出る
    que.push(P(0,s)); // P < ans , Node >
    while(!que.empty()){
      P p = que.top(); que.pop(); //pに <ans,Node> 入れる
      ll v = p.second; //vに Node 入れる
      if(d[v] < p.first) continue; //すでに良い数値が入っているならパス
      rep(i,G[v].size()){
        edge& E = G[v][i];
        if(d[E.to] > d[v] + E.cost){ //更新するなら
          d[E.to] = d[v]+ E.cost;
          parent[E.to] = v; //親を記録,goalから遡れば道順
          que.push(P(d[E.to], E.to));
        }
      }
    }
  }
};



void Main(){

  int N;
  cin>>N;

  graph g(N);

  rep(i,N-1){
    ll a,b,c;
    cin>>a>>b>>c;
    g.add_edge(a-1,b-1,c);
    g.add_edge(b-1,a-1,c);
  }

  int Q,K;
  cin>>Q>>K;

  g.dijkstra(K-1);

  rep(i,Q){
    int x,y;
    cin>>x>>y;
    cout<< g.d[x-1]+g.d[y-1]<<"\n";
  }

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


struct Edge {
    int src, dest, cost;
    Edge(int dest, int cost) : src(-1), dest(dest), cost(cost) {}
    Edge(int src, int dest, int cost) : src(src), dest(dest), cost(cost) {}
};

int prim(vector<vector<Edge>> g){
    int ans = 0;
    vb used(g.size(), false);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.emplace(0, 0);
    while (!pq.empty()){
        auto p = pq.top();
        pq.pop();
        if (used[p.second]) continue;
        used[p.second] = true;
        ans += p.first;
        for (Edge &e : g[p.second]) {
            pq.emplace(e.cost, e.dest);
        }
    }
    return ans;
}

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

    int n, x, y;
    cin >> n;

    vector<pair<pair<int, int>, int>> srtx, srty;
    for (int i = 0; i < n; i++){
        cin >> x >> y;
        srtx.emplace_back(make_pair(x, y), i);
        srty.emplace_back(make_pair(y, x), i);
    }
    sort(all(srtx));
    sort(all(srty));

    int a, b, c, d, p1, p2, cost;
    vector<vector<Edge>> g(n);
    for (int i = 0; i < n - 1; i++){
        a = srtx[i].first.first;
        b = srtx[i].first.second;
        c = srtx[i + 1].first.first;
        d = srtx[i + 1].first.second;
        p1 = srtx[i].second;
        p2 = srtx[i + 1].second;
        cost = min(abs(a - c), abs(b - d));
        g[p1].emplace_back(p2, cost);
        g[p2].emplace_back(p1, cost);

        a = srty[i].first.first;
        b = srty[i].first.second;
        c = srty[i + 1].first.first;
        d = srty[i + 1].first.second;
        p1 = srty[i].second;
        p2 = srty[i + 1].second;
        cost = min(abs(a - c), abs(b - d));
        g[p1].emplace_back(p2, cost);
        g[p2].emplace_back(p1, cost);
    }

    cout << prim(g) << endl;

    return 0;
}


Measured memory_bytes: 23212
while True:
    H, W = map(int,raw_input().split())
    if H == W == 0:
        break
    room = [list(raw_input()) for i in range(H)]
    x,y = 0,0
    while True:
        tile = room[y][x]
        room[y][x] = '*'
        if tile == '>':
            x += 1
        elif tile == '<':
            x -= 1
        elif tile == 'v':
            y += 1
        elif tile == '^':
            y -= 1
        elif tile == '.':
            print x,y
            break
        else:
            print 'LOOP'
            break

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n, 0);
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a]++;
  }

  ll ans = 1;
  if (n % 2) {
    for (int i = 0; i < n; i += 2) {
      if (i == 0 && cnt[i] == 1)
        ;
      else if (i != 0 && cnt[i] == 2)
        ans = ans * 2 % MOD;
      else
        ans = 0;
    }
  } else {
    for (int i = 1; i < n; i += 2) {
      if (cnt[i] == 2)
        ans = ans * 2 % MOD;
      else
        ans = 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
import math
def trial_division(fact_dict):    # It is necessary that n > 2
    global n
    f = 2
    while True:
        if f ** 2 <= n:
            if n % f == 0:
                if f in fact_dict:
                    fact_dict[f] += 1
                else:
                    fact_dict[f] = 1
                n = int(n / f)
                break
            else:
                f += 1
        else:
            if n in fact_dict:
                fact_dict[n] += 1
            else:
                fact_dict[n] = 1
            n = 1
            break


N, P = map(int, input().split())
n = P
fact_dict = {}
ans = 1
lst = []
while n > 1:
    trial_division(fact_dict)
for i in range(len(fact_dict)):
    keys = list(fact_dict.keys())
    key = keys[-i]
    val = fact_dict[key]
    if val >= N:
        power = val // N
        lst.append(key ** power)

if lst != []:
    for i in lst:
        ans *= i

print(ans)


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

int main(){
    int n;
    cin >> n;
    vector<pair<char, int>> v(2 * n);
    for(auto& x : v) cin >> x.first >> x.second, --x.second;

    vector<int> b_pos(n), w_pos(n);
    for(int i = 0; i < 2 * n; ++i){
        if(v[i].first == 'B')
            b_pos[v[i].second] = i;
        if(v[i].first == 'W')
            w_pos[v[i].second] = i; }

    vector<vector<int>> pre_b(n, vector<int>(n + 1, 0)),
        pre_w(n, vector<int>(n + 1, 0));

    for(int i = 0; i < n; ++i){
        int cnt_w = 0, cnt_b = 0;
        for(int j = 0; j < i; ++j){ 
            if(b_pos[i] < b_pos[j]) ++cnt_b;
            if(w_pos[i] < w_pos[j]) ++cnt_w; }

        pre_b[i][0] = cnt_b;
        pre_w[i][0] = cnt_w;
        for(int j = 0; j < n; ++j){
            if(b_pos[i] < w_pos[j]) ++cnt_b;
            if(w_pos[i] < b_pos[j]) ++cnt_w;
            pre_b[i][j + 1] = cnt_b;
            pre_w[i][j + 1] = cnt_w; } }

    vector<vector<int>> d(n+1, vector<int>(n+1, 0));
    d[0][0] = 0;
    for(int i = 0; i <= n; ++i){
        for(int j= 0; j <= n; ++j){
            if(i == 0 && j == 0) continue;
            d[i][j] = min((i == 0 ? 1000000000 : d[i-1][j] + pre_b[i-1][j]),
                (j == 0 ? 1000000000 : d[i][j-1] + pre_w[j-1][i])); } }

    cout << d[n][n] << endl;
    return 0; }


Measured memory_bytes: 47360
#include <stdio.h>
int main(void)
{
    int n;
    int i;
    int x;

    scanf("%d", &n);
    for (i = 1; i <= n; i++)
    {
        x = i;
        if (x % 3 == 0)
        {
            printf(" %d", i);
        }
        else
        {
            while (x)
            {
                if (x % 10 == 3)
                {
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");
}


Measured memory_bytes: 2088
#include <bits/stdc++.h> // {{{
using namespace std;
// clang-format off
#define ARG4(_1,_2,_3,_4,...) _4
#define rep(...) ARG4(__VA_ARGS__,FOR,REP)(__VA_ARGS__)
#define REP(i, a) FOR(i,0,a)
#define FOR(i, a, b) for(int i=(a);i<(int)(b);++i)
#define rrep(...) ARG4(__VA_ARGS__,RFOR,RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i,0,a)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(int)(a);--i)
#define ALL(c) begin(c),end(c)
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template<typename __VA_ARGS__>inline
#define USE2(T, ...) USE1(T,typename __VA_ARGS__)

using ll=long long;
template<typename T>using vec=vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<T>ndvec(T&&v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T&&v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pu(T&&x){cout<<x;}
USE1(T)void pr(T&&x){cout<<x<<'\n';}
USE2(T,...Ts)void pr(T&&x,Ts...xs){cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T)ostream&operator<<(ostream&o,vector<T>const&v){int f=0;for(auto&&x:v){if(f++)o<<' ';o<<x;}return o;}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout.setf(ios::fixed);
  }
} iosetup; //}}}
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

const ll mod = 1000000007;

int N;
string S[2];

ll pre[3][3];

int mex(int a, int b) {
  rep(i, 3) {
    if (a != i && b != i)
      return i;
  }
}

signed main() {
  N = in(); // <= 52
  cin >> S[0] >> S[1];

  int s = 1;
  if (S[0][0] == S[1][0]) {
    rep(i, 3) pre[i][i] = 1;
  } else {
    s++;
    rep(i, 3) rep(j, 3) if (i != j) {
      pre[i][j] = 1;
    }
  }

  rep(x, s, N) {
    ll nxt[3][3] = {};
    bool tate = S[0][x] == S[1][x];
    if (tate) {
      rep(j, 3) rep(k, 3) {
        if (j != k) {
          int i = mex(j, k);
          nxt[i][i] += pre[j][k];
          nxt[i][i] %= mod;
        } else {
          rep(i, 3) if (k != i) {
            nxt[i][i] += pre[k][k];
            nxt[i][i] %= mod;
          }
        }
      }
    } else {
      rep(j, 3) rep(k, 3) rep(i, 3) rep(l, 3) {
        if (j != i && k != l && i != l) {
          nxt[i][l] += pre[j][k];
          nxt[i][l] %= mod;
        }
      }
      x++;
    }
    memcpy(pre, nxt, sizeof(nxt));
  }

  ll ans = 0;
  rep(i, 3) rep(j, 3) ans += pre[i][j];
  pr(ans % mod);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	int a[n+5];
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum^=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cout<<(sum^a[i])<<" ";
	}
	cout<<endl;
	
	
}

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




typedef long long ll;
#define mod 1000000007
int N, K;
ll dp[2010][2010];
//-----------------------------------------------------------------
int main() {
	cin >> N >> K;
	rep(i, 1, N - K + 2) dp[N - K + 1][i] = 1;
	rep(i, N - K + 2, N + 1) {
		ll su = 0;
		rep(j, 0, i + 1) {
			su += dp[i - 1][j];
			dp[i][j] = su % mod;
		}
	}
	ll ans = dp[N][N];
	rep(i, 0, max(0, N - K - 1)) ans = 2 * ans % mod;
	cout << ans << endl;
}

Measured memory_bytes: 22912
#include<iostream>
using namespace std;
int main(){
	int a,b,c,k,m,x;
	cin >> a >> b >> c >> k;
	m=a;
	if(m<b)
		m=b;
	if(m<c)
		m=c;
    x=(a+b+c-m);
	while(k--)
	{
		m*=2;
	}
	cout << m+x << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()+'?'
ans=10**10
arr=[0]*n
ans1=n-s.count('#')
ans2=n-s.count('.')
if s[0]=='.':
  arr[0]=1
for i in range(1,n):
  if s[i]=='.':
    arr[i]=arr[i-1]+1
  else:
    arr[i]=arr[i-1]
for i in range(1,n):
  tmp=(i-arr[i-1])+(arr[-1]-arr[i])
  if tmp<ans:
    ans=tmp
print(min(ans,ans1,ans2))

Measured memory_bytes: 11236
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    string s;
    cin >> s;
    ll n = s.size();
    s.push_back('R');
    vector<ll> ans(n,0);
    ll start = 0;
    ll end = 0;
    ll top = 0;

    for (ll i = 0; i < n; i++){
        if (s[i] == 'L' && s[i+1] == 'R'){
            end = i+1;
            ll even = 0;
            ll odd = 0;
            if (start%2 == 0){
                if (end%2 == 0){
                    even = (end - start)/2;
                    odd = (end - start)/2;
                }
                else{
                    even = ((end - start)/2) +1;
                    odd = (end - start)/2;
                }
            }
            else {
                if (end%2 == 0){
                    even = (end - start)/2;
                    odd = ((end - start)/2) +1;
                }
                else{
                    even = (end - start)/2;
                    odd = (end - start)/2;
                }
            }

            for (ll j = start; j < end; j++){
                if (s[j] == 'R' && s[j+1] == 'L'){
                    if (j % 2 == 0){
                        ans[j] = even;
                        ans[j+1] = odd;
                    }
                    else{
                        ans[j] = odd;
                        ans[j+1] = even;
                    }
                    break;
                }
            }
            start = i+1;
        }
    }

    rep(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003

int main()
{
    ios;
    ll n,i,ans=0;
    cin>>n;
    ll divisors[n+1];
    memset(divisors,0,sizeof(divisors)); 
    for (ll i=1;i<=n;i++)
    { 
        for (ll j=1;j*i<=n;j++) 
            divisors[i*j]++; 
    } 
    rep(i,n)
        ans+=((i+1)*divisors[i+1]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 81752
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

long long int dp[100][10001], v[100], w[100];

int main()
{
	int N, W;

	cin >> N >> W;

	for (int i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i];
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (j < w[i])
			{
				dp[i][j] = i == 0 ? 0 : dp[i - 1][j];
			}
			else
			{
				dp[i][j] = i == 0 ? v[i] + dp[i][j - w[i]] : max(dp[i - 1][j], max(v[i] + dp[i][j - w[i]], v[i] + dp[i - 1][j - w[i]]));
			}
		}
	}

	cout << dp[N - 1][W] << endl;

	return 0;
}


Measured memory_bytes: 10900
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
	int n, l;
  	bool check = false;
	int mix = 0;
    cin >> n >> l;
  if((l*(l+n-1))>0){
    check = true;
  }
  if(check){
    if((l+n-1)>0){
    for(int i=1;i<n;i++){
        mix += l+i;
    }
    }else{
     for(int i=0;i<n-1;i++){
       mix += l+i;
     }
    }
  }else{
      for(int i=0;i<n;i++){
       mix += l+i;
     }
  }
  
  cout << mix << endl;
  return 0;
    
}


Measured memory_bytes: 256