akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

//debug処理
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n;
int count(int p) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(p); i++) {
		if (p % i == 0 && i * i != p)cnt += 2;
		else if (p % i == 0)cnt++;
	}
	return cnt;
}
signed main() {
	int n, k;
	cin >> n >> k;
	cout << min(n % k, k - n % k) << endl;
	ggr
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/big"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
					`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	a := big.NewInt(int64(nextInt()))
	b := big.NewInt(int64(nextFloat64()*100 + 0.0000000000001))
	a.Mul(a, b).Div(a, big.NewInt(100))
	//a.Div(a, big.NewInt(100))

	//fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, a)
}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}


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

int main(){
  int N;
  cin >> N;
  
  int num_P = 0;
  int num_W = 0;
  int num_G = 0;
  int num_Y = 0;
  int num;
  for (int i=0; i<N; i++){ 
    string color;
    cin >> color;
    
    if (color=="P"){
      if (num_P==0){
        num_P++;
      }else{
        ;
      } 
    } else if (color=="W"){
      if (num_W==0){
        num_W++;
      }else{
        ;
      }
    } else if (color=="G"){
      if (num_G==0){
        num_G++;
      }else{
        ;
      }
    } else if (color=="Y"){
      if (num_Y==0){
        num_Y++;
      }else{
        ;
      }
    } else {
      ;
    }
  }
  num = num_P+num_W+num_G+num_Y;
  if (num==3){
    cout << "Three" << endl;
  } else if (num==4){
    cout << "Four" << endl;
  } else {
    cout << "error" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextInt(),b = sc.nextInt();
    if(a==1||b==1)System.out.println(1);
    else System.out.println((a*b+1)/2);
  }
}

Measured memory_bytes: 21844
// Vicfred
// https://atcoder.jp/contests/abc167/tasks/abc167_c
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n, m, x;
    readf("%s %s %s\n", &n, &m, &x);

    int[] c = new int[n];
    int[][] A = new int[][](n,m);

    for(int i = 0; i < n; ++i) {
        int[] line = readln.split.map!(to!int).array;
        c[i] = line[0];
        A[i] = line[1..$];
    }

    int minima = int.max;

    for(int mask = 0; mask <= (1<<n)-1; mask++) {
        int total = 0;
        int[] level = new int[m];

        for(int bit = 0; bit < n; bit++) {
            if(mask&(1<<bit)) {
                total += c[bit];
                for(int i = 0; i < m; i++) {
                    level[i] += A[bit][i];
                }
            }
        }

        auto gtx = (int a) => a >= x;

        if(all!gtx(level))
            minima = min(minima, total);
    }

    if(minima == int.max)
        minima = -1;

    minima.writeln;
}



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

void solve(){
    int n,d;
    cin>>n>>d;
    cout << (n+ 2*d +1-1)/(2*d+1);

 

}


int main(){
   solve();
}

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

int main () {
	int a,b,c,d,L;
	int hi,tuki;
	float fhi,ftuki;
	cin >> L >> a >> b >> c >> d;
	hi=a/c;
	fhi=(float)a/c;
	tuki=b/d;
	ftuki=(float)b/d;
	if(hi<fhi){
		hi++;
		}
	if(tuki<ftuki){
		tuki++;
		}
	if(hi>tuki){
		cout << L-hi <<'\n';
	}else{
		cout << L-tuki <<'\n';
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int H,W;
char s[50][50];
int dist[50][50];

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

int BFS(){
	queue<P> que;
	REP(i,H)
		REP(j,W)
			dist[i][j] = INF;
	que.push(P(0, 0));
	dist[0][0] = 0;
	while(que.size()){
		P p = que.front();
		que.pop();
		if(p.first == H - 1 && p.second == W - 1) break;
		REP(i,4){
			int ny = p.first + dy[i], nx = p.second + dx[i];
			if(0 <= ny && ny < H && 0 <= nx && nx < W && s[ny][nx] != '#' && dist[ny][nx] == INF){
				que.push(P(ny, nx));
				dist[ny][nx] = dist[p.first][p.second] + 1;
			}
		}
	}
	return dist[H - 1][W - 1];
}

int main(){
	cin >> H >> W;
	REP(i,H)
		REP(j,W)
			cin >> s[i][j];
	int cnt = 0;
	REP(i,H){
		REP(j,W){
			if(s[i][j] == '.') cnt++;
		}
	}
	if(BFS() == INF) cout << -1 << endl;
	else cout << cnt - BFS() - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;

    if (s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]) {
        cout<<"No"<<endl;
    }
    else if(s[0]==s[1]&&s[2]==s[3]){
        cout<<"Yes"<<endl;
    }
    else if (s[0]==s[2]&&s[1]==s[3]) {
        cout<<"Yes"<<endl;
    }
    else if (s[0]==s[3]&&s[1]==s[2]) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int N;
    cin>>N;
    vector<long long int> T(N,0);
    vector<long long int> A(N,0);
    vector<long long int> T2(N,0);
    vector<long long int> A2(N,0);
    for(int i=0;i<N;i++){
        cin>>T[i];
    }
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N-1;i++){
        
        if(T[i]==T[i+1]){
            T2[i+1]=T[i];
        }
    }
    for(int i=N-1;i>0;i--){
        
        if(A[i]==A[i-1]){
            A2[i-1]=A[i];
        }
    }
    
    // for(auto a:T2){
    //     cout<<a<<" ";
    // }
    
    // cout<<endl;
    // for(auto a:A2){
    //     cout<<a<<" ";
    // }
    
    // cout<<endl;
    
    for(int i=0;i<N;i++){
        if(T2[i]==0&&A2[i]==0){
            if(T[i]!=A[i]){
                cout<<0;
                return 0;
            }
        }
        if(T2[i]==0){
            if(T[i]>A[i]){
                cout<<0;
                return 0;
            }
        }
        if(A2[A.size()-1-i]==0){
            if(A[A.size()-1-i]>T[A.size()-1-i]){
                cout<<0;
                return 0;
            }
        }
    }
    if(T[T.size()-1]!=A[0]){
        cout<<0;
        return 0;
    }
    unsigned long long int ans=1;
    for(int i=0;i<N;i++){
        ans=(ans*(min(T2[i]==0?1:T2[i],A2[i]==0?1:A2[i])%1000000007))%1000000007;
    }
    cout<<ans;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

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

int main() {
  int a,b;
  scanf("%d%d", &a,&b);
  if (a<=8 && b<=8) printf("Yay!");
  else printf(":(");
}


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

using namespace std;
using ll = long long;

int main() {

  ios_base::sync_with_stdio (false);
  cin.tie (0);

  ll n;
  cin >> n;
  string s;
  cin >> s;

  ll ans = 0;
  ll low = 1, high = n;
  while (low <= high) {
    ll mid = (low + high) >> 1;
    string slide = "";
    map<string, ll>mp;
    for (ll i = 0; i < mid; i++) {
      slide += s[i];
    }
    bool ok = 0;
    mp[slide] = 0;
    ll st = 1;
    for (ll i = mid; i < n; i++) {
      slide.erase (slide.begin() );
      slide += s[i];
      /*if (mid == 2) {
        cerr << slide << ' ' << mp[slide] + mid << ' ' << i - mid + 1 << '\n';
      }*/
      if (mp.find (slide) != mp.end() && mp[slide] + mid <= i - mid + 1) {
        ok = 1;
        break;
      }
      if (mp.find (slide) == mp.end() ) {
        mp[slide] = st;
      }
      st++;
    }
    if (ok) {
      ans = max (ans, mid);
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 6704
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
# define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;
typedef queue<int> qi;


const int N = 2e5 + 5;

int powm(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) /*% mod*/;
		a = (a * a) /*% mod*/;
		b >>= 1;
	}
	return res;
}

void solve() {

	int n;
	cin >> n;
	int ans = 1;
	vi a(n);
	fr(i, 0, n - 1)
		cin >> a[i];
	sort(all(a));
	if (a[0] == 0) {
		cout << 0;
		return;
	}
	int x = powm(10, 18);
	fr(i, 0, n - 1) {
		if (ans>x/a[i]+1) {
			cout << -1;
			return;
		}
		ans *= a[i];
		if(ans>x) {
			cout << -1;
			return;
		}
	}
	cout << ans;
}


signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout << fixed << setprecision(15);
	int t = 1;
	//cin >> t;

	while (t--)
		solve();
#ifdef aa
	cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


int norm(int a) {
	while (a >= mod) a -= mod;
	while (a < 0) a += mod;
	return a;
}



int divide(int a, int b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}


Measured memory_bytes: 3976
def check(num):
  count = 0
  while True:
    if num % 2 != 0:
      return count
    num //= 2
    count += 1

N = int(input())
if N==1: print(1);exit()
max_num = 0
result_num = 0
count = 0
for i in range(1, N+1):
  count = check(i)
  if max_num < count:
    max_num = count
    result_num = i
print(result_num)

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

using namespace std;

int main(void){
    string S,T;
    cin>>S>>T;
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    reverse(T.begin(),T.end());

    if(S<T){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	if ((A - B) % 2 == 0) {
		cout <<abs(A-B) / 2;
	}
	else
	{
		cout << min(min(N - A, N - B), min(A-1, B-1))+1+(abs(A-B)-1)/2;
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define NODE 30
#define LIM 31
const double inf = 1e200;

class state{
public:
  int cur,prev,speed;
  double c;
  state(){};
  state(int tcur,int tprev,int tspeed,double tc):cur(tcur),prev(tprev),
						 speed(tspeed),c(tc){};
  bool operator<(const state & a)const{
    return c >a.c;
  }
};

double cost[30][30][31];
double dist[30][30];
int lim[30][30];
bool visited[30][30][31];

void solve(int n,int s,int g){
  rep(i,n)rep(j,n)rep(k,31)cost[i][j][k]=inf,visited[i][j][k]=false;
  priority_queue<state> Q;
  cost[0][0][1]=0;
  rep(i,n){
    if ( lim[s][i] >= 1){
      cost[i][s][1]=dist[s][i];
      Q.push(state(i,s,1,cost[i][s][1]));
    }
  }

  while(!Q.empty()){
    state now = Q.top();
    Q.pop();
    /*
    if ( cost[now.cur][now.prev][now.speed] <now.c){
      puts("test");
      continue;
      }*/
    if ( visited[now.cur][now.prev][now.speed])continue;
    visited[now.cur][now.prev][now.speed]=true;
    if ( now.cur == g && now.speed == 1){
      printf("%.3lf\n",now.c);
      return;
    }
    rep(i,n){
      if ( i == now.prev)continue;
      REP(j,-1,2){
	if ( now.speed + j > 0 && now.speed + j <= lim[now.cur][i] &&
	     cost[i][now.cur][now.speed+j] > now.c + dist[now.cur][i]/(now.speed+j)){
	  cost[i][now.cur][now.speed+j]=now.c+dist[now.cur][i]/(now.speed+j);
	  Q.push(state(i,now.cur,now.speed+j,cost[i][now.cur][now.speed+j]));
	}
      }
    }
  }
  

  puts("unreachable");
  
}


main(){
  int n,m;
  while(cin>>n>>m && n){
    rep(i,n)rep(j,n)lim[i][j]=0,dist[i][j]=inf;
    int s,g;
    cin>>s>>g;
    s--;g--;
    rep(i,m){
      int f,t,v;
      double d;
      cin>>f>>t>>d>>v;
      f--;t--;
      dist[f][t]=dist[t][f]=d;
      lim[f][t]=lim[t][f]=v;
    }
    solve(n,s,g);
  }
}

Measured memory_bytes: 2428
#include<iostream>
using namespace std;
long long int f(long long int a,long long int x);
int main(){
  long long int a,b,x;
  cin >> a >> b >> x;
  cout << f(b,x)-f(a-1,x);
}

long long int f(long long int a,long long int x){
  if (a == -1){
    return 0;
  }else{
    return a/x+1;
  }
}


Measured memory_bytes: 256
#include <iostream>
int main() {
	char x, y, z;
	std::cin >> x >> y >> z;
	int a = 0, b = 0, c = 0;

	a += (x == 'a');
	a += (y == 'a');
	a += (z == 'a');

	b += (x == 'b');
	b += (y == 'b');
	b += (z == 'b');

	c += (x == 'c');
	c += (y == 'c');
	c += (z == 'c');

	if (a && b && c)
		std::cout << "Yes";
	else
		std::cout << "No";

	return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    maxv = 0
    minv = n
    for i in range(m):
        l, r = map(int, input().split())
        if l > maxv:
            maxv = l
        if r < minv:
            minv = r
    if (minv - maxv) >= 0:
        print(minv - maxv + 1)
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    string s;cin>>s;
    ll Q;cin>>Q;
    vec<string> a(2);

    bool w = 0;
    while(Q--){
        ll t;cin>>t;
        if (t==1){
            w ^= 1;
        }
        if (t==2){
            ll f;cin>>f;
            char c;cin>>c;
            if (f==1){ a[w] += c; }
            if (f==2){ a[w^1] += c; }
        }
        dump(a);
    }

    string ans;
    if (w==0){
        reverse(all(a[0]));
        ans += a[0];
        ans += s;
        ans += a[1];
    }
    else{
        reverse(all(a[1]));
        ans += a[1];
        reverse(all(s));
        ans += s;
        ans += a[0];
    }
    cout << ans << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 1300
#include <cstdio>
#include <cctype>
#include <queue>
#define int long long

std::priority_queue<int > a;
int n, m;

int read() {
    int ret, f = 1;
    char ch;
    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);
    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');
    return ret * f;
}

void print(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

signed main() {
    n = read(), m = read();
    for(int i = 1; i <= n; ++i) a.push(read());
    while(m--) {
        int t = a.top();
        a.pop();
        a.push(t >> 1);
    }
    int ans = 0;
    while(!a.empty()) ans += a.top(), a.pop();
    print(ans);
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
    int N;
    long long K;
    cin>>N>>K;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    vector<int> S(N, -1);
    map<int, int> M;
    for (int i=N-1; i>=0; i--)
        M[A[i]] = i;
    for (int i=N-1; i>=0; i--)
    {
        S[i] = M[A[i]];
        M[A[i]] = i;
    }

    int p = 0;
    long long k = 0;
    while (k<K-1)
    {

        if (S[p]<=p)
            k++;
        p = S[p]+1;
        if (p>=N)
        {
            p %= N;
            k++;
        }

        if (p==0)
        {
            long long t = (K-1)/k;
            k *= t;
        }
        //cout<<k<<" "<<p<<endl;
    }

    vector<int> ans;
    set<int> SS;

    for (int i=p; i<N; i++)
    {
        if (SS.count(A[i])>0)
        {
            while (ans.back()!=A[i])
            {
                SS.erase(ans.back());
                ans.pop_back();
            }
            ans.pop_back();
            SS.erase(A[i]);
        }
        else
        {
            ans.push_back(A[i]);
            SS.insert(A[i]);
        }
    }

    bool f = true;
    for (int a: ans)
    {
        cout<<(f?"":" ")<<a;
        f = false;
    }
    cout<<endl;
}


Measured memory_bytes: 22644
#include<cstdio>
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<=n;++i)
        for(int j=0;j<=n;++j)
            for(int k=0;k<=n&&i+j+k<=n;++k)
                if(i+j+k==n&&1000*i+5000*j+10000*k==m)
                {
                    printf("%d %d %d\n",k,j,i);
                    return 0;
                }
    printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}




int main (){
	int n;
	cin >> n;
	ll a,ans=0;

	rep (i,n){
		cin >> a;

		ans += a;
	}
	cout << ans - n << endl;
	
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;




int main()
{
    int n;
    cin>>n;
    vector<pii> task(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        task[i] = mp(b,a);
    }
    sort(all(task));
    int now = 0;
    rep(i,n){
        now+=task[i].S;
        if (now>task[i].F){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

int n;
int res[10];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= 9; ++i)
		res[i] = res[i-1]+111;
	printf("%d\n", *lower_bound(res, res+10, n));
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  A.append(sorted(input()))
A.sort()
ans = 0
c = 1
for i in range(N-1):
  if A[i] == A[i+1]:
    c += 1
  else:
    ans += c * (c-1) // 2
    c = 1
ans += c * (c-1) // 2
print(ans)

Measured memory_bytes: 127300
A, B, K= gets.split.map(&:to_i)

count = 0

for i in 1..[A,B].max do
  i = 1-i+[A,B].max
  if A%i == 0 && B%i == 0
    count += 1
  end

  if count == K
    puts i
    exit
  end

end


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl count(n,0);
    rep(i,n-1){
        ll a;cin >> a;a--;
        count[a]++;
    }
    rep(i,n){
        cout << count[i] <<endl;
    }
}

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

int dist(int N,int x){
	if(N&1) return min(abs(x - N/2),abs(x - (N+1)/2));
	else return abs(x - N/2);
}
int main(){
	int N;cin>>N;
	vector<int> nos(N);
	for(int i=0;i<N;i++) cin>>nos[i];
	sort(nos.begin(),nos.end());
	int X = nos[N-1];
	int sel = nos[0],bdist = dist(X,nos[0]);
	for(int i=0;i<N;i++){
		int d = dist(X,nos[i]);
		if(d < bdist){
			sel = nos[i];
			bdist = d;
		}
	}
	cout<<X<<" "<<sel<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        int div = b / a;
        int rem = b % a;
        if (div == 4 && rem != 0)
            cout << "No"
                 << "\n";
        else
        {
            if (b % 2 == 0)
            {
                if (div >= 2 && div <= 4)
                    cout << "Yes"
                         << "\n";
                else
                    cout << "No"
                         << "\n";
            }
            else
            {
                cout << "No"
                     << "\n";
            }
        }
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int mod=1000000007;
    int n,m;
    cin>>n>>m;
    int s[n],t[m];
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<m;i++)cin>>t[i];
    vector<vector<long long>>dp(n+1,vector<long long>(m+1,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i]==t[j])dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j]+1)%mod;
            else dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j]-dp[i][j]+mod)%mod;
        }
    }
    cout<<(dp[n][m]+1)%mod<<endl;
    return 0;
}

Measured memory_bytes: 34580
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,a,b;
    cin>>x>>a>>b;
    if(b<=a)cout<<"delicious"<<endl;
    else if(b>a+x) cout<<"dangerous"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}


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

typedef long long LL;
#define SZ(a) int((a).size())
#define FOR(var,a,b) for(int var=(a);var<(b);var++)
#define REP(var,n) FOR(var,0,n)
#define INT(n) int n;scanf("%d",&n);
#define AI(a,n) int a[n];REP(i,n){scanf("%d",&a[i]);}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  INT(n); AI(as, n);
  LL dp0[n], dp1[n];
  dp0[0] = as[0] / 2;
  dp1[0] = as[0] / 2 - 1 + as[0] % 2;
  FOR(i, 1, n){
    if (as[i] % 2 == 0){
      dp0[i] = dp0[i - 1] + as[i] / 2;
      if (0 <= dp1[i - 1]){
        dp0[i] = max(dp0[i], dp1[i - 1] + as[i] / 2);
      }
      if (as[i] == 0){
        dp1[i] = -1;
      }
      else{
        dp1[i] = dp0[i - 1] + as[i] / 2 - 1;
        if (0 <= dp1[i - 1]){
          dp1[i] = max(dp1[i], dp1[i - 1] + as[i] / 2);
        }
      }
    }
    else {
      dp0[i] = dp0[i - 1] + as[i] / 2;
      if (0 <= dp1[i - 1]){
        dp0[i] = max(dp0[i], dp1[i - 1] + as[i] / 2 + 1);
      }
      dp1[i] = dp0[i - 1] + as[i] / 2;
      if (0 <= dp1[i - 1]){
        dp1[i] = max(dp1[i], dp1[i - 1] + as[i] / 2);
      }
    }
  }
  printf("%lld\n", max(dp0[n - 1], max(dp1[n - 1], 0LL)));
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

unsigned gcd(unsigned a, unsigned b)
{
    if (a == 0){
        return b;
    }else if(b==0){
        return a;
    }

    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int main()
{
    int N;
    cin >> N;
    unsigned A[N], M[N], gcdL[N], gcdR[N],gcds[N];
    unsigned max = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N;i++){
        if (i==0){
            gcdL[0] = 0;
            gcdR[N - 1] = 0;
        }
        else
        {
            gcdL[i] = gcd(gcdL[i - 1], A[i - 1]);
            gcdR[N -1 - i] = gcd(gcdR[N -1 - i + 1], A[N -i]);
        }
    }

    for (int i = 0; i < N; i++)
    {
        unsigned gcd_ = gcd(gcdL[i], gcdR[i]);
        //cout << gcd_ << endl;
        if (max < gcd_)
        {
            max = gcd_;
        }
        }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

//CHECK FOR N = 1 OR OTHER DUMB TESTS 

using namespace std;

int n;
ll bst = 0;
ll c, v[100100], x[100100], V[100100], dp[100100], dp2[100100], x2[100100];
set <pair <ll, int> > s;

int main() {
//	ifstream cin("tst.in");
//	ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n >> c;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> v[i];
	//	x[n + i] = c + x[i];
	//	v[n + i] = v[i];
	//	bst = max(bst, v[i]);
	}
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] + v[i];
	}
	for (int i = 1; i <= n; i++)
		dp[i] -= x[i];
	for (int i = 1; i <= n; i++) 
		dp2[i] = dp2[i - 1] + v[n - i + 1];
	for (int i = 1; i <= n; i++)
		dp2[i] -= c - x[n - i + 1], x2[i] = c - x[i];
	reverse(dp2 + 1, dp2 + n + 1);
//	reverse(x2 + 1, x2 + n + 1);
//	for (int i = 1; i <= n; i++)
//		cout << x2[i] << ' ';
//	cout << endl;
//	cout << endl;
//	for (int i = 1; i <= n; i++)
//		out << dp[i] << ' ';
//	out << endl;
//	for (int i = 1; i <= n; i++)
//		out << dp2[i] << ' ';	
	for (int i = 1; i <= n; i++)
		bst = max(bst, dp[i]);
	for (int i = 1; i <= n; i++)
		bst = max(bst, dp2[i]);
	int p = 1;
//	cout << bst << endl;
	for (int i = 1; i <= n; i++) {
		ll aux = x[i];
		while (p <= n && x2[p] >= aux) {
			s.insert({dp2[p], p});
			p++;
		}
		while (!s.empty()) {
			auto it = s.end();
			it--;
			auto IT = *it;
			if (IT.se <= i)
				s.erase(it);
			else break;
		}
		if (s.empty())
			continue;
		auto it = s.end();
		it--;
		auto IT = *it;
		bst = max(bst, dp[i] + IT.fi - aux);
	}
//	cout << bst << endl;
	s.clear();
	p = 1;
	for (int i = n; i > 0; i--) {
		ll aux = x2[i];
		while (p <= n && x[p] >= aux) {
			s.insert({dp[p], p});
			p++;
		}
		while (!s.empty()) {
			auto it = s.end();
			it--;
			auto IT = *it;
			if (IT.se >= i)
				s.erase(it);
			else break;
		}
		if (s.empty())
			continue;
		auto it = s.end();
		it--;
		auto IT = *it;
		bst = max(bst, dp2[i] + IT.fi - aux);
	}
	cout << bst;
	return 0;
}

Measured memory_bytes: 11264
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

int x, y;

int main()
{
    scanf("%d%d", &x, &y);
    printf("%d\n", x*y);
    return 0; 
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==0 && b==0 && c==0) break;
  int x[1001],y[1001],z[1001];
  for(int i=0;i<b;i++){
    cin>>x[i]>>y[i]>>z[i];
  }
  for(int i=0;i<b-1;i++){
    for(int j=b-1;j>i;j--){
      if(x[j]>x[j-1]){
	int tmp =x[j-1];
	x[j-1]=x[j];
	x[j]=tmp;
	tmp=y[j-1];
	y[j-1]=y[j];
	y[j]=tmp;
	tmp=z[j-1];
	z[j-1]=z[j];
	z[j]=tmp;
      }
    }
  }
  for(int i=0;i<b;i++){
    if(y[i]==c){
      c=z[i];
    }
    else if(z[i]==c){
      c=y[i];
    }
  }

  cout<<c<<endl;
  }
  return 0;
}



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

int main() {
	int N;
	cin >> N;
	int(*heights)[100] = new int[100][100];
	int xs[100];
	int ys[100];
	int x, y, h;
	int k = 0;
	while (cin >> x >> y >> h)
	{
		xs[k] = x;
		ys[k++] = y;
		heights[x][y] = h;
	}

	long long int H = 1;
	long long int max_H = 1000000000 + 201;
	int i = 0;
	int Cx = 0;
	int Cy = 0;
	for (Cx = 0; i < N && Cx <= 100; Cx++)
		for (Cy = 0; i < N && Cy <= 100; Cy++)
		{
			long long int temp_H = 0; //作为测试标杆，如果对于每一对坐标，H都与temp_H相等，则说明H正确。
			for (i = 0; i < N; i++)
			{
				if (heights[xs[i]][ys[i]] > 0)
				{
					H = abs(xs[i] - Cx) + abs(ys[i] - Cy) + heights[xs[i]][ys[i]];
					if (temp_H == 0)
						temp_H = H;
					if (H != temp_H || H > max_H)
						break;
				}
				else
				{
					max_H = abs(xs[i] - Cx) + abs(ys[i] - Cy) + heights[xs[i]][ys[i]];
					if (temp_H > max_H)
						break;
				}
			}

		}
	delete[] heights;
	cout << Cx - 1 << ' ' << Cy - 1 << ' ' << H;
}


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

using namespace std;

int main(){
  char c[1];
  cin >> c;

  if((strcmp(c,"a")) == 0 || (strcmp(c,"i")) == 0 || (strcmp(c,"u")) == 0 || (strcmp(c,"e")) == 0 || (strcmp(c,"o")) == 0)
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

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


using namespace std;


int main() {

	string s;

	cin >> s;

	if (s[s.length() - 1] == 's') {
		cout << s + "es" << endl;
	}
	else {
		cout << s + "s" << endl;
	}

	return 0;


}

Measured memory_bytes: 3628
cards = list()
suit = ["S", "H", "C", "D"]
n = int(input())
for i in range(n):
    s, r = map(str, input().split())
    r = int(r)
    if s == "S":cards.append(0+r)
    if s == "H":cards.append(13+r)
    if s == "C":cards.append(26+r)
    if s == "D":cards.append(39+r)
for i in range(1, 53):
    if not(i in cards):
        print(suit[(i-1)//13], (i-1)%13+1)



Measured memory_bytes: 5608
# ABC105D - Candy Distribution
from collections import Counter
from itertools import accumulate as acc


def main():
    N, M, *A = map(int, open(0).read().split())
    cumsum = [0] + list(acc(A))
    cnt = Counter(i % M for i in cumsum).values()
    ans = sum(i * (i - 1) // 2 for i in cnt)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16856
import math
from functools import reduce
N = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)


ans =0
for a in range(1,N+1,1):
    for  b in range(a,N+1,1):
        for c in range(b,N+1,1):
            if len(set([a,b,c])) == 3:
                ans += gcd(a, b, c)*6
            elif len(set([a,b,c])) == 2:
                ans += gcd(a,b,c)*3
            else:
                ans += gcd(a,b,c)
print(ans)

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

int main(){
    int N; cin>>N;
    vector<int> H(N);
    for(int i=0;i<N;i++) cin>>H.at(i);

    int ans=N;
    for(int i=1;i<N;i++){
        for(int j=0;j<i;j++){
            if(H.at(i)<H.at(j)){
                ans--;
                break;
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int H, W; cin >> H >> W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    REP(i, H){
        bool w = true;
        REP(j, W) if(S[i][j] == '#') w = false;
        if(w) REP(j, W) S[i][j] = 'x';
    }
    REP(j, W){
        bool w = true;
        REP(i, H) if(S[i][j] == '#') w = false;
        if(w) REP(i, H) S[i][j] = 'x';
    }

    REP(i, H){
        bool l = false;
        REP(j, W){
            if(S[i][j] != 'x'){
                l = true;
                cout << S[i][j];
            }
        }
        if(l) cout << endl;
    }

    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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


int main() {
    int H, W, A, B;
    std::cin >> H >> W >> A >> B;

    int h = 0;
    for (;h < H - B; h++) {
        int w = 0;
        for (;w < A; w++) {
            std::cout << 1;
        }
        for (;w < W; w++) {
            std::cout << 0;
        }
        std::cout << std::endl;
    }
    for (;h < H; h++) {
        int w = 0;
        for (;w < A; w++) {
            std::cout << 0;
        }
        for (;w < W; w++) {
            std::cout << 1;
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10){
        cout << -1 << endl;
        return 0;
    }
    cout << A * B << endl;
}


Measured memory_bytes: 256
#ABC170C ×

x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
    
else:
    _x = x 
    x_ = x
    while True:
        if _x not in p:
            print(_x)
            break
        if x_ not in p:
            print(x_)
            break
        _x -= 1
        x_ += 1

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    cout << A + pow(A, 2) + pow(A, 3) << endl;
    return 0;
}


Measured memory_bytes: 4188
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n;
  cin >> n;
  bool second = true;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a & 1) {
      second = false;
    }
  }
  if (second)
    cout << "second" << endl;
  else
    cout << "first" << endl;
  return 0;
}


Measured memory_bytes: 384
from itertools import product
a, b, c = list(map(int, input().split()))
k = int(input())
for bit in product([0, 1, 2, 3], repeat=k):
    aa, bb, cc = [a, b, c][:]
    for t in bit:
        if t == 0:
            pass
        elif t == 1:
            aa *= 2
        elif t == 2:
            bb *= 2
        elif t == 3:
            cc *= 2
    if aa < bb < cc:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 67936
# coding: utf-8
# Your code here!
import sys
n=int(input())
A=list(map(int,input().split()))

for i in A:
    if i % 2 ==0:
        if i % 3 != 0 and i % 5 != 0:
            print("DENIED")
            sys.exit()
print("APPROVED")

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  string s, t; cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int ans = 1e9;
  for(int i=0; i<=n-m; i++) {
    int cnt = 0;
    for(int j=0; j<m; j++) {
      if (s[i+j] == t[j]) cnt++;
    }
    ans = min(ans, m-cnt);
  }
  cout << ans << endl;

  return 0;
}

// EOF

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

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

  std::vector<unsigned int> B_array(N - 1);
  for (int i = 0; i < N - 1; ++i) {
    std::cin >> B_array.at(i);
  }

  unsigned long sum = 0;

  for (int i = 0; i < N; ++i) {
    if (i == 0) {
      sum += B_array.at(i);
    } else if (i == N - 1) {
      sum += B_array.at(i - 1);
    } else {
      sum += std::min(B_array.at(i), B_array.at(i - 1));
    }
  }

  std::cout << sum << std::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 rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)

int a[200010];
int b[200010];
int lk[20];
int rk[20];

int main() {
	int n;
	int m;
	int k;
	int ans,lkk,rkk;
	long long p;

	m=998244353;
	a[1]=1;
	b[1]=1;

	cin >> n >> k ;
	rep(i, k) cin >> lk[i] >> rk[i] ;
	rep3(i,2,n+1){
		rep(j,k){
			rkk=max(i-rk[j]-1,0);
			lkk=max(i-lk[j],0);
			p=b[lkk]-b[rkk]+m;
			p%=m;
			a[i]+=p;
			a[i]%=m;
		}
		b[i]=b[i-1]+a[i];
		b[i]%=m;
	}
	ans=a[n]+m;
	ans%=m;

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

Measured memory_bytes: 5180
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
# define LL long long
using namespace std;
const int MAX=1e6+5;
int n,k,tot;
LL a[MAX];
LL qwq[2][MAX];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	  scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)
	  {
	  	LL sum=0;
	  	for(int j=i;j<=n;++j)
	      qwq[0][++tot]=sum+=a[j];
	  }
	LL tt=tot,fl=1,cnt=0,ans=0;
	for(LL i=63;i>=0;--i)
	  {
	  	fl^=1,cnt=0;
	  	for(int j=1;j<=tt;++j)
	  	  if(qwq[fl][j]&(1ll<<i)) qwq[fl^1][++cnt]=qwq[fl][j];
	  	if(cnt>=k) ans+=(1ll<<i),tt=cnt;
	  	else for(int j=1;j<=tt;++j)
	  	  qwq[fl^1][j]=qwq[fl][j];
	  }
	return printf("%lld",ans),0;
}


Measured memory_bytes: 12672