akhauriyash/Code-Regression huggingface dataset:
// {{{ include
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
// }}}
#include <cassert>

using namespace std;

typedef long long ll;
inline int in(){int x;scanf("%d",&x);return x;}

struct Lex {
  string S;
  int P, Q, R;
  Lex(){}
  void load(string s){ S = s; }
  void set(int p, int q, int r){ P = p, Q = q, R = r; }
  int minus(int x){ return 2 - x; }
  int mul(int x, int y){ return min(x, y); }
  int add(int x, int y){ return max(x, y); }
  int solve(){
    char *p = (char*)S.c_str();
    return formula(&p);
  }
  int formula(char** p){
    if (isdigit(**p)){
      int r = **p - '0';
      consume(p, **p);
      return r;
    }
    if (isalpha(**p)){
      int r;
      if (**p == 'P') r = P;
      if (**p == 'Q') r = Q;
      if (**p == 'R') r = R;
      consume(p, **p);
      return r;
    }
    if (**p == '-'){
      consume(p, '-');
      return minus(formula(p));
    }
    if (**p == '('){
      consume(p, '(');
      int x = formula(p);
      if (**p == '*'){
        consume(p, '*');
        int y = formula(p);
        consume(p, ')');
        return mul(x, y);
      }
      if (**p == '+'){
        consume(p, '+');
        int y = formula(p);
        consume(p, ')');
        return add(x, y);
      }
    }
  }
  inline void consume(char** p, char expected){
    assert(**p == expected);
    (*p)++;
  }
};

int main()
{
  string s;
  while (cin >> s, s != "."){
    Lex lex;
    lex.load(s);
    int ans = 0;
    for (int p = 0; p < 3; p++){
      for (int q = 0; q < 3; q++){
        for (int r = 0; r < 3; r++){
          lex.set(p, q, r);
          if (lex.solve() == 2) ans++;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/02  Problem: ABC 101 D / Link: http://abc101.contest.atcoder.jp/tasks/abc101_d  ----- */


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	auto digitsum = [](LL a) {
		LL ret = 0;
		while (a) {
			ret += a % 10;
			a /= 10;
		}
		return ret;
	};

	if (0) {
		VL ret;
		FOR(i, 1, 100000) {
			bool ok = 1;
			FOR(j, i + 1, 100000) {
				ok &= (i*digitsum(j) <= j * digitsum(i));
			}
			if (ok) {
				ret.push_back(i);
			}
		}
		for (auto it : ret) {
			cout << it << ", ";
		}cout << endl;
		return 0;
	}

	if (0) {
		FOR(i, 1, 1000 + 1) {
			cout << i << " " << 1.0*i / (1.0*digitsum(i)) << (i % 10 == 9 ? " Suf9" : "") << endl;
		}

		return 0;
	}

	LL N;
	cin >> N;
	VL ans;
	LL ten = 1;
	FOR(i, 0, 15) {
		FOR(j, 1, 150 + 1) {
			ans.push_back(ten*(j + 1) - 1);
		}
		ten *= 10;
	}
	SORT(ans);
	UNIQ(ans);
	DD(de(SZ(ans)));
	set<LL>prohibit(ALL(ans));
	FOR(i, 0, SZ(ans)) {
		FOR(j, i + 1, SZ(ans)) {
			LL a = ans[i], b = ans[j];
			if (prohibit.count(a) && prohibit.count(b) && a*digitsum(b) > b*digitsum(a)) {
				prohibit.erase(a);
				break;
			}
		}
	}
	DD(de(SZ(prohibit)));
	FOR(k, 0, N) {
		auto it = prohibit.begin();
		cout << *it << endl;
		prohibit.erase(it);
	}

	return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int t = scanner.nextInt();
		while (t-- > 0) {
			g = new char[12][6];
			ps = new boolean[12][6];
			for (int y = 0; y < 12; y++)
				g[y] = scanner.next().toCharArray();
			for (int i = 0;; i++) {
				boolean co = false;
				for (int j = 0; j < 12; j++) {
					Arrays.fill(ps[j], false);
				}

				for (int y = 0; y < 12; y++) {
					for (int x = 0; x < 6; x++) {
						step = 0;
						if (!cn(y, x, g[y][x]))
							continue;
						cr(y, x, g[y][x]);
						co = true;
					}
				}
				if (!co) {
					System.out.println(i);
					break;
				}
				for (int j = 0; j < 11; j++)
					for (int y = 0; y < 11; y++)
						for (int x = 0; x < 6; x++) {
							if (g[y][x] != '.' && g[y + 1][x] == '.') {
								g[y + 1][x] = g[y][x];
								g[y][x] = '.';
							}
						}
			}
		}
	}

	private void cr(int y, int x, char p) {
		if (g[y][x] != p)
			return;
		g[y][x] = '.';
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (!isOK(nx, ny))
				continue;
			if (g[ny][nx] == 'O') {
				g[ny][nx] = '.';
				continue;
			}
			cr(ny, nx, p);

		}
	}

	private boolean cn(int y, int x, char p) {
		if (p == 'O' || p == '.' || p != g[y][x] || ps[y][x])
			return false;
		step++;
		if (step == 4)
			return true;
		ps[y][x] = true;
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (!isOK(nx, ny))
				continue;

			if (cn(ny, nx, p))
				return true;
		}
		return false;
	}

	private boolean isOK(int nx, int ny) {
		return 0 <= nx && nx < 6 && 0 <= ny && ny < 12;
	}

	int step;
	char[][] g;
	boolean[][] ps;
	int dx[] = { 1, 0, -1, 0 };
	int dy[] = { 0, 1, 0, -1 };

}

Measured memory_bytes: 24528
input()
l=[[int(c)] for c in raw_input().split()]
for i,a in enumerate(sorted(l)):
    a[0]=i+1
s=0
r=len(l)+1
b=[0]*r
for n, in reversed(l):
    i=n
    while i>0:
        s+=b[i]
        i&=i-1
    while n<r:
        b[n]+=1
        n+=n&-n
print s

Measured memory_bytes: 42280
/*
 * Created by KeigoOgawa
 赤い点のx，ｙ座標が青い店のx，ｙ座標より小さいときにペアになれる
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int N;
vector<PII> a, b;


typedef int Weight;
struct Edge {
    int src, dst;
    Edge(int src, int dst) :
        src(src), dst(dst){};
};
typedef vector<Edge*> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;


bool augment(const Graph& g, int u,
             vector<int>& matchTo, vector<bool>& visited) {
    if (u < 0) return true;
    for(auto e : g[u]) if (!visited[e->dst]) {
        visited[e->dst] = true;
        if (augment(g, matchTo[e->dst], matchTo, visited)) {
            matchTo[e->src] = e->dst;
            matchTo[e->dst] = e->src;
            return true;
        }
    }
    return false;
}
int bipartiteMatching(const Graph& g, int L) {
    const int n = g.size();
    vector<int> matchTo(n, -1);
    int match = 0;
    REP(u, L) {
        vector<bool> visited(n);
        if (augment(g, u, matchTo, visited)) ++match;
    }
    return match;
}

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

    cin >> N;
    REP(i, N) {
        int t, m;
        cin >> t >> m;
        a.push_back({t, m});
    }
    REP(i, N) {
        int t, m;
        cin >> t >> m;
        b.push_back({t, m});
    }
    Graph g(N*2);
    REP(i, N){
        PII ta = a[i];
        REP(j, N) {
            PII tb = b[j];
            if (ta.first < tb.first && ta.second < tb.second) {
                Edge* e = new Edge(i, j+N);
                g[i].push_back(e);
                Edge *e1 = new Edge(j+N, i);
                g[j+N].push_back(e1);
            }
        }
    }
    cout << bipartiteMatching(g, N) << endl;


    return 0;
}


Measured memory_bytes: 512
while True:
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    else:
        line = '#.' * (w // 2 + 1)
        for i in range(h):
            if i % 2:
                print(line[1:w+1])
            else:
                print(line[:w])
        print()


Measured memory_bytes: 5612
n = int(input())
dp = [[0, 0, 0] for _ in range(n+1)]
for i in range(1, n+1):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b
    dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c

ans = max(dp[n][0], dp[n][1], dp[n][2])
print(ans)

Measured memory_bytes: 59428
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d;
 long long A;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
A=max(max(a*c,a*d),max(b*c,b*d));
  cout<<A<<endl;
}

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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (s == u){
    a -= 1;
  }else{
    b -= 1;
  }
  cout << a << " " << b << endl;
}

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

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

		
		var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			//答えの出力
			var ans = N%2==0? 0.5 : (double)(N/2+1)/N;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28292
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        
        try{
            String line;
            line = reader.readLine();
            String[] data = line.split(" ",2);
            int a = 0, b = 0;
            a = Integer.parseInt(data[0]);
            b = Integer.parseInt(data[1]);

            if(a == b){
                System.out.println("a == b");
            }else if(a > b){
                System.out.println("a > b");
            }else if(a < b){
                System.out.println("a < b");
            }

        }catch(NumberFormatException e){
            System.out.println(e);
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24184
#include <bits/stdc++.h>
using namespace std;
int64_t DP[100][2]; // i桁目, j: Kに一致する/しない, の時の最大値

int main()
{
  int64_t N, K, a;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  for (int i = 0; i < 100; i++)
  {
    DP[i][0] = DP[i][1] = -1;
  }
  DP[45][0] = 0;
  for (int i = 44; i >= 0; i--)
  {
    int64_t mask = (1LL << i);
    int64_t n = 0;
    for (int j = 0; j < N; j++)
    {
      if (A[j] & mask)
        n++; // i番目のbitが1のものを集計する
    }
    if (DP[i + 1][1] >= 0) // Kより小さい場合
    {
      DP[i][1] = max(DP[i][1], DP[i + 1][1] + mask * max(n, N - n));
    }
    if (DP[i + 1][0] >= 0)
    {
      if (K & (1LL << i)) // Kのi桁目のフラグが立っている
      {
        DP[i][1] = max(DP[i][1], DP[i + 1][0] + mask * n); // 0
        DP[i][0] = max(DP[i][0], DP[i + 1][0] + mask * (N - n));
      }
      else
      {
        DP[i][0] = max(DP[i][0], DP[i + 1][0] + mask * n); // 0
      }
    }
  }
  cout << max(DP[0][0], DP[0][1]) << endl;
}


Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int X = sc.nextInt();
			final int Y = sc.nextInt();
			
			if(X == 0 && Y == 0){
				break;
			}
			
			int[][] map = new int[Y][X];
			
			for(int i = 0; i < Y; i++){
				for(int j = 0; j < X; j++){
					map[i][j] = sc.nextInt();
				}
			}
			
			int[][] dp = new int[Y+2][X];
			
			for(int i = 0; i < Y; i++){
				for(int j = 0; j < X; j++){
					if(map[i][j] == 1){
						dp[i][j] = 0;
						//System.out.print(dp[i][j] + " ");
						continue;
					}
					
					if(i == 0){
						dp[i][j] = 1;
					}else{
						dp[i][j] += (map[i-1][j] == 0 ? dp[i-1][j] : 0);
						if(map[i][j] != 2){
							dp[i][j] += j != 0 ? (map[i-1][j-1] == 0 ? dp[i-1][j-1] : 0) : 0;
							dp[i][j] += j != X-1 ? (map[i-1][j+1] == 0 ? dp[i-1][j+1] : 0) : 0;
						}
					}
					
					if(map[i][j] == 2){
						dp[i+2][j] = dp[i][j];
					}
					
					//System.out.print(dp[i][j] + " ");
				}
				
				//System.out.println();
			}
			/*
			for(int i = Y; i < Y+2; i++){
				for(int j = 0; j < X; j++){
					System.out.print(dp[i][j] + " ");
				}
				System.out.println();
			}
			*/
			for(int i = Y; i < Y+2; i++){
				for(int j = 0; j < X; j++){
					if(i == Y && map[i-1][j] == 2){
						continue;
					}
					dp[i][j] += dp[i-1][j];
				}
			}
			/*
			System.out.println("--------------------------");
			for(int i = Y; i < Y+2; i++){
				for(int j = 0; j < X; j++){
					System.out.print(dp[i][j] + " ");
				}
				System.out.println();
			}
			*/
			int sum = 0;
			for(int j = 0; j < X; j++){
				sum += dp[Y+1][j];
			}
			
			System.out.println(sum);
		}
		
	}

}

Measured memory_bytes: 12000
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
using namespace std;

int main(void){
    int n,a,b;
    cin>>n>>a>>b;

    if(n*a < b) cout<<n*a<<endl;
    else cout<<b<<endl;
    
    return 0;

}

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

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

string s, t;

int main()
{
	while (cin >> s >> t, s != "0"){
		int a = 0, b = 0;
		rep(i, 4){
			if (s[i] == t[i]){
				a++;
				s[i] = t[i] = '*';
			}
		}
		rep(i, 4){
			if (s[i] == '*') continue;
			int p = t.find(s[i]);
			if (p != -1){
				b++;
				t[p] = '*';
			}
		}
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 1184
N = int(input())
X = [int(i) for i in input().split()]
a = X.copy()
a.sort()
a_l = a[N // 2 - 1]
a_r = a[N // 2]
for i in range(N):
    if X[i] <= a_l:
        print(a_r)
    else:
        print(a_l) 



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

int main(){ 
   int a ,b,c,d ; 
   cin>>a>>b>>c>>d; 
   long long m = max(1ll*a*d , max(1ll*b*d,max(1ll*a*c,1ll*b*c)));
   
   cout<<m ; }

Measured memory_bytes: 3636
int main(void){
   int r,c,i,j,x[100+1][100+1];
   scanf("%d %d",&r,&c);
   for(i=0;i<=r;i++){
       for(j=0;j<=c;j++){
          x[i][j]=0;
       }
   }
   for(i=0;i<r;i++){
       for(j=0;j<c;j++){
           scanf("%d",&x[i][j]);
       }
   }
   for(i=0;i<=r;i++){
       for(j=0;j<=c;j++){
           if(i!=r){
               printf("%d",x[i][j]);
               x[r][j]=x[r][j]+x[i][j];
               if(j==c) break;
                   x[i][c]=x[i][c]+x[i][j];
                   printf(" ");
           }
           else {
               printf("%d",x[i][j]);
               if(j==c) break;
               printf(" ");
           }
       }
       printf("\n");
   }
   return (0);
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

class UnionFind {
public:
  std::vector<int> parent;
  UnionFind(int n) {
    parent = std::vector<int> (n, -1);
  }

  int root(int x) {
    if(parent[x] < 0) return x;
    return parent[x] = root(parent[x]);
  }

  int size(int x) {
    return -parent[root(x)];
  }

  void unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if(rx == ry) return;
    if(size(rx) < size(ry)) std::swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
  }
};

int main() {
  int N, M, K;
  std::cin >> N >> M >> K;

  UnionFind uf(N);
  std::vector<int> friends(N);

  std::vector<int> A(M), B(M), C(K), D(K), ans(N);
  rep(i, M) {
    std::cin >> A[i] >> B[i];
    --A[i], --B[i];
    uf.unite(A[i], B[i]);
    ++friends[A[i]];
    ++friends[B[i]];
  }
  rep(i, N) {
    ans[i] = uf.size(i) - friends[i] - 1;
  }

  rep(i, K) {
    std::cin >> C[i] >> D[i];
    --C[i], --D[i];
    if(uf.root(C[i]) == uf.root(D[i])) {
      --ans[C[i]], --ans[D[i]];
    }
  }

  rep(i, N) {
    std::cout << ans[i] << ' ';
  } std::cout << "" << '\n';
}


Measured memory_bytes: 3584
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int A,B,M;
    cin >> A >> B >>M;

    vector<int> al(A);
    vector<int> bl(B);
    for(int i=0;i<A;i++){
        cin >>al[i];
    }
    for(int i=0;i<B;i++){
        cin >>bl[i];
    }
    
    int mina = *std::min_element(al.begin(), al.end());
    int minb = *std::min_element(bl.begin(), bl.end());
    int ans=mina+minb;

    for (int i=0;i<M;i++){
        int x,y,c;
        cin >> x >> y >>c;
        int xy=al[x-1]+bl[y-1]-c;
        if (xy < ans){
            ans=xy;
        }
    }
    cout << ans <<endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/
const int maxn = 1e6;
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    vector<int>pre(maxn+1);
    for(int i = 1;i<=maxn;i++)
    {
        int cnt = 0;
        for(int j = 1;j*j <= i;j++)
        {
            if(i%j == 0)
            {
                if(j == i/j)
                    cnt+=1;
                else
                    cnt += 2;
            }
        }
        pre[i] = cnt;
    }
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 1;i<n;i++)
    {
        ans += pre[n-i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7104
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
constexpr int inf=(1<<30)-1;
constexpr ll mod=1e9+7;



int main(){
      int n;
      cin>>n;
      int h[n];
      rep0(i,n) cin>>h[i];
      int posmax=1;
      int pos=1;
      rep0(i,n-1){
            if(h[i]>=h[i+1]){
                  pos++;
                  posmax=max(pos,posmax);
            }
            else{
                  pos=1;
            }
      }
      cout<<posmax-1<<endl;
      return 0;
}


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

int main() {
  int N, K, x, S = 0;
  cin >> N >> K;
    for(int i = 0; i < N; i++) {
      cin >> x;
      if(K >= x) {
        if(K - x >= x) {
          S += 2 * x;
        }
        else {
          S += 2 * (K - x);
        }
      }
      else {
        if(x - K >= x) {
          S += 2 * x;
        }
        else {
          S += 2 * (x - K);
        }
      }
    }
  cout << S << endl;
}

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

int main() {
    vector<int> A(9);
    for (int i = 0; i < 9; i++){
        cin >> A.at(i);
    }

    int N;
    cin >> N;

    vector<int> B(N);
    vector<int> C(9);
    for (int i = 0; i < N; i++){
        cin >> B.at(i);
        for (int j = 0; j < 9; j++){
            if (B.at(i) == A.at(j)){
                C.at(j) = 1;
                break;
            }
        }
    }
    
    int ans = 0;
    if (C.at(0)==1 && C.at(1)==1 && C.at(2)==1) ans = 1;
    if (C.at(3)==1 && C.at(4)==1 && C.at(5)==1) ans = 1;
    if (C.at(6)==1 && C.at(7)==1 && C.at(8)==1) ans = 1;
    if (C.at(0)==1 && C.at(3)==1 && C.at(6)==1) ans = 1;
    if (C.at(1)==1 && C.at(4)==1 && C.at(7)==1) ans = 1;
    if (C.at(2)==1 && C.at(5)==1 && C.at(8)==1) ans = 1;
    if (C.at(0)==1 && C.at(4)==1 && C.at(8)==1) ans = 1;
    if (C.at(2)==1 && C.at(4)==1 && C.at(6)==1) ans = 1;
    
    if (ans == 1){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt(); in.nextLine();
		
		char[][] ary = new char[h+2][w+2];
		String tempS = "";
		
		for ( char[] row : ary ) {
			Arrays.fill(row, '?');
		}
		
		for ( int i = 0; i < h; i++ ) {
			tempS = in.nextLine();
			for ( int j = 0; j < w; j++ ) {
				ary[i+1][j+1] = tempS.charAt(j);
			}
		}
		
		// System.out.println(Arrays.deepToString(ary));
		String[][] newAry = new String[h][w];
		int ctr = 0;
		int newAryH = 0;
		int newAryW = 0;
		for ( int i = 0; i < h+1; i++ ) {
			for ( int j = 0; j < w+1; j++ ) {
				if ( ary[i][j] == '#' ) {
					newAry[newAryH][newAryW] = "#";
					newAryW++;
					// System.out.println(Arrays.deepToString(newAry));
				} else if ( ary[i][j] == '?' ) {
				} else {
					if ( ary[i-1][j-1] == '#' )
						ctr++;
					if (ary[i-1][j] == '#' )
						ctr++;
					if (ary[i-1][j+1] == '#' )
						ctr++;
					if (ary[i][j-1] == '#' )
						ctr++;
					if (ary[i][j+1] == '#' )
						ctr++;
					if (ary[i+1][j-1] == '#' )
						ctr++;
					if (ary[i+1][j] == '#' )
						ctr++;
					if (ary[i+1][j+1] == '#' )
						ctr++;
					
					// System.out.println("h: "+newAryH);
					// System.out.println("w: "+newAryW);
					// System.out.println(ctr);
					newAry[newAryH][newAryW] = Integer.toString(ctr);
					// System.out.println(Arrays.deepToString(newAry));
					ctr = 0;
					newAryW++;
				}
			}
			newAryW = 0;
			if ( i != 0 )
				newAryH++;
		}
		
		String fin = "";
		for ( int i = 0; i < h; i++ ) {
			for ( int j = 0; j < w; j++ ) {
				if ( newAry[i][j] != "#" )
					fin += Integer.parseInt(newAry[i][j]);
				else
					fin += newAry[i][j];
			}
			fin += "\n";
		}
		
		System.out.println(fin);
	}
}

Measured memory_bytes: 35924
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int N = s.size();
  std::vector<int> v(N+1);
  v[0] = 0;
  for(int i = 0; i < N; ++i) v[i+1] = v[i] ^ (1<<s[i]-'a');
  std::vector<int> dp(1<<26, N+1);
  int ans = 0;
  dp[0] = 0;
  for(int i = 0; i < N; ++i) {
    ans = dp[v[i+1]]+1;
    for(int j = 0; j < 26; ++j) {
      ans = std::min(ans, dp[v[i+1]^(1<<j)]+1);
    }
    dp[v[i+1]] = std::min(dp[v[i+1]], ans);
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 263572
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#![allow(unused_macros, unused_mut)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!{
        n: i32,
    }
    let n = n % 1000;
    if n == 0 {
        println!("0");
    } else {
        println!("{}", 1000 - n);
    }
    
}


Measured memory_bytes: 2136
////////////////////////////////////
//          ,.                    //
//         (_|,.                  //
//        ,' /, )_______   _      //
//     __j o``-'        `.'-)'    //
//    (")                 \'      //
//     `-j                |       //
//        `-._(           /       //
//           |_\  |--^.  /        //
//          /_]'|_| /_)_/         //
//             /_]'  /_]'         //
//                                //
//           PIGMEISTER™          //
//                                //
////////////////////////////////////

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

#define ll long long
#define ull unsigned long long
#define mod (ll)1000000007
#define sidha(i, x, n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i, x, n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mii map<ll, ll>
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define modInv(x) powah(x, mod-2)
#define test ll t;cin>>t;while(t--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
ll powah(ll, ll);

int main()
{
    jaldi;
    
    map<string, ll> m;
    ll n;
    cin >> n;
    string s;
    sidha (i, 0, n) {
        cin >> s;
        m[s]++;
    }
    ll Max = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        Max = max(Max, it->second);
    }
    for (auto it = m.begin(); it != m.end(); it++) {
        if (it->second == Max)
            cout << it->first << endl;
    }

    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1;
    x = x % mod;
    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % mod; 
        y = y>>1;
        x = (x*x) % mod;   
    } 
    return res; 
}

Measured memory_bytes: 23808
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<vector>
#define ll long long
#define mt(a) memset(a,0,sizeof(a))
#define MAXI 2000000000
#define PAI pair<int,int>

using namespace std;

ll  f[200009],w[200009],v[200009];
int main()
{
	int n, m,vv=0;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld%lld", &w[i], &v[i]);
		vv += v[i];
	}
	for (int i = 1; i <= vv; i++)
		f[i] = MAXI;
	for (int i = 1; i <= n; i++)
	{
		for (int c = vv; c >= v[i]; c--)
		{
			f[c] = min(f[c], f[c - v[i]] + w[i]);
		}
	}
	ll maxx = -MAXI;
	for (int i = 0; i <= vv; i++)
		if (f[i] <= m) maxx = i;
	printf("%lld\n", maxx);
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
using namespace std;
int GCD(int a,int b);
int main(){
  int n;
  int data[100005];

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

  int left_gcd[100005];
  int right_gcd[100005];
  left_gcd[0]=data[0];
  right_gcd[n-1]=data[n-1];
  for(int i=1;i<n;i++){
    left_gcd[i]=GCD(left_gcd[i-1],data[i]);
  }
  for(int i=n-2;i>=0;i--){
    right_gcd[i]=GCD(right_gcd[i+1],data[i]);
  }

  int maxim=max(right_gcd[1],left_gcd[n-2]);
  for(int i=1;i<n-1;i++){
    maxim=max(maxim,GCD(left_gcd[i-1],right_gcd[i+1]));
  }
  cout<<maxim<<endl;
  return(0);
}

int GCD(int a,int b){
  while(b>0){
    int temp=a%b;
    a=b;
    b=temp;
  }
  return(a);
}


int gcd(int a,int b){
  while(b>0){
    int temp=a%b;
    a=b;
    b=temp;
  }
  return(a);
}



Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 14 21:06:03 2020

@author: H_Hoshigi
"""

s_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(s_list[K-1])



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

/*
 考察
 ドミノの接し方は、
 ab
 ab
 
 abb
 acc
 
 aac
 bbc
 
 aabb
 ccdd
 の４種類
 これを縦をv、横をhと表すと、
 vv,vh,hv,hh
 のように表現できる
 vとhの塗り方は左の縦横に依存して、独立である
 vv:*2
 vh:*2
 hv:*1
 hh:*3
 左端は
 v:3
 h:6
*/

int n;
string s1;
string s2;
string d = "";

int main() {
    cin >> n >> s1 >> s2;
    REP(i,n){
        if(s1[i]==s1[i+1]){
            d += "h";
            i++;
        }else{
            d += "v";
        }
    }
    ll res;
    if(d[0]=='h'){
        res = 6;
    }else{
        res = 3;
    }
    FOR(i,1,d.size()){
        if(d[i-1]=='h'){
            if(d[i]=='h'){
                res *= 3;
            }
        }else{
            res *= 2;
        }
        res = res%1000000007;
    }
    //put(d);
    put(res);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def rec(i):
    if memo[i] != -1:
        return memo[i]
    elif not graph[i]:
        return 0
    else:
        memo[i] = max([rec(edge) for edge in graph[i]]) + 1
        return memo[i]


N, M = map(int, input().split())
memo = [-1 for i in range(N+1)]
graph = [[] for i in range(N+1)]
for i in range(M):
    x, y = map(int, input().split())
    graph[y].append(x)

for i in range(N+1):
    rec(i)

print(max(memo))


Measured memory_bytes: 216112
S = input()
C = [chr(97+i) for i in range(26)]

if len(S) != 26:
    for c in C:
        if c not in S:
            print(S + c)
            break
else:
    S = list(S)
    for i in range(25, -1, -1):
        if S[i:] != sorted(S[i:], reverse=True):
            Z = sorted(list(filter(lambda x: x > S[i], S[i:])))
            print("".join(S[:i]) + Z[0])
            break
    else:
        print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007

int main() {
  int h, a;
  cin >> h >> a;
  int ans = h / a;
  if (h % a != 0) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		long A=stdIn.nextLong();
		long B=stdIn.nextLong();
		long C=stdIn.nextLong();
		long D=stdIn.nextLong();
		long ans=B-A+1,hoge=0,hoge2=0,hoge3=0;
		if(A>C)
			hoge=(A/C)*C;
		else
			hoge=0;
		if(A%C==0&&A>C)
			hoge-=C;
		if(B>C)
			hoge2=(B/C+1)*C;
		else
			hoge2=C;
		if(C==B)
			hoge2+=C;
		ans-=(hoge2-hoge)/C;ans++;
		//kireme
		if(A>D)
			hoge=(A/D)*D;
		else
			hoge=0;
		if(A%D==0&&A>D)
			hoge-=D;
		if(B>D)
			hoge2=(B/D+1)*D;
		else
			hoge2=D;
		if(D==B)
			hoge2+=D;
		ans-=(hoge2-hoge)/D;ans++;
		//kireme2
		hoge=C;hoge2=D;
		while(hoge%hoge2!=0){
			hoge3=hoge%hoge2;
			hoge=hoge2;
			hoge2=hoge3;
		}
		hoge3=(C*D)/hoge2;
		if(A>hoge3)
			hoge=(A/hoge3)*hoge3;
		else
			hoge=0;
		if(A%hoge3==0&&A>hoge3)
			hoge-=hoge3;
		if(B>C)
			hoge2=(B/hoge3+1)*hoge3;
		else
			hoge2=hoge3;
		if(hoge3==B)
			hoge2+=hoge3;
		ans+=(hoge2-hoge)/hoge3;ans--;
		System.out.println(ans);
	}
}

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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    map<int,int> mp;
    int p = 0,ans = 0;
    for(int i = 0; i < m; i++){
        int a; string s;
        cin >> a >> s;
        if(mp[a] == -1)
            continue;
        if(s == "AC"){
            p += mp[a];mp[a] = -1; ans++;}
        else
            mp[a]++;
    }
    cout << ans << ' ' << p << endl;

}


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

int func(int x)
{
    if(x%2==0)
    {
        return x/2;
    }
    else
    {
        return 3*x+1;
    }
}
int main()
{
    int n,d,x;
    cin>>n>>d>>x;
    vector <int> a(n);
    int choco = n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }

    for(int i=0;i<n;i++)
    {
        bool flag = true;
        int mult = 1;
        while(flag)
        {
            if(mult*a[i]+1<=d)
            {
                choco++;
                mult++;
            }
            else
            {
                flag = false;
            }
        }
    }

    cout<<choco+x<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int nax=3000;

int main()
{
    int n;
    cin >> n;
    vector<double> dp(nax);
    dp[0]=1;
    
    cout << fixed << setprecision(10);
    
    for(int i=0;i<n;++i)
    {
        double p;
        cin >> p;
        
        for(int j=n;j>=0;--j)
        {
            if(j>0)
            dp[j]=(dp[j-1]*p)+dp[j]*(1-p);
            else 
            dp[j]=dp[j]*(1-p);
        }
    }
    double ans=0;
    
    for(int i=0;i<=n;++i)
    {
        if(i>n-i)
        ans+=dp[i];
    }
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <atcoder/dsu>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using namespace atcoder;
using P = pair<int, int>;

int main() {
    int N; cin >> N;
    vector<P> ps(N);
    vector<int> id(N);
    vector<int> ytox(N);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        ps[i] = make_pair(x, y);
        id[i] = x;
        ytox[y] = x;
    }
    sort(ps.begin(), ps.end());
    stack<int> st;
    dsu uf(N);
    for(auto &[x, y] : ps) {
        int mn = y;
        while(!st.empty() && st.top() < y) {
            uf.merge(ytox[st.top()], x);
            mn = min(mn, st.top());
            st.pop();
        }
        st.push(mn);
    }
    rep(i, N) cout << uf.size(id[i]) << '\n';
}


Measured memory_bytes: 7208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,a,b;
  cin>>n>>a>>b;
  in mn=a*(n-1)+b;
  in mx=a+(n-1)*b;
  cout<<max(0LL,(mx-mn+1))<<endl;
  return 0;
}


Measured memory_bytes: 256
// Try yahoo procon 2019 qual
// author: Leonardone @ NEETSDKASU 

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let k = get!();
    let a = get!();
    let b = get!();
    
    if b - a <= 2 || a + 1 > k {
    	let ans = k + 1;
        println!("{}", ans);
        return;
	}
    
    let mut ans = b;
    let r = k - a - 1;
    ans += (r / 2) * (b - a);
    ans += r % 2;
    
    println!("{}", ans);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n ; i++) cin >> a.at(i);
    int ans = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < n - 1; i++) {
        if (a.at(i) == a.at(i + 1)) {
            ans ++;
        }
    }
    if (1 <= ans) cout << "NO" << endl;
    else cout << "YES" << endl;
    //for (int i = 0; i < n; i++) cout << a.at(i) << endl;
    return 0;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
arr = [input() for _ in range(H)]

for i in range(H):
    for j in range(W):
        if arr[i][j] == '#':
            flg =False
            if i-1>=0:
                if arr[i-1][j] == '#':
                    flg = True
            if j-1>=0:
                if arr[i][j-1] == '#':
                    flg = True
            if i+1<H:
                if arr[i+1][j] == '#':
                    flg = True
            if j+1<W:
                if arr[i][j+1] == '#':
                    flg = True
            if flg == False:
                print('No')
                exit()

print('Yes')




Measured memory_bytes: 67444
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF = 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
const ll LINF=100000000000000000LL;
int v[1005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>v[i];
    int resp=INF;
    for(int tgt=-100;tgt<101;tgt++)
    {
        int tmp=0;
        for(int i=0;i<n;i++)
        {
            tmp+=(v[i]-tgt)*(v[i]-tgt);
        }
        resp=min(resp,tmp);
    }
    pri(resp);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 19 17:29:01 2019

@author: makigon
"""
mod = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

aset = set(a)
f = [0 for i in range(N)]
f[0] = 1
if 1 in a and N>=2 :
    f[1] = 0
elif 1 not in a and N>=2:
    f[1] = 1

for i in range(2,N):
    if i in aset:
        continue
    else:
        f[i] = f[i-1]+f[i-2]
    f[i] %= mod

if N == 1:
    print(f[N-1])
else:       
    print((f[N-1]+f[N-2]) % mod)
    
    


Measured memory_bytes: 13216
/*
ID: markusz1
TASK: template
PROG: template
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ul;
typedef priority_queue<int> p_int;
typedef priority_queue<ll> p_ll;
typedef priority_queue<double> p_double;

int a[300001], n, temp;
ll sum;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	for (int i=0;i<3*n;i++) cin >> a[i];
	sort(a, a+3*n, greater<int>());
	for (int i=1;i<2*n;i+=2) sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 1408
N = int(input())
x = 1
for i in range(1,N+1):
  x = x*i
  x = x%(10**9+7)
  if x >= 10**9+7:
    x = x-10**9-7
print(x%(10**9+7))
#457992974
# 計算の桁数を減らすことで処理が早くなる

Measured memory_bytes: 2940
n = int(input())
a = [0]*n

for i in range(n):
    a[i] = int(input())
ans = 0
for i in range(n-1):
    if a[i] >= 2:
        ans += a[i]//2
        a[i] = a[i]%2
    if a[i] == 1 and a[i+1] >= 1:
        ans += 1
        a[i] -= 1
        a[i+1] -= 1
print(ans+a[-1]//2)


Measured memory_bytes: 12756
n = int(input())
a = [None for _ in range(n)]
b = [None for _ in range(n)]
for i in range(n):
    a[i], b[i] = map(int, input().split())
a.sort()
b.sort()

if n % 2:
    print(b[n // 2] - a[n // 2] + 1)
else:
    bb = b[n // 2] + b[n // 2 - 1]
    aa = a[n // 2] + a[n // 2 - 1]
    print(bb - aa + 1)


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





ll int arr[2*n_size+1],arr2[2*n_size+1];



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

	ll int n,m=0,T,res;

	ll int maxi=-mx,mini=mx,count=0;

	ll int i,j,k=0;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,0,n-1){

        cin>>arr[i];

        count+=arr[i];

	}

    if(n==2){

        cout<<abs(arr[0]-arr[1])<<endl,exit(0);

    }

	f(i,0,n-2){

	    m+=arr[i];

	    k=count-m;

        mini=min(mini,abs(m-k));

        //cout<<m<<" "<<k<<" "<<mini<<endl;

	}

	cout<<mini<<endl;

}


Measured memory_bytes: 1792
import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def main():
    x = int(input())

    while True:
        if is_prime(x):
            ans = x
            break
        x += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.*;

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

        String s = sc.next();

        String[] parts = s.split("/");

        int y = Integer.parseInt(parts[0]);
        int m = Integer.parseInt(parts[1]);
        int d = Integer.parseInt(parts[2]);

        if (y > 2019) {
            System.out.println("TBD");
            return;
        }

        if (m > 4) {
            System.out.println("TBD");
            return;
        }

        if (d > 30) {
            System.out.println("TBD");
            return;
        }

        System.out.println("Heisei");
    }
}

Measured memory_bytes: 23124
X=int(input())
if X<600:
    print("8")
elif 600<=X and X<800:
    print("7")
elif 800<=X and X<1000:
    print("6")
elif 1000<=X and X<1200:
    print("5")
elif 1200<=X and X<1400:
    print("4")
elif 1400<=X and X<1600:
    print("3")
elif 1600<=X and X<1800:
    print("2")
else:
    print("1")


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int h,a;
	cin>>h>>a;
	for(long long int i=1;i<=h;i++)
	{
		if((a*i)>=h)
		{
			cout<<i<<endl;
			return 0;	
		}
	}
}


Measured memory_bytes: 256
a,b = map(int, input().split())
res = 0
for i in range(a,b+1):
  i = str(i)
  flg = 0
  for j in range(len(i)//2):
    if i[j] != i[-j-1]:
      flg = 1
  if flg == 0:
    res += 1
print(res)

Measured memory_bytes: 3060