akhauriyash/Code-Regression huggingface dataset:
/*  ex4_3
    supercomputerjoi    */

#include <stdio.h>

// calculate answer
int calc(int west, int east);

// calculate xth tower's height
int xHeight(int size);

int main(void){

    int west, east;

    // input A B
    scanf("%d %d", &west, &east);

    // print answer
    printf("%d\n", calc(west, east));

    return 0;
}

int calc(int west, int east){

    int ans = xHeight(east - west) - east;

    return ans;
}

int xHeight(int size){

    if(size > 1){
        return xHeight(size - 1) + size;
    }

    return 1;
}

Measured memory_bytes: 128
function main(input) {
  var a = input.split(" ")[0]-0, b = input.split(" ")[1]-0, c = input.split(" ")[2]-0;
  for(var i= Math.min(a,b);i>=1;i--){
    if(a%i==0 && b%i==0) c--;
    if(c==0) {console.log(i); return}
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;
#define DIM 1000007
#define INF 10E16
#define MAXN 1023
#define LG 18

typedef long long  ll;
typedef long double ld;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pair<ll, ll> pll;
typedef pll parr[DIM];
struct pp {
	ll a, b;
	bool operator <(const pp& V)const {
		if (a == V.a)return b < V.b;
		return a < V.a;
	}
	bool operator ==(const pp& V)const {
		if (a == V.a && b == V.b)return 1;
		return 0;
	}
};


ll n, w;
parr A;
ll D[107][DIM];
int main()
{
	cin >> n >> w;
	for (int i = 1; i <= n; i++)cin >> A[i].first >> A[i].second;
	ll sum = 0;
	for (int i = 0; i <= n; i++) {

		for (int j = 0; j <= DIM; j++)D[i][j] = INF;
	}
	D[0][0] = 0;
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		sum += A[i].second;
		for (ll j = 0; j <= sum; j++) {
 			ll p = D[i - 1][j];
			if (j>=A[i].second)
			p = min(p, D[i - 1][j - A[i].second] + A[i].first);
			D[i][j] = p;
			if (D[i][j] <= w)res = max(res, j);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 792960
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,t; cin >> n >> t;
    vector<int>v;
    rep(_,n){
        int a,b; cin >> a >> b;
        if(b <= t)v.push_back(a);
    }
    cout << (v.size() ? to_string(*min_element(all(v))) : "TLE")<< endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
const auto inf=LLONG_MAX; 
int main() 
{
	fastio
	//t_case
	{
		ll sum=0,f=1,ans=0,n,m=0,z=0,mx=-inf,mn=inf,q;cin>>n;
		ll a[n]; take (a,n); mn=a[0];
		fr(i,1,n) {
			if (mn<=a[i]) mn=a[i];
			else {
				ans+=mn-a[i];
			}
		}
		cout<<ans;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 5144
s = list(map(int, input().split()))
n=s[0]
dp=[[0]*3 for i in range(n)]
s = list(map(int, input().split()))
dp[0][0]=s[0]
dp[0][1] = s[1]
dp[0][2] = s[2]
for i in range(1,n):
    s = list(map(int, input().split()))
    dp[i][0] = max(dp[i-1][1]+s[0], dp[i-1][2]+s[0])
    dp[i][1] = max(dp[i-1][0]+s[1], dp[i-1][2]+s[1])
    dp[i][2] = max(dp[i-1][0]+s[2], dp[i-1][1]+s[2])
print(max(dp[n-1]))

Measured memory_bytes: 22824
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

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

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 3e3 + 345;
const ll MOD = 998244353;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

main() {
	fre("");
	ACCELERATE;
	
	int n;
	cin >> n;
	
	n *= 2;
	int a[N];
	for (int i = 0; i < n; i++) cin >> a[i];
	
	sort(a, a + n);
	
	ll ans = 0;
	for (int i = 0; i < n; i += 2) {
		ans += a[i];
	}
	
	cout << ans;
	return 0;
}
/*
 
*/


Measured memory_bytes: 768
h,w=map(int, input().split())
a=[]
b=[]
c=[]
d=[]

if h%3==0 or w%3==0:
    print(0)
    exit()

a.append(h//3*w)
a.append(w//2*(h-h//3))
a.append((w-w//2)*(h-h//3))
ans1=max(a)-min(a)

b.append((h//3+1)*w)
b.append(w//2*(h-(h//3+1)))
b.append((w-w//2)*(h-(h//3+1)))
ans2=max(b)-min(b)

c.append(w//3*h)
c.append(h//2*(w-w//3))
c.append((h-h//2)*(w-w//3))
ans3=max(c)-min(c)

d.append((w//3+1)*h)
d.append(h//2*(w-(w//3+1)))
d.append((h-h//2)*(w-(w//3+1)))
ans4=max(d)-min(d)

print(min(ans1,ans2,ans3,ans4,min(h,w)))




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
 
bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

string s;
int k;
int cnt[114514];
signed main(){
	cin>>s>>k;
	rep(i,s.size()){
		cnt[i]=(26-(s[i]-'a'))%26;
	}
	rep(i,s.size()){
		if(k>=cnt[i]){
			k-=cnt[i];
			s[i]='a';
		}
	}
	if(k){
		s[s.size()-1]=(char)((((s[s.size()-1]-'a')+k)%26)+'a');
	}
	cout<<s<<endl;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=stdIn.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=stdIn.nextInt();
		}
		System.out.print(a[n-1]);
		for(int i=n-2;i>=0;i--)
			System.out.print(" "+a[i]);
		System.out.println("");
	}	
}

Measured memory_bytes: 26280
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int ans = 0;
  sort(a, a+n);
  for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (a[k] < a[i] + a[j]) 
                    ++ans;
                else break;
                
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
x = "" #10000
y = "" #5000
z = "" #1000 (N-x-y)
ans = 0

for a in range(N+1):
    for b in range(N+1):
        if 10000 * a + 5000 * b + 1000 * (N - a - b) == Y:
            if (N - a - b)<0:
                pass
            else:
                x = str(a)
                y = str(b)
                z = str(N - a - b)
                ans = 1
                break
        else:
            pass

if ans == 1:
    print(x + " " + y + " " + z)
else:
    print("-1 -1 -1")

Measured memory_bytes: 9200
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b;
	if(a==1)
	a+=13;
	if(b==1)
	b+=13;
	if(a>b)
	cout<<"Alice";
	else if(b>a)
	cout<<"Bob";
	else
	cout<<"Draw";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, x, ans = 0; cin >> n >> a;
    x = a;

    do {
        if(x >= a) ans++;
        x = min(x, a);
    } while(cin >> a);
    cout << ans;
}


Measured memory_bytes: 256
N = int(input())
S = [str(input()) for i in range(N)]
a = S.count("AC")
w = S.count("WA")
t = S.count("TLE")
r = S.count("RE")
print("AC x" + " " + str(a))
print("WA x" + " " + str(w))
print("TLE x" + " " + str(t))
print("RE x" + " " + str(r))

Measured memory_bytes: 16300
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;


int main()
{
	string a;
	cin >> a;
	if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) {
		cout << "Bad" << endl;
	}
	else
		cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int64 modpow(int64 a, int64 x) {
    if (x == 0) return 1;
    if (x == 1) return a;
    if (x % 2 == 0) {
        int64 h = modpow(a, x/2);
        return h * h % MOD;
    }
    return a * modpow(a, x-1) % MOD;
}

int64 modinv(int x) {
    return modpow(x, MOD-2);
}

int64 modfact[100002];
void set_modfact() {
    modfact[0] = 1;
    for (int j = 1; j <= 100001; ++j) modfact[j] = j * modfact[j-1] % MOD;
}

int N, T;
int64 D[100000];

int main() {
    set_modfact();

    cin >> N >> T;
    for (int j = 0; j < N; ++j) cin >> D[j];

    int64 accum[100001];
    fill(accum, accum + 100001, 0);

    for (int j = 0; j < N; ++j) ++accum[D[j]];
    for (int j = 1; j <= 100000; ++j) accum[j] += accum[j-1];

    int64 arr[100001];
    arr[100000] = 1;
    for (int j = 100000-1; j > 0; --j) {
        int rlim = min(100000, j + T);
        int n = accum[rlim] - accum[j], k = accum[j] - accum[j-1];
        int mul = modfact[n+k] * modinv(modfact[n]) % MOD;
        arr[j] = (mul * arr[j+1]) % MOD;
    }

    cout << arr[1] << endl;

    return 0;
}

Measured memory_bytes: 6204
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	int a,b;
	cin >> a >> b;
	int ans = max(0,a - 2 * b);
	cout << ans << ln;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char s[maxn];

int main()
{
	//freopen("t1.in","r",stdin);
	cin>>(s+1);
	if(s[3]==s[4]&&s[5]==s[6]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool g[410][410];
int n,m,ans;
int main(){
	scanf("%d%d",&n,&m);
	memset(g,1,sizeof(g));
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		if(g[x][y]){
			g[x][y]=g[y][x]=false;
			for(int i=1;i<=n;++i)if(!g[x][i])
				g[y][i]=g[i][y]=false;
			for(int i=1;i<=n;++i)if(!g[y][i])
				g[x][i]=g[i][x]=false;
		} else for(int i=1;i<=n;++i)g[x][i]=g[i][x]=g[y][i]=g[i][y]=false;
	}
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			ans+=g[i][j];
	printf("%d",ans);
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = input()
LS = len(S)

LEFT = [None] * LS
RIGHT = [None] * LS

# 最寄りのR
near_R = 0
for i in range(LS):
    s = S[i]
    if s == 'R':
        near_R = i
    else:
        LEFT[i] = near_R

# 最寄りのL
near_L = LS - 1
for i in range(LS - 1, -1, -1):
    s = S[i]
    if s == 'L':
        near_L = i
    else:
        RIGHT[i] = near_L

ans = [0] * LS

# LEFTから
for i in range(LS):
    if LEFT[i] == None:
        continue

    near_R = LEFT[i]
    d = i - near_R
    if d % 2 == 0:
        ans[near_R] += 1
    else:
        ans[near_R+1] += 1

# RIGHT
for i in range(LS):
    if RIGHT[i] == None:
        continue

    near_L = RIGHT[i]
    d = near_L - i

    if d % 2 == 0:
        ans[near_L] += 1
    else:
        ans[near_L - 1] += 1

print(" ".join((map(str, ans))))


Measured memory_bytes: 15220
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <stack>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <cctype>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;
	vi A(N);
	rep(i, N) cin >> A[i];
	rep(i, N) A[i] -= i + 1;
	sort(begin(A), end(A));
	int M = A[N / 2];
	ll ans = 0;
	rep(i, N) ans += abs(A[i] - M);
	cout << ans << endl;
	return 0;
}


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

s = list(s)

l1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
l1 = list(l1)

l2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
l2 = list(l2)

s1 = [0]*len(s)
s2 = [0]*len(s)

for i in range(len(s)):
	s1[i] = l1.index(s[i])

for i in range(len(s)):
	s2[i] = l2[s1[i]+n] 

#リスト１つずつくっつけて文字列にする
ans = ''
for i in range(len(s2)):
	ans = ans + s2[i]

print(ans)

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

int main(){
  string s;
  cin >> s;
  
  for(int i = 0; i < 3; i++){
    char k = s.at(i);
    if(k == '1') s.at(i) = '9';
    if(k == '9') s.at(i) = '1';
  }
  
  cout << s << endl;
}

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

int N;

vector<int> S[400001];
vector<int> T[400001];

vector<pair<int,int>> PU,PR,PD,PL;

int ans;
int intinf=1000000000;

void F(){
 rep(x,400001){
  if(S[x].empty() || T[x].empty()) continue;
  sort(S[x].begin(),S[x].end()); sort(T[x].begin(),T[x].end());
  T[x].push_back(intinf/5);
  int q=0;
  rep(p,S[x].size()){
   while(T[x][q]<S[x][p]) q++;
   ans=min(ans,(T[x][q]-S[x][p])*10);
  }
 }
 rep(x,400001){ S[x].clear(); T[x].clear(); }
}

int main() {
 ans=intinf;

 scanf("%d",&N);
 rep(i,N){
  int x,y; char c;
  scanf("%d%d %c",&x,&y,&c);
  if(c=='U') PU.push_back({x,y});
  if(c=='R') PR.push_back({x,y});
  if(c=='D') PD.push_back({x,y});
  if(c=='L') PL.push_back({x,y});
 }

 for(auto& p:PU) S[p.first].push_back(p.second);
 for(auto& p:PD) T[p.first].push_back(p.second);
 F();

 for(auto& p:PR) S[p.second].push_back(p.first);
 for(auto& p:PL) T[p.second].push_back(p.first); 
 F();

 ans/=2; intinf/=2;

 for(auto& p:PU) S[p.first+p.second].push_back(p.second);
 for(auto& p:PR) T[p.first+p.second].push_back(p.second);
 F();

 for(auto& p:PU) S[p.first-p.second+200000].push_back(p.second);
 for(auto& p:PL) T[p.first-p.second+200000].push_back(p.second);
 F();

 for(auto& p:PL) S[p.first+p.second].push_back(p.second);
 for(auto& p:PD) T[p.first+p.second].push_back(p.second);
 F();

 for(auto& p:PR) S[p.first-p.second+200000].push_back(p.second);
 for(auto& p:PD) T[p.first-p.second+200000].push_back(p.second);
 F();


 if(ans==intinf) cout<<"SAFE"<<endl;
 else cout<<ans<<endl;

 return 0;
}



Measured memory_bytes: 39468
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[3*n];
        for(int i=0;i<3*n;i++){
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        long[] lsum = new long[3*n+1];
        PriorityQueue<Integer> right = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });
        PriorityQueue<Integer> left = new PriorityQueue<>();
        for(int i=0;i<n;i++){
            lsum[i+1] = lsum[i] + a[i];
            left.add(a[i]);
        }
        Integer tmp;
        for(int i=n;i<2*n;i++){
            tmp = left.peek();
            if(a[i] > tmp){
                lsum[i+1] = lsum[i] + a[i] - tmp;
                left.poll();
                left.add(a[i]);
            }else{
                lsum[i+1] = lsum[i];
            }
        }
        long[] rsum = new long[3*n+1];
        for(int i=3*n;i>2*n;i--){
            rsum[i-1] = rsum[i] + a[i-1];
            right.add(a[i-1]);
        }

        for(int i=2*n;i>n;i--){
            tmp = right.peek();
            if(a[i-1] < tmp){
                rsum[i-1] = rsum[i] + a[i-1] - tmp;
                right.poll();
                right.add(a[i-1]);
            }else{
                rsum[i-1] = rsum[i];
            }
        }
        long max = Long.MIN_VALUE;
        for(int i=n;i<=2*n;i++){
            max = Math.max(max, lsum[i] - rsum[i]);
        }
        System.out.println(max);
        

    }

}

Measured memory_bytes: 69464
/**
 *  Author: Wasi Ur Rahman
 *  FROM RMSTU
**/
#include <bits/stdc++.h>
using namespace std;
// defines
#define ll long long
#define MOD 100000
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sc scanf
#define pf printf
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(d, min(a, min(b, c)))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(d, max(a, max(b, c)))
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 3.141592653589793238462643
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;
#define elif else if
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
/* important funct */
inline int Int(){int c;scanf("%d",&c);return c;}
#define Int Int()
void sortStr(string &str)
{sort(str.begin(), str.end());}
bool isPrime(ll n){if(n <= 1)return false;for (ll i = 2; i * i < n; i++)if (n % i == 0)return false;return true;}
ll ManualLcm(ll a,ll b){return((a)*(b)/gcd(a,b));}
ll fact(ll n){ll res = 1;for(ll i = n;i>=1;i--)res *= i;return res;}
ll nCr(ll n,ll r){return (fact(n)/(fact(r)*fact(n-r)));}
ll nPr(ll n,ll r){return fact(n)/fact(n-r);}
ll mod(ll a, ll mod){ll res = a%mod;if(res<0)res=res + mod;return res;}
ll modpow(ll a, ll n, ll mod){ll res=1;while(n>0){if(n&1) res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
int a[1001];
/**************************************
** A main function starts from here  **
***************************************/
int main()
{
    fast;/*
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif
    */
    int n=Int,k=Int;int cnt = 0;
    for(int i = 1;i<=k;i++){
      int d=Int;
      int arr[d];
      for(int j = 0;j<d;j++)
      {
        arr[j]=Int;
        a[arr[j]-1]++;
      }
    }
    for(int i = 0;i<n;i++){
        if(a[i] == 0)
          cnt++;
      }
    cout << cnt << endl;

}


Measured memory_bytes: 3720
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, x] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)
const l = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  b = [0]
  for (let i = 1; i < n + 1; i++) {
    const bounce = b[i - 1] + l[i - 1]

    b.push(bounce)
  }

  return b.filter(e => x >= e).length
}

console.log(ans())


Measured memory_bytes: 9420
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, *data = map(int, readlines())
    d = [int(i) for i in data]
    mi = min(d)
    if mi > n:
        print(5)
        return
    n = (n+mi-1)//mi
    print(n+4)
if __name__ == '__main__':
    main()


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

#define ALL(v) (v).begin(), (v).end()

class DisjointSet{
private:
  vector<int> rank, p;
  void link(int x,int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
public:
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i = 0; i < size; i++){
      makeSet(i);
    }
  }
  void makeSet(int x){
    p[x] = x, rank[x] = 0;
  }
  void Union(int x,int y){
    link(findSet(x),findSet(y));
  }
  int findSet(int x){
    return( x != p[x] ? p[x] = findSet(p[x]) : p[x]);
  }
};

int main()
{
  int N;
  while(cin >> N, N){
    DisjointSet UnionFind(N * N);
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        int x, y;
        cin >> x >> y;
        UnionFind.Union( i * N + j, y * N + x);
      }
    }
    vector< bool > size(N * N, false);
    for(int i = 0; i < N * N; i++){
      size[UnionFind.findSet(i)] = true;
    }
    cout << count(ALL(size), true) << endl;
  }
}

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

using namespace std;

int main(){
string S; cin >> S; string T;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == '0'){T.push_back('0');}
    else if(S[i] == '1'){T.push_back('1');}
    else{T = T.substr(0,T.size() - 1);}}
  
  cout << T << endl;
  
  return 0;}

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

using namespace std;

int edgecol[100005];
int maxcol = 0;

void color(vector<vector<pair<int, int>>>* arr, int vert, int pcol)
{
	int col = 1;
	if (vert >= arr->size()) return;
	for (auto j : (*arr)[vert])
	{
		if (col == pcol) col++;
		color(arr, j.second, col);
		edgecol[j.first] = col;
		if (col > maxcol) maxcol = col;
		col++;
	}
	return;
}

int main()
{
	vector<vector<pair<int, int>>> adjList;

	int n, a, b;
	cin >> n;
	adjList.resize(n);
	for (int i = 0; i < n - 1; i++)
	{
		cin >> a >> b;
		adjList[a].push_back(pair<int, int>(i, b));
	}
	color(&adjList, 1, -1);
	cout << maxcol << endl;
	for (int i = 0; i < n - 1; i++)
	{
		cout << edgecol[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 8320
#include<stdio.h>
#include<algorithm>
struct A{
	int h,w;
	int d;
}a[999999];
int n;
bool compare(const A &p, const A &q)
{
	if(p.d < q.d)return true;
	else if(p.d == q.d && p.h < q.h)
		return true;
	return false;
}
void inil()
{
	int i, j;
	for(i=1; i<=200; i++)
	{
		for(j=i+1;j<=200;j++)
		{
			a[n].h = i;
			a[n].w = j;
			a[n].d = i*i + j*j;
			n++;
		}
	}
	std::sort(a,a+n,compare);
}
void find_d(int n,int m)
{
	int d = n*n + m*m;
	A k;
	k.h = n;
	k.w = m;
	k.d = d;
	int l,r;
	int mid;
	l=0;r=n;
	while(l<r)
	{
		mid = (l+r)/2;
		if(compare(a[mid],k))
			l = mid+1;
		else
			r = mid;
	}
	int i;
	i = l-20;
	if(i<0)i=0;
	for(;;i++)
	{
		if(a[i].d < k.d)continue;
		else if(a[i].d == k.d) 
		{
			if(a[i].h < k.h) continue;
			else break;
		}
	}
	i++;
	printf("%d %d\n",a[i].h,a[i].w);
}
int main()
{
	inil();
	while(1)
	{
		int n, m;
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		find_d(n,m);
	}
}

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

int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	for(auto &i:P)cin >> i;
	for(auto &i:P)i--;
	vector<int> pos(N);
	for(int i=0;i<N;i++)pos[P[i]]=i;
	
	set<int> s;
	s.insert(pos[N-1]);
	long long ans=(long long)(N)*(N-1)/2;
	
	for(int i=N-2;i>=0;i--){
		int p=pos[i];
		int l,r,ll,rr;
		auto it=s.lower_bound(p);
		
		if(it==s.end())r=rr=N;
		else{
			r= *it;
			if(++it==s.end())rr=N;
			else rr= *it;
			--it;
		}
		if(it==s.begin())l=ll=-1;
		else{
			l= *(--it);
			if(it==s.begin())ll=-1;
			else ll= *(--it);
		}
		//printf("i=%d,ll=%d,l=%d,r=%d,rr=%d\n",i,ll,l,r,rr);
		ans+=(long long)(l-ll)*(r-p)*i;
		ans+=(long long)(rr-r)*(p-l)*i;
		s.insert(p);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	string s;
	getline(cin,s);
	int i,pos;
	pos=s.find(',');
	s[pos]=' ';
//	cout<<s;
	pos=s.find(',');
	s[pos]=' ';
	cout<<s;
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	int res=0,n,m;
	cin >> n >> m;
	if (n > 1) {
		res += n*(n - 1) / 2;
	}
	if (m > 1) {
		res += m*(m - 1) / 2;
	}
	cout << res << endl;
	return(0);
}

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

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc153_c();
        }

        static void abc153_c()
        {
            // ABC153 C - Fennec vs Monster
            // 強い順K個に必殺技、残りは攻撃
            long[] nk = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            long[] H = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            long ans = 0;
            if (nk[0] > nk[1])
            {
                Array.Sort(H);
                for (int i=0; i < nk[0] - nk[1]; i++) ans += H[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 998244353;
template<typename T>
T modpow(T a,unsigned long long b,unsigned long long MOD){
  T base=a,ans=T(1LL);
  while(b){
    if(b&1){
      ans=ans*base%MOD;
    }
    base=base*base%MOD;
    b>>=1;
  }
  return ans;
}
void solve(long long N, std::vector<long long> D){
  vector<ll> d(N);
  ll mx=*max_element(D.begin(),D.end());
  REP(N){
    if((i==0&&D[i]!=0)||(i!=0&&D[i]==0)){
      cout<<0<<endl;
      return;
    }
    ++d[D[i]];
  }
  dump(d);
  ll ans=1;
  REP(mx+1){
    if(i==0)continue;
    ans=(ans*modpow(d[i-1],d[i],MOD))%MOD;
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, std::move(D));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define INF 999999999
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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 int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


int main()
{
	int a,b,c,d;
	int ret = 0;
	cin >> a >> b >> c >> d;
	if (a >= c) {
		if (d <= a) {
			ret = 0;
		}
		else if (a >= c && b <= d) {
			ret = b - a;
		}
		else if (b > d) {
			ret = d - a;
		}
	}
	else {
		if (b <= c) {
			ret = 0;
		}
		else if (b >= c && b <= d) {
			ret = b - c;
		}
		else if (b > d) {
			ret = d - c;
		}
	}
	
	
	cout << ret << endl;
	return 0;
}


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

using namespace std;

int main() 
{
    long long a,b,c,d,ans;
    cin>>a>>b>>c>>d;
    ans=max(a*c,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class A_KenkenRace {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			int c = in.nextInt() - 1;
			int d = in.nextInt() - 1;
			char[] s = in.next().toCharArray();
			boolean[] canA = calcReachability(s, c);
			boolean[] canB = calcReachability(s, d);
			if (!canA[a] || !canB[b]) {
				out.println("No");
				return;
			}
			if (c < d) {
				out.println("Yes");
				return;
			}
			for (int i = b; i < n; i++) {
				if (i > 0 && s[i - 1] != '#' && s[i] != '#' && i + 1 < n && s[i + 1] != '#') {
					boolean[] fa = calcReachability(s, i - 1);
					boolean[] fb = calcReachability(s, i);
					if (fa[a] && fb[b] && canA[i + 1] && canB[i]) {
						out.println("Yes");
						return;
					}
					break;
				}
			}
			out.println("No");
		}

		private boolean[] calcReachability(char[] s, int dst) {
			int n = s.length;
			boolean[] can = new boolean[n];
			can[dst] = s[dst] != '#';
			for (int i = n - 1; i >= 0; i--) {
				for (int j = 1; j <= 2; j++) {
					if (s[i] != '#' && i + j < n && can[i + j]) {
						can[i] = true;
					}
				}
			}
			return can;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 25300
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main() {
    string W;
    cin >> W;

    int count = 0;
    while (true) {
        string T;
        cin >> T;

        if (T == "END_OF_TEXT") { break; }

        if (W.size() != T.size()) {
            continue;
        }
        for (int i = 0; i < W.size(); i++) {
            if (W[i] != tolower(T[i])) {
                break;
            }
            if (i == W.size() - 1) {
                count++;
            }
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array& vec, int n) { for (int i = 0; i < n; i++) cin >> vec[i]; }
inline bool between(int first, int last, int n) { return first <= n && n <= last; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int k, n;
int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };

// day, pizza, renzoku
int dp[101][3][2];
const int MOD = 10000;

int main(void)
{
	while(cin >> n >> k && n)
	{
		memset(dp, 0, sizeof(dp));
		Array kimari(n+1);
		for (int i = 0; i < k; i++)
		{
			int a, b; cin >> a >> b;
			kimari[--a] = b;
		}

		if(kimari[0])
			dp[0][kimari[0] - 1][0] = 1;
		else
			dp[0][0][0] = dp[0][1][0] = dp[0][2][0] = 1;
		for (int i = 1; i < n; i++)
		{
			for (int j = 0; j < 3; j++) //今日
			{
				if(kimari[i] && kimari[i] - 1 != j) continue;

				dp[i][j][1] = dp[i-1][j][0];
				for (int k = 0; k < 3; k++) //前日
				{
					if(j != k)
						dp[i][j][0] = (dp[i][j][0] + dp[i - 1][k][0] + dp[i - 1][k][1]) % MOD;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < 3; i++)
		{
			ans += dp[n-1][i][0] + dp[n-1][i][1];
		}
		cout << ans % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#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>
using ll = long long;

//LLONG_MAX
#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 MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#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()
using namespace std;

int N;
int X[1000];
int Y[1000];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> X[i] >> Y[i];
	}

	bool is_ki = ((abs(X[0]) + abs(Y[0])) % 2) == 1;

	REP(i, N)
	{
		if (((abs(X[i]) + abs(Y[i])) % 2) == (is_ki ? 0 : 1))
		{
			cout << "-1" << endl;
			return 0;
		}
	}

	if (is_ki)
	{
		cout << 32 << endl;
	}
	else
	{
		cout << 33 << endl;
		REP(i, N)
		{
			X[i]++;
		}
		cout << 1 << " ";
	}

	int a[32];
	REP(i, 32)
	{
		a[i] = (int)pow(2, 31 - i);
		cout << a[i] << (i == 31 ? "" : " ");
	}
	cout << endl;

	REP(i, N)
	{
		if (!is_ki)
		{
			cout << "L";
		}

		int x = 0;
		int y = 0;

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


		REP(j, 32)
		{
			int min_diff = LLONG_MAX;
			int min = -1;
			for (int d = 0; d < 4; d++)
			{
				int xx = a[j] * dx[d];
				int yy = a[j] * dy[d];
				int diff = abs(X[i] - (x + xx)) + abs(Y[i] - (y + yy));
				if (min_diff > diff)
				{
					min_diff = diff;
					min = d;
				}
			}

			switch (min)
			{
			case 0: cout << "R"; break;
			case 1: cout << "U"; break;
			case 2: cout << "L"; break;
			case 3: cout << "D"; break;
			}

			x += a[j] * dx[min];
			y += a[j] * dy[min];
		}

		cout << endl;
	}
}








Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

int time_memo[51][11];
bool memo[51][11];

int main(void){
  int M, T, P, R;
  int m, t, p, j;
  vector<pair<int, pair<int, int> > > v;

  while(cin >> M >> T >> P >> R, M || T || P || R){
    v.clear();

    for(int i=1; i<=T; i++){
      for(int k=1; k<=P; k++){
        time_memo[i][k] = 0;
        memo[i][k] = false;
      }
    }

    for(int i=0; i<R; i++){
      cin >> m >> t >> p >> j;
      if(j == 0){
        time_memo[t][p] += m;
        memo[t][p] = true;
      } else {
        time_memo[t][p] += 20;
      }
    }

    for(int i=1; i<=T; i++){
      int t = 0, c = 0;
      for(int k=1; k<=P; k++){
        if(memo[i][k] == true){
          ++c;
          t += time_memo[i][k];
        }
      }

      v.push_back(make_pair(c, make_pair(-1 * t, i)));
    }
    sort(v.begin(), v.end(), greater<pair<int, pair<int, int> > >());
    
    cout << v[0].second.second;
    int tbuf = v[0].second.first, mbuf = v[0].first;
    for(int i=1; i<v.size(); i++){
      if(tbuf == v[i].second.first && mbuf == v[i].first){
        cout << "=" << v[i].second.second;
      } else {
        cout << "," << v[i].second.second;
        tbuf = v[i].second.first; mbuf = v[i].first;
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	
	int i = 0;
	int na, nb, nc;
	while (!(a % 2 || b % 2 || c % 2)) {
		i++;
		if (i > 114514) {
			i = -1;
			break;
		}
		
		na = (b + c) / 2;
		nb = (a + c) / 2;
		nc = (a + b) / 2;
		
		a = na;
		b = nb;
		c = nc;
	}
	
	std::cout << i << std::endl;
	
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dob double
int main(){
	int a,b;
	cin>>a>>b;
	if (a > 9 || b>9){
		cout<<-1;
	}
	else{
		cout<<a*b;
	}
	return 0;
}


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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL);
typedef long long li;
const int INF = 1e9 + 12;
//#define int long long
const int N = 1e5 + 10;
int dp[N][3];
signed main(){

	int n;
	cin>>n;
	int a , b , c;
	cin>>a>>b>>c;

	dp[0][0] = a;
	dp[0][1] = b;
	dp[0][2] = c;

	for(int i = 1 ; i < n ; ++i){

		cin>>a>>b>>c;
		dp[i][0] = a + max(dp[i-1][1] , dp[i-1][2]);
		dp[i][1] = b + max(dp[i-1][0] , dp[i-1][2]);
		dp[i][2] = c + max(dp[i-1][1] , dp[i-1][0]);
	}

	cout<<max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2]))<<endl;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    from collections import defaultdict
    dd = defaultdict(int)
    
    N=I()
    A=LI()
    B=LI()
    
    cntA=[0]*(N+1)
    cntB=[0]*(N+1)
    
    for i in range(N):
        cntA[A[i]]+=1
        cntB[B[i]]+=1
        
    cnt=[0]*(N+1)
    # 合計がNより多いと無理
    for i in range(N+1):
        v1=cntA[i]
        v2=cntB[i]
        if v1+v2>N:
            print("No")
            exit()
        cnt[i]=v1+v2
       
    ans=B[::-1]
    
    same=-1
    for i in range(N):
        if A[i]==ans[i]:
            same=A[i]
            break
    
    sames=[]
    nots=[]
    for i in range(N):
        if A[i]==same and ans[i]==same:
            sames.append(i)
        elif A[i]!=same and ans[i]!=same:
            nots.append(i)
            
    if len(nots)<len(sames):
        print("No")
        exit()
    
    for i in range(len(sames)):
        ans[sames[i]],ans[nots[i]] = ans[nots[i]], ans[sames[i]]
        

 
    print("Yes")
    print(' '.join(map(str, ans)))
                
            


main()


Measured memory_bytes: 143188
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;
 const ll MOD = 1000000007;
 // const ll INF = 1000000000000000000LL;
 
 int main(){
	 string s;
	 cin >> s;
	 int cnt=0;
	 rep(i,s.size()/2){
		 if(s[i]!=s[s.size()-1-i]) cnt++;
	 }
	 cout << cnt << endl;
   return 0;	
 }

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  ll d = abs(a - b);
  ll s = w - v;

  if (d + s * t > 0) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct edge{
  ll from;
  ll to;
  ll cost;
};

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

  ll N,M;
  cin>>N>>M;
  vector<int>A(M),B(M),C(M);
  for(int i=0;i<M;i++)cin>>A[i]>>B[i]>>C[i];
  for(int i=0;i<M;i++)A[i]--,B[i]--;

  vector<edge>v(M);

  for(int i=0;i<M;i++)v[i]={A[i],B[i],-C[i]};

  vector<ll>d(2*N,LONG_MAX);
  d[0]=0;
  int n=0;
  bool ok=true;
  while(true){
    bool update=false;
    for(auto it:v){
      if(d[it.from]!=LONG_MAX && d[it.to]>d[it.from]+it.cost){
        d[it.to]=d[it.from]+it.cost;
        if(n>=2*N-1&&it.to==N-1)ok=false;
        update=true;
      }
    }
    if(!update)break;
    n++;
    if(n>=2*N)break;
  }
  if(ok)cout<<-d[N-1]<<endl;
  else cout<<"inf"<<endl;

  return 0;
}


Measured memory_bytes: 384