akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        int LOWER_LIMIT = -1000_000_000;
        int UPPER_LIMIT = 1000_000_000;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int X = in.nextInt();
            int start = 0;
            int end = 0;
            if (X - LOWER_LIMIT + 1 < K) {
                start = LOWER_LIMIT;
                end = X + K - 1;
            } else if (UPPER_LIMIT - X + 1 < K) {
                start = UPPER_LIMIT - X + 1;
                end = UPPER_LIMIT;
            } else {
                start = X - (K - 1);
                end = X + (K - 1);
            }

            for (int i = start; i <= end; i++) {
                out.println(i);
            }
        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int a[100010], c, n;
long long ans = 0;
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    for(int i = 1; i <= n; ++i){
        c = a[i] - a[i - 1];
        if(c > 0) ans += c;
    }
    cout << ans;
    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());

  int alice = 0;
  int bob = 0;
  rep(i, n) {
    if (i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }
  int res = alice - bob;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

void solve();

ll n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    while (cin >> n) {
        solve();
    }
    return 0;
}

void solve() {
    ll c, ans = 0;
    for (ll a = 1; a <= n; ++a) {
        for (ll b = a; b * a < n; ++b) {
            c = n - a * b;
            if (a != b) ans += 2LL;
            else ans++;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <string>


int i=0;
int stack[200];

void push(int n){
    stack[i++] = n;
}

int pop(){
    return stack[--i];
}

int main(){
    std::string str;
    std::getline(std::cin,str);
    std::istringstream iss(str);
    std::string a;
    int tmp;
    while(iss>>a){
        if(a=="+"){
            push(pop()+pop());
        }else if(a=="-"){
            tmp = pop();
            push(pop()-tmp);
        }else if(a=="*"){
            push(pop()*pop());
        }else if(a=="/"){
            tmp = pop();
            push(pop()/tmp);
        }else{
            tmp = std::stoi(a);
            push(tmp);
        }
    }
    std::cout << stack[0] << "\n";
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
 
using namespace std;
 
 
int main() 
{
    int N;
    cin >> N;
    
    if(N<1000)
    {
        cout << 1000-N << endl;
    }
    else if(N % 1000 == 0)
    {
        cout << N % 1000 << endl;
    }
    else
    {
        cout << 1000 - (N % 1000) << endl;
    } 
 
 
    return 0;
 
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

int n,m;

int main()
{

	cin >> n >> m;
	for (int i = 0; i < max(n,m); i++) {
		cout << min(n,m);
	}

	return 0;
}


Measured memory_bytes: 256
def solve():
    N, K, *h = map(int, open(0).read().split())
    h.sort(reverse=True)
    
    ans = 10 ** 9
    for i in range(N - K + 1):
        ans = min(ans, h[i] - h[i + K - 1])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp46
{
    class Program
    {
        static void Main(string[] args)
        {

            string a = Console.ReadLine();
            string b = Console.ReadLine();

            if (a.Length > b.Length)
            {
                Console.WriteLine("GREATER");
                return;
            }
            else if (a.Length < b.Length)
            {
                Console.WriteLine("LESS");
                return;
            }
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] > b[i])
                {
                    Console.WriteLine("GREATER");
                    return;
                }
                else if (b[i] > a[i])
                {
                    Console.WriteLine("LESS");
                    return;
                }else if (b[i] == a[i])
                {
                    Console.WriteLine("EQUAL");
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

  priority_queue<LL> pq;
  rep(i, n) {
    while (a[i] > 0) {
      pq.push(a[i] - (a[i] / 2));
      a[i] /= 2;
    }
  }

  rep(i, m) {
    LL t = pq.top();
    sum -= t;
    pq.pop();
  }

  cout << max((LL)0, sum) << endl;
}

Measured memory_bytes: 35940
N,*A=`dd`.split.map &:to_i;x,y=[A,A.reverse].map{|_|t=[];r=[c=0];_.each_with_index{|a,i|b=a;q=1;(x,d,n=t.pop;k=Math.log(b.to_f/x,4).ceil*2;b=d<<k;c+=n*k;q+=n)while !t.empty?&&t[-1][0]<b;t<<(t.empty? ? [a,0,q]:[a,b,q]);r<<c};r};p (0..N).map{|i|x[i]+i+y[-1-i]}.min

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

int main(){
        int H, W;
        while(cin >> H >> W && H || W){
                for(int i = 0; i < H; i++){
                        for(int ii = 0; ii < W; ii++){
                                if(i == 0 || i == H - 1){
                                        cout << '#';
                                }else{
                                        if(ii == 0 || ii == W - 1){
                                                cout << '#';
                                        }else{
                                                cout << '.';
                                        }
                                }
                        }
                        cout << endl;
                }
                cout << endl;
        }
}


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

int main(){

    int n;
    cin >> n;
    vector<bool> spade(13);
    vector<bool> heart(13);
    vector<bool> club(13);
    vector<bool> diamond(13);
    for(int i = 0; i < n; ++i){
        char mark;
        int num;
        cin >> mark >> num;
        num--; // ゼロインデックスのため
        if(mark == 'S'){
            spade[num] = true;
        }
        else if(mark == 'H'){
            heart[num] = true;
        }
        else if(mark == 'C'){
            club[num] = true;
        }
        else{
            diamond[num] = true;
        }
    }

    for(int i = 0; i < 13; ++i){
        if(!spade[i]){
            cout << "S " << i + 1 << endl;
        }
    }
    for(int i = 0; i < 13; ++i){
        if(!heart[i]){
            cout << "H " << i + 1 << endl;
        }
    }
    for(int i = 0; i < 13; ++i){
        if(!club[i]){
            cout << "C " << i + 1 << endl;
        }
    }
    for(int i = 0; i < 13; ++i){
        if(!diamond[i]){
            cout << "D " << i + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int d;
    while(cin>>d){
        int i = 2;
        int x = d;
        long sum = 0;
        while(600-x>0){
            sum += x*x*d;
            x = d * i;
            i++;
        }
        cout<<sum<<endl;
        sum = 0;
    }

    return 0;
}


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

const int MAXN = 30, MAXM = 80;
int L, n, m, pw;

struct Edge {
	int u, v, w;
	Edge() {}
	Edge(int _, int __, int ___) {
		u = _, v = __, w = ___;
	}
} edge[MAXM];

int main() {
	scanf("%d", &L);
	for (pw = 1, n = 0; pw <= L; pw <<= 1, ++n);
	for (int i = 1; i < n; ++i) {
		edge[++m] = Edge(i, i + 1, 1 << i - 1);
		edge[++m] = Edge(i, i + 1, 0);
	}
	int sum = 1 << n - 1;
	for (int i = n - 1; i; --i)
		if (L & (1 << i - 1)) {
			edge[++m] = Edge(i, n, sum);
			sum += 1 << i - 1;
		}
	printf("%d %d\n", n, m);
	for (int i = 1; i <= m; ++i) printf("%d %d %d\n", edge[i].u, edge[i].v, edge[i].w);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  //input
  int n;
  cin >> n;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  
  int dp[n+10]={};
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  rep(i,n){
    if(i>=2)dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << endl;
  
  
}
    


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <deque>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	deque<int> ans(1);
	for(int i=0;i<N;i++)cin >> a[i];
	ans[0] = a[0];
	if(N%2==0){
		for(int i=1;i<N;i++){
			if(i%2!=0){
				ans.push_front(a[i]);
			}else{
				ans.push_back(a[i]);
			}
		}
	}else{
		for(int i=1;i<N;i++){
			if(i%2!=0){
				ans.push_back(a[i]);
			}else{
				ans.push_front(a[i]);
			}
		}
	}
	for(int i=0;i<N;i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3840
n, p = map(int, input().split())
s = [int(x) for x in input()]

if p == 2:
    ans = 0
    for i in range(n):
        if s[i] % 2 == 0:
            ans += i+1
    print(ans)
    exit()

if p == 5:
    ans = 0
    for i in range(n):
        if s[i] == 0 or s[i] == 5:
            ans += i+1
    print(ans)
    exit()


po10 = [1]
for i in range(n-1):
    po10.append((po10[-1]*10) % p)

for i in range(n):
    s[i] *= po10[n-1-i]
    s[i] %= p

ss = [0]

for i in range(n):
    ss.append(ss[-1]+s[i])
    ss[-1] %= p


ss = sorted(ss)

ll = len(ss)

ans = 0
tmp = [0,0]
for i in range(ll):
    if ss[i] != tmp[0]:
        ans += (i-tmp[1])*(i-tmp[1]-1) //2
        tmp[0] = ss[i]
        tmp[1] = i

ans += (ll-tmp[1])*(ll-tmp[1]-1)//2

print(ans)


Measured memory_bytes: 65292
N,Y = list(map(int,input().split()))

a=-1
b=-1
c=-1
for i in range(0,N+1):
    for j in range(0,N-i+1):
        if 10000*i+5000*j+1000*(N-i-j)==Y:
            a=i
            b=j
            c=N-i-j
            break
                            
print(a,b,c)

Measured memory_bytes: 9176
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n,k,q = readmi()
t = [0] * n
for i in range(q):
    s = readi()
    t[s - 1] += 1
for i in t:
    p = k - q + i
    if p >= 1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 7056
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),a[]=new int[4],i=0;
		do {
			a[i]=n%10;
			i++;
			n/=10;
		}while(n!=0);
		System.out.print(a[0]==a[1]&&a[1]==a[2]||a[1]==a[2]&&a[2]==a[3]?"Yes":"No");
	}
}

Measured memory_bytes: 23764
N, K = input().split(" ")
N = int(N)
K = int(K)

nums = []

def calc_num(n, k):
    if n <= k:
        nums.append(min(n, k-n))
        return
    
    n = n % k
    if n in nums:
        return
    elif n == 0:
        nums.append(0)
        return
    else:
        nums.append(n)
        calc_num(n, k)
        
calc_num(N, K)
print(min(nums))

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

using namespace std;

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

	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		s += s;
		if (s.find(S) != string::npos) cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 1212
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    string ans = "No";
    for(int i = 0; i <= x; ++i){
        if(2 * (x - i) + 4 * i == y) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 

int main() {
    float n,av,sum=0,ans=0;
    float v;
    cin >> n;
    vector<int> k(n);
    rep(i,n){
        cin >>k[i];
        sum += k[i];
    }
    av = sum/n;
    v = (sum-(int)sum%(int)n)/n;
    if(av-v>0.5){
        v++;
    }
  sum = 0;
    rep(i,n){
        sum += (v-k[i])*(v-k[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n; cin>>n;
    string s; cin>>s;
    s.insert(0,"0");
    vector<string> c={"SS","WW","SW","WS"};
    for(auto x:c){
        string a(n+1,'0');
        a[0]=x[0],a[1]=x[1];
        char t=a[0];
        for(int i=1;i<=n;i++){
                long nx;
                if(i!=n)
                        nx=i+1;
                else{
                        nx=0;
                        if(a[i]!=a[nx]){
                                a[0]='0';
                                break;
                        }
                }
                if(a[i]=='S'){
                        if(s[i]=='o')
                                a[nx]=a[i-1];
                        else{
                                if(a[i-1]=='S')
                                        a[nx]='W';
                                else
                                        a[nx]='S';
                        }
                }
                else{
                        if(s[i]=='x')
                                a[nx]=a[i-1];
                        else{
                                if(a[i-1]=='S')
                                        a[nx]='W';
                                else
                                        a[nx]='S';
                        }
                }
        }
        if(a[0]==a[1]){
                        for(int j=1;j<=n;j++)
                                cout<<a[j];
                        return 0;
        }

    }
    cout<<-1;
}

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

int main()
{
  int D;
  cin >> D;
  
  if(D == 22)
  {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  else if(D == 23)
  {
    cout << "Christmas Eve Eve" << endl;
  }
  else if(D == 24)
  {
    cout << "Christmas Eve" << endl;
  }
  else if(D == 25)
  {
    cout << "Christmas" << endl;
  }
  
  return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,k;
    Scd3(a,b,k);

    int i = a*b+1;
    while( k ){
        i--;
        if( a%i == 0 && b%i == 0 ){
            k--;
        }
    }

    printf("%d\n", i );


    return 0;
}



Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999


int main(){
  string s;
  cin >> s;
  int n=s.length();
  bool flag=true;
  REP(i,n){
    if(i%2==0){
      if(s[i]=='L'){flag=false;}
    }
    else {
      if(s[i]=='R'){flag=false;}
    }
  }
  if(flag==true)cout <<"Yes";
  else cout <<"No";
}


Measured memory_bytes: 256
H, W = 12, 12
dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
field = []

def solver(x, y):
  global field
  if x < 0 or y < 0 or x >= H or y >= W:
    return
  for dx, dy in dxy:
    if x+dx < 0 or y+dy < 0 or x+dx >= H or y+dy >= W:
      continue
    if field[x+dx][y+dy] == 1:
      field[x+dx][y+dy] = 0
      solver(x+dx, y+dy)

while True:
  field = []
  for i in xrange(H):
    field.append(map(int, raw_input()))

  ans = 0
  for x in xrange(H):
    for y in xrange(W):
      if field[x][y] == 1:
        solver(x, y)
        ans += 1
  print ans
  try:
    raw_input()
  except EOFError:
    break

Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			10005
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(((a==b) && (a!=c))||((a==c)&&(a!=b))||((b==c)&&(b!=a)))
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair
int is_palindrome(string s)
{
    string t(s.rbegin(),s.rend());
    if(s==t)
    return 1;
    else return 0;
}
  int main()
  {
     FASTIO;
     string s;
     cin>>s;
     ll len;
     len=s.size();
     if(is_palindrome(s)&&is_palindrome(s.substr(0,(len-1)/2))&&is_palindrome(s.substr((len+1)/2)))
     cout<<"Yes";
     else
     cout<<"No";
     }

Measured memory_bytes: 256
using System;

public class C
{
    public const int INF = -999999999;
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var dp = new int[n+1];
            for (int i = 0; i < n + 1; i++) dp[i] = C.INF;
            var ret = C.INF;
            for (int i = 1; i <= n; i++)
            {
                var a = int.Parse(Console.ReadLine().Trim());
                dp[i] = Math.Max(dp[i - 1] + a, a);
                ret = Math.Max(ret, dp[i]);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 9256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define int long long

const int MAXN = 105;

int n;
vector<pair<int, int> > ed;

signed main() {
	ios_base::sync_with_stdio(0);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < i; ++j) {
			if (!((n % 2 == 0 && i + j == n + 1) || (n % 2 == 1 && i + j == n))) ed.push_back({ j, i });
		}
	}

	cout << ed.size() << endl;
	for (auto x : ed) cout << x.first << " " << x.second << endl;

	return 0;
}

Measured memory_bytes: 512
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

x,y,z=map(int,input().split())
print(str(z)+" "+str(x)+" "+str(y))

Measured memory_bytes: 66156
n,k = map(int,input().split())
a = list(map(int,input().split()))

machi = 1
toutatu = []
pypyosoi = set()
while not machi in pypyosoi:
	toutatu.append(machi)
	pypyosoi.add(machi)
	machi = a[machi-1]

saigo = machi
num = toutatu.index(saigo)
unchi = toutatu[num:]
cnt = len(unchi)

if num > k:
	print(toutatu[k])
else:
	print(unchi[(k-num)%cnt])

#pypyが遅いのは自分のコードが悪いだけごめんねpypyちゃん

Measured memory_bytes: 124568
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    unsigned long long x;
    cin >> x;
    unsigned long long result = 100;
    rep(i,1,4000){
        result += (result / 100);
        if(x <=result){
            cout << i << endl;
            break;
        }
    }
    //--------------
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(C, B / A) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int a,b,c,d;
     cin>>a>>b>>c>>d;
     int n,m;
     if(c%b==0)
         n=c/b;
     else
        n=c/b+1;
     if(a%d==0)
        m=a/d;
     else
        m=a/d+1;
     if(n<=m)
        cout<<"Yes\n";
     else
        cout<<"No\n";
}


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

N = int(input())
hn = list(map(int,input().split()))
rtn = [0]*N
for i in range(N):
  if i==0:
    rtn[i]=0
  elif i==1:
    rtn[i]=abs(hn[i]-hn[i-1])
  else:
    rtn[i]=min(rtn[i-1]+abs(hn[i]-hn[i-1]), rtn[i-2]+abs(hn[i]-hn[i-2]))
print(rtn[N-1])

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

#define ll long long
#define endl '\n'
#define pii pair<ll,ll>
#define N 100007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    string s;
    cin>>s;
    if(s=="RRR")
    {
        cout<<3;
    }
    else if(s=="RRS"||s=="SRR")
    {
        cout<<2;
    }
    else if(s=="SSS")
    {
        cout<<0;
    }
    else
    {
        cout<<1;
    }
}

Measured memory_bytes: 3592
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>
const long long INF=1e18;

using namespace std;

int main(void) {
    int A,B;
    cin>>A>>B;

    if(2*A<=B&&A*4>=B&&B%2==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


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

int main() {
  int L, R;
  cin >> L >> R;
  int ans = 2018;
  if (R / 2019 == L / 2019) {
    for (int i = L; i < R; i++) {
      for (int j = L + 1; j <= R; j++) {
        if (i < j) {
          ans = min(ans, (i % 2019) * (j % 2019) % 2019);
        }
      }
    }
    cout << ans << endl;
  }
  else {
    cout << '0' << endl;
  }
}

Measured memory_bytes: 256
import random


d = int(input())
c = list(map(int,input().split()))
s = []

class field:
    def __init__(self):
        self.ans = [-1 for i in range(365)]
        self.last = [-1 for i in range(26)]


    def score_day(self,day,type):
        inc = s[day][type]
        dec = 0
        for i in range(26):
            dec += c[i]*(day-self.last[i])

        return  inc-dec


for i in range(d):
    arr = list(map(int,input().split()))
    s.append(arr)

best_score = 0
alloc = []

F = field()
ans = 0
good = []
childs = 70
badchild = 15
for day in range(d):
    if day == 0:
        tp_scores = []
        for j in range(25):
            prob = j
            befl = F.last[prob]
            F.last[prob] = day
            sc = F.score_day(day, prob)
            tp_scores.append([-sc, j,F.last.copy(),str(j)])

            F.last[prob] = befl

        tp_scores.sort()
        good = tp_scores
    else:
        tp_scores = []
        for i in range(min(childs+badchild,len(good))):
            befs = good[i][0]
            befp = good[i][1]
            befl = good[i][2]
            befa = good[i][3]
            F.last = befl
            for j in range(25):
                prob = j
                bt = F.last[prob]
                F.last[prob] = day
                sc = F.score_day(day,prob)
                tp_scores.append([befs-sc,j,F.last.copy(),befa+","+str(j)])

                F.last[prob] = bt

        tp_scores.sort()
        good = tp_scores[:childs]

        if len(tp_scores) > childs:
            rest =len(tp_scores)-childs
            pick = min(badchild,rest)
            sp = random.sample(range(childs,len(tp_scores)),pick)
            for sss in sp:
                good.append(tp_scores[sss])


# print(good[0])


# for g in good:
#     tp = 0
#     root = list(map(int,g[-1].split(",")))
#     F = field()
#     for i in range(len(root)):
#         F.ans[i] = root[i]
#         F.last[root[i]] = i
#         tp += F.score_day(i,root[i])
#     print(root,tp)


root = map(int,good[0][-1].split(","))

for r in root:
    print(r+1)


Measured memory_bytes: 194344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a, b, c;
  int k;
  cin >> a >> b >> c;
  cin >> k;
  cout << a + b + c + max(a, max(b, c)) * (pow(2, k) - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    h,n = map(int, r.split())
    r = stdin.readline()[:-1]
    a = list(map(int, r.split()))
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if h > sum(a):
        print('No')
    else:
        print('Yes')
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 53316
import math

import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

a,b=LI()

print(math.ceil((a+b)*0.5))


Measured memory_bytes: 3064
#include <stdio.h>

int f(int n){
  return n*n;
}

int main(){
  int n;
  while(scanf("%d", &n)!=EOF){
    long long int v=0;
    for(int i=1;i<600/n;i++){
      v += f(n*i)*n;
    }
    printf("%lld\n", v);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

int str_to_int(char s){
    if(s=='A') return 0;
    if(s=='B') return 1;
    if(s=='C') return 2;
    if(s=='D') return 3;
    if(s=='E') return 4;
    if(s=='F') return 5;
    if(s=='G') return 6;
    if(s=='H') return 7;
    if(s=='I') return 8;
    if(s=='J') return 9;
    if(s=='K') return 10;
    if(s=='L') return 11;
    if(s=='M') return 12;
    if(s=='N') return 13;
    if(s=='O') return 14;
    if(s=='P') return 15;
    if(s=='Q') return 16;
    if(s=='R') return 17;
    if(s=='S') return 18;
    if(s=='T') return 19;
    if(s=='U') return 20;
    if(s=='V') return 21;
    if(s=='W') return 22;
    if(s=='X') return 23;
    if(s=='Y') return 24;
    if(s=='Z') return 25;
}
char int_to_str(int n){
    if(n==0) return 'A'; 
    if(n==1) return 'B'; 
    if(n==2) return 'C'; 
    if(n==3) return 'D'; 
    if(n==4) return 'E'; 
    if(n==5) return 'F'; 
    if(n==6) return 'G'; 
    if(n==7) return 'H'; 
    if(n==8) return 'I'; 
    if(n==9) return 'J'; 
    if(n==10) return 'K'; 
    if(n==11) return 'L'; 
    if(n==12) return 'M'; 
    if(n==13) return 'N'; 
    if(n==14) return 'O'; 
    if(n==15) return 'P'; 
    if(n==16) return 'Q'; 
    if(n==17) return 'R'; 
    if(n==18) return 'S'; 
    if(n==19) return 'T'; 
    if(n==20) return 'U'; 
    if(n==21) return 'V'; 
    if(n==22) return 'W'; 
    if(n==23) return 'X';
    if(n==24) return 'Y'; 
    if(n==25) return 'Z'; 
}
int main(){
    int N;
    string S;
    cin>>N;
    cin>>S;
    for(int i=0;i<S.length();i++){
        cout<<int_to_str((str_to_int(S[i])+N)%26);
    }
    return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int a,b,c,d;
int main(){
  cin >>a>>b>>c>>d;
  printf("%d\n",max(a*b,c*d));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;



void func()
{
	int N;
	cin >> N;
	vector<int> shain(N, 0);

	for (int i = 1; i < N; i++)
	{
		int Ai;
		cin >> Ai;
		shain[Ai-1]++;
	}
	for (int i = 0; i < N; i++)
	{
		cout << shain[i] << endl;
	}
}

int main() {

//	while (1)
		func();
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    pr(n+a+b >= 22 ? "bust":"win");
}


Measured memory_bytes: 764
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int H, W, D;
  cin >> H >> W >> D;
  auto A = vect(H, vect(W, 0));
  cin >> A;
  vector<P> id(H * W + 1);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) { id[A[i][j]] = P(i, j); }
  }
  auto dist = [](P a, P b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
  };
  vector<int> dp(H * W + 1, 0);
  for (int i = D + 1; i <= H * W; i++) {
    dp[i] = dp[i - D] + dist(id[i - D], id[i]);
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    cout << dp[R] - dp[L] << endl;
  }
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 2560
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	double f(double kaku) {
		double theta = kaku * Math.PI / 180;

		double ans;

		if (a * Math.tan(theta) <= b) {
			ans = a * a * b - a * a * a * Math.tan(theta) / 2.0;
		} else {
			ans = b * b / Math.tan(theta) * a / 2.0;
		}

		return ans;
	}

	int a, b, x;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		a = sc.nextInt();
		b = sc.nextInt();
		x = sc.nextInt();

		sc.close();

		double low = 0;
		double high = 90;

		double e = 0.0000001;

		double mid;

		while (true) {
			mid = (high - low) / 2 + low;
			double a = f(mid);
			if (Math.abs(a - x) <= e) {
				break;
			}

			if (a < x) { // 角度midで入れられる最大量aよりも、もともと入っていた量xが多い
				// かたむけすぎ
				high = mid;
			} else {
				low = mid;
			}
		}

		out.println(mid);
	}

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


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int n;
int a[22][22];
int dp[1 << 21], nxt[1 << 21];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
        }
    }
    dp[0] = 1;
    rep(i, 0, n){
        for(int mask = 0; mask < (1 << n); mask++) nxt[mask] = 0;
        for(int mask = 0; mask < (1 << n); mask++){
            if(dp[mask] == 0) continue;
            rep(j, 0, n){
                if(mask & (1 << j)) continue;
                if(a[i][j]){
                    (nxt[mask | (1 << j)] += dp[mask]) %= mod;
                }
            }
        }
        swap(dp, nxt);
    }
    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define MAXN 300000
#define ll long long
using namespace std;


int melhor[MAXN], power[MAXN], escola[MAXN];

int main() {
	int n;
	vector <int> arr;
	int num;
	bool ruim = false;
	scanf("%d", &n);
	for (int i=0; i<n; i++){
		scanf("%d", &num);
		if (arr.size() < num-1){
			ruim = true;
		} else {
			arr.insert(arr.begin()+num-1, num);
		}
	}
	if (ruim){
		printf("%d\n", -1);
	} else {
		for (int i=0; i<n; i++){
			printf("%d\n", arr[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;

int main(){
    int n,d; cin >> n >> d;
    long double xy[n][d];
    rep(i,n){
        rep(j,d){
            cin >> xy[i][j];
        }
    }
    int ans = 0;
    rep(i,n){
        rep(j,n){
            if(i >= j)continue;
            long double sum = 0;
            bool ok = true;
            rep(k,d)sum += (xy[i][k] - xy[j][k]) * (xy[i][k] - xy[j][k]);
            long double sq = sqrtl(sum); 
            // cout << i  << ' ' << j  << ' ' << sq << endl;
            rep(k,sum+1){
                if(k == sq){
                    // cout << i  << ' ' << j << endl;
                    ans++;
                    break;
                }
                if(k  > sq){
                    ok = false;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, cost_r, cost_l;
    cin >> N >> cost_r >> cost_l;
    vector<int> A(N);
    vector<int> num2pos(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        num2pos[A[i]] = i;
    }

    int dp[N+1][N]; // 数字iを区間jにおいたときのコストの最小値
    for (int i = 0; i < N; i++) dp[0][i] = 0;

    // dp[i+1][j] = min(dp[i][0], ..., dp[i][j]) + cost;
    for (int i = 0; i < N; i++) {
        int mn = INF;
        for (int j = 0; j < N; j++) {
            mn = min(mn, dp[i][j]);
            int cost;
            if (num2pos[i + 1] == j) cost = 0;
            else if (num2pos[i + 1] > j) cost = cost_l;
            else cost = cost_r;
            dp[i+1][j] = mn + cost;
        }
    }

    int ret = INF;
    for (int j = 0; j < N; j++) ret = min(ret, dp[N][j]);
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 195712
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;



int main(){
    int N;
    cin >> N;
    vector<LL> A,B(N+1,0LL);
    for(int i=0;i<N;i++){
        LL a;
        cin >> a;
        A.pb(a);
    }
    LL sum=0;
    for(int i=0;i<N;i++){
        sum+=A[i];
        B[i]=sum;
    }
    LL ans=LINF;
    for(int i=1;i<N-2;i++){
        LL l=B[i],r=B[N-1]-B[i];
        for(int j=0;j<3;j++){
            auto p=lower_bound(All(B),l/2);
            auto q=lower_bound(All(B),r/2+B[i]);
            if(j==1) p--;
            else if(j==2) p++;
            if(p==B.begin()+i) p--;
            else if(p==B.begin()-1) p++;
            if(q==B.begin()+i) q++;
            if(q==B.end()) q=q-3;
            else if(q==B.begin()+i) q++;
            for(int k=0;k<3;k++){
                if(k==1) q--;
                else if(k==2) q++;
                if(q==B.end()) q=q-3;
                else if(q==B.end()-2) q=q-1;
                else if(q==B.begin()+i) q++;
                LL mini,maxi;
                maxi=max(*p,B[i]-*p);
                maxi=max(maxi,max(*q-B[i],B[N-1]-*q));
                mini=min(*p,B[i]-*p);
                mini=min(mini,min(*q-B[i],B[N-1]-*q));
                ans=min(ans,maxi-mini);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() 
{
  string S;
  cin >> S;
  
  int num = 0,ka = 0;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == 'R'){
      num++;
      ka = num;
    }else{
      num = 0;
    }
  }//for
  
  cout << ka << endl;
}

Measured memory_bytes: 3608