akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

public class Main {

	int INF = 1 << 28;
	int w, h;
	boolean[][][] map;
	int[][][] dp;
	boolean visited[][];
	LinkedList<P> que;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			h = sc.nextInt();
			w = sc.nextInt();
			if( (h|w) == 0) break;
			map = new boolean[h][w][4];
			dp = new int[h][w][4];
			visited = new boolean[h][w];
			que = new LinkedList<P>();
			for(int i=0;i<2*h-1;i++) for(int j=0;j<((i%2==0)? w-1:w); j++) {
				if(i%2==0) map[i/2][j][2] = map[i/2][j+1][0] = ( sc.nextInt() == 0 )? true: false;
				else map[(i-1)/2][j][3] = map[(i-1)/2+1][j][1] = ( sc.nextInt() == 0 )? true: false;
			}
			for(int i=0;i<h;i++) for(int j=0;j<w;j++) for(int k=0;k<4;k++) {
				if( !map[i][j][k] ) continue;
				map[i][j][k] = false;
				dp[i][j][k] = bfs(j, i);
				map[i][j][k] = true;
			}
			System.out.println(dijkstra());
		}
	}
	int[] dx = {-1,0,1,0};
	int[] dy = {0,-1,0,1};
	
	int bfs(int x, int y) {
		for(boolean[] a: visited)fill(a, false);
		que.clear();
		P now = new P(x, y, 0);
		que.add(now);
		for(;!que.isEmpty();) {
			now = que.removeFirst();
			if( now.x == w-1 && now.y == h-1) return now.c;
			for(int i=0;i<4;i++) {
				if(!map[now.y][now.x][i]) continue;
				int nx = now.x + dx[i];
				int ny = now.y + dy[i];
				if( !visited[ny][nx]) {
					visited[ny][nx] = true;
					que.addLast(new P(nx, ny, now.c+1));
				}
			}
		}
		return INF;
	}
	
	int dijkstra() {
		PriorityQueue<P> que = new PriorityQueue<P>(1, new MyComp());
		int[][] c = new int[h][w];
		for(int[] a: c) fill(a, INF);
		P now = new P( w-1, h-1, 0 );
		c[h-1][w-1] = 0;
		que.add(now);
		
		for(;!que.isEmpty();) {
			now = que.remove();
			if(now.x == 0 && now.y == 0) return now.c;
			if(now.c != c[now.y][now.x]) continue;
			for(int i=0;i<4;i++) {
				if( !map[now.y][now.x][i] ) continue;
				int nx = now.x + dx[i];
				int ny = now.y + dy[i];
				int nc = now.c + 1;
				nc = max(nc, dp[ny][nx][(i+2)%4]);
				if( c[ny][nx] <= nc ) continue;
				c[ny][nx] = nc;
				que.add(new P(nx, ny, nc));
			}
		}
		
		return -1;
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
	
	class MyComp implements Comparator<P> {

		@Override
		public int compare(P p1, P p2) {
			// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
			return p1.c-p2.c;
		}
		
	}
	
	class P implements Comparable<P>{
		int x, y, c;
		P(int x, int y, int c) {
			this.x = x;
			this.y = y;
			this.c = c;
		}
		@Override
		public int compareTo(P p) {
			// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
			return c - p.c;
		}
	}
}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29


int main(){
int n,t;
cin >> n>>t;
vector<int> lis;

for(int i=0;i<n;i++){
int c,ts;
cin >> c >> ts;
if(t>=ts)lis.push_back(c);
}
if((int)lis.size()==0){
cout << "TLE";
}else{
sort(lis.begin(),lis.end());
cout << lis[0];
}


}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
	long long n,a,b,c;
	scanf("%lld",&n);
	for(a=1ll;a<=3500ll;a++)
		for(b=1ll;b<=3500ll;b++){
			if(4ll*a*b-n*a-n*b!=0ll)
			if((n*a*b)%(4ll*a*b-n*a-n*b)==0ll&&(n*a*b)/(4ll*a*b-n*a-n*b)>0ll&&(n*a*b)/(4ll*a*b-n*a-n*b)<=3500){
				printf("%lld %lld %lld\n",a,b,(n*a*b)/(4ll*a*b-n*a-n*b));
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
//#define int long long

void solve() {
	string s; cin >> s;
    int res = 0;
    rep(i, 4) {
        if(s[i] == '+') res ++;
        else res --;
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

struct edge {
    long long to,cost;
};
long long N,M;

vector<vector<edge> > g(100010);
bool dfs(long long x, vector<bool> &visited, vector<long long> &W){
    bool flg = true;
    visited[x] = 1;
    for (int i = 0; i < g[x].size(); i++){
        long long To = g[x][i].to;
        long long Co = g[x][i].cost;
        if (!visited[To]){
            W[To] = W[x] + Co;
            flg *= dfs(To,visited,W);
        } else if (W[To] != W[x] + Co) {
            return false;
        }
    }
    return flg;
}

int main(){
    cin >> N >> M;
    vector<bool> visited(100010,0);
    vector<long long> W(100010,0);
    
    for (int i = 0; i < M; i++){
        long long l,r,d; cin >> l >> r >> d;
        l--; r--;
        g[l].push_back({r,d});
        g[r].push_back({l,-d});
    }
    for (int i = 0; i < N; i++){
        if (visited[i]) continue;
        W[i] = 0;
        if (!dfs(i,visited,W)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
 long long modpow(long long a,long long n){
  long long res = 1;
  long long mod = n + 2;
  while(n > 0){
   if(n&1) res = res * a % mod;
   a = a * a % mod;
   n >>= 1;
  }
  return res;
 }
 long long inverse(long long x,long long modding){
  return modpow(x,modding-2);
 }

ll calc(int x,int y){
  //xC(i+j)
  ll bunbo = 1;
  ll bunbotemp = x;
  while(bunbotemp>0){
    bunbo *= bunbotemp;
    bunbotemp--;
    bunbo %= MOD;
  }
  ll bunsi = 1;
  ll bunsitemp=x+y;
  bunbotemp = x;
  while(bunbotemp>0){
    bunsi*= bunsitemp;
    bunsi %= MOD;
    bunsitemp--, bunbotemp--;
  }
  return bunsi * inverse(bunbo, MOD) % MOD;

}
int main() {
  int X, Y;
  cin >> X >> Y;
  if((X+Y)%3!=0){
    puts("0");
    return 0;
  }
  int n = (2 * Y - X) / 3, m = Y - 2 * n;
  if(n<0||m<0){
    puts("0");
    return 0;
  }
  ll ans = calc(n, m);
  if (ans <= 0) ans += MOD;
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	p := nextInt()

	pnum := a*3 + p

	fmt.Println(pnum / 2)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
n, t = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
  a[i], b[i] = map(int, input().split())

dp = [[[0] * (t+1) for i in range(n+1)] for j in range(2)]
for i in range(n):
  for d in range(2):
    for l in range(1,t+1):
      if(l < a[i]):
        dp[d][i+1][l] = max(dp[d][i][l], d*(b[i]+dp[0][i][l-1]))
      else:
        dp[d][i+1][l] = max(dp[d][i][l], b[i]+dp[d][i][l-a[i]], d*(b[i]+dp[0][i][l-1]))

print(dp[1][n][t])

Measured memory_bytes: 183256
/*
 * atcoder/abc125/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <functional> // function
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/* セグメントツリー */
template<class Monoid> struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int SIZE_R;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
  void init(int n) {
    SIZE_R = 1;
    while (SIZE_R < n) SIZE_R *= 2;
    dat.assign(SIZE_R * 2, UNITY);
  }

  /* set, a is 0-indexed */
  void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
  void build() {
    for (int k = SIZE_R - 1; k > 0; --k)
      dat[k] = F(dat[k*2], dat[k*2+1]);
  }

  /* update a, a is 0-indexed */
  void update(int a, const Monoid &v) {
    int k = a + SIZE_R;
    dat[k] = v;
    while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
  }

  /* get [a, b), a and b are 0-indexed */
  Monoid get(int a, int b) {
    Monoid vleft = UNITY, vright = UNITY;
    for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
      if (left & 1) vleft = F(vleft, dat[left++]);
      if (right & 1) vright = F(dat[--right], vright);
    }
    return F(vleft, vright);
  }
  inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }

  /* debug */
  void print() {
    for (int i = 0; i < SIZE_R; ++i) {
      cout << (*this)[i];
      if (i != SIZE_R-1) cout << ",";
    }
    cout << endl;
  }
};
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

int N;

void solve() {
  cin >> N;
  int a;
  SegTree<int> seg(N, [](int a, int b) { return gcd(a, b); }, 0);
  loop(n,0,N) {
    cin >> a;
    seg.set(n, a);
  }
  seg.build();

  int max_ = 0;
  loop(n,0,N) {
    chmax(max_, gcd(seg.get(0, n), seg.get(n+1, N)));
  }

  cout << max_ << endl;
}

int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1280
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
B = sorted(A)
B = set(B[1::2])
C = [i%2==1 and a not in B for i, a in enumerate(A)]
print(sum(C))


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

int main()
{
  long X;
  cin >> X;
  
  long happiness = 0;

  happiness += X / 500 * 1000;
  X -= X / 500 * 500;
  
  happiness += X / 5 * 5;
  
  cout << happiness << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    cout <<s.substr(0,3)<<endl;
    return 0;
}

Measured memory_bytes: 3624
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    char a;
    cin >> a;
    if('A' <= a && a <= 'Z') cout << "A\n";
    else cout << "a\n";

    return 0;
}

Measured memory_bytes: 3564
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n,q=MI()
v=[0]*n
c=[0]*n
g=[[] for i in range(n)]
for i in range(n-1):
    a,b=MI()
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x=MI()
    c[p-1]+=x

#print(c)


def bfs(x):
    p=deque()
    p.append(x)
    while p:
        cur=p.popleft()
        v[cur]=1
        for i in g[cur]:
            if v[i]==0:
                p.append(i)
                c[i]+=c[cur]
bfs(0)

print(*c)

Measured memory_bytes: 106900
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

const ll B_MOD = 998244353ll;

ll clac(ll child, ll parent)
{
	if (parent == 1)
	{
		return 1;
	}
	else if (child == 1)
	{
		return parent;
	}
	else
	{
		return clac(child - 1, parent) * parent % B_MOD;
	}
}

int main()
{
	int N;
	cin >> N;
	ll ans = 1;
	vector<int> D(N, 0);
	vector<ll> counter(N, 0);
	for (auto && d : D)
	{
		cin >> d;
		counter[d]++;
	}

	if (D[0] == 0 && counter[0] == 1)
	{
		bool is_cut = false;
		for (int i = 1; i < N; i++)
		{
			if (counter[i] == 0)
			{
				is_cut = true;
			}
			else
			{
				if (is_cut)
				{
					// 浮いてる
					ans = 0;
					break;
				}
				else
				{
					ans *= clac(counter[i] , counter[i - 1]);
					ans %= B_MOD;
				}
			}
		}
	}
	else
	{
		ans = 0;
	}

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


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

int n;

typedef pair<int, int> P;
//³û`Ì¸_
//u¢½ªY
P cubes[200];

//¶¤(= 0)Cº¤ (= 1)CE¤ (= 2)Cã¤ (= 3)
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};

int main() {
	while (1) {
		cin >> n;
		if (n == 0) break;
		int minX, maxX, minY, maxY;
		minX = maxX = 0;
		minY = maxY = 0;
		cubes[0] = P(0, 0);
		for (int i = 1; i < n; i++) {
			int ni, di;
			cin >> ni >> di;
			cubes[i] = P(cubes[ni].first + dx[di], cubes[ni].second + dy[di]);
			minX = min(minX, cubes[i].first);
			maxX = max(maxX, cubes[i].first);
			minY = min(minY, cubes[i].second);
			maxY = max(maxY, cubes[i].second);
		}
		cout << maxX - minX + 1 << " " << maxY - minY + 1 << endl;
	}
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int x = c-a, y = d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
}

Measured memory_bytes: 256
/*
    Author: Anthony Ngene
    Created: 19/09/2020 - 13:12
*/

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long ans = 0;
        int last = n;
        for (int i = 1; i < n; i++) {
            while (i * last >= n) last--;
            if (last == 0) break;
            ans += last;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35728
import heapq
import math

N, M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1), A))

heapq.heapify(A)
ans = 0
for i in range(M):
    x = heapq.heappop(A)*(-1)
    heapq.heappush(A, math.floor(x/2)*(-1))

A = list(map(lambda x: x*(-1), A))

print(sum(A))

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> a(N, vector<int>(N));
    REP(i, N) REP(j, N) cin >> a[i][j];

    // dp[i][j]: 男性は 1-index, 女性は 0 index で状態
    //           i 番目の男性までマッチングしたとき、 女性 j もマッチングが終わっている場合の数
    vector<vector<long long>> dp(N+1, vector<long long>(1<<N));
    dp[0][0] = 1;
    REP(i, N){
        REP(j, (1<<N)){  // 立っている bit はマッチが終わっている
            int count = 0;
            REP(k, N) if(j & 1<<k) ++count;
            if(i != count) continue;
            //if(i != __builtin_popcount(j)) continue;
            REP(k, N){
                if(!(j & (1<<k)) and a[i][k] == 1){
                    dp[i+1][j+(1<<k)] += dp[i][j];
                    dp[i+1][j+(1<<k)] %= MOD;
                }
            }
        }
    }
    cout << dp[N][(1<<N)-1] << endl;

    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007

int32_t main()
{

	ios::sync_with_stdio(0), cin.tie(0);

	int t = 1;
	//cin >> t;

	while(t--)
	{
		string str;
        cin >> str;

        if(str[str.length()-1] != 's') str += "s";
        else str += "es";

        cout<<str<<"\n";
	}

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int n, r, t;
  cin >> n >> r >> t;
  int h[101], p[101], dk[101] = {}, y[1001] = {}, ka[1001] = {};
  int ans = 0;
  rep(i, 0, n) {
    cin >> p[i];
    dk[i] = p[i];
    ans++;
  }

  rep(i, 1, t) {
    rep(j, 0, n) {
      dk[j] = (dk[j] + p[j]) % r;
      if(y[dk[j]]) y[dk[j]]--;
      else ans++;
      ka[dk[j]]++;
    }
    rep(j, 0, r) {
      if(ka[j]) y[j] += ka[j], ka[j] = 0;
    }
  }

  cout << ans << endl;
}

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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    long long x = 0;
    for(int i = 0; i < n; i++){
        int ae = a[i];
        if(i % 2 != 0){
            ae = -ae;
        }
        x += ae;
    }
    std::cout << x << " ";
    for(int i = 0; i < n-1; i++){
        x = -x + 2 * a[i];
        std::cout << x << " ";
    }
    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    ll a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    for(int i=0; i<N; i++){
        if(a[i]%2!=0){
            cout<<"first"<<endl;
            return 0;
        }
    }
    
    cout<<"second"<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner

import scala.util.control.Breaks

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextLine()

  val b = new Breaks
  b.breakable {
    for (seq <- Seq("dreamer", "eraser", "dream", "erase").permutations) {
      n.replace(seq(0), "").replace(seq(1), "").replace(seq(2), "").replace(seq(3), "").length match {
        case 0 => {
          println("YES")
          b.break()
        }
        case _ =>
      }
    }
    println("NO")
  }

}


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

int main()
{
  int a,b;
  cin >> a >> b;
  if(a + b > 9) cout << "error" << endl;
  else cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 3600
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

max = a.max

ans = 0
tmp = 10 ** 10
a.each do |i|
    next if i == max
    if (i - max/2.0).abs < tmp
        tmp = (i - max/2.0).abs
        ans = i
    end
end

puts "#{max} #{ans}"

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

using namespace std;

void solve() {
  int64_t h, n;
  cin >> h >> n;
  int64_t sum = 0;
  for (int i = 0; i < n; ++i) {
    int64_t a;
    cin >> a;
    sum += a;
  }
  cout << (h <= sum ? "Yes" : "No") << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,e) for(int i = s; i < e; i++)
#define test(t) int t; cin >> t; while(t--) 
#define iterate(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef set<int> si;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  int a,b;
  int tmp;
  cin >> n;
  cin >> a >> b;
  int lta,bab,gtb;
  lta = bab = gtb = 0;
  rep(i,0,n) {
    cin >> tmp;
    if(tmp <= a) lta++;
    else if(tmp <= b) bab++;
    else gtb++;
  }
  int ans = min(lta,min(bab,gtb));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1,_2,_3,name,...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i=(a); i<(n); ++i)
#define rep(...) _overload3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<class T> inline void print(const T& x) {cout << x << "\n";}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main(){
    ll n;
    cin >> n;
    vi a(n + 1, 0), b(n + 1, 0);
    rep(i, 1, n + 1) cin >> a[i];
    for (ll i = n; i > 0; --i) {
        ll s = 0;
        for(ll j = i; j <= n; j += i) s += b[j];
        if (s % 2 != a[i]) ++b[i];
    }
    ll m = 0;
    each(x, b) m += x;
    print(m);
    if(m) rep(i, 1, n + 1) if (b[i]) cout<<i<<" ";
}

Measured memory_bytes: 6348
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            int ans = 0;
            if(op.equals("?")){
                break;
            }else if(op.equals("+")){
                ans = a+b;
            }else if(op.equals("-")){
                ans = a-b;
            }else if(op.equals("*")){
                ans = a*b;
            }else if(op.equals("/")){
                ans = a/b;
            }
            System.out.println(ans);
        }
        sc.close();
    }
}


Measured memory_bytes: 26332
import java.io.*;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
	
	Scanner sc=new Scanner(System.in);
	
	String str=sc.next();
	
	char ar[]=str.toCharArray();
	int L=ar.length;
	
	int left=sc.nextInt();
	for (int i = 0; i < L-1; i++) {
	    int aaa=va((int) ar[i]);
	    
	    if(aaa!=26&&aaa<=left){
		ar[i]='a';
		left-=aaa;
	    }
	}
	while(left>0){
	    if(left>=26){
		left%=26;
	    }else{
		ar[L-1]+=left;
		left=0;
		if(ar[L-1]>122)
		    ar[L-1]+=97-123;
		    
	    }
	
	}
	
	System.out.println(String.valueOf(ar));
	
    }

static int va(int aa){
    return -aa+97+26;
        
}
 
    
    
}


Measured memory_bytes: 14244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		if (n == 3 || n == 5 || n == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 32592
import math

n = int(input())
x = []
x.extend(list(map(int, input().split())))
y = []
y.extend(list(map(int, input().split())))

i = 0
sum = 0
for i in range(n):
    sum += abs(x[i] - y[i])

print(sum)

sum = 0
for i in range(n):
    sum += (x[i] - y[i]) ** 2

print(math.sqrt(sum))

sum = 0
for i in range(n):
    sum += abs(x[i] - y[i]) ** 3

print(sum ** (1/3))

check = 0
for i in range(n):
    if check < abs(x[i] - y[i]):
        check = abs(x[i] - y[i])

print(check)



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

using namespace std;

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

	int *x = new int[n];

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

	int *cost = new int[n];
	cost[n - 1] = 0;
	cost[n - 2] = abs(x[n - 2] - x[n - 1]);
	int node = n - 3;

	while(node >= 0){
		cost[node] =
			min(cost[node + 1] + abs(x[node] - x[node + 1]), cost[node + 2] + abs(x[node] - x[node + 2]));
		node--;
	}

	cout << cost[0] << endl;
	// for(int i = 0; i < n; i++) cout << cost[i] << " ";

	delete x, cost;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        String s = sc.next();

        int length = s.length();

        for ( int i = 1; i <= length; i++ ) {
            if ( (i % 2) != 0 ) {
                System.out.print( s.charAt( i - 1 ) );
            }
        }
    }

}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


ll h[100001];
ll ok[100001];

signed main() {
    //my-code
    ll N, M; cin >> N >> M;
    REP(i, N) cin >> h[i];
    ll a, b;
    REP(i, N) ok[i] = true;
    REP(i, M) {
        cin >> a >> b;
        a--;
        b--;
        if (h[a] > h[b]) {
            ok[b] = false;
        } else if (h[b] > h[a]) {
            ok[a] = false;
        } else {
            ok[a] = false;
            ok[b] = false;
        }
    }
    ll ans = 0;
    REP(i, N) {
        if (ok[i]) ans++;
    }
    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 5212
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <queue>
#include <limits.h>
using namespace std;

typedef long long ll;

const int N = 3000;
char a[N + 1], b[N + 1];
int n, m, dp[N][N];
string sol;

int calc(int i, int j) {
	if (i == n || j == m)
		return 0;
	int &res = dp[i][j];
	if (res != -1)
		return res;
	if (a[i] == b[j])
		return res = calc(i + 1, j + 1) + 1;
	res = max(res, calc(i + 1, j));
	res = max(res, calc(i, j + 1));
	return res;
}

void path(int i, int j) {
	if (i == n || j == m)
		return;
	if (a[i] == b[j]) {
		sol += a[i];
		path(i + 1, j + 1);
		return;
	}
	if (calc(i + 1, j) == calc(i, j))
		path(i + 1, j);
	else
		path(i, j + 1);
}

int main(int argc, char **argv) {
	scanf("%s%s", a, b);
	n = strlen(a);
	m = strlen(b);
	memset(dp, -1, sizeof dp);
	calc(0, 0);
	path(0, 0);
	puts(sol.c_str());
	return 0;
}


Measured memory_bytes: 35584
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	al = list(IN())
	#b , c = IN()
	#s = input()
	tl=[(v,i+1) for i,v in enumerate(al)]
	tl.sort(reverse=True)
	#print(tl)
	th = lambda f,t:100000*f + t
	fh = lambda hv : (hv//100000, hv%100000)
	
	ss = th(1,n)
	dd={ss:0}
	for uresisa, pos in tl:
		ndd={}
		for dk in dd:
			pu=dd[dk]
			f, t =fh(dk)
			temp_dkf = uresisa*abs(f-pos)+pu
			h=th(f+1, t)
			if h not in ndd:
				ndd[h] = temp_dkf
			else:
				ndd[h] = max(ndd[h], temp_dkf)
			
			temp_dkt = uresisa*abs(t-pos)+pu
			h=th(f, t-1)
			if h not in ndd:
				ndd[h]=temp_dkt
			else:
				ndd[h]=max(ndd[h], temp_dkt)
		else:
			dd=ndd
			#for d in dd:
			#	print(d, dd[d])
			
	rr=0
	for d in dd:
		rr=max(rr, dd[d])
	return rr
			
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
  char a;
  cin >> a;
  if(a=='A')cout << 'T' << endl;
  if(a=='T')cout << 'A' << endl;
  if(a=='G')cout << 'C' << endl;
  if(a=='C')cout << 'G' << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

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

int main()
{
	int n;
	int array[100][100];
	
	int ca = 1;
	
	while (scanf("%d", &n), n){
		memset(array, -1, sizeof(array));
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				array[i][j] = 0;
			}
		}
		
		int y = 1;
		int x = 1;
		int angle = 0;
		int number = 1;
		
		while (x != n || y != n){
			if (array[y + dy[angle]][x + dx[angle]] != 0){
				angle = (angle + 1) % 4;
			}
			else {
				array[y][x] = number++;
				y += dy[angle];
				x += dx[angle];
				
				if (angle% 2 == 0){
					angle = (angle + 1) % 4;
				}
			}
		}
		array[y][x] = number;
		
		printf("Case %d:\n", ca++);
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				printf("%3d", array[i][j]);
			}
			puts("");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)cout<<"Left"<<endl;
    else if(a+b<c+d)cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
}

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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

ll calc(ll a, ll b, ll x) {
  ll f0, f1;
  f0 = a*x/b;
  f1 = x/b;
  return f0-a*f1;
}

int main() {
  ll ans0, ans1, a, b, n;
  cin >> a >> b >> n;

  ans0 = calc(a, b, n);
  ans1 = calc(a, b, n/b*b-1);

  cout << max(ans0, ans1) << endl;

  return 0;
}


Measured memory_bytes: 3644
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto cnt = new long[](100001);
    foreach (a; A)
    {
        if (a != 0)
            cnt[a - 1]++;
        cnt[a]++;
        cnt[a + 1]++;
    }
    writeln(cnt.reduce!max);
}


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

int main(){
	long long n;cin>>n;
  	int suma=0,sumb=0;
  	while(n>0){
    	suma+=n%10;
      	if(n/10==0){
          sumb+=n%10-1;
        }else{
          sumb+=9;
        }
      	n=n/10;
    }
  cout<<max(suma,sumb)<<endl;
}    

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n, q; rd(n, q);
  auto tree=new SquareRootDecomposition(n);
  while(q--){
    auto args=readln.split.to!(int[]);
    if(args[0]==0){
      tree.add(args[1], args[2]+1, args[3]);
    }else{
      writeln(tree.rmin(args[1], args[2]+1));
    }
  }
}

class SquareRootDecomposition{ // starry
  import std.algorithm;
  int D=1;
  int[] val, buc, star;
  this(int n){
    while(D*D<n) D++;
    val.length=D*D;
    buc.length=star.length=D;
  }

  void add(int ql, int qr, int x){
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        star[k]+=x;
      }else{
        val[max(l, ql)..min(r, qr)]+=x;
        buc[k]=reduce!(min)(val[l..r]);
      }
    }
  }

  int rmin(int ql, int qr){
    int ret=1_000_000_000;
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        chmin(ret, buc[k]+star[k]);
      }else{
        chmin(ret, reduce!(min)(val[max(l, ql)..min(r, qr)])+star[k]);
      }
    }
    return ret;
  }

  void chmin(T)(ref T l, T r){
    if(l>r) l=r;
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 3688
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = 999 - (n - 1) % 1000;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
/*
¼ÙÉèS[1] = R¡£ÄÇÃ´ÏÔÈ»£¬»·ÉÏ²»»á³öÏÖÁ½¸öÁ¬ÐøµÄ±ß¶¼ÊÇB£¬·ñÔòÔÚËüÃÇ½»µã´¦µÚÒ»²½ÍùÁ½±ß×ß¶¼²»ºÏ·¨
ÌØÅÐµôSÖÐÈ«ÊÇRµÄÇé¿ö£¬¿¼ÂÇÒ»°ãÇé¿ö 
Ê×ÏÈ°ÑËùÓÐÊÇBµÄÎ»ÖÃ¶Ï¿ª£¬ÄÇÃ´¾ÍÐÎ³ÉÁËÈô¸É¸öRµÄÁ¬Ðø¶Î¡£¿ÉÒÔ·¢ÏÖÕâÃ´Ò»¸öÐÔÖÊ£ºÃ¿¸öÁ¬Ðø¶ÎµÄ³¤¶È¾ùÎªÆæÊý
Ö¤Ã÷¿¼ÂÇ·´Ö¤¡£¼ÙÉèÓÐÒ»¸öÅ¼ÊýµÄ¶Î£¬¿¼ÂÇ¶þ·ÖÍ¼¿ÉÒÔ·¢ÏÖ£¬ÄÇÃ´ÓÐµÄµã×ßµ½ÕâÒ»¶ÎµÄ¶Ëµã¾àÀëÓÀÔ¶ÊÇÅ¼Êý¡¢ÓÐµÄµã×ßµ½ÕâÒ»¶ÎµÄ¶Ëµã¾àÀëÓÀÔ¶ÊÇÆæÊý£¬ÒòÎª¶ËµãÍ¬É«
¶øSµÄµÚÒ»¶ÎÁ¬ÐøR³¤¶ÈÊÇ¹Ì¶¨µÄ£¬²»ÄÜÍ¬Ê±ÎªÅ¼Êý»òÆæÊý£¬Ã¬¶Ü¡£ËùÒÔ¿ÉÒÔµÃµ½½áÂÛ
Í¬Ê±£¬SÖÐÃ¿¸öRµÄÁ¬Ðø¶Î¶¼»á¶Ô»·ÉÏÃ¿¸öRµÄÁ¬Ðø¶ÎÓÐ¸öÉÏ½çµÄÏÞÖÆ 
*/
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_NM(200050);
const int MOD(1000000000 + 7);
typedef long long int LL;

int N, M, L, F[Max_NM], Pre[Max_NM][2], Ans;
char S[Max_NM];

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

void dp(bool have)
{
	F[1] = 1, Pre[1][1 & 1] = 1;
	for (int i = 2, j;i <= N;++i)
	{
		Pre[i][0] = Pre[i - 1][0], Pre[i][1] = Pre[i - 1][1];
		upd(Pre[i][i & 1], F[i - 2]);
		//jµ½iÊÇR£¬i - j + 1 <= L   =>   j >= i - L + 1
		//i - j + 1ÊÇÆæÊý£¬i - jÊÇÅ¼Êý£¬iºÍjÆæÅ¼ÐÔÏàµÈ
		j = max(1, i - L + 1);
		if (j <= i)
		{
			F[i] = Sub(Pre[i][i & 1], Pre[j - 1][i & 1]);
			if (have)
				upd(F[i], Sub(Pre[i][(i & 1) ^ 1], Pre[j - 1][(i & 1) ^ 1]));
		}
	}
	
}

int main()
{
	scanf("%d%d", &N, &M);
	scanf("%s", S + 1);
	bool haveB = false;
	if (S[1] == 'B')
		for (int i = 1;i <= M;++i)
			S[i] = 'R' + 'B' - S[i];
	for (int i = 1;i <= M;++i)
		haveB |= (S[i] == 'B');
	L = N;
	for (int i = 1, length = 0, stop = 0;i <= M;++i)
		if (S[i] == 'B')
			length = 0, stop = 1;
		else
		{
			++length;
			if (i + 1 <= M && S[i + 1] == 'B')
				if (stop == 0)
					if (length & 1)
						L = min(L, length);
					else
						L = min(L, length + 1);
				else
					if (length & 1)
						L = min(L, length);
		}
	dp(!haveB);
	upd(Ans, F[N - 1]);//edge(1, 2) = B
	for (int x = 1, val;x <= L && x < N;++x)//edge(1, 2) = R
	{
		if (haveB && ((x & 1) == 0))
			continue;
		if (x + 1 == N)
			val = 1;
		else
			val = F[N - x - 2];
		upd(Ans, Mult(x, val));
	}
	if (haveB == false)
		upd(Ans, 1);
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 2688
n=int(input())
b=list(map(int,input().split()))
a=[]
for i in range(n):
    j=n-i-1
    flg=False
    while j>=0:
        if b[j]==j+1:
            a+=[b.pop(j)]
            flg=True
            break
        j-=1
    if not flg:
        break
if b:
    print(-1)
else:
    for x in a[::-1]:
        print(x)

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

int n;
string s1, s2;
int main(){
	cin>>s1>>s2;	
	for(int i=0;i<3;i++) if(s1[i]==s2[i]) n++;
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
priority_queue <int> mountain;
int m;
int main()
{
    while(cin>>m) mountain.push(m);
    int i=3;
    while(i) {
        printf("%d\n", mountain.top());
        mountain.pop();
        i--;
    }
    return 0;
}


Measured memory_bytes: 3268
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import heapq
import bisect
import copy
# import math
def warshall_floyd(d, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i * N +j] = min(d[i * N +j], d[i * N + k] + d[k * N + j])
    return d

MOD = 10**9 + 7

def main():
    t1, t2 = getlist()
    a1, a2 = getlist()
    b1, b2 = getlist()
    if (a1 > b1 and a2 > b2) or (a1 < b1 and a2 < b2):
        print(0)
        return

    if t1 * a1 + t2 * a2 == b1 * t1 + b2 * t2:
        print("infinity")
        return

    if t1 * a1 + t2 * a2 < b1 * t1 + b2 * t2:
        # 多く走る方がa
        a1, a2, b1, b2 = b1, b2, a1, a2


    if a1 < b1:
        gap = (b1 - a1) * t1
        totalgap = (t1 * a1 + t2 * a2) - (b1 * t1 + b2 * t2)
        # print(gap, totalgap)
        ans = 1 + (gap // totalgap) * 2 - (gap % totalgap == 0)
        print(ans)

    else:
        print(0)


if __name__ == '__main__':
    main()



Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 3e18
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
int n,N;
P dat[444444];
void init(){
	int x=1;
	while(x<n)x*=2;
	N=x;
	rep(i,N*2-1)dat[i]={((int)1<<31)-1,INF};
}
void eval(int k,int l,int r){
	if(dat[k].second!=INF){
		dat[k].first=dat[k].second;
		if(r-l>1){
			dat[2*k+1].second=dat[k].second;
			dat[2*k+2].second=dat[k].second;
		}
		dat[k].second=INF;
	}
}
void update(int a,int b,int x,int k,int l,int r){
	eval(k,l,r);
	if(b<=l||r<=a)return;
	if(a<=l&&r<=b){
		dat[k].second=x;
		eval(k,l,r);
	}
	else{
		update(a,b,x,2*k+1,l,(l+r)/2);
		update(a,b,x,2*k+2,(l+r)/2,r);
	}
}
int query(int a,int k,int l,int r){
	eval(k,l,r);
	if(r-l==1)return dat[k].first;
	if(a<(l+r)/2)return query(a,k*2+1,l,(l+r)/2);
	else return query(a,k*2+2,(l+r)/2,r);
}
signed main(){
	int q;
	cin>>n>>q;
	init();
	rep(i,q){
		int Q;
		cin>>Q;
		if(Q==0){
			int s,t,x;
			cin>>s>>t>>x;
			update(s,t+1,x,0,0,N);
		}
		else{
			int x;
			cin>>x;
			cout<<query(x,0,0,N)<<endl;
		}
	}
	return 0;
}




Measured memory_bytes: 7200
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
namespace LibraryOfComputationalGeometry {
	typedef long double ld;
	const ld eps = 1e-9;
	struct point {ld x, y; };
	struct line {point a, b; }; //Be sure that a and b are distinct.
	void ReadPointInt(point &a) {read(a.x), read(a.y); }
	void ReadLineInt(line &a) {ReadPointInt(a.a), ReadPointInt(a.b); }
	void CerrPoint(point a) {cerr << a.x << ' ' << a.y << endl; }
	void CerrLine(line a) {cerr << a.a.x << ' ' << a.a.y << ' ' << a.b.x << ' ' << a.b.y << endl; }
	point operator + (point a, point b) {return (point) {a.x + b.x, a.y + b.y}; }
	point operator - (point a, point b) {return (point) {a.x - b.x, a.y - b.y}; }
	point operator * (point a, ld b) {return (point) {a.x * b, a.y * b}; }
	ld dot(point a, point b) {return a.x * b.x + a.y * b.y; }
	ld operator * (point a, point b) {return a.x * b.y - a.y * b.x; }
	ld moo(point a) {return sqrtl(a.x * a.x + a.y * a.y); }
	ld dist(point a, point b) {return moo(a - b); }
	point unit(point a) {
		ld tmp = moo(a);
		assert(tmp > eps);
		return a * (1.0 / tmp);
	}
	point Projection(point x, line a) {
		ld d = dot(x - a.a, a.b - a.a) / dist(a.a, a.b);
		return a.a + unit(a.b - a.a) * d;
	}
	point Reflection(point x, line a) {
		return Projection(x, a) * 2 - x;
	}
	bool OnLine(point x, line a) {
		return fabsl((a.b - a.a) * (x - a.a)) <= eps;
	}
	bool OnSegment(point x, line a) {
		return dist(x, a.a) + dist(x, a.b) - dist(a.a, a.b) <= eps;
	}
	bool Parallel(line a, line b) {
		return fabsl((a.b - a.a) * (b.b - b.a)) <= eps;
	}
	bool Orthogonal(line a, line b) {
		return fabsl(dot(a.b - a.a, b.b - b.a)) <= eps;
	}
	bool SegmentIntersect(line a, line b) {
		if (Parallel(a, b)) return OnSegment(b.a, a) || OnSegment(b.b, a) || OnSegment(a.a, b) || OnSegment(a.b, b);
		ld tmp = ((a.b - a.a) * (b.a - a.a)) * ((a.b - a.a) * (b.b - a.a));
		ld tnp = ((b.b - b.a) * (a.a - b.a)) * ((b.b - b.a) * (a.b - b.a));
		return tmp <= eps && tnp <= eps;
	}
}
int main() {
	using namespace LibraryOfComputationalGeometry;
	int q; read(q);
	while (q--) {
		line a, b;
		ReadLineInt(a);
		ReadLineInt(b);
		if (SegmentIntersect(a, b)) puts("1");
		else puts("0");
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N, X, T;
  cin >> N >> X >> T;
  int ans = 0, cur = 0;
  while (cur < N) {
    ans += T;
    cur += X;
  }
  cout << ans << nl;
  return 0;
}


Measured memory_bytes: 3588