akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  string s, t;
  cin >> s;
  cin >> t;
	
  vector <vector <int> > dp(s.size(), vector <int> (t.size(), 0));
  if (s[0] == t[0]) dp[0][0] = 1;
  for (int i = 1; i < s.size(); ++i) {
    dp[i][0] = dp[i - 1][0];
    if (s[i] == t[0]) {
      dp[i][0] = 1;
    }
  }
  for (int j = 1; j < t.size(); ++j) {
    dp[0][j] = dp[0][j - 1];
    if (s[0] == t[j]) {
      dp[0][j] = 1;
    }
  }
  
  for (int i = 1; i < s.size(); ++i) {
    for (int j = 1; j < t.size(); ++j) {
      if (s[i] == t[j]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  
  int state = dp[s.size() - 1][t.size() - 1];
  int i = s.size() - 1;
  int j = t.size() - 1;
  int I = i;
  string ans("");
  while (state > 0) {
    if (i - 1 >= 0 && dp[i - 1][j] == state) {
      i--;
    } else {
      if (j - 1 >= 0 && dp[I][j - 1] == state) {
        j--;
        i = I;
      } else {
        ans = s[i] + ans;
        state--;
        i--;
        j--;
        I = i;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 38196
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String S = in.nextLine();
        if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt() * 2;
	myout(Math.PI * N);
}

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

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

	int pasta[3];
	for(int i = 0; i < 3; ++i) {
		cin >> pasta[i];
	}

	int juice[2];
	for(int i = 0; i < 2; ++i) {
		cin >> juice[i];
	}

	cout << *min_element(pasta, pasta + 3) + *min_element(juice, juice + 2) - 50 << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll a[3], k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a, a + 3);
	for (int i = 0; i < k; i++)a[2] *= 2;
	ll ans = a[0] + a[1] + a[2];
	cout << ans << endl;
	return 0;
}


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

int a[100035],n,l,t,x,y;
long long cnt;

int main()
{
    scanf("%d%d%d",&n,&l,&t);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d",&x,&y);
        if (y==1){
            x += t;
            cnt += x/l;
            x %= l;
        }else{
            cnt += (x-t)/l;
            x = (x-t)%l;
            if (x < 0) cnt--, x += l;
        }
        a[i] = x;
    }
    std::sort(a+1, a+n+1);
    ((cnt%=n)+=n)%=n;
    for (int i=cnt+1; i<=n; i++) printf("%d\n",a[i]);
    for (int i=1; i<=cnt; i++) printf("%d\n",a[i]);
    return 0;
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    
    int n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];

    ll x = 0;
    for (int i = 2; i < n; i++) x ^= a[i];
    ll s = a[0] + a[1];

    if ((s - x) % 2 != 0 or s < x) {
        cout << -1 << endl;
        return 0;
    }
    ll d = (s - x) / 2;
    DEBUG(d);
    ll ans = 0;
    rep (i, 50) {
        ll mask = 1LL << i;
        if (d & mask) {
            if (x & mask) {
                cout << -1 << endl;
                return 0;
            }
            ans += mask;
        }
    }
    if (ans > a[0]) {
        cout << -1 << endl;
        return 0;
    }
    rrep (i, 50) {
        ll mask = 1LL << i;
        if (d & mask) continue;
        if (x & mask) {
            if (ans + mask <= a[0]) ans += mask;
        }
    }

    if (ans > 0) {
        cout << a[0] - ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}


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

int main() {
    int b, r, g, c, s, t;
    while (cin >> b >> r >> g >> c >> s >> t, b || r || g || c || s || t) {
        int count = 100;
        count += 15 * b;
        t -= 5 * b;
        count += 15 * r;
        t -= 3 * r;
        count += (5 * b + 3 * r) * 15;
        count += 7 * g;
        count += 2 * c;
        count -= 3 * (t - s) + 2 * (5 * b + 3 * r);

        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3012
# 空白区切の入力値を数値の配列で返す
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

# 入力値を数値で返す
def gets_i()
  gets.chomp.to_i
end

def gets_n_array
  n = gets.chomp.to_i
  array = []
  n.times do
    array.push(gets.chomp.to_i)
  end
  return n, array
end

board = []
board.push(gets_i_list)
board.push(gets_i_list)
board.push(gets_i_list)

N, array = gets_n_array

bingo_list =
  board +
  board.transpose +
  [[board[0][0], board[1][1], board[2][2]]] +
  [[board[0][2], board[1][1], board[2][0]]]

bingo_list.each do |b|
  if array.include?(b[0]) && array.include?(b[1]) && array.include?(b[2])
    puts "Yes"
    exit
  end
end
puts "No"


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int A_MAX = 200000;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0;i<n;++i) {
        cin >> a[i];
        a[i] %= m;
        if(i) a[i] += a[i-1];
        a[i] %= m;
    }

    ll ans = 0LL;
    map<ll, ll> cnt;
    cnt[0] = 1LL;
    for(int i=0;i<n;++i) {
        ans += cnt[a[i]]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 7488
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
//END OF TEMPLATE

void main(){
    auto s=scan!string;
    auto t=scan!string;
    foreach(i;0..s.length){
        if(s[i]!=t[i]){
            "No".writeln;
            return;
        }
    }   
    "Yes".writeln;
}


Measured memory_bytes: 3608
//Keep working hard :)
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const int N = 1e5+5;
int a[N];

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}
int main()
{
	IOS;
        //fileIO();
        int a,b;
        cin >> a >> b;
        if(a <= 5)cout << 0;
        else if(a >= 6 && a <= 12)cout << b/2;
        else cout << b;
	return 0;
}


Measured memory_bytes: 892
main = do  
    [a, b, h, m] <- map read . words <$> getLine :: IO [Double]
    let theta = (30 * h - 5.5 * m) * pi / 180  
    let a_times = a ^ 2
    let b_times = b ^ 2
    let total_cos = cos theta

    print $ sqrt ( a_times + b_times - 2 * a * b * total_cos )


Measured memory_bytes: 4520
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(b-a==c-b)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
"""
NTC here
"""
import sys
input= sys.stdin.readline
# import t  hreading
# setrecursionlimit(10**6)
# threading.stack_size(2**26)

def iin(): return int(input())
def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input

def main():
    n=iin()
    h=lin()
    ans=[0]*(n-2)+[abs(h[-2]-h[-1]),0]
    for i in range(n-3,-1,-1):
        ans[i]=min(
            abs(h[i]-h[i+1])+ans[i+1],
            abs(h[i]-h[i+2])+ans[i+2]
            )
    print(ans[0])
        



                









        
main()
#threading.Thread(target=main).start()


Measured memory_bytes: 52116
#include <cstdio>
#include <iostream>
using namespace std;
#define int long long
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
int A,B,N;
signed main()
{
    A=read();B=read();N=read();
    int x=min(B-1,N);
    printf("%lld\n",(A*x)/B);
}


Measured memory_bytes: 3160
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main() {
    ll n;
    set<string> st;
    
    cin >> n;
    REP(i, n){
        string s;
        cin >> s;
        st.insert(s);
    }
    
    ll p[5] = {};
    for(auto x : st){
        if(x[0] == 'M'){
            p[0]++;
        }
        else if(x[0] == 'A'){
            p[1]++;
        }
        else if(x[0] == 'R'){
            p[2]++;
        }
        else if(x[0] == 'C'){
            p[3]++;
        }
        else if(x[0] == 'H'){
            p[4]++;
        }
    }
    
    sort(p, p + 5);
    /*
    REP(i, 5){
        cout << p[i] << ' ';
    }
    cout << endl;
    */
    
    if(p[3] == 0){
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 0;
    REP(i, 3){
        if(p[i]){
            for(int j = i + 1; j < 4; j++){
                ll t = 0;
                for(int k = j + 1; k < 5; k++){
                    t += p[k];
                }
                ans += p[i] * p[j] * t;
                // cout << p[i] << ' ' << p[j] << ' ' << t << endl;
                // cout << i << ' ' << j << ' ' << endl;
            }
        }
    }
    
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  map<int, int> a;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    if(a.count(ai)) a[ai]++;
    else a[ai] = 1;
  }
  int ans = 0;
  for (auto p: a) {
    if(p.second % 2 == 1) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 8204
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl
#define De(...)
using namespace std; 

int _; 

int n,ans[4]={0,0,0,0};
string s,ANS[4]={"AC","WA","TLE","RE"};
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		cin >> s;
		for(int i=0;i<4;i++)
			if(s == ANS[i])
				ans[i]++;
	}
	for(int i=0;i<4;i++)
		printf("%s x %d\n",ANS[i].c_str(),ans[i]);
	return 0;
}


Measured memory_bytes: 3788
#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++)
typedef long long ll;

int main() {
    int s,w; cin >> s >> w;
    if(s <= w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

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

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<pair<char, int>> HF;
  char now = S[0];
  int count = 1;
  for(int i = 1; i < N; i++){
    char pre = now;
    now = S[i];
    if(pre == now) count++;
    else{
      HF.push_back(make_pair(pre, count));
      count = 1;
    }
  }
  HF.push_back(make_pair(S[N-1], count));
//  for(int i = 0; i < HF.size(); i++){
//    std::cout << i << ": (" << HF.at(i).first << ", " << HF.at(i).second << ")"<< std::endl;
//  }
//std::cout << "HF.size() " << HF.size() << std::endl;
//std::cout << "HF.size()-2*K " << HF.size()-2*K << std::endl;
  
  int ans = 0;
  bool check = true;
  for(int i = 0; i+2*K <= HF.size()+1; i++){
//    std::cout << "i: "<< i << std::endl;
    check = false;
    int temp = 0; 
    if(HF.at(i).first == '1'){
      temp += HF.at(i).second;
      i++;
//      std::cout <<"HF.size()-2*K+1 " << HF.size()-2*K+1 << std::endl;
      if(i+2*K > HF.size()+1){
        ans = max(ans, temp);
        break;
      }
    };   
    for(int j = i; j < 2*K-1+i; j++){
//      std::cout << "j: " << j << std::endl;
      temp += HF.at(j).second;
    }
    if(2*K-1+i < HF.size()) temp += HF.at(2*K-1+i).second;
    ans = max(ans, temp);
  }
  if(check){
    for(int i = 0; i < HF.size(); i++) ans += HF.at(i).second;
  }
  std::cout << ans << std::endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<string>x(n);
  for(int i=0;i<n;i++){
  cin>>x.at(i);
  vector<char>y(10);
  for(int j=0;j<10;j++){
  y.at(j)=x.at(i).at(j);
  }
  sort(y.begin(),y.end());
  string z="";
  for(int k=0;k<10;k++){
  z+=y.at(k);
  }
  x.at(i)=z;
  }
  sort(x.begin(),x.end()); 
  x.push_back("");
  long long sum=0;
  long long m=1;
  for(int l=0;l<n;l++){
  if(x.at(l)==x.at(l+1)){
  m++;
  }
  else{
  sum+=m*(m-1)/2;
  m=1;
  }
  }
  cout<<sum<<endl;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> x(n, 0);
	vector<int> y(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		y[i] = x[i];
	}
	
	sort(y.begin(), y.end());

	for (int i = 0; i < n; i++) {
		if (x[i] <= y[n / 2-1]) { cout << y[n / 2] << endl; }
		else { cout << y[n / 2-1] << endl; }
	}

}

Measured memory_bytes: 3712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    int a = s.nextInt();
    int b = s.nextInt();
    int c = s.nextInt();
    System.out.println(a == b && a == c ? "Yes" : "No");
  }
}


Measured memory_bytes: 22100
def cal():
    N=int(input())
    A=list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    ans=1
    for i in A:
        ans = i*ans
        if ans > 1000000000000000000:
            print(-1)
            return
    print(ans)

cal()

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

int main() {
    long long a, b, c, k;
    cin>>a>>b>>c>>k;
    long long sum = 0;
    if(a >= k) {
        cout<<k<<endl;
        return 0;
    } else {
        sum = a;
        k -= a;
        if(b >= k) {
            cout<<sum<<endl;
            return 0;
        } else {
            k -= b;
            sum += k * -1;
        }
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  int s=0,b=0;
  cin>>a;
  for(int i=0;i<a.size();i++){
  	if(a[i]=='C') s++;
	if(a[i]=='F'&&s>=1){
	  b++;
	  break;
	} 
  }
  if(s>=1&&b>=1) cout<<"Yes"<<endl;
  else  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n + 1);
	rep(i, n + 1) cin >> a[i];
	Vec r(n + 1);

	ll rest = 1;
	bool flg = true;
	rep(i, n + 1){
		if(i) rest *= 2;
		chmin(rest, LINF);
		if(a[i] <= rest){
			rest -= a[i];
		}else{
			flg = false;
			break;
		}
		r[i] = rest;
	}
	// co(r);

	if (flg){
		ll ans = 0, node = 0;
		repr(i, n + 1){
			node += a[i];
			ans += min(node, r[i] + a[i]);
		}
		co(ans);
	}
	else
		co(-1);

	return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <string>

using namespace std;

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

	// 1, 4, 9, ... 400 の配列
	// これが長さの2乗と一致すれば長さは整数
	int maxSqrtLength = 400;
	int squareNums[400];
	for (int i = 1; i <= maxSqrtLength; i++)
		squareNums[i - 1] = i * i;

	int pos[10][10];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			cin >> pos[i][j];
		}
	}

	int answer = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			// 重複計算は除外
			if (i < j)
				continue;

			// 二乗距離の計算
			int sqLength = 0;
			for (int k = 0; k < d; k++)
			{
				int diff = abs(pos[i][k] - pos[j][k]);
				sqLength += (diff * diff);
			}

			// 二乗距離とが整数の二乗かどうかの確認
			for (int l = 0; l < maxSqrtLength; l++)
			{
				if (sqLength == squareNums[l])
					answer += 1;
			}
		}
	}

	cout << answer;

	return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    P s, t;
    P pos = MP(0, 0);
    cin >> s.F >> s.S >> t.F >> t.S;
    string o;
    for(int i = s.F; i < t.F; ++i) {
        o += "R";

    }
    for(int i = s.S; i < t.S; ++i) {
        o += "U";

    }
    for(int i = t.F; i > s.F; --i) {
        o += "L";

    }
    for(int i = t.S; i > s.S; --i) {
        o += "D";

    }

    cout << o;
    cout << 'D';
    int p = 0;
    while(o[p] == 'R') {
        cout << char(o[p]);
        ++p;

    }
    cout << "RU";
    while(o[p] == 'U') {
        cout << char(o[p]);
        ++p;

    }
    cout << "LU";
    while(o[p] == 'L') {
        cout << char(o[p]);
        ++p;

    }
    cout << "LD";
    while(p < o.size()) {
        cout << char(o[p]);
        ++p;

    }
    cout << 'R' << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  vector<int> done(102, 0);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    done[p[i]] = 1;
  }
  int left, right;
  for (int k = x; k >= 0; --k) {
    if (!done[k]) {
      left = k;
      break;
    }
  }
  for (int k = x + 1; k < 102; ++k) {
    if (!done[k]) {
      right = k;
      break;
    }
  }
  if (x - left <= right - x) {
    cout << left << endl;
  } else {
    cout << right << endl;
  }
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

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

int main(){
ll a;
cin >> a;
ll year=0;
ll b=100;
while(b<a){
  b*=1.01;
  year++;
}
cout<<year<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool check[3][3];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a[3][3], n;
  REP(i, 3){
    REP(j, 3){
      cin>>a[i][j];
    }
  }
  cin>>n;
  REP(i, n){
    int b;
    cin>>b;
    REP(j, 3){
      REP(k, 3){
        if(a[j][k]==b){
          check[j][k]=true;
        }
      }
    }
  }
  bool ok=false;
  REP(i, 3){
    bool ok2=true;
    REP(j, 3){
      if(!check[i][j]){
        ok2=false;
        break;
      }
    }
    if(ok2){
      ok=true;
      break;
    }
  }
  REP(i, 3){
    bool ok2=true;
    REP(j, 3){
      if(!check[j][i]){
        ok2=false;
        break;
      }
    }
    if(ok2){
      ok=true;
      break;
    }
  }
  if(check[0][0] && check[1][1] && check[2][2]){
    ok=true;
  }
  if(check[0][2] && check[1][1] && check[2][0]){
    ok=true;
  }
  cout<<(ok ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (10000-n)%1000 << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bitset>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(h, w, k);
  vector<vector<char>> field(h, vector<char>(w));

  vector<ll> hcnt(h);
  REP(i, h) {
    REP(j, w) {
      cin >> field[i][j];
      if (field[i][j] == '#') hcnt[i]++;
    }
  }

  ll all = accumulate(hcnt.begin(), hcnt.end(), 0ll);
  ll ans = 0;

  REP(i, 1 << h) {
    bitset<6> hs(i);
    REP(j, 1 << w) {
      bitset<6> ws(j);

      ll cnt = 0;
      REP(hi, 6) if (hs[hi]) cnt += hcnt[hi];
      REP(wi, 6) {
        if (ws[wi]) {
          REP(hi, h) {
            if (!hs[hi] && field[hi][wi] == '#') cnt++;
          }
        }
      }

      ans += all - cnt == k;
    }
  }
  print(ans);
}


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

#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;

typedef long long ll;

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

int main(){
	stack<int> S1;
	stack<pair<int,int> >S2;
	char ch;
	int sum=0;
	for(int i=0;cin>>ch;i++){
		if(ch=='\\')S1.push(i);
		else if(ch=='/'&&S1.size()>0){
			int j=S1.top();
			S1.pop();
			sum+=i-j;
			int a=i-j;
			while(S2.size()>0&&S2.top().first>j){
				a+=S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	} 
	
	vector<int>ans;
	while(S2.size()>0){
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	cout<<ans.size();
	for(int i=0;i<ans.size();i++){
		cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}




Measured memory_bytes: 3236
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
    long n = long.Parse(input[0]);
    long k = long.Parse(input[1]);
    long p = 1000000007;
    long answer = 1;
    for(long i = 1; i <= n+k-1; i++)
    {
      answer *= i;
      answer %= p;
    }
    answer *= DivideModFactorial(n,p);
    answer %= p;
    answer *= DivideModFactorial(k-1,p);
    answer %= p;
	  Console.WriteLine(answer);//nCk(mod p),pは素数
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    for(long i = a; i > a-b; i--)
    {
      answer *= i;
      answer %= p;
    }
    answer *= DivideModFactorial(b, p);
    answer %= p;
    return answer;
  }
  
}



Measured memory_bytes: 18032
//
//AtCoder Beginner Contest 097
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    string s;
    cin >> s;

    int wCntE = count(s.begin(), s.end(), 'W');
    int eCntE = count(s.begin(), s.end(), 'E');

    int wCntW = 0;
    int eCntW = 0;

    int ans = n;
    REP(i,n){
        if (s[i]=='W') {
            wCntE--;
            ans = min(ans, wCntW + eCntE);
            wCntW++;
        }
        else if (s[i]=='E'){
            eCntE--;
            ans = min(ans, wCntW + eCntE);
            eCntW++;
        }
    }

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


Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

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

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

int main(){
    ll a,b; cin >> a >> b;
    ll tmp = gcd(a,b);
    cout << a/tmp*b << endl;
}


Measured memory_bytes: 256
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b,c)   for(ll i=a;i<b;i+=c)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
 
void solve()
{
	ll a,b;
	
	cin>>a>>b;
	
	if(a>b) swap(a,b);
	
	if(a==1 && b==2)
	{
		cout<<3;
	}
	else if(a==1 && b==3)
	{
		cout<<2;
	}
	else
	{
		cout<<1;
	}
}

 
signed main(){
 
    fast;
 
    ll t;
    
    t=1;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

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

__int128_t ans;

int main()
{
	LL n;cin>>n;
	vector<LL> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		if(a[i]==0){
			cout<<0<<"\n";
			return 0;
		}
	}
	LL k = 1e18;
	ans=1;
	for(int i=0;i<n;i++){
		ans*=a[i];
		if(ans > k ){
			ans = -1;break;
		}
	}
	cout<<(LL)ans<<endl;
	return 0;
}


Measured memory_bytes: 3988
using System;
using System.Collections.Generic;//list用
using System.Text.RegularExpressions;//正規表現用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用

//デリゲータの使い方をマスターしたい

class Program
{
    Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static long result;
    static int d;
        static int m;
    StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular();//素数で割った余りを出せで使う★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）カッコ内が初期値
        //Node no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        // delegate int CFunc();//下関数に使うデリゲータ。コイツと同じ引数と戻り値で関数作って、下の評価式の部分に関数名を入れる。
        //PriorityQueue pr = new PriorityQueue<>(評価式);//優先度付キュー★Enqueue()で格納、Dequeue()で取りだし。引数は評価式（大と小のどちらが優先か）。
        //Read1();
        Read2();
        for (int j = 1; j <= m; j++)
        {
            for (int i = 1; i <= d; i++)
            {
                int d10 = i / 10;
                int d1 = i % 10;
                if (d10>1 && d1>1 && j == d10 * d1) { result++; }
            }
        }
        Console.WriteLine(result.ToString());
    }




    static void Read2()
    {
        string[] tmp = Console.ReadLine().Split(' ');
        m=int.Parse(tmp[0]);
        d=int.Parse(tmp[1]);
    }


    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }


}

Measured memory_bytes: 11092
/* In the name of God */
     
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pii pair <int, int>
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;

void solve() {
    int n;
    ll yen = 1e3;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++) {
        if(a[i + 1] > a[i]) {
            ll stock = yen/a[i];
            yen = yen%a[i];
            yen += (a[i + 1])*stock;
            // cout << yen << " ";
        }
    }
    cout << yen;
}
 
int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        // cout << "Case #" << tc << ": ";
        solve();
    } 
}                        

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

const int mod = 1000000007;

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

  //n文字目まで作る方法（n-1文字目、n-2文字目、n-3文字目の値がそれぞれ記載されている通りの時）
  int dp[110][4][4][4] ={0};
  dp[0][3][3][3]=1;

  for(int pos = 1; pos < N+1; pos++){
    for(int i = 0; i < 4; i++){
      for(int j = 0; j < 4; j++){
        for(int k = 0; k < 4; k++){
          for(int l = 0; l < 4; l++){
            //i , j , k,  l ともA = 0, C = 1, G = 2, T = 3
            if(i == 1 && j == 2 && k == 0) continue;
            if(i == 1 && j == 0 && k == 2) continue;
            if(i == 2 && j == 1 && k == 0) continue;
            if(i == 1 && j == 2 && l == 0) continue;
            if(i == 1 && k == 2 && l == 0) continue;
            dp[pos][i][j][k] += dp[pos-1][j][k][l];
            dp[pos][i][j][k] %= mod;
          }
        }
      }
    }
  }

  ll ans = 0;
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 4; j++){
      for(int k = 0; k < 4; k++){
        ans += dp[N][i][j][k];
        ans %= mod;
      }
    }
  }

  cout << ans << endl;

  return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

 
    ll N; cin >> N;
    ll ac=0, wa=0, tle=0, re=0;
    REP(i, N){
        string s; cin >> s;
        if(s == "AC")ac++;
        if(s == "WA")wa++;
        if(s == "TLE")tle++;
        if(s == "RE")re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

void swap(int x, int y) {
    if (x > y) {
        cout << y << " " << x << endl;
    } else {
        cout << x << " " << y << endl;
    }
}

int main() {
    int x, y;
    while(1) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        swap(x, y);
    }
    return 0;
}


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

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

	int a[100][100] = {};
	int b[100] = {};

	int x = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> x;
			a[i][j] = x;
		}
	}

	for (int i = 0; i < m; i++) {
		cin >> x;
		b[i] = x;
	}

	int c;
	for (int i = 0; i < n; i++) {
		c = 0;
		for (int j = 0; j < m; j++) {
			c += a[i][j] * b[j];
		}
		cout << c << endl;
	}

	return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

int n, a[maxn], ans;
main () {
	scanf("%d", &n);
	n += n;
	forn(i, 1, n) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	priority_queue<int> q;
	q.push(a[1]);
	forn(i, 1, n){
		ans += q.top();
		q.pop();
		q.push(a[i + 1]);
		q.push(a[i + 2]);
		i++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
    string a,b;
    cin>>a>>b;
    a+=a;
    bool s=false;
    for(int c=0;c<a.length()/2+5;c++){
	for(int d=0;d<b.length();d++){
	    if(a[c+d]!=b[d])break;
	    if(b.length()-1==d)s=true;
	    }
	}
	if(s)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  string s;
  cin >>s;
  if(s == "AAA" || s ==  "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int calc(int m,int n,int p,int q){
  if( (m==1 && n==0) || (m==0 && n==1) || (m==-1 && n==0) ||
      (m==0 && n==-1) || (m==p && n==q) || (m==-q && n==p) ||
      (m==-p && n==-q) || (m==q && n==-p) || (m==0 && n==0)){
    return 0;
  }
    if( (m*p+n*q) %(m*m+n*n)==0){
      if( (-p*n+m*q)%(m*m+n*n)==0){
	//cout << "baka" << endl;
	//cout << "m " << m<<"n "<<n<< endl;
	return 1;//テ・ツ可イテ」ツつ甘・ツ按?」ツつ古」ツつ?
      }
    }
  //cout << "p " << m<<"q "<<n<< endl;
  return 0;//テ・ツ可イテ」ツつ甘・ツ按?」ツつ古」ツ?ェテ」ツ??
}

int main(){
  int a,m,n;
  bool flag=0;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>m>>n;
    flag=0;
    for(int j=-500;j<500;j++){
      for(int k=-500;k<500;k++){
	if(calc(j,k,m,n) == 1){
	  flag=1;
	  break;
	}
      }
      if(flag==1) break;
    }
    if(flag==1){
      cout<<"C"<<endl;
    }else{
      cout<<"P"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define Sort(v) sort((v).begin(), (v).end())
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
int main(){
    char a;
    cin >> a;
    if ('a' <= a && a <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
}

Measured memory_bytes: 3620
#-*-coding:utf-8-*-
from collections import Counter

def main():
    w = list(input())
    counter = Counter(w)
    for c in set(w):
        if counter[c] % 2 != 0:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char **argv) {
  size_t r, D, x[11];
  cin >> r >> D >> x[0];

  for (int i = 1; i < 11; i++) {
    x[i] = r * x[i - 1] - D;
    cout << x[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
<?php
$str = "0".trim(fgets(STDIN));
$l = strlen($str);
$dp0 = array_fill(0, $l+1, 0);//超えてないやつ
$dp1 = array_fill(0, $l+1, 0);//超えたやつ
for($i = 0; $i < $l; ++$i){
  $s = intval($str[$i]);
  $dp0[$i+1] = min($dp0[$i]+$s, $dp1[$i] + 10 - $s);
  $dp1[$i+1] = min($dp0[$i]+$s+1, $dp1[$i] + 9 -  $s);
}
echo $dp0[$i],"\n";


Measured memory_bytes: 72184
from collections import deque

def sum_to(n):
    return (n+1)*int((n/2))+(n%2)*((n+1)/2)

def expected(n):
    return sum_to(n) / n

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

max_sum = 0
cur_sum = 0
select = deque()
c = 0
for i in P:
    e_val = expected(i)
    select.append(e_val)
    cur_sum += e_val
    if len(select) == K:
        if cur_sum > max_sum:
            max_sum = cur_sum
        cur_sum -= select.popleft()

print(max_sum)

Measured memory_bytes: 25572
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    print(int(input())*2*3.1415926535)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61988
#include<iostream>

int main(){
int a,b,c;
std::cin>>a>>b>>c;
int temp;
if(a>b){
temp = b;
b = a;
a = temp;
}

if(a>c){
temp = c;
c = a;
a = temp;
}

if(b>c){
temp = c;
c = b;
b = temp;
}
std::cout<<a<<" "<<b<<" "<<c<<std::endl;


return 0;

}

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int n,i,x[100000],y[100000];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x[i]);
		y[x[i]]=i;
	}
	for(i=1;i<=n;i++){
		printf("%d ",y[i]);
	}
	return 0;
}

Measured memory_bytes: 2436