akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll INF=1e18L+5;
const ll mod=1e9+7;
ll h,w;
vector<ll>adj[100005];
bool vis[100005];
ll dp[1001][1001];
char a[1001][1001];
int path(int i,int j){

        if(i>h||j>w)return 0;
        if(dp[i][j]!=-1)return dp[i][j];
        if(a[i][j]=='#')return 0;
        dp[i][j]=(path(i+1,j)+path(i,j+1))%mod;
        return dp[i][j];
}


int main()
{
  memset(dp,-1,sizeof(dp));
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
        cin>>a[i][j];
    }
  }dp[h][w]=1;
  cout<<path(1,1)<<endl;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    set<ll>s;
    ll n;
    cin>>n;
    ll num;
    for(ll i=0;i<n;i++)
    {
        cin>>num;
        s.insert(num);
    }
    if(s.size()==n)
        cout<<"YES";
    else
        cout<<"NO";
}

Measured memory_bytes: 9600
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
#print(a)
b = list(map(int,input().split()))
#print(b)
price_min = min(a) + min(b)
#print(price_min)
#xyc = []
for i in range(M):
  x,y,c = map(int,input().split())
  new_price = a[x-1] + b[y-1] -c
  price_min = min(price_min,new_price)
  
  
print(price_min)

Measured memory_bytes: 18736
from heapq import heappop, heappush

X, Y, Z, K = map(int, input().split())

# heahqで最大値を扱いたいのでマイナスにしておく
A = sorted(list(map(lambda x: -int(x), input().split())))
B = sorted(list(map(lambda x: -int(x), input().split())))
C = sorted(list(map(lambda x: -int(x), input().split())))

#　プライオリティキュー
#　heapqの要素はタプルに出来る
hq = []
u = (A[0] + B[0] + C[0], 0, 0, 0)
heappush(hq, u)

# 同じものを複数回追加しないようにチェック
visited = set()
visited.add(u)

for i in range(K):
    x, i, j, k = heappop(hq)
    print(-x)
    # A, B, Cについての次の値をpush
    if i + 1 <= X - 1:
        next_i = (A[i + 1] + B[j] + C[k], i + 1, j, k)
        if next_i not in visited:
            heappush(hq, next_i)
            visited.add(next_i)
    if j + 1 <= Y - 1:
        next_j = (A[i] + B[j + 1] + C[k], i, j + 1, k)
        if next_j not in visited:
            heappush(hq, next_j)
            visited.add(next_j)
    if k + 1 <= Z - 1:
        next_k = (A[i] + B[j] + C[k + 1], i, j, k + 1)
        if next_k not in visited:
            heappush(hq, next_k)
            visited.add(next_k)


Measured memory_bytes: 78568
N = int(input())

l = []
for i in range(N):
    S = input()
    l.append(S)
    
print('AC x '+str(l.count('AC')))
print('WA x '+str(l.count('WA')))
print('TLE x '+str(l.count('TLE')))
print('RE x '+str(l.count('RE')))


Measured memory_bytes: 16152
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int main()
{
	int n;
	cin>>n;
	while(n) {
		int t=n%10;
		if(t==7) {
			puts("Yes");
			return 0;
		}
		n/=10;
	}
	puts("No");

	return 0;
}

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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int a,b;
int main()
{
    cin>>a>>b;
    if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
    {
        if(b==31)
        {
            cout<<1;
            return 0;
        }
    }
    else if(a==2)
    {
        if(b==29||b==28)
        {
            cout<<1;
            return 0;
        }
    }
    else
    {
        if(b==30)
        {
            cout<<1;
            return 0;
        }
    }
    cout<<0;
    return 0;
}


Measured memory_bytes: 256
import math
n=int(input())
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct
def ff(x):
    temp=(-1+math.sqrt(1+8*x))/2
    return int(temp)
s=0
x=factorize(n)
for i in x:
    s+=ff(i[1])
    
    
if(n==1):
    print(0)
else:
    print(s)

Measured memory_bytes: 9224
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	x <- readInt
	uncurry ( printf "%d %d\n" ) $ head $ do
		i <- [ -200 .. 200 ]
		j <- [ -200 .. 200 ]
		guard $ i ^ 5 - j ^ 5 == x
		return ( i, j )

Measured memory_bytes: 4000
#include<stdio.h>

int main(){
	int n,m;
	int sum = 0;
	scanf("%d %d",&n,&m);
	
	for(int i = n-1; i>=0; i--) sum+=i;
	
	for(int i = m-1; i>=0; i--) sum+=i;
	
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 3236
/*
AuThOr GaRyMr
技巧:
1.区别对待大数据&小数据！
2.Dp难推时算贡献！
3.long long (尤其乘法)！
4.long long INF 要大
5.Dp on trees: 换根法，每次清空当前的节点和换到的子节点
6.long double | 输出浮点数
7.注意特判!(prince and princess)
8.是否可以记录两个值之间的关系 CSPday2 meal
9.括号-》数组or栈
10.是否可以先构造
11.网络流奇偶构图
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,m,v,p,a[100000+10];
bool cmp(int A,int B){return A>B;}
bool check(int x){
	int _X_=0;
	rb(i,1,n){
		_X_+=a[i]>a[x];
	}
	if(_X_<p) x=p;
	if(x<=p) return 1;
	int tot=0;
	rb(i,1,n){
		if(tot==v-1) break;
		if(a[i]<=a[x]&&i!=x) tot++;
	}
	int rest=v-1;
	rest-=tot;
	rest=max(0,rest-p+1);
	LL chan=-1,sum=0;
	rb(i,p,n){
		chan=max(chan,(LL)a[i]);
	}
	LL ALL=0,tmp=0;
	rb(i,p,n)
	{
		if(a[i]>a[x]){
		
		ALL+=a[i],tmp++;}
	}
	ALL+=(LL)(rest)*m;
	chan=max(chan,(ALL+tmp-1)/tmp);	
	return (LL)a[x]+(LL)m>=chan;
}
int main(){
	cin>>n>>m>>v>>p;
	rb(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	int l=1,r=n+1;
	while(l<r-1){
		int mid=(l+r)>>1;
		if(check(mid)){
			l=mid;
			
		}
		else{
			r=mid;
		}
	}
	cout<<l<<endl;
//	cout<<check(6)<<endl;
	return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
limL = -454554565454
limR = 7896541265478456
for i in range(M):
  L, R = map(int, input().split())
  limL = max([limL, L])#lとしては，大きい方が嬉しい
  limR = min([limR, R])#rは小さい方がいい

print(limR-limL+1) if limR-limL+1>0 else print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int mo=998244353;
typedef string S;
S s;
map<S,int>mp;
inline S operator&(const S&a,const S&b){
	S ans;ans=a;for(int i=0;i<a.size();++i)if(b[i]=='0')ans[i]='0';
	return ans;
}
int calc(S s){
	int&ans=mp[s];if(ans)return ans;
	ans=(s[0]-'0'+1)*calc(s.substr(1,s.size()-1))%mo;
	for(int d=1;d*2<=s.size();++d){
		S z=s.substr(0,d);
		for(int k=2;d*k<=s.size();++k)z=z&s.substr((k-1)*d,d),
			ans=(ans+1ll*calc(z)*calc(s.substr(k*d,s.size()-k*d)))%mo;
	}
	return ans;
}
int main(){
	mp[""]=1;
	cin>>s;
	cout<<calc(s)<<endl;
}

Measured memory_bytes: 5632
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <random>
#include <chrono>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

int main() {
	int N;
	cin >> N;
	vector <int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	auto b = a;
	sort(a.begin(), a.end());

	for (int i = 0; i < N; i++) {
		if (b[i] != a[N - 1]) cout << a[N - 1] << endl;
		else cout << a[N - 2] << endl;
	}

}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else
    cout << "Right" << endl;
  
}


Measured memory_bytes: 3636
#include <stdio.h>

int n,m;
int map[50][3];

/* [song][new][lv1] */
int memo[51][51][51];
char visited[51][51][51];

int getscore(int song,int lv2,int lv1) {
	if(lv2==0 && lv1==0)return map[song][2];
	if(lv2+lv1>8)return -0x7fffffff;
	return map[song][0]*lv2+map[song][1]*lv1;
}

int tansaku(int song,int rest,int lv1) {
	int result=-0x7fffffff;
	int oru;
	int i,j;
	if(song>=n)return 0;
	if(visited[song][rest][lv1])return memo[song][rest][lv1];
	for(oru=0;oru<=8 && oru<=rest;oru++) {
		int nowresult=-0x7fffffff;
		for(i=0;i<=oru;i++) {
			for(j=0;j<=lv1;j++) {
				int tempresult;
				tempresult=getscore(song,i,j);
				if(tempresult>nowresult)nowresult=tempresult;
			}
		}
		nowresult+=tansaku(song+1,rest-oru,oru);
		if(nowresult>result)result=nowresult;
	}
	visited[song][rest][lv1]=1;
	memo[song][rest][lv1]=result;
	return result;
}

int main(void) {
	int i;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++) {
		scanf("%d%d%d",&map[i][0],&map[i][1],&map[i][2]);
	}
	printf("%d\n",tansaku(0,m,0));
	return 0;
}

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

int main() {
    string a; cin >> a;
    string b; cin >> b;

    int n = a.size(), m = b.size();

    vector<vector<int>> dp(n + 1, vector<int> (m + 1, 0));

    for (int i = 1; i <= n; i += 1)
        for (int j = 1; j <= m; j += 1) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (a[i - 1] == b[j - 1])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    int value = dp[n][m];
    int nn = n;
    int mm = m;
    
    string answer = "";

    while (value > 0) {
        if (nn >= 1 and dp[nn - 1][mm] == value)
            nn -= 1;
        else if (mm >= 1 and dp[nn][mm - 1] == value)
            mm -= 1;
        else {
            nn -= 1;
            mm -= 1;
            answer += a[nn];
            value -= 1;
        }
    }

    reverse(answer.begin(), answer.end());
    cout << answer << "\n";
}

Measured memory_bytes: 35584
using System;
class Program
{
    public static void Main()
    {
        int[] t = Array.ConvertAll(System.Console.ReadLine().Split(' '),int.Parse);
        int a = t[0]; 
        int b = t[1];
        int c = t[2];
        string s;
        
        if(a < b && b < c)
            s = "Yes";
        else
            s = "No";
        
        System.Console.WriteLine("{0}",s);
    }
}


Measured memory_bytes: 15932
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
signed main(){
  ll n,m,k,cun=0,a;
  map<ll,ll> mp;
  cin>>n>>m;
  rep(i,n){
    cin>>k;
    rep(j,k){
      cin>>a;
      mp[a]++;
      if(mp[a]==n){
        cun++;
      }
    }
  }
  cout<<cun<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

bool is_money[101];

int main(){
	int n, m, x;
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++){
		int y;
		cin >> y;
		is_money[y] = true;
	}
	int coun1 = 0, coun2 = 0;
	for (int i = 0; i <= x; i++){
		if (is_money[i]) coun1++;
	}

	for (int i = x; i <= n; i++){
		if (is_money[i]) coun2++;
	}

	cout << min(coun1, coun2) << endl;
	return 0;
}



Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

void call(int n) {
	int i = 1;
	int x = i;

	while (1) {
		if (x % 3 == 0) {
			CO " " << i;
		}
		else {
			if (x % 10 == 3) {
				CO " " << i;
			}
			else {
				while (1) {
					x /= 10;
					if (x % 10 == 3) {
						CO " " << i;
						break;
					}
					if (x == 0)break;
				}
			}
		}
		++i;
		x = i;
		if (i > n)break;
	}
	
}

int main(void) {
	int n = 0;
	CI n;

	call(n);

	CO endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int A,B,sum;
	scanf("%d",&A);
	scanf("%d",&B);
	sum=A+B;
	if(sum>=24){
		sum=sum-24;
	}
	printf("%d",sum);
	system("pause");
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{   
    ll N, K; 
    cin >> N >> K;

    double res = 0;
    for(int i=1;i<=N;i++){
        if(i>=K) res += 1;
        else{
            int ntry = 1;
            for(;(i<<ntry)<K;ntry++){}
            res += 1./(1<<ntry);
        }
    }
    cout<<setprecision(15)<<res/(double)N<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(n),c(m),d(m);
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    vector<int> ans(n);
    rep(i,n){
        //cout<<"start:"<<i<<endl;
        int x=0;
        int min1=inf;
        set<int> si;
        rep(j,m){
            int dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
            //cout<<dis<<endl;
            if(dis<min1 && si.find(dis)==si.end()){
                //cout<<"new"<<endl;
                x=j+1;
                min1=dis;
                si.insert(dis);
            }
        }
        //cout<<x<<endl;
        ans[i]=x;
    }
    rep(i,n) cout<<ans[i]<<endl;
    return 0;
}

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

const int maxn = 15;
LL has[maxn],f[maxn];
LL Base = 10LL;
char s[maxn];
int len;

void Init(){
	f[0] = 1LL;
	for(int i = 1;i <= 11;i++) f[i] = f[i - 1] * 10LL;
	for(int i = 1;i <= len;i++){
		has[i] = has[i - 1] * Base + (s[i] - '0');
	}
}

LL Get(int l,int r){
	if(l > r) return 0LL;
	return has[r] - has[l - 1] * f[r - l + 1];
}

int main(){
	scanf("%s",s + 1);
	len = strlen(s + 1);
	Init();
	LL sum = 0LL;
	int sta = 1 << (len - 1);
	for(int i = 0;i < sta;i++){
		int pre = 0;
		for(int j = 1;j <= len - 1;j++){
			int tmp = j - 1;
			if((i & (1 << tmp))){
				sum += Get(pre + 1,j);
				pre = j;
			}
		}
		sum += Get(pre + 1,len);
	}
	printf("%lld\n",sum);
}

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

string s[15];

int h, w;
int t[15][15], A[15][15];

void init(){
  
  memset( t, 0, sizeof(t) );
  memset( A, 0, sizeof(A) );
  
  for(int i=0;i<h;i++){
    
    for(int j=0;j<w;j++){
      
      if( s[i][j] != '.' && s[i][j] != '*' ){

	if( s[i][j] == '0' ) continue;
	
	t[i][j] = 1;
	A[i][j] = s[i][j] - '0';
	
      }
      
    }
    
  }
  
}

bool check(){
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if( A[i][j] != 0 ) return false;
    }
  }

  return true;
}

int update(int y, int x){
  
  int flag = 1;
  
  for(int i=-1;i<=1;i++){
    
    for(int j=-1;j<=1;j++){
      
      int ny = y + i, nx = x + j;
      
      if( ny < 0 || nx < 0 || h <= ny || w <= nx ) continue;
      
      if( t[ny][nx] && A[ny][nx] == 0 ) flag = 0;
      
    }
    
  }
  
  if( flag == 1 ){
    
    for(int i=-1;i<=1;i++){
    
      for(int j=-1;j<=1;j++){
      
	int ny = y + i, nx = x + j;
	
	if( ny < 0 || nx < 0 || h <= ny || w <= nx ) continue;
	
	if( t[ny][nx] ) A[ny][nx]--;
	
      }
    
    } 
    
  }

  return flag;
}

void add(int y, int x){
  
  for(int i=-1;i<=1;i++){
    
    for(int j=-1;j<=1;j++){
      
      int ny = y + i, nx = x + j;
      
      if( ny < 0 || nx < 0 || h <= ny || w <= nx ) continue;
      
      if( t[ny][nx] ) A[ny][nx]++;
      
    }
    
  }
  
}

const int INF = 1e8;

typedef unsigned long long ull;

ull Hash(){
  
  ull res = 0, base = 1777771;
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if( t[i][j] ) res = res * base + A[i][j] + 1;
    }
  }
  
  return res;
}

bool End(int y, int x){
  
  for(int i=0;i<y;i++){
    
    for(int j=0;j<w;j++){
      
      if( A[i][j] ){
	if( y - i >= 2 ) return true;
	if( y - i == 1 && x - j >= 2 ) return true;
      }
      
    }
        
  }

  return false;
}

map<ull,int> memo[15][15];

int dfs(int y, int x){
  
  if( y == h ){
    if( check() == false ) return INF;
    return 0;
  }
  
  if( End( y, x ) == true ) return INF;
  
  if( memo[y][x].count( Hash() ) ) return memo[y][x][Hash()];
  
  int ny = y, nx = x + 1;
  
  if( nx == w ) ny++, nx = 0;
  
  int res = INF;
  
  res = min( res, dfs( ny, nx ) );
  
  if( t[y][x] == 1 || s[y][x] == '*' ){
    
    int r = update( y, x );
    
    res = min( res, dfs( ny, nx ) + r );
    
    if( r == 1 ) add( y, x );
    
  }
  
  return memo[y][x][Hash()] = res;
}

signed main(){

  while(1){
    
    cin>>h>>w;
    if( !h && !w ) break;
    
    for(int i=0;i<h;i++) cin>>s[i];
    
    init();
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) memo[i][j].clear();
    
    cout << dfs( 0, 0 ) << endl;

  }
  
  return 0;
}



Measured memory_bytes: 11952
#include<bits/stdc++.h>
#define N 200005
#define M 1000000007
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define rep(i,s,e) for(int i=s;i<e;i++)
#define drep(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
ll a[N];
int main(){
    ios_base::sync_with_stdio(0);
    ll n,t;
    cin>>n>>t;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll p=a[0];
    ll sum=0;
    for(int i=1;i<n;i++){
       sum+=min(a[i]-a[i-1],t);
       p=a[i];
    }
    cout<<sum+t<<endl;


    return 0;
}


Measured memory_bytes: 1792
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  h,w = map(int,input().split())
  rec = [list(input()) for _ in range(h)]
  #print(rec)
  flag = False
  # yoko
  for i in range(h):
    for j in range(w):
      if rec[i][j] == '.':
        flag = True
        pass
      else:
        flag = False
        break
    if flag:
      for r in range(w):
        rec[i][r] = 'd'
  #print(rec)
  
  
  # tate
  for j in range(w):
    for i in range(h):
      if rec[i][j] == '.' or rec[i][j] == 'd':
        flag = True
        pass
      else:
        flag = False
        break
    if flag:
      for r in range(h):
        rec[r][j] = 'd'
        
  #print(rec)
  
  
  for i in range(h):
    new = ""
    for j in range(w):
      if rec[i][j] != 'd':
        new += rec[i][j]
    if len(new) != 0:print(new)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n, d, x; cin >> n >> d >> x;
    FOR(i, 0, n) {
        int a; cin >> a;
        x += (int)(d/a);
        if (d%a != 0) ++x;
    }
    cout << x << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <valarray>
#include <cmath>
#include <algorithm>

using namespace std;

typedef valarray<long long> array_t;

valarray<array_t> multiply(valarray<array_t> &A, valarray<array_t> &B){
	valarray<array_t> C(array_t((long long)0,B[0].size()),A.size());
	if(A[0].size() != B.size()) return C;
	for(int i = 0; i < A.size(); i++){
		for(int j = 0; j < B[0].size(); j++){
			for(int k = 0; k < A[0].size(); k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	return C;
}

int main(){
	int n,m,l;
	cin >> n >> m >> l;
	valarray<array_t> A(array_t((long long)0,m),n);
	valarray<array_t> B(array_t((long long)0,l),m);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}

	valarray<array_t> C = multiply(A,B);

	for(int i = 0; i < C.size(); i++){
		for(int j = 0; j < C[0].size(); j++){
			cout << C[i][j];
			if(j == C[0].size() - 1) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 1404
//?????????????¢???????????????????????????????????????¨??????
//(?????????, ???????????§??????????????????)??????????????§?????£???????????????, TL????????§?????????????????????
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <tuple>
#include <cstdio>
using namespace std;

int n, m, q;
int a[200000], b[200000], tl[200000];
int r[200000];

vector<int> et[200000];
vector<int> etl[200000];

int cost[200000];
int maxTl[200000];	//??????i???maxTl[i]?????????????????????

void bfs(){
	typedef pair<int, int> P;	//cost, verb
	static queue<P> que;
	que.push(P(0, 0));
	cost[0] = 0;
	while(!que.empty()){
		int d = que.front().first;
		int v = que.front().second;
		que.pop();
		for( int i = 0; i < et[v].size(); i++ ){
			int nv = et[v][i];
			int nc = d + 1;
			if( cost[nv] > nc ){
				que.push(P(nc, nv));
				cost[nv] = nc;
			}
		}
	}
}

void Dijkstra(){
	typedef tuple<int, int, int> T;	//maxTl, minCost, verb
	static priority_queue<T> que;
	que.push(T(10000001, 0, 0));
	maxTl[0] = 10000000;
	
	while(!que.empty()){
		T now = que.top();
		int t = get<0>(now);
		int d = get<1>(now);
		int v = get<2>(now);
		que.pop();
		for( int i = 0; i < et[v].size(); i++ ){
			int nv = et[v][i];
			int nc = d + 1;
			int nt = min(t, etl[v][i]);
			if( cost[nv] == nc && maxTl[nv] < nt ){
				que.push(T(nt, nc, nv));
				cost[nv] = nc;
				maxTl[nv] = nt;
			}
		}
	}
}

void init(){
	for( int i = 0; i < n; i++ ){
		cost[i] = 100000000;
		maxTl[i] = 0;
	}
}

void construct(){
	for( int i = 0; i < m; i++ ){
		et[a[i]].push_back(b[i]);
		etl[a[i]].push_back(tl[i]);
		et[b[i]].push_back(a[i]);
		etl[b[i]].push_back(tl[i]);
	}
}

void input(){
	int i;
	scanf("%d%d%d", &n, &m, &q);
	for( i = 0; i < m; i++ ){
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;
	}
	for( i = 0; i < m; i++ ){
		tl[i] = 10000000;
	}
	for( i = 0; i < q; i++ ){
		scanf("%d", &r[i]); r[i]--;
		tl[r[i]] = i;
	}
}

signed main(){
	input();
	construct();
	init();
	bfs();
	Dijkstra();
	
	static int pack[200000] = {0};
	for( int i = 0; i < n; i++ ){
		if( maxTl[i] < q )
			pack[maxTl[i]]++;
	}
	for( int i = 1; i < q; i++ )
		pack[i] += pack[i-1];
	for( int i = 0; i < q; i++ ){
		printf("%d\n", pack[i]);
	}
	return 0;
}

Measured memory_bytes: 25812
#include<stdio.h>
#include<math.h>
#define MAX 200000
 
int max(int,int);
int min(int,int);
 
int main(){
  int R[MAX],n,i,maxv,minv;
 
scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d",&R[i]);
}
maxv=R[1]-R[0];
minv=R[0];
 
for(i=1;i<n;i++){
  maxv = max(maxv,R[i]-minv);
  minv = min(minv,R[i]);
}
 
printf("%d\n",maxv);
return 0;
}
int max(int x,int y){
  if(x>y){
    return x;
  }else{
    return y;
  }
}
int min(int x,int y){
  if(x<y){
    return x;
  }else{
    return y;
  }
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int k = Integer.parseInt(tmpArray[1]);

		int red = n - k;

		calcCom();
//		fact[0] = 1;
//		for(int i = 1; i < fact.length; i++){
//			fact[i] = fact[i-1]*i%P;
//		}
		//test
//		System.out.println(Com[2000][1000]);
		for(int i = 1; i <= k; i++){
			long result;

			//まずはどこに置くか決める

			result = Com[red + 1][i];

			//この時点でn - i個余ってる
//			for(int j = 1; j <= n - i; j++){
//				result = result * (i - 1) % MOD;
//			}

			result = result * Com[k - 1][i - 1] % MOD;

			System.out.println(result);

		}

	}
	static long MOD = 1000000007;
	static int MAX_C = 2002;
	static long[][] Com = new long[MAX_C][MAX_C];

	static void calcCom() {
	    Com[0][0] = 1;
	    for (int i = 1; i < MAX_C; ++i) {
	        Com[i][0] = 1;
	        for (int j = 1; j < MAX_C; ++j) {
	            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]) % MOD;
	        }
	    }
	}

	static int extGCD(int a, int b, X x, X y){
		System.out.println("a = "+a+" b = "+b);
		int d = a;
		if(b != 0){
			d = extGCD(b, a % b, y, x);
			y.x -= (a/b) *x.x;
		}

		else {
			x.x = 1;
			y.x = 0;
		}

		return d;
	}

	static int modInverse(int a, int m){
//		XY xy = new XY(0,0);
		X x = new X(0);
		X y = new X(0);

		extGCD(a, m, x, y);

		System.out.println("x = "+x.x);
		return (m + x.x % m) % m;
	}

	static int[] fact = new int[3000];
	static final int P = 1000000007;

	static int modFact(int n, int p, X e){
		e.x = 0;

		if(n == 0) return 1;

		int res = modFact(n/p, p, e);

		e.x += n/p;

		if(n/p % 2 != 0){
			return res*(p - fact[n % p]) % p;

		}

		return res * fact[n % p] % p;
	}
	static int modComb(int n, int k, int p){
		if(n < 0 || k < 0 || n < k){
			return 0;
		}

		X e1 = new X(0), e2 = new X(0), e3 = new X(0);
		int a1 = modFact(n, p, e1), a2 = modFact(k, p, e2), a3 = modFact(n - k, p, e3);
		System.out.println(a1+" "+a2+" "+a3);
		if(e1.x > e2.x + e3.x){
			return 0;
		}

		return a1 * modInverse(a2*a3%p, p) % p;
	}


}

class X {
	int x;

	X(int x){
		this.x = x;
	}
}

class XY {
	int x;
	int y;

	XY(int x, int y){
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 80340
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
            _out.println("Possible");
        } else {
            _out.println("Impossible");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (3e2) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

int dp[N][N][N];
string s;
int n, K;

void solve()
{
	int i, j, k, ans = 0;
	cin >> s;
	cin >> K;
	n = s.length();
	fo(i,1,n+1)
		fo(j,1,n-i+1+1)
			fo(k,0,K+1)
			{
				if(s[i-1] == s[n-j])
					dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k] + ((i+j <= n) ? 2 : 1));
				dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]);
				dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
				if(k > 0)
					dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-1] + ((i+j <= n) ? 2 : 1));
				ans = max(ans, dp[i][j][k]);
			}
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

using namespace std;
typedef long long ll;

ll N;
vector<ll> v;
unordered_map<ll,ll> um;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        v.push_back(a-i);
        if(um.count(a-i) == 0) um[a-i] = 1;
        else um[a-i] = um[a-i] + 1;
    }
    ll count = 0;
    for(int i=0;i<N-1;i++){
        ll s = 0 - i * 2 - v[i];
        if(um.count(s) == 0){
            um[v[i]] = um[v[i]] - 1;
            continue;
        }
        if(um[s] <= 0){
            um[v[i]] = um[v[i]] - 1;
            continue;
        }
        count += um[s];
        um[v[i]] = um[v[i]] - 1;
    }
    cout << count << endl;
    return 0;
}

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

bool j(string s){
    string t = s;
    reverse(t.begin(),t.end());
    return t == s;
}

int main(){
    string s;
    cin >> s;
    bool ans(true);

    if(!j(s))    ans = false;
    if(!j(s.substr(0,s.size()/2))) ans = false;

    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
s = int(input())
#a = list(map(int, input().split()))
#a, b, c, d = map(int, input().split())

A = [0] * 2001
A[3] = 1
A[4] = 1
A[5] = 1
for i in range(1995):
  A[i+6] = A[i+5] + A[i+3]

print(A[s] % (10**9+7))

Measured memory_bytes: 9332
using System;
using System.Collections.Generic;
using System.Linq;


namespace ABC050
{
	class Q3
	{
		static void Main()
		{
			int N = int.Parse(Console.ReadLine());
			List<int> nums2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
			List<int> nums = Enumerable.Range(1, N).Select(x => 0).ToList();
			foreach(int n in nums2)
			{
				nums[n] += 1; 
			}
			bool isOK = true;
			foreach (int n in nums)
				isOK = isOK && (n < 3 && n >= 0);
			if (N % 2 == 0)
			{
				for (int i = 0; i < N; i++)
				{
					if (i % 2 == 0)
						isOK = isOK && (nums[i] == 0);
					else
						isOK = isOK && (nums[i] == 2);
				}
			}
			else
			{
				for (int i = 0;i<N;i++)
				{
					if (i % 2 != 0)
						isOK = isOK && (nums[i] == 0);
					else
					{
						if (i == 0)
						{
							isOK = isOK && (nums[i] == 1);
						}
						else
						{
							isOK = isOK && (nums[i] == 2);
						}
					}
				}
			}
			int ans = 1;
			int mod = (int)Math.Pow(10, 9) + 7;
			if (isOK)
			{
				if (N % 2 == 0)
				{
					for (int i = 0; i < N; i++)
					{
						if (i % 2 == 1)
							ans = (ans * nums[i]) % mod;
					}
				}
				else
				{
					for (int i = 0; i < N; i++)
					{
						if (i % 2 == 0)
							ans = (ans * nums[i]) % mod;
					}
				}
			}
			else
				ans = 0;
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 11608
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    string s; cin >> s;
    deque<char> d;
    repeat(i, 0, s.size()) d.push_back(s[i]);

    int q, f; cin >> q;
    bool start = true;
    char c;
    while(q--){
        cin >> f;
        if(f==2){
            cin >> f >> c;
            if(!start){
                if(f==1) d.push_back(c);
                else d.push_front(c);
            }else{
                if(f==1) d.push_front(c);
                else d.push_back(c);
            }
        }else start = (!start);
    }
    if(start)
        while(!d.empty())
            cout << (char)d.front(), d.pop_front();
    else
        while(!d.empty())
            cout << (char)d.back(), d.pop_back();

    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 976
#include <stdio.h>
#include <string.h>
int main(void){
    char line[201],line1[101],line2[101];
    scanf("%s",line);
    strcpy(line1,line);
    strcat(line,line1);
    scanf("%s",line2);
    if(strstr(line,line2))
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    string s,t;
    cin>>s>>t;
    t+=s;
    cout<<t<<endl;

    return 0;
}


Measured memory_bytes: 256
def myAnswer(s:list) -> str:
   ans = 0
   pre =s.pop(0)
   for i in s:
      if(pre == i):
         ans += 1
         pre = "1" if(i == "0") else "0"
      else:
         pre = i
   return ans

def modelAnswer():
   tmp=1
def main():
   s = list(input())
   print(myAnswer(s))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3956
s=input()
n=len(s)
if s[-1]=='1' or s[0]=='0':
    print(-1)
    exit()
for i in range(n-1):
    if s[i]!=s[-i-2]:
        print(-1)
        exit()
edges=[]
par=n
for i in range(n-1,0,-1):
    print(i,par)
    if s[i-1]=='1':
        par=i

Measured memory_bytes: 4764
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    fsscan();
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='o')
        c++;
    }
    cout<<700+c*100;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <unistd.h>
#include <sstream>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1];
    bool f=0;
    for(int i=0;i+2<n;i++)
    {
        if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1])
            f=1;
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3608
sx,sy,tx,ty=map(int,input().split())

xdif=tx-sx
ydif=ty-sy

S="R"*xdif+"U"*ydif+"L"*xdif+"D"*ydif
S=S+"D"+"R"*(xdif+1)+"U"*(ydif+1)+"LU"+"L"*(xdif+1)+"D"*(ydif+1)+"R"
print(S)

Measured memory_bytes: 3060
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()

k = -1

for i in range(10000):
    if i * (i - 1) / 2 == N:
        k = i
        break

if k == -1:
    print "No"
    exit()

print "Yes"
print k

E = [[] for i in range(k)]

S = 1
for i in range(k):
    for j in range(i + 1, k):
        E[i].append(S)
        E[j].append(S)
        S += 1

for i in range(k):
    print k - 1, ' '.join(map(str, E[i]))


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

int main() {
    bool chart[26];
    string str;
    cin >> str;

    for (int i = 0; i < 26; ++i) {
        chart[i] = false;
    }

    for (int i = 0; i < str.size(); ++i) {
        char letter = str[i];
        int id = letter - 'a';
        chart[id] = true;
    }

    int flag = 0;
    for (int i = 0; i < 26; ++i) {
        if (!chart[i]) {
            flag = 1;
            cout << (char)('a' + i) << endl;
            break;
        }
    }
    if (flag == 0) {
        cout << "None" << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

bool vis1[10];
bool vis2[100];
bool vis3[1000];

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

    for(int i=0; i<N; i++){
        for(int j=0; j<100; j++){
            if(!vis2[j]) continue;
            int to = 10*j+(S[i]-'0');
            vis3[to] = true;
        }
        for(int j=0; j<10; j++){
            if(!vis1[j]) continue;
            int to = 10*j+(S[i]-'0');
            vis2[to] = true;
        }
        vis1[S[i]-'0'] = true;
    }
    int ans = 0;
    for(int i=0; i<1000; i++)
        if(vis3[i])
            ans++;
    cout << ans << endl;
    return 0;
}

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

const int INF = 2100000000;

int main() {
  auto max = [](int a, int b) { return (a < b ? b : a); };
  int N;
  std::cin >> N;

  std::vector<int[3]> A(N+1);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) std::cin >> A[i+1][j];
  }

  std::vector<int[3]> dp(N + 5);
  for(int i=0;i<3;i++) dp[1][i] = A[1][i];
  for (int i = 1; i <= N; i++) { // day i -> i+1
    for (int j = 0; j < 3;j++){ // today(day i)'s activity
      for (int k = 0; k < 3;k++){ // tomorrow(day i+1)'s
        if (j == k) continue;
        dp[i + 1][k] = max(dp[i+1][k], dp[i][j]+A[i+1][k]);
      }
    }
  }
  std::cout << max(max(dp[N][0], dp[N][1]), dp[N][2]) << std::endl;
  return 0;
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

from functools import reduce

def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

def lcm(a, b):
  return a*b // gcd(a, b)

N, M = map(int, input().split())
A = list(map(int, input().split()))
# 2で割ったものに置き換え a -> a'
Ad = [a//2 for a in A]

# 各要素について、2で割り切れる回数が等しいかチェック
div2 = None
for a in Ad:
  cnt = 0
  while a%2 == 0:
    a //= 2
    cnt += 1
  if div2 is None:
    div2 = cnt
  elif div2 != cnt:
    print(0)
    exit()
    
# LCM
_lcm = reduce(lcm, Ad)
if _lcm > M:
  print(0)
  exit()
  
print((M//_lcm + 1) // 2)   # 切り上げ



Measured memory_bytes: 13028
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    fast
    string s="";
    ll n;
    cin >> n;
    while(n>0)
    {
        n-=1;
        s+='a'+(n%26);
        n/=26;
    }
    for(ll i=s.size()-1; i>=0; i--)
        cout << s[i];
    return 0;
}



Measured memory_bytes: 3600
k,a,b=map(int,input().split())
ans=1
if b-a<=2: #交換するメリットがない k回すべて一枚増やす
    print(ans+k)
else:
    if k<(a+1):
        print(ans+k)
    else:
        zan=(k-(a-1))
        if zan%2==0:
            print(max(ans+k,a+(zan//2)*(b-a)))
        else:
            print(max(ans+k,a+(zan//2)*(b-a)+1))

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

int Number_of_digits(int n)
{
	int digits = 1;

	while (1) {
		n /= 10;
		if(n)
			++digits;
		else break;
	}

	return digits;
}

int main(int argc, char **argv)
{
	int a, b;
	while (cin >> a >> b) {

		cout << Number_of_digits(a + b) << endl;

	}

	return 0;
}

Measured memory_bytes: 3080
import sys
def input():
    return sys.stdin.readline()[:-1]
S = list(input())

if S[0]=='A':
    if S[2:-1].count('C')==1:
        for s in S[1:]:
            if s=='C':
                continue
            else:
                if not s.islower():
                    break
        else:
            print('AC')
            exit()
print('WA')

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


int next(int r,int D, int x)
{
    return r*x-D;
}

int main(){
    int r,D,x_tmp;
    cin >> r >> D >> x_tmp;
    for (size_t i = 0; i < 10; i++)
    {   x_tmp = next(r,D,x_tmp);
        cout << x_tmp <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
using namespace std;
#define mp make_pair
#define ll long long
#define re register
typedef pair<int,int> pii;
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'&&ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int n,a[N],b[N],p[N];
int main()
{
	n=gi();
	for(int i=1;i<=n;i++)a[i]=gi(),b[i]=gi();
	ll lm=0,rm=0;
	for(int i=1;i<=n;i++)p[i]=a[i];
	sort(p+1,p+n+1);
	if(n&1)lm=p[(n+1)/2]*2ll;else lm=p[n/2]+p[n/2+1];
	for(int i=1;i<=n;i++)p[i]=b[i];
	sort(p+1,p+n+1);
	if(n&1)rm=p[(n+1)/2]*2ll;else rm=p[n/2]+p[n/2+1];
	printf("%lld\n",(rm-lm+1)/((n&1)?2:1)+(n&1)*(rm-lm+1&1));
	return 0;
}


Measured memory_bytes: 6104
#include <bits/stdc++.h>
#define ll long long int 

using namespace std ;

int main()
{
	int n ;
	cin >> n ;
	int arr[n] ;

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

	bool poss=true ;
	ll cost=0 ;
	ll last ;

	last=arr[n-1] ;
	if(last>n-1)
		poss=false ;
	cost+=last ;
	for(int i=n-2 ; i>=0 ; i--){
		if(arr[i]<last-1)
			poss=false ;
		if(arr[i]==last-1){
			last=arr[i] ;
			continue ;
		}
		else{
			last=arr[i] ;
			if(last>i)
				poss=false ;
			cost+=last ;
		}
	}

	if(poss){
		cout << cost << endl ;
	}
	else{
		cout << -1 << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 1024