akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }
    else if(k<=a+b){
        cout << a << endl;
    }
    else{
        cout << a - (k - (a + b)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <string>
#include <list>
using namespace std;

list<int>::iterator find_key(list<int>& li,int key) {
  list<int>::iterator li_itr = li.begin();
  while(li_itr != li.end()) {
    if(*li_itr == key) {
      return li_itr;
    }
    ++li_itr;
  }
  return li.end();
}

int main(void) {
  ios::sync_with_stdio(false);

  int n;
  list<int> li;

  cin >> n;
  for(int i=0;i<n;i++) {
    string command;
    cin >> command;

    int key;
    if(command == "insert") {
      cin >> key;
      li.push_front(key);
    }
    else if(command == "deleteFirst") {
      li.pop_front();
    }
    else if(command == "deleteLast") {
      li.pop_back();
    }
    else {
      cin >> key;
      list<int>::iterator erace_itr = find_key(li,key);
      if(erace_itr != li.end()) {
        li.erase(find_key(li,key));
      }
    }
  }

  list<int>::iterator itr = li.begin();
  while(itr != li.end()) {
    cout << *itr;
    ++itr;
    itr == li.end() ? cout << "" : cout << " ";
  }
  cout << endl;
}

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

int main(){
  int x[110];
  int N, K;
  cin >> N >> K;
  
  for (int i =0; i<N ; i++){
    cin >> x[i];
  }
  int ans= 0;
  for( int i =0; i< N; i++){
    ans += 2*min(x[i], K-x[i]);
  }
  cout << ans << endl;
    
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> box(n);
  for(int i=0;i<n;i++) {
    cin >> box.at(i);
  }
  sort(box.begin(),box.end());
  for(int i=0;i<m;i++) {
    int temp = box.at(n-1)/2;
    int ok=-1,ng=n-1;
    int now=(ok+ng)/2;
    while(ng-ok>1) {
      if(box.at(now)<temp) {
        ok=now;
      }
      else {
        ng=now;
      }
      now=(ok+ng)/2;
    }
    box.insert(box.begin()+ok+1,temp);
    box.erase(box.begin()+n);
  }
  long long ans=0;
  for(int i=0;i<n;i++) {
    ans+=box.at(i);
  }
  cout << ans << endl;
}

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

long long K;
long long cnt;

void dfs(string T,long long X){
  long long tmp=stoll(T);
  if(tmp>X) return;
  cnt++;

  int aa=T.at(T.size()-1)-'0';
  T+=('0'+aa);
  dfs(T,X);
  if(aa!=0){
    T.at(T.size()-1)=('0'+aa-1);
    dfs(T,X);
  }
  if(aa!=9){
    T.at(T.size()-1)=('0'+aa+1);
    dfs(T,X);
  }
}

bool isOK(long long X){
  cnt=0;
  for(int i=1;i<=9;i++){
    string T="";
    T+=('0'+i);
    dfs(T,X);
  }
  if(cnt>=K)  return true;
  else  return false;
}

int main(){
  cin >> K;

  long long ng=0;
  long long ok=1e11;
  while(abs(ok-ng)>1){
    long long mid=(ok+ng)/2;
    if(isOK(mid)) ok=mid;
    else  ng=mid;
  }
  cout << ok << endl;

  return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int card[200]={};


int solve(int n,int k){
    int maxi=-1;
    
    int now=1;
    rep(i,k){
        now*=card[i];
    }
    for(int i=1;i<n-k+1;i++){
        now=now/card[i-1]*card[i+k-1];

        maxi=max(maxi,now);
    }
    return maxi;
}

int main() {
    int n,m,p;
    
    while(cin>>n>>m>>p){
        if(n==0 && m==0 && p==0)break;
        
        int sum=0;
        int num[200]={};
        rep(i,n){
            cin>>num[i];
            sum+=num[i];
        }
        if(num[m-1]!=0)
            cout<<(int)((double)sum*(100-p)/num[m-1])<<endl;
        else
            cout<<"0"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
public class Main {


  private static void solve() {
    char[] s = ns();
    int n = s.length;
    
    int[] sum = new int[n + 1];
    for (int i = 0 ; i <n ; i++) {
      sum[i + 1] = sum[i] + (s[i] == 'W' ? 1 : 0);
    }
    
    long ret = 0;
    for (int i = 0; i < n; i ++ ) {
      if (s[i] == 'B') {
        ret += sum[n] - sum[i];
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

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

  private static long nl() {
    return Long.parseLong(next());
  }

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

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

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

  ll ans = 0, sum = 0, dig = 0;
  for (int i = 0; i < M; i++){
    ll D, C; cin >> D >> C;
    dig += C;
    sum += D * C;

    ans += sum / 9; sum %= 9;
    if (sum == 0){
      ans--; sum = 9;
    }
  }

  cout << ans + dig - 1 << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
const int MAX = 2000000;
long long 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;
	}
}

// 二項係数計算
long long COM(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;
}

int main() {
	COMinit();
	ll x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0;
		return 0;
	}
	if (x * 2 < y || y * 2 < x) {
		cout << 0;
		return 0;
	}
	cout << COM((x + y) / 3, x - ((x + y) / 3));
}

Measured memory_bytes: 47104
N = int(input())
S=[]
P=[]
spi=[]
idx=1
for i in range(N):
    s_tmp, p_tmp = input().split()
    S.append(s_tmp)
    P.append(int(p_tmp))
    spi.append([s_tmp,-(int(p_tmp)),idx])
    idx=idx+1

spi=sorted(spi, key=lambda x:(x[0],x[1]), reverse=False)
for i in spi:
    print(i[2])

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int r, D, x;
    scanf("%d%d%d", &r, &D, &x);
    
    for (int i = 0; i < 10; i++)
    {
        x = r * x - D;
        printf("%d\n", x);
    }

    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    long long tmp = 0;
    long long ans = 0;
    for(int i=0; i<n; ++i){
        long long x, s;
        cin >> x >> s;
        ans = max({ans, s, s - x + tmp});
        tmp = max(tmp + s, s + x);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for (int i=(a); i<(b); i++)

int main(){
	int a,b;
	cin>>a>>b;
	if (a*500>=b)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

from fractions import gcd

N, M = map(int, input().split())
X = list(map(int, input().split()))

A = [0] * N
for i in range(N):
    A[i] = abs(M-X[i])

#print(A)

gc = A[0]
for i in range(N):
    gc = gcd(gc, A[i])

print(gc)


Measured memory_bytes: 16280
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = scan!(usize, usize);

    let (mut x, mut y) = (0, n);
    for _ in 0..m {
        let (l, r) = scan!(usize, usize);
        if x < l {
            x = l
        }
        if r < y {
            y = r;
        }
    }

    if y >= x {
        println!("{}", y - x + 1);
    } else {
        println!("0")
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll H,max=0;
    ll i;
    for(i=0;i<N;i++){
      cin >> H;
      if(max<H){
        max=H;
      }else if(H<max-1){
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
    return 0;
}


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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    int H, W;
    vector<string> a;
    vector<bool> colwhite;
    vector<bool> rowwhite;

    cin >> H >> W;
    rep(i, W) {
        colwhite.push_back(true);
    }
    rep (i, H) {
        string buf;
        cin >> buf;
        a.push_back(buf);

        rowwhite.push_back(true);
        rep (j, W) {
            if (buf[j] == '#') {
                colwhite[j] = false;
                rowwhite[rowwhite.size()-1] = false;
            }
        }
    }

    rep (i, H) {
        if (rowwhite[i] == true) {continue;}
        rep(j, W) {
            if (colwhite[j] == false) {
                cout << a[i][j];
            }
        }
        cout << endl;
    }

}


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

void solve()
{
    int k;cin>>k;
    for(int i=0;i<k;i++)
    {
        cout<<"ACL";
    }
    cout<<endl;
}
int32_t main()
{
   int t=1;
//   cin>>t;
   while(t--)
   {
       solve();
   }



    return 0;
}


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

using ll = long long;

#define mod 2019
#define INF 2<<30

int x[10][10];

int main(void){
    // Your code here!
    ll n,d;
    cin >> n >> d;
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)cin>>x[i][j];
    }
    
    int ans=0;
    
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)
    {
        int a=0;
        for(int k=0;k<d;k++)
        {
            int b=x[i][k]-x[j][k];
            a+=b*b;
        }
        
        float ip=0.0f;
        float d=sqrt(a);
        if(modf(d, &ip)==0)ans++;
    }
    
    cout<<ans;
}



Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;
import java.lang.StringBuilder;

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    int coins = 0;
    for(int i = 0; i < 2; i++) {
      if (A > B) {
        coins += A;
        A--;
      } else {
        coins += B;
        B--;
      }
    }

    System.out.println(coins);

  }
}


Measured memory_bytes: 22996
// inout macro begin
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        p: [u64;n],
    }

    println!("{}", p.iter().sum::<u64>() - p.iter().max().unwrap() / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int abs(int x,int y) {
  if(x>=y){
    return x-y;
  }
  else{
    return y-x;
  }
}


int main() {
  int N,M,k,x;
  k=0,x=0;
  cin>>N>>M;
  vector<int> vec1(N*2);
    for(int i=0;i<N*2;i++){
      cin>>vec1.at(i);
    }
  vector<int> vec2(M*2);
  for(int j=0;j<M*2;j++){
    cin>>vec2.at(j);
  }
  while(k<N*2){
    int j=M*2-1;
    long long d=10000000000000;
    while(j>0){
      int a=abs(vec1.at(k),vec2.at(j-1));
      int b=abs(vec1.at(k+1),vec2.at(j));
      int c=a+b;
      if(c<=d){
        d=c;
        x=(j+1)/2;
        j-=2;
      }
      else{
        j-=2;
      }
    }
      cout<<x<<endl;
      k+=2;
  }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef ll V;
typedef pair<V, V> pVV;
const V INF_V = (1ll<<60);
const int ME = 18;
const int N = 1<<ME;
class RMQ_segtree{
public:
    pVV dat[2*N-1];
    RMQ_segtree(){
        REP(i, 2*N-1) dat[i] = make_pair(INF_V, -1);
    }

    void update(int k, V a){
        //k番目の要素をaに変更
        k += N-1;
        dat[k] = make_pair(a, k-(N-1));
        while(k>0){
            k = (k-1)/2;
            dat[k] = min(dat[2*k+1], dat[2*k+2]);
        }
    }

   pVV recursion(int a, int b, int k, int l, int r){
        //最小値計算用の再帰関数
        if(r<=a || b<=l) return make_pair(INF_V, -1);
        if(a<=l && r<=b) return dat[k];
        else{
            pVV vl = recursion(a, b, 2*k+1, l, (l+r)/2);
            pVV vr = recursion(a, b, 2*k+2, (l+r)/2, r);
            return min(vl, vr);
        }
    }

    pVV minimum(int a, int b){
        //区間[a, b)の最小値
        return recursion(a, b, 0, 0, N);
    }

    void print_val(int a, int b){
        //区間[a, b)の値を出力
        for(int i=a;i<b;i++) cout << dat[i+N-1].first << endl;
        cout << endl;
    }

    ll get_val(int x){
    	auto y = minimum(x, x+1);
    	return y.first;
    }
};

RMQ_segtree seg;

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

    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;

    const ll INF = (1ll<<60);

    seg.update(0, 0);

    for(int i=1;i<=N;i++){
    	if(S[i]=='1') continue;
    	ll lb = max(0ll, i-M);
    	ll rb = i-1;
    	auto mi = seg.minimum(lb, rb+1);
    	seg.update(i, mi.first+1);
    }

    if(seg.get_val(N)==INF){
    	cout << -1 << endl;
    }else{
    	
		ll now = N;
		vector<ll> res;
		while(now!=0){
			ll lb = max(0ll, now-M);
			ll rb = now-1;
			auto pp = seg.minimum(lb, rb+1);
			ll pos = pp.second;
			res.push_back(now-pos);
			now = pos;
		}
		ll L = res.size();
		REP(i, res.size()){
			cout << res[L-1-i] << " ";
		}
		cout << endl;
		
    }

    /*
    REP(i, N+1) cout << seg.get_val(i) << " ";
    cout << endl;
    */
    return 0;
}

Measured memory_bytes: 9672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,k;
    cin >> n >> k;
    int ans = 0;
    while(n>0){
        n /= k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int f[55][26];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		int m = (int)str.size();
		for (int j = 0; j < m; j++) {
			f[i][str[j] - 'a']++;
		}	
	}
	string ans = "";	
	for (int i = 0; i < 26; i++) {
		int cur = f[0][i];
		for (int j = 1; j < n; j++) {
			cur = min(cur, f[j][i]);
		}

		while (cur > 0) {
			ans += (char)('a' + i);
			cur--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  return (n+1)//2

# main()
print(main())


Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K, C;
    cin >> N >> K >> C;
    string s;
    cin >> s;

    vector<int> L(K), R(K);

    int ind = 0;
    int pre = -10000000;
    rep(i, N)
    {
        if (s[i] == 'o' && i > pre + C) {
            L[ind++] = i;
            pre = i;
        }
        if (ind == K) {
            break;
        }
    }

    ind = K - 1;
    pre = 10000000;
    for (int i = N - 1; i >= 0; i--) {
        if (s[i] == 'o' && i < pre - C) {
            R[ind--] = i;
            pre = i;
        }
        if (ind == -1) {
            break;
        }
    }

    int ans = 0;
    rep(i, K)
    {
        //cout << L[i] << ' ' << R[i] << endl;
        if (L[i] == R[i]) {
            cout << L[i] + 1 << endl;
        }
    }
}


Measured memory_bytes: 3348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int R, int G, int B, int N)
        {
            int cnt = 0;
            for (int r = 0; r * R <= N; ++r)
            {
                for (int g = 0; r * R + g * G <= N; ++g)
                {
                    if ((N - r * R - g * G) % B == 0) { ++cnt; }
                }
            }
            return cnt;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], V[2], V[3]));
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <math.h>

int main(void) {
    int n, total = 0;
    scanf("%d", &n);
    int a[n],b[n-1];
    for(int i = 0; i < n-1; i++) {
        scanf("%d", &b[i]);
    }
    a[0] = b[0];
    a[n-1] = b[n-2];
    for(int i = 1; i < n-1; i++) {
        a[i] = fmin(b[i-1], b[i]);
    }
    for(int i = 0; i < n; i++) {
        total += a[i];
    }
    printf("%d\n", total);
    return 0;
}

Measured memory_bytes: 128
/* 
 * Author: aps
 * Time: 2019-07-28 19:29:58
**/
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
 
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n; cin >> n;
    ll a[n+1],b[n];

    for(int i=0;i<n+1;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    
    ll ans = 0;
    for(int i=n-1;i>=0;i--) {
        ll take = min(b[i],a[i+1]);
        ans += take;
        b[i] -= take;
        take = min(b[i],a[i]);
        a[i] -= take;
        ans += take;
    }

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


Measured memory_bytes: 1792
from collections import defaultdict
S = [int(x) for x in input()]
N = len(S)
l = 1
ans = 0
dic = defaultdict(int)
dic[0] = 1
m = 0
for x in S[::-1]:
    m = (x * l + m) % 2019
    ans += dic[m]
    l = l * 10 % 2019
    dic[m] += 1
print(ans)

Measured memory_bytes: 78940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    set<int> s;
    vector<vector<int>> v(n+1);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(auto i:v[1]){
        s.insert(i);
    }
    for(auto i:v[n]){
        if(s.find(i)!=s.end()){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 16752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    vint k(q);
    rep(i,q) cin >> k[i];
    rep(i,q) {
        ll ans = 0;
        int sum_d = 0, sum_m = 0;
        ll sum_dm = 0;
        rep(j,n) {
            if (j < k[i]) {
                if (s[j] == 'D') sum_d++;
                if (s[j] == 'M') {
                    sum_m++;
                    sum_dm += sum_d;
                }
                if (s[j] == 'C') ans += sum_dm;
            } else {
                if (s[j] == 'D') sum_d++;
                if (s[j-k[i]] == 'D') {
                    sum_dm -= sum_m;
                    sum_d--;
                }
                if (s[j] == 'M') {
                    sum_m++;
                    sum_dm += sum_d;
                }
                if (s[j-k[i]] == 'M') sum_m--;
                if (s[j] == 'C') ans += sum_dm;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5260
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    cout << n/3 << endl;
}
    

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public String circulate(int n, int m){
		StringBuilder ans = new StringBuilder();
		for(int i = 0; i < n; i++){
			ans.append(" ");
		}
		for(int i = n; i <= m; i++){
			ans.append("^");
		}
		return ans.toString();
	}
	
	public void solve() throws IOException{
		Scanner stdIn = null;
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				int p = stdIn.nextInt();
				int q = stdIn.nextInt();
				Map<Integer, Integer> map = new HashMap<Integer, Integer>();		
				StringBuilder ans = new StringBuilder();
				int index = 0;
				int n = 10*p/q;
				int m = 10*p%q;
		outer:	while( true ){
					ans.append(n);
					if( m == 0 ){
						System.out.println(ans);
						break;
					}
					for(Integer x : map.keySet()){
						if( x == m ){
							if( ans.charAt(map.get(x))-'0' == n ){
								ans.deleteCharAt(ans.length()-1);
								System.out.println(ans);
								System.out.println(circulate(map.get(x), index-1));
							} else {
								System.out.println(ans);
								System.out.println(circulate(map.get(x)+1, index));
							}
							break outer;
						}
					}
					if( m != q ){
						map.put(m, index);
					}		
					n = 10*m/q;
					m = 10*m%q;			
					index++;
				}
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
			
	public static void main(String[] args) throws IOException{ 
		new Main().solve();
	}
}
			

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

//約数列挙O(root n)
vector<PLL> divisor(ll n){
  vector<PLL> v;
  for(ll i=1; i<=sqrt(n); i++){
    if(n%i == 0){
      v.push_back(PLL(i,n/i));
    }
  }
  return v;
}


int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll S;cin >> S;
  ll x1,y1,x2,y2;
  //if(S==1e18){
  //  cout << 0 SP 0 SP 0 SP 1e9 SP 1e9 SP 0 << endl;
  //  return 0;
  //}

  cout << 0 SP 0 SPF;
  for(ll sX = sqrt(S); sX<=1e9; ++sX){
    ll X = sX*sX;
    ll Y = X-S;
    if(Y<0)continue;
    if(Y==0){
      cout << sX SP 0 SPF;
      cout << 0 SP sX << endl;
      return 0;
    }
    vector<PLL> d = divisor(Y);
    for(auto &a : d) if(a.first <= 1e9 && a.second <= 1e9){
      cout << sX SP a.first SPF;
      cout << a.second SP sX << endl;
      return 0;
    }
  }
  //S以上でx1*y2(x1<=1e9, y2<=1e9となる最小の組を見つける
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll MOD = 1000000007;
ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int main()
{
    string S;
    cin >> S;
    char smp= S[0];
    ll count = 0;
    for(int i = 1; i < S.size(); i++)
    {
        if(smp != S[i]) count++,smp = S[i];
    }
    cout << count << endl;
}

Measured memory_bytes: 512
from collections import defaultdict
from math import gcd

mod = 10 ** 9 + 7
n = int(input())
fishes = defaultdict(int)
zero_zero = 0
zero = 0
inf = 0

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero_zero += 1

    elif a == 0:
        zero += 1

    elif b == 0:
        inf += 1

    else:
        div = gcd(a, b)
        a //= div
        b //= div
        if b < 0:
            a *= -1
            b *= -1
        key = (a, b)
        fishes[key] += 1


def get_bad_pair(fish):
    a, b = fish
    if a < 0:
        a *= -1
        b *= -1
    return (-b, a)


ans = 1
counted_key = set()
for fish_key, count in fishes.items():
    if fish_key in counted_key:
        continue

    bad_pair = get_bad_pair(fish_key)
    if bad_pair in fishes:
        pair_count = fishes[bad_pair]
        pattern = pow(2, count, mod) + pow(2, pair_count, mod) - 1
        counted_key.add(bad_pair)

    else:
        pattern = pow(2, count, mod)

    ans = ans * pattern % mod

ans *= pow(2, zero, mod) + pow(2, inf, mod) - 1
if zero_zero:
    ans += zero_zero

ans -= 1
print(ans % mod)


Measured memory_bytes: 49476
# include <iostream>

using namespace std;

int Abs( int A ) {
	if ( A < 0 )
		return -A;
	return A;
} // Abs

int main() {
	int N_spot = 0;
	long long int Total = 0;
	int Spot[100001] = {0};
	cin >> N_spot;
	
	for ( int i = 1; i <= N_spot; i++ ) {
		cin >> Spot[i];
		Total += Abs( Spot[i] - Spot[i-1] );
	} // for
	
	Total += Abs( Spot[N_spot+1] - Spot[N_spot] );
	
	for ( int i = 1; i <= N_spot; i++ ) {
		cout << Total - Abs( Spot[i] - Spot[i-1] ) - Abs( Spot[i+1] - Spot[i] ) + Abs( Spot[i+1] - Spot[i-1] ) << "\n";
	} // for
}// main

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

vector<vector<int> >adj;

pair<int,int> dis[100005][11];

vector<pair<int,pair<int,int> > >fi[12];
int n;

void bfs()
{
    queue<int>qq;
    for(int i=10;i>=1;i--)
    {
        for(auto j:fi[i])
        {
            if(dis[j.first][i].first<j.second.first)
                dis[j.first][i]=j.second;
        }
        for(int j=1;j<=n;j++)
        {
            if(dis[j][i].first)
            {
               qq.push(j);
            }
        }
        while (!qq.empty())
        {
            int z=qq.front();
            qq.pop();
            for(auto j:adj[z])
            {
                if(dis[j][i-1].first<dis[z][i].first)
                    dis[j][i-1]=dis[z][i];
            }
        }        
    }
}

signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int m;
    cin>>n>>m;
    int x,y;
    adj.resize(n+1);
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int q;
    cin>>q;

    int cnt=0;
    
    while (q--)
    {
        ++cnt;
        int v,d,c;
        cin>>v>>d>>c;        
        dis[v][d]={cnt,c};
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=10;j++)
        {
            if(dis[i][j].first)
            {
                fi[j].push_back({i,dis[i][j]});
            }
        }
    }    
    bfs();
    for(int i=1;i<=n;i++)
    {
        int mx=0;
        int ind=0;
        for(int j=0;j<=10;j++)
        {
            if(dis[i][j].first>mx)
            {
                mx=dis[i][j].first;
                ind=dis[i][j].second;
            }
        }
        cout<<ind<<'\n';
    }

} 
    
 


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

bool check(int N, const set<char>& S) {
    string s = to_string(N);
    EACH(c, s) {
        if (S.count(c) > 0) return false;
    }
    return true;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N, K; cin >> N >> K;
    set<char> s;
    REP(i, K) {
        char c; cin >> c;
        s.insert(c);
    }
    while ( !check(N, s) ) ++N;
    cout << N << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int h, w;
int func(int i,int j, vector<vector<bool>>&has,vector<string>&s, int dis ){
	int res=dis;
	if(has[i][j]==false and s[i][j]=='#'){
		has[i][j]=true;
		for(int ii=i-1;ii<=1+i;ii++){
			if(ii <0 or ii >= h or ii==i){continue;}
			chmax(res,func(ii,j,has,s,dis+1));
		}
		for (int jj = j - 1; jj <=j+ 1; jj++)
		{
			if (jj < 0 or jj >= w or jj == j)
			{
				continue;
			}
			chmax(res, func(i, jj, has, s, dis + 1));
		
		}	
	}else{return 0;}
//	clog<<i<<" "<<j<<" -- "<<res<<endl;
	return res;
	
}
int main(){

	bool ans=true;
	cin >>h>>w;
	vector<string> s(h);
	vector<vector<bool>>has(h,vector<bool>(w,false));
	rep(i,h){
		cin>>s[i];
	}
	rep(i,h){
		rep(j,w){
			if (has[i][j] == false and s[i][j] == '#')
			{
				ans &= (func(i, j, has, s, 0) != 0);
			}
		}
	}
	cout<<solve(ans)<<endl;
}

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

int p[11];
vector <int> s[11];

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

	int n,m,a,b;
	int res = 0;

	cin >> n >> m;

	for(int i=1;i<=m;i++)
	{
		cin >> a;
		for(int j=0;j<a;j++)
		{
			cin >> b;
			s[i].push_back(b);
		}
	}

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

	for(int i=0;i<(1<<n);i++)
	{
		int check[11];
		int cnt = 0;

		memset(check,0,sizeof(check));

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

		//cout << i << '\n';
		for(int j=1;j<=m;j++)
		{
			int sum = 0;
			for(int k=0;k<s[j].size();k++)
			{
				//cout << j << ' ' << s[j][k] << '\n';
				if(check[s[j][k]]==1)
				{
					//cout << j << ' ' << s[j][k] << '\n';
					sum++;
				}
			}
			if(sum%2==p[j])
			{
				cnt++;
			}
		}
		
		if(cnt==m)
		{
			res++;
		}
	}

	cout << res << '\n';

	return 0;	
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<ll> l(m), r(m);

    REP(i, m)
    {
        cin >> l[i] >> r[i];
    }
    ll l_max = *max_element(ALL(l)), r_min = *min_element(ALL(r));
    ll res = 0;
    // dump(l_max);
    // dump(r_min);
    FOR(i, 1, n + 1)
    {
        if (i >= l_max && i <= r_min)
            res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

x = readInt()

if x>=30:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9452
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=1e3+3;
const int MOD=1000000007;

int h,w;
char a[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];

int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++) scanf("%s",a[i]+1);
	if(a[1][1]!='#') dp[1][1]=1;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) if(a[i][j]!='#')
		dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%MOD;
	printf("%d\n",dp[h][w]);
	return 0;
}



Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
input:
    ll n;
    cin >> n;
    string s;
    cin >> s;

    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    string s0, s1;
    s0 = s.substr(0, n / 2);
    s1 = s.substr(n / 2, n / 2);

    if (s0 == s1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

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

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

int N;

int dist(int r1, int s1, int r2, int s2) {
  return abs(r1 - r2) + abs(s1 - s2);
}

int main(void) {
  scanf("%d", &N);
  int x = 0, y = 0, t = 0;
  for (int i = 0; i < N; ++i) {
    int ti, xi, yi;
    scanf("%d%d%d", &ti, &xi, &yi);
    int d = dist(x, y, xi, yi);
    if (d > ti - t || (ti - t - d) % 2 == 1) {
      printf("No\n");
      return 0;
    }
    t = ti; x = xi; y = yi;
  }

  printf("Yes\n");
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int A,B,C; cin>>A>>B>>C;
  cout << (A*B/2) << endl;
  return 0;
}


Measured memory_bytes: 256