akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
	int maxv = 100001, maxw=1000000001;
	int N, W;
	cin >> N >> W;
	int64_t **r = new int64_t*[N];
	for(int n=0; n<N; n++){
		r[n] = new int64_t[maxv];
	}

	int64_t w0, v0;
	cin >> w0 >> v0;

	int vi;
	r[0][0] = 0;
	for(vi=1; vi<=v0; vi++){
		r[0][vi] = w0;
	}
	for(;vi<maxv; vi++){
		r[0][vi] = maxw;
	}

	for(int n=1; n<N; n++){
		int64_t wn, vn, vi;
		cin >> wn >> vn;
		r[n][0] = r[n-1][0];
		for(vi=1; vi<vn; vi++){
			r[n][vi] = min(
				r[n-1][vi],
				wn
			);
		}
		for(;vi<maxv; vi++){
			r[n][vi] = min(
				r[n-1][vi],
				r[n-1][vi-vn] + wn
			);
		}
	}

	for(vi=0; vi<maxv; vi++){
		if(r[N-1][vi] > W){
			break;
		}
	}

	cout << vi-1 << endl;

	return 0;
}


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

  int h, w;
  cin >> h >> w;

  queue<pair<int, int>> q;
  char board[h][w];

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> board[i][j];
      if (board[i][j] == '#') q.push({i, j});
    }
  }

  int dirs[8][2] = {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}};

  while (!q.empty()) {
    pair<int, int> p = q.front(); q.pop();

    for (int k = 0; k < size(dirs); ++k) {
      int i = p.first + dirs[k][0], j = p.second + dirs[k][1];

      if (i >= 0 && i < h && j >= 0 && j < w && board[i][j] != '#') {
        if (board[i][j] == '.') board[i][j] = '1';
        else board[i][j] = (int) board[i][j] + 1;
      }
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (board[i][j] == '.') cout << 0;
      else cout << board[i][j];
    }
    cout << "\n";
  }
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int now=0;
	while(a>0&&c>0){
		if(now%2==0){
			c-=b;
		}else{
			a-=d;
		}
		now++;
	}
	if(a<=0){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int N,K,L,x;
  cin >> N>>K;
  
  for(int i=0;i<N;i++) 
  {
  	cin>>x;
  	if (K-x>x)
  	L+=x*2;
  	else
  	L+=(K-x)*2;
  }
 cout<<L<<endl;
 }
	

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

int grid[105][105], h, w;
int a[100005];
void paintPos(const int& x, const int& y, const int& c) {
    grid[x][(x & 1 ? w - y - 1 : y)] = c;
}

int main() {
    int n, c = 0;
    scanf("%d%d%d", &h, &w, &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            if (!a[c]) c++;
            paintPos(i, j, c);
            a[c]--;
        }
    for (int i = 0; i < h; i++, printf("\n")) for (int j = 0; j < w; j++)
            printf("%d ", grid[i][j]);
}

Measured memory_bytes: 384
using System;

namespace ForAizuSol
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = Console.ReadLine().Split(' ');
            var a = int.Parse(list[0]);
            var b = int.Parse(list[1]);

            if (a > b)       Console.WriteLine("a > b");
            else if (a < b)  Console.WriteLine("a < b");
            else if (a == b) Console.WriteLine("a == b");
        }
    }
}



Measured memory_bytes: 17936
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const int mod1 = 1000000007;
const int mod2 = 998244353;
const int N = 1e5;

int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	string s;
	cin>>s;
	int sz = s.size();
	if(s[sz-1] != 's')
		cout<<s<<"s"<<endl;
	else
		cout<<s<<"es"<<endl;

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    if(x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int W = scanner.nextInt();
		int H = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int r = scanner.nextInt();
		if(x>=r&y>=r&(x+r)<=W&(y+r)<=H) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		scanner.close();
	}
}


Measured memory_bytes: 26364
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    --a; --b; --c; --d;
    string s;
    cin >> s;

    for (int i = a; i < c; ++i) {
        if (s[i] == '#' && s[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = b; i < d; ++i) {
        if (s[i] == '#' && s[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if ((a < b && b < d && d < c) || (b < a && a < c && c < d)) {
        int l = max(a, b), r = min(c, d);
        bool f = false;
        for (int i = l; i <= r; ++i) {
            if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
                f = true;
                break;
            }
        }
        if (!f) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve() {
		int A = ni(), B = ni();
		out.println(A > 9 || B > 9 ? -1 : A * B);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private String nsl() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b) && b != ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 21204
N=gets.to_i
MOD=10**9+7
array=gets.chomp.split(" ").map(&:to_i)
M={}
M[0]=3
ret=1
array.each do |a|
    M[a]||=0
    ret*=M[a]
    ret%=MOD
    M[a]-=1
    M[a+1]||=0
    M[a+1]+=1
end
puts ret


Measured memory_bytes: 25808
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}
//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

int main() {
	int n, m;
	cin >> n >> m;
	int a[m];
	for (int i = 0; i<m; i++) cin >> a[i];

	ll steps[n + 1] = { 0 };
	steps[n] = 1;
	int p = m - 1;
	for (int i = n - 1; i >= 0; i--) {
		if (p >= 0 && i == a[p]) {
			p--;
			continue;
		}
		if (i == n - 1) steps[i] = steps[i + 1];
		else steps[i] = (steps[i + 1] + steps[i + 2]) % 1000000007;
	}
	cout << steps[0] << endl;

}

Measured memory_bytes: 1408
import java.util.Scanner;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  private static int N;
  private static int[] a;

  private static void print() {
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < N; i++) {
      result.append(a[i]);
      result.append(" ");
    }
    System.out.println(result.toString().trim());
  }

  private static void sort() {
    if (N == 1) {
      print();
      return;
    }

    for (int i = 1; i < N; i++) {
      print();
      int key = a[i];
      int j = i - 1;
      while (j >= 0 && key < a[j]) {
        a[j + 1] = a[j];
        j--;
      }
      a[j + 1] = key;
    }
    print();
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    N = in.nextInt();
    a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = in.nextInt();
    }

    // sort a.
    sort();
    // a is now sorted.


  }
}

Measured memory_bytes: 28812
def dfs(i,f,ans):
  if i<3:
    dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1]))
  elif ans==7:
    print(f+"=7")
    exit()
s=input()
dfs(0,s[0],int(s[0]))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int a = 0, b = 0, c = 0, n = 0;
	std::cin >> a >> b;
	std::cout << (a*b) - (b + a - 1) << std::endl;
	return 0;
}

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

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

  //vector<int> P;
  //vector<string> S; 
  //S.reserve(N);
  //P.reserve(N);
  
  vector< tuple<string, int, int> > SP;
  SP.reserve(N);

  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    
    tuple<string, int, int> sp = tuple<string, int, int> (s, p, i+1);
    SP.push_back(sp);
  }
  
  sort(SP.begin(), SP.end());

  vector< pair<int, int> > RES;

  for (int i = 0; i < N; i++) {
    string s = get<0> (SP[i]);
    int p = get<1>(SP[i]);
    int j = get<2>(SP[i]);
    
    RES.push_back( pair<int, int> (p, j));
    
    if (i == N-1 || s != get<0> (SP[i+1]) ) {
      sort(RES.rbegin(), RES.rend());
      for (int k = 0; k < RES.size(); k++) {
        cout << RES[k].second << endl;
      }
      RES = {};
    }
  }
  

  return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int H, W;
	cin >> H >> W;

	while (H != 0){

		int j, k;
		for (j = 0; j < H; j++){
			for (k = 0; k < W; k++){

				if (j == 0 || j == H - 1 || k == 0 || k == W - 1)
					cout << "#";
				else cout << ".";

			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define N 51
using namespace std;
int w,h,s;
string mp[N];
string sw[11][N];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
 
bool check(int x,int y,int f,int bit){
  if(mp[y][x]=='#')return 0;
 
  int cnt=0;
  for(int i=0;i<s;i++)
    if((bit>>i)&1)cnt+=sw[i][y][x]=='*';
 
  char ch = mp[y][x];
  if((cnt+f)%2==0)
    if(isupper(ch)||ch=='^')return 0;
  
  if((cnt+f)%2==1)
    if(islower(ch)||ch=='_'||ch=='&'||ch=='%')return 0;
  return 1;
}

int nbit(int bit,int x){
  if((bit>>x)&1) return ~((~bit)|(1<<x));
  return bit|(1<<x);
}
 
int used[N][N][2][1<<10];
struct dat{int x,y,f,bit,cost;};
int bfs(int sx,int sy){
  queue<dat> Q;
  Q.push((dat){sx,sy,0,0,0});
  
  while(!Q.empty()){
    dat t=Q.front();Q.pop();
    int x=t.x,y=t.y,f=t.f,bit=t.bit,cost=t.cost;
    if(mp[y][x]=='&')return cost;
    if(used[x][y][f][bit]++) continue;
    
    if(mp[y][x]=='|') Q.push((dat){x,y,!f,bit,cost+1});
    int th=mp[y][x]-(isupper(mp[y][x])? 'A':'a');
    if(isalpha(mp[y][x]))Q.push((dat){x,y,(sw[th][y][x]=='*')?!f:f,nbit(bit,th),cost+1});
    
    for(int i=0;i<4;i++){
      int nx=x+dx[i],ny=y+dy[i];
      if(check(nx,ny,f,bit))Q.push((dat){nx,ny,f,bit,cost+1});
    }
  }
  return -1;
}
  
int main(){
  cin>>w>>h;
  for(int i=0;i<h;i++)cin>>mp[i];
  cin>>s;
  for(int i=0;i<s;i++)
    for(int j=0;j<h;j++) cin>>sw[i][j];
 
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j]=='%')cout<<bfs(j,i)<<endl;
    return 0;
}

Measured memory_bytes: 24896
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = a - b;
		if (d >= c) {
			System.out.println(0);
		}
		else {
			System.out.println(c - d);
		}
	}
}


Measured memory_bytes: 23764
def main():
    import sys
    readline = sys.stdin.readline

    maxw = 10 ** 11  # 重さの最小化なので、初期値は最大重さとすることにdebugで気づいた
    maxv = 10 ** 5

    n, w = map(int, readline().split())

    dp = [[maxw] * (maxv + 1) for _ in range(n + 1)]
    dp[0][0] = 0

    for i in range(1, n + 1):  # i個目の品物を選ぶかどうか決めた後の重さの総和の最小値,1-indexed
        wi, vi = map(int, readline().split())
        for j in range(vi):
            dp[i][j] = dp[i - 1][j]
        for j in range(vi, maxv + 1):
            dp[i][j] = min(
                dp[i - 1][j],
                dp[i - 1][j - vi] + wi
            )

    ret = next(j for j in reversed(range(maxv + 1)) if dp[n][j] <= w)

    print(ret)


if __name__ == '__main__':
    main()


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

using namespace std;

int main(void)
{
  long long K;
  cin >> K;

  vector<long long> L; // Lunlun 数
  long long count = L.size(); // = 0

  vector<long long> TMPold; // ある桁の Lunlun 数を保存する
  
  // 1 桁
  for(long long i=0; i<9; i++) {
    long long newL = i+1;
    TMPold.push_back(newL);
    L.push_back(newL);
  }

  // 2 桁以降
  long long digit = 10; // 今の桁 
  while (count <= 100001) { // Lunlun 数の個数が 100001 を超えたらストップ
    long long size = TMPold.size(); // TMPold の要素の個数
    vector<long long> TMPnew = {}; // 新しい桁の Lunlun 数を保持する（毎回初期化）
    for (long long j=0; j<10; j++) { // j = 新たに付け足す桁の数
      for (long long i=0; i<size; i++) { // i = TMP のインデックス
        if (TMPold.at(i)%10 == j
         || TMPold.at(i)%10 == j-1 || TMPold.at(i)%10 == j+1) {
           long long newLun = TMPold.at(i) * 10 + j;
           L.push_back(newLun);
           TMPnew.push_back(newLun);
           count++;
        }
      }
    }
    TMPold = TMPnew; // TMPold を TMPnew に更新
    digit *= 10; // 桁数を更新
  }

  sort(L.begin(), L.end());

  cout << L.at(K-1) << endl;
 
}


Measured memory_bytes: 5744
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] area = new char[h][w];
		for (int i = 0; i < h; i++) {
			area[i] = sc.next().toCharArray();
		}
		ArrayList<Integer> hh = new ArrayList<>();
		ArrayList<Integer> ww = new ArrayList<>();
		boolean b;
		for (int i = 0; i < h; i++) {
			b = true;
			for (int j = 0; j < w; j++) {
				if (area[i][j] == '#') {
					b = false;
					break;
				} else {

				}
			}
			if (!b) {
				hh.add(i);
			}
		}

		for (int i = 0; i < w; i++) {
			b = true;
			for (int j = 0; j < h; j++) {
				if (area[j][i] == '#') {
					b = false;
					break;
				} else {

				}
			}
			if (!b) {
				ww.add(i);
			}
		}

		for (int i : hh) {
			for (int j : ww) {
				sb.append(area[i][j]);
			}
			sb.append("\n");
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 23252
n = int(input())
num_list = list()
param = 1
counter = 0

for i in range(n):
    num_list.append(int(input()))
    
for i in range(n):
    param = num_list[param-1]
    counter += 1
    if param == 2:
        print(counter)
        break
else:
    print(-1)

Measured memory_bytes: 7084
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,A,B;
void solve(){
	cin>>n;
	VI a(n);
	VI b(n);
	rep(i,0,n)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	VI c(n);
	rep(i,0,n)c[i] = i+1;
	ll tol=1;
	rep(i,1,n+1)tol*=i;
	int cnt=1;
	do{
		int f=1;
		/*
		rep(i,0,n)if(a[i]!=c[i]){
			f=0;
			break;
		}
		if(f){
			A = cnt;
		}
		f=1;
		rep(i,0,n)if(b[i]!=c[i]){
			f=0;
			break;
		}
		if(f){
			B = cnt;
		}
		*/
		if(a==c)A = cnt;
		if(b==c)B = cnt; 
		cnt++;
	}while(cnt<=tol&&next_permutation(all(c)));
	cout<<abs(A-B);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#define Max 1000000001
using namespace std;
long long cnt;

void merge(int A[],int left,int mid,int right)
{
    int L[mid-left+1],R[right-mid+1],L_index=0,R_index=0;
    for(int i=0;i<mid-left;i++)
        L[i]=A[left+i];
    L[mid-left]=Max;
    for(int i=0;i<right-mid;i++)
        R[i]=A[mid+i];
    R[right-mid]=Max;
    for(int i=left;i<right;i++)
    {
        if(L[L_index]<=R[R_index])
        {
            A[i]=L[L_index];
            L_index++;
        }
        else{
            A[i]=R[R_index];
            R_index++;
            if(L_index!=mid-left)
                cnt+=mid-left-L_index;
        }
    }
}
void mergeSort(int A[],int left,int right)
{
    if(left+1<right)
    {
        int mid = (left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}
int main(){
    int n,A[200000];
    cin>>n;
    cnt=0;
    for(int i=0;i<n;i++)
        cin>>A[i];
    mergeSort(A,0,n);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 4648
while True:
    H, W = map(int, input().split())
    if (H == 0) & (W == 0):
        break
    for i in range(H):
        if (i == 0) | (i == H - 1):
            print("#" * W)
        else:
            print("#{}#".format("." * (W - 2)))
    print("")



Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N,K;
	cin >> N >> K;
	vector<pair<ll,ll>> p(N);
	rep(i,N){
		cin >> p[i].first >> p[i].second;
	}
	
	sort(p.begin(),p.end());

	ll cnt = 0;
	rep(i,N){
		cnt += p[i].second;
		if(cnt >= K){
			ans = p[i].first;
			break;
		}
	}

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

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;


int main() {

	unsigned long long X;
	cin >> X;

	unsigned long long val1 = X / 500;
	unsigned long long val2 = (X - val1 * 500) / 5;

	cout << val1 * 1000 + val2 * 5 << endl;

	return 0;
}



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

int main() {
    int n;
    cin >> n;
    int ans = n*800 - n/15*200;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const ll MAXN = 1e3 + 10;
ll w[MAXN],s[MAXN],v[MAXN];
ll indexs[MAXN];

bool cmp(ll a,ll b){
    if(w[a] + s[a] == w[b] + s[b]) return v[a] < v[b];
    else return (w[a] + s[a] < w[b] + s[b]);
}

ll n;
ll dp[MAXN][20004];

ll rec(ll idx,ll t_w){
    if(idx == n+1) return 0;

    ll &ans = dp[idx][t_w];

    if(ans != -1) return ans;

    ans = rec(idx+1,t_w);

    if(s[indexs[idx]] >= t_w) ans = max(ans,v[indexs[idx]] + rec(idx+1,t_w + w[indexs[idx]]));
    return ans;
}

void solve(){
    cin>>n;

    FOR(i,1,n){
        cin>>w[i]>>s[i]>>v[i];
        indexs[i] = i;
    }

    sort(indexs+1,indexs+n+1,cmp);

    MINUS(dp);

    cout<<rec(1,0)<<endl;
}

signed main(){
 
   FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 158208
#include <iostream>
#include <iomanip>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;

template<class T>
class set2 : public set<T> {
private:
    typename set<T>::iterator back_itr() {
        auto e = this->end();
        e--;
        return e;
    }

public:
    T front() {
        if (this->empty()) throw;
        return *this->begin();
    }

    T back() {
        if (this->empty()) throw;
        return *this->back_itr();
    }

    void erase_front() {
        if (!this->empty()) this->erase(this->begin());
    }

    void erase_back() {
        if (!this->empty()) this->erase(this->back_itr());
    }
};

int n, k, a[500], s;

bool ok(int m) {
    if (s % m) return false;
    int b[500];
    for (int i = 0; i < n; i++) {
        b[i] = a[i] % m;
    }
    sort(b, b + n);
    int l = 0, r = n - 1, c = 0;
    while (l < r) {
        if (b[l] == 0) {
            l++;
            continue;
        }
        if (b[r] == 0) {
            r--;
            continue;
        }
        int v = min(b[l], m - b[r]);
        b[l] = b[l] - v;
        b[r] = (b[r] + v) % m;
        c += v;
    }
    return k >= c;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) s += a[i];
    for (int i = s; i > 0; i--) {
        if (ok(i)) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import sys
from collections import Counter
from math import factorial

N = int(input())
S = input()
mod = 10**9+7

if S[0] == 'W' or S[-1] == 'W':
    print(0)
    sys.exit()

op = [0]*(2*N)
op[0] = False
ct_L = 1
ans = 1
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        if op[i-1] is False:
            op[i] = True
            ans *= ct_L
            ct_L -= 1
        else:
            op[i] = False
            ct_L += 1
    else:
        if op[i-1] is False:
            op[i] = False
            ct_L += 1
        else:
            op[i] = True
            ans *= ct_L
            ct_L -= 1
    ans %= mod

ct_L, ct_R = Counter(op).values()
if ct_L != ct_R:
    print(0)
    sys.exit()


print(factorial(N) * ans % mod)


Measured memory_bytes: 6240
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = Integer.parseInt(scanner.nextLine());
        int r = 0;
        if (400 <= x && x <= 599) r = 8;
        if (600 <= x && x <= 799) r = 7;
        if (800 <= x && x <= 999) r = 6;
        if (1000 <= x && x <= 1199) r = 5;
        if (1200 <= x && x <= 1399) r = 4;
        if (1400 <= x && x <= 1599) r = 3;
        if (1600 <= x && x <= 1799) r = 2;
        if (1800 <= x && x <= 1999) r = 1;
        System.out.println(r);
        scanner.close();
    }
}

Measured memory_bytes: 26960
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = a*b/2;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int r;
    scanf("%d", &r);

   if (r < 1200)
   {
     printf("ABC\n");
   }
  else if (r < 2800)
  {
    printf("ARC\n");
  }
  else
  {
    printf("AGC\n");
  }
  return (0);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>

int main(){
    std::string N;
    std::cin >> N;
    for(int i = 0; i < N.size(); i++){
        if(N[i] == '7'){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3628
# coding : utf-8

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))

ans = 'Yes'
endFlg = False
# '#'の点をみつけたときに、その上下左右に'#'がない場合、孤立した点を黒く塗ることはできないので、答えはNoとなる。
# 全部の'#'の点について、その上下左右のいずれかに'#'が見つかれば、答えはYesとなる。

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            if i != 0 and S[i-1][j] == '#':
                continue
            elif i != H-1 and S[i+1][j] == '#':
                continue
            elif j != 0 and S[i][j-1] == '#':
                continue
            elif j != W-1 and S[i][j+1] == '#':
                continue
            else :
                ans = 'No'
                endFlg = True
                break
    if endFlg:
        break

print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		int bc = sc.nextInt();
		for (int i = 0; i < bc; i++) {
			String line = sc.next();
			if (map.containsKey(line)) {
				map.put(line, map.get(line) + 1);
			} else {
				map.put(line, 1);
			}
		}
		
		int rc = sc.nextInt();
		for (int i = 0; i < rc; i++) {
			String line = sc.next();
			if (map.containsKey(line)) {
				map.put(line, map.get(line) - 1);
			} else {
				map.put(line, -1);
			}
		}
		
		int max = 0;
		for (String key : map.keySet()) {
			if (map.get(key) > max) {
				max = map.get(key);
			}
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int n,m,set;
	while(cin>>n>>m && n)
	{
		int count[10000]={};
		int number[10000]={};	

		rep(i,m)number[i]=i+1;
		rep(i,n)
		{
			rep(j,m)
			{
				cin>>set;
				count[j]+=set;
			}
		}
		rep(i,m)
		{
			rep_to(i,j,m)
			{
				if(count[i]<count[j])
				{
					swap(count[j],count[i]);
					swap(number[j],number[i]);
				}
				else if(count[i]==count[j] && number[i]>number[j])
					swap(number[j],number[i]);
			}
		}
		rep(i,m)
		{
			cout<<number[i];
			if(i<m-1)cout<<" ";
			else cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,cnt[100];
	int i,j,x,max;
	x=0;
	for(i=0;i<101;i++) cnt[i]=0;
	while(scanf("%d",&n)!=EOF) {
		cnt[n]++;
		x++;
	}
	max=-1;
	for(i=0;i<x;i++) {
		if(max<cnt[i]) max=cnt[i];
	}
	for(i=0;i<x;i++) {
		if(max==cnt[i]) printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1020
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(map(int, input().split()))

AA = list(map(int,list(input())))
L = len(AA)
ans = L
for i in range(1,L):
	if AA[i] != AA[i-1]:
		ans = min(ans,max(L-i,i))

print(ans)

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

using namespace std;

using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

  sort(va.begin(), va.end());

  vector<bool> memo(va.back() + 1, false);

  for (int i = 0; i < va.size() - 1; i++) {
    ll a = va[i];
    for (ll j = a; j <= va.back(); j += a) {
      bool ex = binary_search(va.begin() + i + 1, va.end(), j);
      if (ex) {
        memo[j] = true;
      }
    }
  }

  ll ans = count_if(va.begin(), va.end(), [&](int a) { return !memo[a]; });
  cout << ans << '\n';
  return 0;
}

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

using ll = long long;

const int N = 4005;
const ll M = 998244353;
 
ll n, k, c[N][N];

ll g(ll n, ll r){
    if(n < 0 || r < 0 || r > n) return 0;
    return c[n][r];
}

ll f(ll n, ll k, ll i){
    if(i & 1) return (f(n - 1, k, i - 1) + f(n - 1, k - 1, i - 1)) % M;
    ll r = 0, t = 1;
    for(int j = 0; j <= i / 2; j++, t = (t * 2) % M){
        r = (r + t * g(i / 2, j) % M * g(n - i + k - 1, k - j)) % M;
    }
    return r;
}

int main(){
    for(int i = 0; i < N; i++){
        c[i][0] = 1;
        for(int j = 1; j <= i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % M;
    }
    scanf("%lld%lld", &n, &k);
    for(int i = 1; i <= n; i++) printf("%lld\n", f(n, k, i));
    for(int i = n - 1; i >= 1; i--) printf("%lld\n", f(n, k, i));
}

Measured memory_bytes: 123904
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int n,w,a[110],b[110],i,j,dp[110][10010];
  scanf("%d %d\n",&n,&w);
  for(i=0;i<=n;i++){
    for(j=0;j<=w;j++){
      dp[i][j]=-1;
    }
  }
  dp[0][0]=0;
  for(i=1;i<=n;i++){
    scanf("%d %d\n",&a[i],&b[i]);
  }
  for(i=1;i<=n;i++){
    for(j=0;j<=w;j++){
      if(j-b[i]>=0 && dp[i][j-b[i]]!=-1){
        dp[i][j]=max(dp[i-1][j],dp[i][j-b[i]]+a[i]);
      }
      else{
        dp[i][j]=dp[i-1][j];
      }
    }
  }
  int max=0;
  for(i=0;i<=w;i++){
    if(max<dp[n][i]){
      max=dp[n][i];
    }
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, S, T = 0;
  cin >> N;
   vector<int> vec(N);
 
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);   
  }  
   for (int i = 0; i < N; i++) {
  if (vec.at(i) == S){
      T++;
    S = 10001;
  }
    else {
      S = vec.at(i);
    }
   }
    cout << T << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a, b, c;
if(scanf("%d %d %d", &a, &b, &c) == 1);
for(int i = 1;;i++){
     if( a - i*b - (i-1)*c - 2*c < 0 ){
     printf("%d\n",i-1);
     break ;
      }
   }
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  int result = 0;
  if (A <= K) {
    result += A;
    K -= A;
  }
  else {
    cout << K << endl;
    return 0;
  }
  
  if (B < K) {
    K -= B;
  }
  else {
    cout << result << endl;
    return 0;
  }
  
  cout << result - K << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int64_t n;
vector <int64_t> fac;
int64_t ans = 1e18;


/// find answer a*x+b*y=gcd(a,b)
/// ref: cp-algo
int64_t ex_gcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {
    x = 1, y = 0;
    int64_t x1 = 0, y1 = 1, a1 = a, b1 = b;
    while (b1) {
        int64_t q = a1 / b1;
        tie(x, x1) = make_pair(x1, x - q * x1);
        tie(y, y1) = make_pair(y1, y - q * y1);
        tie(a1, b1) = make_pair(b1, a1 - q * b1);
    }
    return a1;
}


void check(int64_t x, int64_t y) {
    int64_t foo, bar;
    ex_gcd(x, y, foo, bar);
    int64_t real_foo = foo * x;
    int64_t real_bar = -y * bar;
    if (real_bar > 0) ans = min(ans, real_bar);
    else {
        int64_t need = 1 - real_bar;
        int64_t add = (need + n - 1) / n;
        real_bar += add * n;
        ans = min(ans, real_bar);

    }
}

int main() {

    cin >> n;
    n <<= 1;

    for (int64_t i = 1 ; i * i <= n ; ++ i)
        if (n % i == 0 && gcd(i, n / i) == 1)
            check(i, n / i), check(n / i, i);

    cout << ans << '\n';
}
/*
    Why not Ventuswill?
*/


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

struct Vec2D
{
    int x, y;
};

struct TimePos
{
    int time;
    Vec2D pos;
};

int ManhattanDistance(Vec2D v1, Vec2D v2)
{
    using namespace std;
    return abs(v1.x - v2.x) + abs(v1.y - v2.y);
}

void solve()
{
    using namespace std;
    int n;
    cin >> n;
    
    int sum {};

    for (int i = 0; i < n; ++i)
    {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }

    cout << sum << endl;

}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<int>S;
    vector<int>B;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(S.count(x)){
        S.erase(x);
        B.push_back(x);}
        else
        S.insert(x);
    }
    sort(B.begin(),B.end());
    if((int)B.size()<2){
        printf("0\n");
    }
    else
    {
        int x=(int)B.size();
        printf("%lld",1LL*B[x-1]*B[x-2]);
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  ll x;
  cin >> x;
  ll a = 100;
  ll ans = 0;
  ll counter = 0;
  for (;;) {
    a += a*0.01;
    counter++;
    // cout << a << endl;
    if (a >= x) {
      ans = counter;
      cout << ans << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=1000100;

vector<bool> prime(N,false);
vector<ll> v;

void pre(){
    prime[0]=prime[1]=true;
    for(ll i=2;i<N;i++){
        if(!prime[i]){
            for(ll j=2LL*i;j<N;j+=i)
                prime[j]=true;
        }
    }
    for(ll i=2;i<N;i++){
        if(!prime[i]){
            v.pb(i);
        }
    }
}

void solve() {
    pre();
    ll x;
    cin>>x;
    auto it=lower_bound(v.begin(),v.end(),x);
    cout<<*it<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    while (true) {
        cin >> n >> m;
        if (!n && !m) break;
        int p, c;
        vector<int> a(n);
        vector<int> b;
        for (int i = 0; i < n; ++i) {
            a[i] = n-i;
        }
        for (int i = 0; i < m; ++i) {
            cin >> p >> c; --p; --c;
            for (int j = p; j < p+c+1; ++j) {
                b.push_back(a[j]);
            }
            for (int j = 0; j < p; ++j) {
                b.push_back(a[j]);
            }
            for (int j = p+c+1; j < n; ++j) {
                b.push_back(a[j]);
            }
            a = b;
            b.clear();
        }
        cout << a[0] << endl;
    }
}

Measured memory_bytes: 3116
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x,y)       for(int i = 0;i < (y);i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x,y)        for(int i = 0; i < (y);i++)cin >> (x).at(i)

#define rep(i, n)	        for(int i = 0; i < (int)(n); i++)
#define rep_1(i, n) 	    for(int i = 1; i <=(int)(n); i++)

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

void solve() {
    int x;
    read(x);
    println(x*x*x);
}

signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    char a; cin >> a;
    if (a - 'a' >= 0) cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3632
S=input() # 長い文字列
T=input() # 短い文字列

count_min=1000 # SとTの最小距離

for ind_s in range(0,len(S)-len(T)+1): # 各Tのスタートについて
    count=0 # 何文字一致しているか

    for ind_t in range(0,len(T)): # 各T内のオフセットについて
        count+=int(S[ind_s+ind_t]!=T[ind_t]) # 一致していたらカウントをインクリメント

    if count<count_min: # もし最小を更新する場合
        count_min=count # 最小値を更新

print(count_min)

Measured memory_bytes: 8988
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll long long int,ll long long int>
#define vi          vector<ll long long int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll long long int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll long long int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;
const int mod = 1e9 + 7;
#define N  100005

void solve(){
	
	int n; cin>>n;
	double p[n];
	double dp[n+1][n+1];

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

	for(int i = 0; i<n+1; i++){
		for(int j = 0; j<n+1; j++){
			dp[i][j]=0;
		}
	}


	dp[0][0] = 1.0;
	double c = 1.0;
	for(int i=0; i<n+1; i++){
		dp[i][0] = (1-p[i-1])*c;
		c=(1-p[i-1])*c;
	}




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

				dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1];

			}
			else{
				break;
			}
		}
	}

	double sum = 0.0;

	for(int  i = n/2 + 1; i<n+1; i++){
		sum += dp[n][i];
	}

	// for(int i = 0; i<n+1; i++){
	// 	for(int j = 0; j<n+1; j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	cout<< std::setprecision(10)<<sum;





	


	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 70656
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main(void)
{
    int n, m;
    std::cin >> n >> m;

    std::vector<std::pair<int, long long>> goods(m);

    for (int i = 0; i < m; i++) {
        int b;
        std::cin >> goods[i].first >> b;

        for (int j = 0; j < b; j++) {
            int temp;
            std::cin >> temp;

            goods[i].second |= (1 << (temp - 1));
        }
    }

    const long long INF = 10000000000;
    std::vector<long long> dp(1 << n, INF);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        std::vector<long long> next(1 << n, INF);
        for (int j = 0; j < (1 << n); j++) {
            dp[j | goods[i].second] = std::min(dp[j | goods[i].second], dp[j] + goods[i].first);
        }
    }

    if (dp[(1 << n) - 1] == INF) {
        std::cout << -1 << std::endl;
        return 0;
    }
    std::cout << dp[(1 << n) - 1] << std::endl;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String base = null;
		String comparison = null;
		
		try {
			base = br.readLine();
			comparison = br.readLine();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
		Inversions(base, comparison, br);
		
	}

	public static void Inversions(String base, String comparison,  BufferedReader br){ 
		int length = base.length() - comparison.length();
		String 	container;
		
		for(int i = 0; i <= length ; i ++ ) {
			container = base.substring( i, i + comparison.length() );
			if( container.equals(comparison) ) {
				System.out.println(i);
			}
		}
		
	}
}

/* 実行時間計測用

		long start = System.currentTimeMillis();
		long end = System.currentTimeMillis();
		System.out.println((end - start)  + "ms:計測時間");
*/


Measured memory_bytes: 24592