akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <ctime>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << ((a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    ll x;
    cin >> x;
    ll ans = (x/11)*2;
    
    //処理
    if(x%11>6) ans += 2;
    else if(x%11>0) ans++;

    //出力
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  const char weeks[7][10]={   "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  const int months[]={31,29,31,30,31,30,31,31,30,31,30,31};
  int d,m,i,summ;
  while(scanf("%d %d",&m,&d)){
    if(m==0) break;
    summ=d+(-1+3);
    for(i=0;i<m-1;i++)summ+=months[i];
    printf("%s\n",weeks[summ%7]);
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    vector<int> a(3);
    for(int i=0;i<3;i++) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<(a[1]-a[0])+(a[2]-a[1])<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
//#define P pair<ull,ull>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;
 
inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 1e7+5, M = 205; 
bool vis[N]; int p[N], v[M], f[2][M], tot = 0;
inline void pre(int n=1e7) { 
	int t;
	vis[1] = 1;
	rep(i,2,n) { 
		if( !vis[i] ) p[++tot] = i;
		for(register int j = 1; j <= tot && (t = p[j] * i) <= n; j++) { 
			vis[t] = 1;
			if( i % p[j] == 0 ) break;
		}
	}  
	vis[2] = 1;
}

int dy[M]; bool ti[M];
struct edge{ int to, nxt; } e[M*M];
int head[M], cnt = 0;
inline void add(int x,int y) { 
	e[++cnt].to = y, e[cnt].nxt = head[x], head[x] = cnt;
}
#define ez(i,j) for(register int i = head[j]; i; i=e[i].nxt)
#define to e[i].to
inline bool dfs(int x) { 
	ez(i,x) if( !ti[to] ) { 
		ti[to] = 1;
		if( !dy[to] || dfs(dy[to]) ) return dy[to] = x, 1;
	} return 0;
} 

int main() {
	pre();
	int n = read(), x;
	rep(i,1,n) v[i] = read();
	rep(i,1,n) { 
		if( i == 1 || v[i] - 1 != v[i-1] ) {
			x = v[i] & 1;
			f[x][++f[x][0]] = v[i];
		} 
		if( i == n || v[i] + 1 != v[i+1] ) { 
			x = (v[i] + 1) & 1;
			f[x][++f[x][0]] = v[i] + 1;
		}
	}
	
	rep(i,1,f[0][0]) { 
		rep(j,1,f[1][0]) { 
			if( !vis[abs(f[0][i]-f[1][j])] ) add(i,j);
		}
	}
	int ans = 0;
	rep(i,1,f[0][0]) memset(ti,0,sizeof(ti)), ans += dfs(i);
	f[0][0] -= ans;
	f[1][0] -= ans;
	
	ans += f[0][0] + f[1][0];
	f[0][0] %= 2;
	ans += f[0][0];
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(char c='a'; c<='z'; c++){
    for(int i=0; i<s.size(); i++){
      if(s.at(i) == c){
        break;
      }
      if(i == s.size()-1){
        cout << char(c) << endl;
        return 0;
      }
    }
    if(c == 'z'){
      cout << "None" << endl;
    }
  }
}

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

int main()
{
	string s; cin >> s;
		
	int red = 0;
	int blue = 0;

	int n = s.size();

	for (int i = 0; i < n; i++) {

		if (s.at(i) == '0') {
			red++;
		}
		else {
			blue++;
		}		

	}
		
	cout << 2 * min(red, blue) << endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

void ok(){
  cout << "YES" << endl;
  exit(0);
}

void ng(){
  cout <<  "NO" << endl;
  exit(0);
}

vector<Int> edge[216000];
Int deg[216000];
Int A[216000];
Int a, b, n;

int dfs(int x, int last = -1){
  if(deg[x] == 1)return A[x];
  Int mx = 0;
  Int sum = 0;
  for(auto to: edge[x]){
    if(to == last)continue;
    Int u = dfs(to, x);
    mx = max(mx, u);
    sum += u;
  }
  Int flip = sum - A[x];
  Int res = sum - 2 * flip;
  if(flip < 0)ng();
  if(flip > min(sum - mx, sum / 2))ng();
  if(res < 0)ng();
  return res;
}


int main(){
  cin >> n;
  for(int i = 0;i < n;i++)cin >> A[i];
  for(int i = 0;i < n-1;i++){
    cin >> a >> b;a--,b--;
    deg[a]++, deg[b]++;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  if(n == 2){
    if(A[0] == A[1])ok();
    else ng();
  }
  int root = 0;
  while(deg[root] == 1)root++;
  if(dfs(root) == 0)ok();
  ng();
  return 0;
}

Measured memory_bytes: 17536
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    S = SL()

    tmp = S[0]
    ans = 1
    for ch in S:
        if tmp != ch:
            ans += 1
            tmp = ch
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	vi a(n+1);
	vector<set<int> > r(n+2);
	rep(i,1,n+1) {
		cin >> a[i];
		r[a[i]].insert(i);
	}
	a.pb(n+1);
	r[n+1].insert(n+1);
	vector<bool> b(n+1, false);
	b[0] = true;
	int mx = 0;
	rep(i,0,n+1) {
		if(b[i]) {
			int x = a[i]+1;
			auto it = r[x].upper_bound(i);
			for(it; it != r[x].end(); ++it) {
				int idx = *it;
				b[idx] = true;
			}
			mx = max(mx, a[i]);
		}
	}

	if(mx == 0) {
		cout << -1 << '\n';
	} else {
		cout << (n - mx) << '\n';
	}
	return 0;
}


Measured memory_bytes: 20608
import java.util.*;
import java.io.*;
class Main
{
 	public static void main (String[]args){
      Scanner sc=new Scanner(System.in);
      int A=sc.nextInt(),B=sc.nextInt(),C=sc.nextInt();
      int ans=0;
      if(B>=C-1)
        ans=B+C;
      else
      {
        ans=2*B;
        C-=B;
        int x=Math.min(C,A);
        ans+=x;
        C-=x;
        if(C>0)
          ans++;
      }
      System.out.println(ans);
      
        
    }
  
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <set>

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

  std::set<int> res;
  for (int i = A; i <= std::min(A+K-1, B); ++i)
    res.insert(i);
  for (int i = std::max(B-K+1, A); i <= B; ++i)
    res.insert(i);

  for (auto x: res)
    std::cout << x << std::endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int a = sc.nextInt();
    int b = sc.nextInt();
		int wa = a + b;
		int sa = a - b;
		int seki = a * b;
		if(wa < sa){
			if(sa < seki){
				System.out.println(seki);
			}else{
				System.out.println(sa);
			}
		}else{
			if(wa < seki){
				System.out.println(seki);
			}else{
				System.out.println(wa);
			}
		}
 
 
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)(1 << 18);

int a[N];
bool vis[N];
vector<pii> T[N];

int main(){
  fastIO;
  int n;
  cin >> n;
  int m = (1 << n);
  for(int i = 0 ; i < m ; i ++ ){
    cin >> a[i];
    T[i].push_back(mp(a[i],i));
  }
  vis[0]=true;
  queue<int> bf;
  bf.push(0);
  int node;
  int nx;
  while(!bf.empty()){
    node = bf.front();
    bf.pop();
    sort(T[node].begin(), T[node].end());
    T[node].resize(unique(T[node].begin(), T[node].end()) - T[node].begin());
    reverse(T[node].begin(), T[node].end());
    while(T[node].size() > 2) T[node].pop_back();
    for(int i = 0 ; i < n; i ++ ){
      if((node & (1 << i))) continue;
      nx = (node | (1 << i));
      if(!vis[nx]){
        vis[nx]=true;
        bf.push(nx);
      }
      for(auto p : T[node]){
        T[nx].push_back(p);
      }
    }
  }
  int out = 0;
  for(int i = 1; i < m ; i ++ ){
    out = max(out, T[i][0].fi + T[i][1].fi);
    cout << out << "\n";
  }
  return 0;
}

Measured memory_bytes: 74624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
	
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	ll a,b,sa[n+1],sb[m+1];
	sa[0]=0;
	sb[0]=0;
	rep(i,n){
		cin>>a;
		sa[i+1]=sa[i]+a;
	}
	rep(i,m){
		cin>>b;
		sb[i+1]=sb[i]+b;
	}
	int pb=0;
    ll sum=0;
	ll rest=0;
	rep(i,n+1){
		rest=k-sa[i];
		pb=upper_bound(sb,sb+m+1,rest)-sb-1;
		if(pb<0)continue;
		if(sum<i+pb)sum=i+pb;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char> (w));
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  rep(i,w+2){
    cout << '#';
  }
  cout << endl;
  rep(i,h){
    cout << '#';
    rep(j,w){
      cout << a[i][j];
    }
    cout << '#' << "\n";
  }
  rep(i,w+2){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
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)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        an:[usize;n],
        bn:[usize;n],
        cn:[usize;n-1],
    }
    let mut ans = 0;
    for i in 0..n {
        if i !=0 && an[i-1]  == an[i]-1{
            ans += cn[an[i]-2];
        }
        ans += bn[an[i]-1];
    }
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

ll mod=1e9+7;

int main()
{
  int N,M;
  cin >> N >> M;
  
  vint oks(N+1,true);
  REP(i,M){
    int a;
    cin >> a;
    oks[a]=false;
  }
  
  vll dp(N+1);
  dp[0] = 1;
  REP(now,N){
    for(int next=now+1; next<=min(N,now+2);next++){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N = int(input())
    H = list(map(int, input().split()))

    flag = 0

    for i in range(N-1):
        if H[i]-1 >= H[i+1]:
            flag = 2
            # print(flag, H)
            break
        elif H[i]+1 <= H[i+1]:
            H[i+1] -= 1
        # print(flag, H)
    if flag == 2:
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
//F5で実行 Shift+F5で停止
//F9でブレークポイント
#include<cmath>
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
//Shift+PageUpで上部の大半を選択できる
// 1e18 = 10の18乗

string S;

void _main(){
	cin >> S;

	string rs = "RS";

	int ans = 0;
	int count = 0;

	rep(i, 0, S.length()) {
		//雨ならカウント
		if (S[i] == rs[0])
			count++;
		else{
			chmax(ans,count);
			count = 0;
		}
	}
	chmax(ans,count);

	cout << ans;
}

Measured memory_bytes: 3644
import java.util.Scanner;

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

        int num = Integer.valueOf(line).intValue();
        line = sc.nextLine();
        String[] input = line.split(" ", 0);
        double list[] = new double[num];

        int i = 0;
        while(i != num){
            list[i] = Double.parseDouble(input[i]);
            i++;
        }

        i = 0;
        double db = 0.0;
        while(i != num-1){
            sort(list);
            db = (list[i]+list[i+1])/2.0;
            list[i] = 0;
            list[i+1] = db;

            i++;
        }
        System.out.println(db);

    }

    public static void sort( double[] array ) {
        double tmp;
        for( int i=0; i<array.length-1; i++ ) {
            for( int j=0; j<array.length-i-1; j++ ) {
                if( array[j] > array[j+1] ) {
                    tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                }
            }
        }
    }
}

Measured memory_bytes: 23252
//#include "bits/stdc++.h"
#include<iostream>
using namespace std;
#define int int64_t
#define mp make_pair
#define f first
#define s second
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string ss;cin>>ss;
    int co=0;
    for(int i=0;i<ss.length()/2;i++)
    {
        if(ss[i]!=ss[ss.length()-1-i])
            co++;
    }
    cout<<co<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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; }


int N, M, Q;
int dp[600][600];

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

  Rep(i, M) {
    int l, r;
    cin >> l >> r;
    dp[l][r]++;
  }

  for (int i=N;i>=1;--i) {
    rep(j, N) {
      dp[i-1][j] += dp[i][j];
    }
  }

  for (int j=1;j<=N;++j) {
    rep(i, N) {
      dp[i][j] += dp[i][j-1];
    }
  }

  Rep(i, Q) {
    int l, r;
    cin >> l >> r;
    cout << dp[l][r] << "\n";
  }
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	ll total = 0;
	rep(i, n){
		int in;
		cin >> in;
		total += (ll)in;
		a.at(i) = in;
	}
	sort(a.begin(), a.end());

	vector<ll> tv(n);
	tv.at(0) = 0;
	int index = 0;
	rep(i, n){
		if(i != 0) tv.at(i) = tv.at(i-1);
		tv.at(i) += a.at(i);
		if(i != 0 && tv[i-1]*2 < a[i]) index = i; 
		//cerr << tv.at(i) << " ";
	}
	//cerr << endl;
	cout << n - index << endl;

	return 0;
}

/*
	int ans = 0;
	int left = 0, right = n, ii;
	while(1){
		ii = (right + left)/2;
		//cerr << left << " " << right << endl;
		if(left >= right) break;
		bool flag = true;
		ll temp = tv.at(ii);
		rep2(j, ii+1, n){
			if(temp*2 >= a.at(j)) temp +=a.at(j);
			else{
				flag = false;
				break;
			}
		}
		if(flag == true){
			right = ii;
		}else{
			left = ii+1;
		}
	}
	ans = n - left;
	cout << ans << endl;
	return 0;
}
*/

Measured memory_bytes: 1408
#include <iostream>
#include <string>
using namespace std;
int main(){
	
	string s="", ent;
	cin>>ent;
	
	for(int i=0 ; i<ent.size() ; i++){
		if(ent[i]=='0')
		s += '0';
		else if(ent[i]=='1')
		s += '1'; 
		else if(s.size()>=1){
				s.erase(s.end()-1); 
			}
		
		
	}
	cout<<s<<"\n";
	
	return 0;
	}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

  
  ll X;
  cin>>X;
  ll Y=100;
  ll counter=0;
  while(Y<X){
    Y*=1.01;
    counter++;
  }
  
  cout<<counter<<endl;
}



Measured memory_bytes: 3596
#include <stdio.h>
#define N 101


int main(){
    int n, i, j;
    int arr[N];
    int temp, cnt = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    // bubble
    for(i = 0; i < n-1; i++) {
        for(j = n-1; j > i; j--) {
            if(arr[j-1] > arr[j]){
                temp = arr[j];
                arr[j] = arr[j-1];
                arr[j-1] = temp;
                cnt++;
            }
        }
    }

    for(i = 0; i < n-1; i++) {
        printf("%d ", arr[i]);
    }
    printf("%d\n", arr[n-1]);
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 600
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	if x == "H":
		a.append(y + 13)
	if x == "C":
		a.append(y + 26)
	if x == "D":
		a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))



Measured memory_bytes: 5592
from collections import Counter

n = int(input())
nums = sorted(list(map(int, input().split())), reverse=True)

num_map = Counter(nums)

answer = 0
for num in nums:
    pair = (1 << (num.bit_length())) - num

    if num_map[num] > 0 and num_map[pair]:
        if num == pair and num_map[num] > 1:
            answer += 1
            num_map[num] -= 2
        if not num == pair:
            answer += 1
            num_map[num] -= 1
            num_map[pair] -= 1

print(answer)

Measured memory_bytes: 33424
#include <bits/stdc++.h>
using namespace std;
typedef long long signed int LL;
#define incID(i, l, r) for(int i = (l); i < (r); i++)
#define inc(i, n) incID(i, 0, n)

// ---- ----

const int MOD = 1000000007;
LL n, a[2], s[100000];
LL sum[2][100001], last[2], lim[2][100000];

int main() {
	cin >> n >> a[0] >> a[1];
	inc(i, n) { cin >> s[i]; }
	
	inc(k, 2) {
		int p = 0;
		inc(i, n) {
			while(s[i] - s[p] >= a[k] && p < i - 1) { p++; }
			lim[k][i] = p;
		}
	}
	
	last[0] = -1;
	last[1] = -1;
	sum[0][0] = 1;
	sum[1][0] = 1;
	
	incID(i, 1, n) {
		LL v[2];
		inc(k, 2) { v[k] = (last[1 - k] < lim[k][i] ? sum[1 - k][ lim[k][i] ] : 0); }
		inc(k, 2) {
			if(s[i] - s[i - 1] < a[k]) { last[k] = i - 1; } else { (v[k] += sum[k][i - 1]) %= MOD; }
		}
		inc(k, 2) { sum[k][i + 1] = sum[k][i] = v[k]; }
		
	}
	
	cout << (sum[0][n - 1] + sum[1][n - 1]) % MOD << endl;
	
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);
ll lcm(ll m, ll n);

int main(void) {

	double a, b, c, d;
	cin >> a >> b >> c >> d;
	double ans = a * b / 2;
	int ans1 = 0;
	if (a / 2 == c && b / 2 == d) ans1 = 1;

	printf("%lf %d\n", ans, ans1);



	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  
#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51},b;
	cin>>b;
	b--;
	cout<<a[b];
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

// union find
class union_find {
public:
    int n;
    vector<int> parent, rnk, num;
    
    union_find(int n) : n(n), parent(n), rnk(n, 0), num(n, 1) {rep(i, n) parent[i] = i; }
    
    int root(int x){ return (parent[x] == x) ? x : root(parent[x]); }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }
        if (rnk[x] < rnk[y]) {
            parent[x] = y;
            num[y] += num[x];
        }
        else{
            parent[y] = x;
            num[x] += num[y];
            if (rnk[x] == rnk[y]) {
                rnk[x]++;
            }
        }
        n--;
    }
    
    bool same(int x, int y) {return root(x) == root(y);}
    
    int count(int x){ return num[root(x)]; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    rep(i, N) rep(j, N) cin >> A[i][j];
    
    auto B = A;
    rep(k, N) rep(i, N) rep(j, N) {
        B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
    }
    
    rep(i, N) rep(j, N){
        if(A[i][j] != B[i][j]) {
            output(-1);
            return 0;
        }
    }
    
    ll sum = 0;
    
    rep(i, N) rep(j, N) {
        ll m = 1e15;
        rep(k, N) {
            if(k != i && k != j) m = min(A[i][k] + A[k][j], m);
        }
        if(m > A[i][j]) sum += A[i][j];
    }
    output(sum / 2);
    
    return 0;
}

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

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

	int n;
	cin >> n;

	deque<int> v;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(i % 2 == 0) v.push_back(a);
		else v.push_front(a);
	}

	if(n % 2) {
		reverse(v.begin(), v.end());
	}

	for(int i = 0; i < n; i++) {
		cout << v[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3072
#include<stdio.h>
int main()
{
  long double l;
  int i;
  scanf("%Lf",&l);
  long double a=l/3;
  long double x=l/3;
  for(i=0;i<2;i++){
    x=a*x;
  }
  printf("%Lf",x);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int ADJ[101];
int G[100][100];


int main(){
  int n,i,j,k,number[100];
  int RESULT[100][100];
  
  for(i=0;i<100;i++){
    ADJ[i]=0;
    for(j=0;j<100;j++){
      RESULT[i][j]=0;
      G[i][j]=0;
    }    
  }
  
 
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&number[i]);
    scanf("%d",&ADJ[number[i]]);
    for(j=0;j<ADJ[number[i]];j++){
      scanf("%d",&G[number[i]-1][j]);
    }
  }
  

  //---------- 
  for(i=0;i<n;i++){   
    for(j=0;j<ADJ[number[i]];j++){
      RESULT[i][G[i][j]-1]=1;
    }      
  }
  //----------
  //printf("%d\n",RESULT[0][3]);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",RESULT[i][j] );
      if(j<n-1){
	printf(" ");
      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 684
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        String a = sc.nextLine();
        String b = sc.nextLine();
        if (a.equals(b)) {
            System.out.println("EQUAL");
        } else if (a.length() < b.length()) {
            System.out.println("LESS");
        } else if (a.length() > b.length()) {
            System.out.println("GREATER");
        } else if (a.compareTo(b) > 0) {
            System.out.println("GREATER");
        } else {
            System.out.println("LESS");
        }
    }
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    int from, to;
    lint cost;
};

vector<edge> edges;

bool reverse_bellman_ford(int v, int e, int start, int goal, vector<long long> &dis){
    dis.resize(v);
    fill(dis.begin(), dis.end(), -LLINF);
    dis[start] = 0;
    for(int i = 0 ; i < v * 2 ; ++i){
        for(int j = 0 ; j < e ; ++j){
            edge now = edges[j];
            if(dis[now.from] != -LLINF && dis[now.to] < dis[now.from] + now.cost){
                dis[now.to] = dis[now.from] + now.cost;
                if(i >= v - 1 && now.to == goal){
                    return false;
                }
            }
        }
    }
    return true;
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        lint c;
        cin >> a >> b >> c;
        --a;
        --b;
        edges.push_back({a, b, c});
    }
    vector<lint> dis;
    if(reverse_bellman_ford(n, m, 0, n - 1, dis)){
        cout << dis.back() << endl;
    }else{
        cout << "inf" << endl;
    }
    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

int n;
vector<int> g[200010];
int sz[200010];
ll res=0;

void dfs(int v,int pre){
  sz[v]=1;
  for(int nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v);
    sz[v]+=sz[nv];
  }
}

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

  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  dfs(0,-1);
  ll p2=mod_pow(2,mod-2);
  rep(i,n){
    vector<int> ch;
    for(int v : g[i]){
      if(sz[v]>sz[i])ch.push_back(n-sz[i]);
      else ch.push_back(sz[v]);
    }
    if(ch.size()==1)continue;
    int chsz=ch.size();
    vector<vector<ll>> dp(chsz+1,vector<ll>(3,0));
    dp[0][0]=1;
    rep(j,chsz)rep(k,3){
      ll wp=mod_pow(p2,ch[j]);
      ll bp=(1-wp+mod)%mod;
      (dp[j+1][k]+=dp[j][k]*wp%mod)%=mod;
      (dp[j+1][min(2LL,k+1)]+=dp[j][k]*bp%mod)%=mod;
    }
    (res+=dp[chsz][2]*p2%mod)%=mod;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 21748
def main():
    """
    1 <= N <= 10^5
    1 <= K <= 10^12
    1 <= Ai <= 10^12
    """
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    ans4 = digit_dp(N, K, A)
    print(ans4)


def digit_dp(N, K, A):
    """桁DP

    http://drken1215.hatenablog.com/entry/2019/02/03/224200
    http://drken1215.hatenablog.com/entry/2019/02/04/013700
    https://qiita.com/nomikura/items/25883985ea148c3cf999
    """
    # dp[i桁見る][未満フラグ] = 総数
    dp = [[0] * 2 for _ in range(100)]

    for i in range(100):
        dp[i][0] = dp[i][1] = -1

    dp[40][0] = 0
    for d in range(40-1, -1, -1):
        mask = 1 << d
        num = 0
        for a in A:
            if a & mask:
                num += 1

        if dp[d+1][1] >= 0:
            dp[d][1] = max(dp[d][1], dp[d+1][1] + mask * max(num, N-num))

        if dp[d+1][0] >= 0:
            if K & (1 << d):
                dp[d][1] = max(dp[d][1], dp[d+1][0] + mask * num)
                dp[d][0] = max(dp[d][0], dp[d+1][0] + mask * (N-num))
            else:
                dp[d][0] = max(dp[d][0], dp[d+1][0] + mask * num)

    ans = max(dp[0][0], dp[0][1])
    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 73304
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}

int main(void) {
  ll N;
  cin >> N;
  ll i;
  ll x[MAX];
  ll t[MAX];
  ll s[MAX]={};
  ll KAI=1; //=(N-1)!
  
  for(i=0; i<N; i++) cin >> t[i];
  for(i=0; i<N-1; i++) x[i+1]=t[i+1]-t[i];
  for(i=1; i<N; i++) moC(KAI, *, i);
  
  for(i=1; i<N; i++) s[i]=(s[i-1]+moP(i, MOD-2))%MOD;
  for(i=1; i<N; i++) moC(s[i], *, KAI);
  
  ll ans=0;
  for(i=1; i<N; i++) {
    moC(ans, +, x[i]*s[i]%MOD);
  }
  
  pt(ans);
  
  
  
}





Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n, x;

int main(void) {
	scanf("%d", &n);
	int mx = -1, z, y;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &x);
		if(abs(x) > mx) {
			mx = abs(x);
			z = x < 0;
			y = i;
		}
	}
	printf("%d\n", 2 * n - 1);
	for(int i = 1; i <= n; i++)
		printf("%d %d\n", y, i);
	if(!z) for(int i = 1; i < n; i++)
			printf("%d %d\n", i, i + 1);
	else for(int i = n; i > 1; i--)
			printf("%d %d\n", i, i - 1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
   int x,y;
   cin >> x >> y;
   cout << (a[x]==a[y] ? "Yes" : "No") << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int main() {
	int h, w;
	cin >> h >> w;
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
		}
	}
	if (s[0][0] == '#')dp[0][0]++;
	rep(i, h) {
		rep(j, w) {
			if (i == 0 && j == 0)continue;
			dp[i][j] = INF;
			if (i != 0) {
				dp[i][j] = dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#');
			}
			if (j != 0) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] == '.'));
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e3+5;
ll x,y,z,k,a[N],b[N],c[N];
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    cin>>x>>y>>z>>k;
    for(ll i=0;i<x;i++)cin>>a[i];
    for(ll i=0;i<y;i++)cin>>b[i];
    for(ll i=0;i<z;i++)cin>>c[i];

    sort(a,a+x);
    sort(b,b+y);
    sort(c,c+z,greater<ll>());

    vector<ll> ab(x*y);
    for(ll i=0;i<x;i++)for(ll j=0;j<y;j++)ab[i*y+j]=a[i]+b[j];
    sort(ab.rbegin(),ab.rend());

    ll len = min(k,x*y);
    vector<ll> abc(len*z);

    for(ll i=0;i<len;i++)for(ll j=0;j<z;j++)abc[i*z+j]=ab[i]+c[j];

    sort(abc.rbegin(),abc.rend());
    for(ll i=0;i<k;i++)cout<<abc[i]<<"\n";

}





Measured memory_bytes: 31616
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define black_tree tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pair_black_tree tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update>
#define gp __gnu_pbds
#define INF 1000000000
#define MOD 1000000007
#define MAX 1000000
#define endl '\n'
#define ll long long
#define ld long double
#define lli long long int
#define ull unsigned long long
#define ulli unsigned long long int
#define pb push_back
#define pf push_front
#define ook order_of_key
#define fbo find_by_order
#define np next_permutation
#define mp make_pair
#define eb emplace_back
#define mae max_element
#define mie min_element
#define lb lower_bound 
#define ub upper_bound
#define bs binary_search
#define ff first
#define ss second
using namespace std;
using namespace gp;
ll n,ans;
ll check(ll n){
	ll ans=1,cnt;
	for(int i=2;i<=sqrt(n);i++){
		cnt=1;
		while(n%i==0){
			n/=i;
			cnt++;
		}
		ans*=cnt;
	}
	if(n>1){
		ans*=2;
	}
	return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<n;i++){
    	ans+=check(i);
	}
	cout<<ans;
}

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

#define rep(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int N, M;
vector<int> k, p;
vector<vector<int>> s;
int ans=0;

void dfs(vector<int> v) {
  if(v.size()==N) {
    bool flag=true;
    rep(i,0,M) {
      int sum=0;
      rep(j,0,k[i]) sum+=v[s[i][j]];
      if(sum%2!=p[i]) flag=false;
    }
    if(flag) ans++;
    return;
  }
  v.push_back(0);
  dfs(v);
  v.pop_back();
  v.push_back(1);
  dfs(v);
}

int main() {
  cin >> N >> M;
  k=vector<int>(M); p=vector<int>(M);
  s=vector<vector<int>>(M);
  rep(i,0,M) {
    cin >> k[i];
    rep(j,0,k[i]) {
      int a;
      cin >> a;
      s[i].push_back(--a);
    }
  }
  rep(i,0,M) cin >> p[i];
  vector<int> v;
  dfs(v);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define LIM 1000000000000000000

int main(){
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    
    if (k%2==0){
        if(a-b>LIM){
            printf("%d\n", LIM);
        }else{
            printf("%d\n", a-b);
        }
    }else{
        if (b-a>LIM){
            printf("%d\n", LIM);
        }else{
            printf("%d\n", b-a);
        }
    }
    
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
        
    Scanner scan = new Scanner(System.in);
    int[] a = new int[5];
    
    for( int i=0; i<5 ; i++){
       a[i] = scan.nextInt(); 
    }
    if(a[2] >= 0 && a[3] >= 0){
        if (((a[2] + a[4]) <= a[0]) && ((a[2] - a[4]) >= 0)){
            if ((a[3] + a[4]) <= a[1] && ((a[3] - a[4]) >= 0)){
                System.out.println("Yes");
            }
            else System.out.println("No");
        }
        else System.out.println("No");
    }
    else System.out.println("No");
    
    
    }
}

Measured memory_bytes: 26264
<?php 
fscanf(STDIN, "%s", $s);
$arr = str_split($s);
$flag = 0;
for ($i=0; $i < strlen($s); $i=$i+2) {
  if($arr[$i] == "L"){
    echo "No";
    $flag = 1;
    break;
  }
}
if($flag == 0){
  for ($j=1; $j < strlen($s); $j=$j+2) {
    if($arr[$j] == "R"){
      echo "No";
      $flag = 1;
      break;
    }
  }
}
if($flag == 0){echo "Yes";}
?>

Measured memory_bytes: 3576
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
t = ns()

if s == t[:len(t) - 1] and len(t) - len(s) == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9120
#include<iostream>
#include<vector>
int main(){
	int a, b;
	std::cin >> a >> b;
	if (a < 10 && b < 10) {
		std::cout << a * b << std::endl;
	}
	else {
		std::cout << -1 << std::endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    map<string, int> cnt;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    vector<string> all = {"AC","WA","TLE","RE"};
    for (auto s: all) {
        cout << s << " x " << cnt[s] << endl;
    }
}


Measured memory_bytes: 3624
// 東京海上日動プログラミングコンテスト2020-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

vector<int> cur(200010);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    // int n=200000,k=200000;
    // rep(i,n){
    //     cur[i]=0;
    // }
    int n,k;
    cin>>n>>k;
    rep(i,n){
        cin>>cur[i];
    }
    //int count=0;
    rep(i,k){
        //count++;
        vector<int> imos(n+1,0);
        rep(j,n){
            int l=max(0,j-cur[j]);
            int r=min(n,j+cur[j]+1);
            imos[l]++,imos[r]--;
        }
        bool flag=true; //全部Nだったら終わり
        cur[0]=imos[0];
        if(cur[0]!=n) flag=false;
        for(int j=1;j<=n-1;j++){
            imos[j]+=imos[j-1];
            cur[j]=imos[j];
            if(cur[j]!=n) flag=false;
        }
        if(flag) break;
    }
    //cout<<count<<endl;
    rep(i,n) cout<<cur[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 4888
T = input()
N = len(T)
mod = 10**9 + 7

def func(X, Y):
    if Y == 0:
        return X
    else:
        return ((3* X + Y) * pow(3, Y - 1, mod)) % mod

A_left = 0
q_left = 0
q_right = T[1:].count('?')
C_right = T[1:].count('C')
ans = 0
for i in range(1, N-1, 1):
    if T[i-1] == 'A':
        A_left += 1
    if T[i-1] =='?':
        q_left += 1
    if T[i] == '?':
        q_right -= 1
    if T[i] == 'C':
        C_right -= 1
    if T[i] == 'B' or T[i] == '?':
        ans += func(A_left, q_left) * func(C_right, q_right)
        ans %= mod
print(ans)


Measured memory_bytes: 3188