akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
ll m;
int a[125252];
ll sum[125252];

int main(){
    scanf("%d%lld",&n,&m);
    REP(i,n)scanf("%d",a+i);
    sort(a,a+n);
    int ok = 0, ng = 1<<30;
    while(abs(ok-ng)>1){
        int x = (ok+ng)/2;
        ll cnt = 0;
        REP(i,n){
            cnt += (a+n)-lower_bound(a,a+n,x-a[i]);
        }
        (cnt>=m ? ok : ng) = x;
    }
    REP(i,n)sum[i+1] = sum[i]+a[i];
    ll rest = m;
    int th = ok;
    ll ans = 0;
    REP(i,n){
        int it = upper_bound(a,a+n,th-a[i])-a;
        ans += sum[n] - sum[it];
        ans += 1ll * (n-it) * a[i];
        rest -= n-it;
    }
    // DEBUG(ans);
    // DEBUG(th);
    // DEBUG(rest);
    ans += rest * th;
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int i;
  bool correct = true;
  int countc = 0;
  if(s.at(0) != 'A') correct = false;
  for(i = 1; i < s.length(); i++)
  {
    if(i >= 2 && i < s.length()-1 && s.at(i) == 'C') countc++;
    else if(s.at(i) < 'a' || s.at(i) > 'z') correct = false;
  }
  if(countc != 1) correct = false;
  if(correct) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
from fractions import gcd
def lcm(a,b):
  return (a*b)//gcd(a,b)

def main():
  n=int(input())
  t=[int(input()) for _ in range(n)]
  ans=t[0]
  for i in range(1,n):
    ans=lcm(ans,t[i])
  print(ans)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 5472
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  cin>>n;
  while(n--){
    string s,t;
    cin>>s>>t;
    int tmp=0;

    REP(i,s.size()){
      if(0<s[i]-'0'&&s[i]-'0'<10){
        if(s[i+1]=='m'){
          tmp+=(s[i]-'0')*1000;
          i++;
        }else if(s[i+1]=='c'){
          tmp+=(s[i]-'0')*100;
          i++;
        }else if(s[i+1]=='x'){
          tmp+=(s[i]-'0')*10;
          i++;
        }else if(s[i+1]=='i'){
          tmp+=(s[i]-'0');
          i++;
        }
      }else if(s[i]=='m')tmp+=1000;
      else if(s[i]=='c')tmp+=100;
      else if(s[i]=='x')tmp+=10;
      else if(s[i]=='i')tmp+=1;
    }
    REP(i,t.size()){
      if(0<t[i]-'0'&&t[i]-'0'<10){
        if(t[i+1]=='m'){
          tmp+=(t[i]-'0')*1000;
          i++;
        }else if(t[i+1]=='c'){
          tmp+=(t[i]-'0')*100;
          i++;
        }else if(t[i+1]=='x'){
          tmp+=(t[i]-'0')*10;
          i++;
        }else if(t[i+1]=='i'){
          tmp+=(t[i]-'0');
          i++;
        }
      }else if(t[i]=='m')tmp+=1000;
      else if(t[i]=='c')tmp+=100;
      else if(t[i]=='x')tmp+=10;
      else if(t[i]=='i')tmp+=1;
    }
    //cout<<tmp<<endl;
    if(tmp/1000>0){
      if(tmp/1000==1)cout<<'m';
      else cout<<tmp/1000<<'m';
    }
    tmp-=(tmp/1000)*1000;
    if(tmp/100>0){
      if(tmp/100==1)cout<<'c';
      else cout<<tmp/100<<'c';
    }
    tmp-=(tmp/100)*100;
    if(tmp/10>0){
      if(tmp/10==1)cout<<'x';
      else cout<<tmp/10<<'x';
    }
    tmp-=(tmp/10)*10;
    if(tmp>0){
      if(tmp==1)cout<<'i';
      else cout<<tmp<<'i';
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.text.BreakIterator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{

	static int[] dx = new int[] { -1, 0, 1, 0, -1, -1, 1, 1 };
	static int[] dy = new int[] { 0, 1, 0, -1, -1, 1, -1, 1 };
	static int A, B, C;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());
		int[] arr = new int[3];
		arr[0] = a;
		arr[1] = b;
		arr[2] = c;
		String[] str = new String[n];
		for (int i = 0; i < str.length; i++) {
			str[i] = br.readLine();
		}
		boolean f = true;
		int[] ans = new int[n];
		for (int i = 0; i < n; i++) {
			String s = str[i];
			int id1 = s.charAt(0) - 'A';
			int id2 = s.charAt(1) - 'A';
			if (arr[id1] == 0 && arr[id2] == 0) {
				f = false;
			} else if (arr[id1] == 1 && arr[id2] == 1 && i != n - 1) {
				String t = str[i + 1];
				int x = t.charAt(0) - 'A';
				int y = t.charAt(1) - 'A';
				if (id1 == x || id1 == y) {
					arr[id1]++;
					arr[id2]--;
					ans[i] = id1;
				} else {
					arr[id1]--;
					arr[id2]++;
					ans[i] = id2;
				}
			} else if (arr[id1] > arr[id2]) {
				arr[id1]--;
				arr[id2]++;
				ans[i] = id2;
			} else {
				arr[id1]++;
				arr[id2]--;
				ans[i] = id1;
			}
		}
		if (f) {
			pw.println("Yes");
			for (int i = 0; i < ans.length; i++) {
				pw.println((char) ('A' + ans[i]));
			}
		} else
			pw.println("No");
		pw.flush();
	}

}


Measured memory_bytes: 42648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define eb emplace_back
using ll=long long;
using vi=vector<ll>;
using vvi=vector<vi>;
const ll inf=1001001001001001;
const int INF=1001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}

void solve() {
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> s(h);
  rep(i,h) cin>>s[i];
  vvi v(h,vi(w,0));
  rep(i,h)rep(j,w) v[i][j]=s[i][j]-'0';
  int ans=INF;
  rep(tmp,1<<ll(h-1)){
    bitset<9> s(tmp);
    vi t;
    rep(i,h-1) if(s.test(i)) t.eb(i);
    t.eb(h-1);
    ll p=t.size();
    bool f=false;
    vvi sum(p,vi(w));
    rep(j,w){
      ll q=0;
      rep(r,p){
        ll d=0;
        REP(i,q,t[r]+1) d+=v[i][j];
        sum[r][j]=d;
        if(d>k) f=true;
        q=t[r]+1;
      }
    }
    if(f) continue;
    int cnt=p-1;
    vi a(p,0);
    rep(j,w){
      bool g=true;
      rep(i,p) if(sum[i][j]+a[i]>k) g=false;
      if(g) rep(i,p) a[i]+=sum[i][j];
      else{
        cnt++;
        rep(i,p) a[i]=sum[i][j];
      }
    }
    chmin(ans,cnt);
  }
  out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

void solve(){

    int n;
	cin >> n;
	vi t(n);
	ll sum = 0;
	fr(0,n) {
	    cin >> t[i];
	    sum+=t[i];}
	int m ;
	cin >> m;
	fr(0,m){
        ll temp = sum;
        int p , x;
        cin >> p >> x;
        temp = temp - t[p-1] + x;
        cout << temp;line
	}

    return;

}

int main(){
    fast
    int tc=1;
    //cin >> tc;
    while(tc--){
             solve();
    }

    R 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get() {}template<class H, class...T>void get(H&h, T&...t) { cin >> h; get(t...); }
template<class T>void geti(T&a) { for (auto&_ : a)cin >> _; }
template<class T>void getii(T&a) { for (auto&_ : a)geti(_); }
void put(string d) {}template<class H, class...T>void put(string d, H&h, T&...t) { cout << h; if (sizeof...(t))cout << d; put(d, t...); }
template<class T>void puti(T&a, string d = " ") { bool f = 1; for (auto&_ : a)cout << (exchange(f, 0) ? "" : d) << _; cout << endl; }
template<class T>void putii(T&a, string d = " ") { for (auto&_ : a)puti(_, d); }
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

int main() {
    int d, n, b;
    while (cin >> d >> n >> b) {
        vi vp(n);
        vi vh(n);
        rep(i, n) {
            cin >> vp[i] >> vh[i];
        }
        double ans = INF;
        for (int i = b; i >= 0; i--) {
            double l = (double)d / (i + 1);
            rep(j, n) {
                double x = fmod(vp[j], l);
                double y = vh[j];
                double vx = sqrt((x / (2 * y))*(l - x));
                double vy = l / (2 * vx);
                double v = hypot(vx, vy);
                bool flag = true;
                rep(k, n) {
                    double x2 = fmod(vp[k], l);
                    double y2 = vh[k];
                    double yy = -(1 / (2 * vx*vx))*x2*x2 + (vy / vx)*x2;
                    
                    if (y2 > yy && abs(y2-yy)>EPS) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    ans = min(ans, v);
                }
            }
            double vx = sqrt(l / 2);
            bool flag = true;
            rep(k, n) {
                double x2 = fmod(vp[k], l);
                double y2 = vh[k];
                double yy = -(1 / (2 * vx*vx))*x2*x2 + (vx / vx)*x2;

                if (y2 > yy && abs(y2 - yy)>EPS) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                ans = min(ans, vx*sqrt(2));
            }
        }
        printf("%.5lf\n", ans);
    }
    
}



Measured memory_bytes: 3272
// https://beta.atcoder.jp/contests/abc110/submissions/3257147

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

using ll = long long;

// ll mod = static_cast<ll>(10e9 + 7);
//
// ll mul(ll a, ll b) {
//     return ((a % mod) * (b % mod)) % mod;
// }
//
// ll power(ll x, ll y) {
//     if (y == 0) {
//         return 1;
//     } else if (y == 1) {
//         return x % mod;
//     } else if (y % 2 == 0) {
//         return static_cast<ll>(pow(power(x, y / 2), 2)) % mod;
//     } else {
//         return static_cast<ll>(pow(power(x, y / 2), 2)) * x % mod;
//     }
// }
//
//
// ll _div(ll a, ll b) {
//     return mul(a, power(b, mod - 2));
// }

const int MAX = 510000;
const ll MOD = 1000000007;

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() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    map <ll, ll> m;
    for (int i = 2; i * i <= M; ++i) {
        while (M % i == 0) {
            M /= i;
            m[i]++;
        }
    }
    if (M != 1) m[M] = 1;

    ll comb = 1;
    COMinit();
    for (auto &e: m) {
        int k = static_cast<int>(e.second);
        comb *= COM(N + k - 1, k);
        comb %= MOD;
    }

    cout << comb << endl;

    return 0;
}


Measured memory_bytes: 12160
import java.util.*;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String x = sc.next();
      char []a = x.toCharArray();
      if(Character.isUpperCase(a[0])){
        System.out.println("A");
      }
      else{
        System.out.println("a");
    
      }
      
      
      
      

     
    }
   
    
       
    
}

Measured memory_bytes: 26696
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll pow(ll x, ll ntimes) {
    ll ret = 1;
    while (ntimes > 0) {
        if ((ntimes & 1) == 1) {
            ret = ret * x;
        }
        x = x * x;
        ntimes >>= 1;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    ll ans = 0;
    while(y>=x){
        ans++;
        x*=2;
    }
    cout << ans << endl;
    return 0;
}

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

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int l,r,d;
    cin >> l >> r >> d;
    int c=0;
    for(int i=l;i<=r;i++) {
        if(i%d==0)
        c++;
    }
    
    cout << c << endl;
    
    
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int h, w, n;
	boolean[][] map;
	
	void run() {
		Scanner sc = new Scanner(System.in);
			h = sc.nextInt(); w = sc.nextInt(); n = sc.nextInt();
			
			map = new boolean[h+2][w+2];
			int[] sx = new int[n+1], sy = new int[n+1];
			for(int i=1;i<=h;i++) {
				String l = sc.next();
				for(int j=1;j<=w;j++) {
					switch (l.charAt(j-1)) {
					case 'X':
						map[i][j] = false;
						break;
					case '.':
						map[i][j] = true;
						break;
					case 'S':
						sx[0] = j; sy[0] = i;
						map[i][j] = true;
						break;
					default:
						sx[l.charAt(j-1)-'0'] = j;
						sy[l.charAt(j-1)-'0'] = i;
						map[i][j] = true;
						break;
					}
				}
			}
			
			int d = 0;
			for(int i=0;i<n;i++) {
				d += bfs(sx[i], sy[i], sx[i+1], sy[i+1]);
			}
			System.out.println(d);
	}
	
	int[] dx = {-1,0,1,0}, dy = {0,-1,0,1};
	int bfs(int sx, int sy, int gx, int gy) {
		boolean[][] vis = new boolean[h+2][w+2];
		
		LinkedList<Integer> qx = new LinkedList<Integer>(), qy = new LinkedList<Integer>(), qt = new LinkedList<Integer>();
		qx.addLast(sx); qy.addLast(sy); qt.addLast(0);
		vis[sy][sx] = true;
		for(;;) {
			int nx = qx.removeFirst(), ny = qy.removeFirst(), nc = qt.removeFirst();
			if(nx == gx && ny == gy) return nc;
			
			for(int i=0;i<4;i++) if(map[ny+dy[i]][nx+dx[i]]&&!vis[ny+dy[i]][nx+dx[i]]) {
				vis[ny+dy[i]][nx+dx[i]] = true;
				qx.addLast(nx+dx[i]); qy.addLast(ny+dy[i]); qt.addLast(nc+1);
			}
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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


int solve(vector<int> &A, vector<int> &B, vector<int> &C, vector<vector<int> > &dp){

  for(int i=0; i<dp.size(); i++){
    for(int j=0; j<3; j++){
        // first day
        if(i == 0){
          if(j == 0) dp[i][j] = A[i];
          else if(j == 1) dp[i][j] = B[i];
          else dp[i][j] = C[i];
        }
        else{

          for(int k=0; k<3; k++){
            if(j == k) continue;
            if(j == 0) dp[i][j] = max(dp[i][j], dp[i-1][k] + A[i]);
            else if(j == 1) dp[i][j] = max(dp[i][j], dp[i-1][k] + B[i]);
            else dp[i][j] = max(dp[i][j], dp[i-1][k] + C[i]);
          }
        }
    }
  }

  int ret = 0;
  ret = max(ret, max(dp[A.size()-1][0], max(dp[A.size()-1][1], dp[A.size()-1][2])));

  return ret;
} 


int main(){

  int n;
  cin >> n;


  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n);
  for(int i=0; i<n; i++){
    cin >> A[i] >> B[i] >> C[i];
  }

  vector<vector<int> > dp(A.size(), vector<int> (3, -1));
  cout << solve(A, B, C, dp) << endl;
  return 0;
}


/*

7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1

46
*/

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b >= c ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    ArrayList<String[]> c = new ArrayList<>();
    for (int i = 0; i < h; i++) {
      c.add(sc.next().split(""));
    }
    int result = 0;
    int hb = (int) Math.pow(2, h);
    int wb = (int) Math.pow(2, w);
    for (int i = 0; i < hb; i++) {
      String hTmp = "000000" + Integer.toString(i, 2);
      String hSt = hTmp.substring(hTmp.length() - h);
      ArrayList<String[]> selectedRows = new ArrayList<>();
      for (int hi = 0; hi < h; hi++) {
        if (hSt.charAt(hi) == '1') {
          selectedRows.add(c.get(hi));
        }
      }
      for (int j = 0; j < wb; j++) {
        String wTmp = "000000" + Integer.toString(j, 2);
        String wSt = wTmp.substring(wTmp.length() - w);
        ArrayList<Integer> selectedIndex = new ArrayList<>();
        for (int wi = 0; wi < w; wi++) {
          if (wSt.charAt(wi) == '1') {
            selectedIndex.add(wi);
          }
        }
        int count = 0;
        for (String[] strings : selectedRows) {
          for (int wi : selectedIndex) {
            if ("#".equals(strings[wi])) {
              count++;
            }
          }
        }
        if (count == k) {
          result++;
        }
      }
    }
    System.out.println(result);
  }
}


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

const int MOD = 1000000007;
const int N = 305;
typedef pair<int, int> Pairs;

inline char get(void) {
	static char buf[100000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
template<typename T>
inline void read(T &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int n, m, x, y, z, w, ans;
vector<Pairs> v[N];
int dp[N][N][N];
int ban[N][N][N];

inline void Add(int &x, int a) {
	x = (x + a) % MOD;
}
inline void Update(int r, int g, int b, int w) {
	if (ban[r][g][b]) return;
	Add(dp[r][g][b], w);
}
inline void Check(int r, int g, int b) {
	int k = max(r, max(g, b));
	ban[r][g][b] = 0;
	for (auto x: v[k])
		if ((r >= x.first) + (g >= x.first) + (b >= x.first) != x.second)
			return (void)(ban[r][g][b] = 1);
}

int main(void) {
	read(n); read(m);
	for (int i = 0; i < m; i++) {
		read(x); read(y); read(z);
		v[y].push_back(Pairs(x, z));
	}
	for (int r = 0; r <= n; r++)
		for (int g = 0; g <= n; g++)
			for (int b = 0; b <= n; b++)
				Check(r, g, b);
	dp[0][0][0] = 1;
	for (int r = 0; r <= n; r++)
		for (int g = 0; g <= n; g++)
			for (int b = 0; b <= n; b++)
				if (w = dp[r][g][b]) {
					int k = max(r, max(g, b));
					Update(k + 1, g, b, w);
					Update(r, k + 1, b, w);
					Update(r, g, k + 1, w);
					if (k == n) Add(ans, w);
				}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 221440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
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

const int MAX_N = 100050;
int n, k;
int x[MAX_N];
int y[MAX_N];
vector<vl> B;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> k;
	B = vector<vl>(2*k, vl(2*k));
	rep(i,0,n) {
		char c;
		cin >> x[i] >> y[i] >> c;
		if(c == 'W') {
			y[i] += k;
		}
		x[i] %= 2*k;
		y[i] %= 2*k;
		B[y[i]][x[i]]++;
	}

	rep(i,0,2*k) {
		B[i].insert(B[i].end(), all(B[i]));
	}
	rep(i,0,2*k) {
		B.pb(B[i]);
	}

	/*rep(i,0,4*k) {
		rep(j,0,4*k) {
			cout << B[i][j] << ' ';
		}
		cout << '\n';
	}*/

	vector<vl> P(4*k+1, vl(4*k+1));
	rep(i,1,4*k+1) rep(j,1,4*k+1) {
		P[i][j] = B[i-1][j-1];
	}

	rep(i,1,4*k+1) {
		rep(j,1,4*k+1) {
			P[i][j] += P[i][j-1];
		}
	}

	rep(j,1,4*k+1) {
		rep(i,1,4*k+1) {
			P[i][j] += P[i-1][j];
		}
	}

	/*rep(i,0,4*k) {
		rep(j,0,4*k) {
			cout << P[i+1][j+1] << ' ';
		}
		cout << '\n';
	}*/

	ll ret = 0;
	rep(i,1,2*k) rep(j,1,2*k) {
		ll A = P[i+k-1][j+k-1] - P[i-1][j+k-1] - P[i+k-1][j-1] + P[i-1][j-1];
		ll B = P[i+2*k-1][j+2*k-1] - P[i+k-1][j+2*k-1] - P[i+2*k-1][j+k-1] + P[i+k-1][j+k-1];
		ret = max(ret, A+B);
	}
 
	cout << ret << '\n';
	return 0;
}


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

int main(){
    int N, subTotA=0, subTotB=0, res = 100000;
    cin >> N;
    vector<int> W(N);
    for(int i=0; i<N; i++){
        cin >> W.at(i);
    }

    //process
    for(int j=0; j<N-1; j++){
        subTotA = 0;
        subTotB = 0;
        for(int k=0; k<=j; k++){
            subTotA += W.at(k);
        }
        for(int l=j+1; l<N; l++){
            subTotB += W.at(l);
        }

        if(abs(subTotA-subTotB)<res){
            res = abs(subTotA - subTotB);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n,k;
    bool have[105]={};//false:dont have, true:have
    cin>>n>>k;
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int t;
            cin>>t;
            have[t]=true;
        }
    }
    int count=0;
    for(int i=1;i<=n;i++){
        if(!have[i])count++;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3636
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<char>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>s1>>s2;
    cout<<s2+s1<<endl;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string s;
  cin >> s;
  fi(0, 10)
    fj(0, 10)
    fk(0, 10) {
      char arr[] = { (char)('0' + i), (char)('0' + j), (char)('0' + k) };
      int now = 0;
      for(char c: s) {
        if(c == arr[now]) {
          now++;
          if(now == 3) {
            ans++;
            break;
          }
        }
      }
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  programs
//
//  Created by Arunesh Sarker on 18/11/19.
//  Copyright © 2019 Arunesh Sarker. All rights reserved.
//

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
int fl=0;
string changes(string s)
{
    fl=(int)(s[0]-48);
    string ret=(char)(++fl%10 + 48)+s.substr(1,3);
    return ret;
    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll i=0;ll j=s.size()-1;
    int count=0;
    while(i<j)
    {
        if(s[i]!=s[j])
            count++;
        i++;j--;
    }
    cout<<count<<"\n";
}


Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct inn{
	int n,c,r;
	inn(int n,int c,int r):n(n),c(c),r(r){}
	bool operator<(const inn& other)const{
		return r>other.r;
	}
};
const int MAX=INT_MAX/10;
int main(){
	int n,m,l;
	while(cin>>n>>m>>l,n){
		vvi dist(n,vi(n,-1));
		vvi risk(n,vi(n,MAX));
		REP(i,m){
			int a,b,d,e;
			cin>>a>>b>>d>>e;
			dist[a-1][b-1]=d;
			dist[b-1][a-1]=d;
			risk[a-1][b-1]=e;
			risk[b-1][a-1]=e;
		}
		
		priority_queue<inn> q;
		q.push(inn(0,0,0));
		vvi cost(n,vi(l+1,MAX));
		cost[0][0]=0;
		while(!q.empty()){
			inn in=q.top();q.pop();
			if(cost[in.n][in.c]<in.r){
				continue;
			}
			REP(i,n){
				if(i!=in.n&&dist[in.n][i]!=-1){
					REP(j,2){
						int nr=in.r+(j==1?0:risk[in.n][i]);
						int nc=in.c+(j==0?0:dist[in.n][i]);
						if(nc<=l&&cost[i][nc]>nr){
							cost[i][nc]=nr;
							q.push(inn(i,nc,nr));
						}
					}
				}
			}
		}
		int best=INT_MAX;
		REP(i,l+1){
			best=min(best,cost[n-1][i]);
		}
		cout<<best<<endl;
	}
}

Measured memory_bytes: 1648
import sys
input=sys.stdin.readline #文字列入力はするな！！
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]*=-1
heapq.heapify(a)
for i in range(m):
    h=-heapq.heappop(a)
    h=h//2
    heapq.heappush(a,-h)
print(-sum(a))



Measured memory_bytes: 86160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,k,l,o,p;
    cin>>n>>m>>k;
    vector<ll> a,b;
    a.push_back(0);
    b.push_back(0);
    for(ll i=1;i<=n;i++)
    {
        ll x,y;
        cin>>x;
        y=x+a[i-1];
        a.push_back(y);
    }
    for(ll i=1;i<=m;i++)
    {
        ll x,y;
        cin>>x;
        y=x+b[i-1];
        b.push_back(y);
    }
    ll ans=0;
    for(ll i=0;i<=n;i++)
    {
        for(ll j=m;j>=0;j--){
            if(a[i]+b[j]<=k){
              	m = j;
                ans=max(i+j, ans) ;
                break;
            }
        }
    }

    cout<<ans;
}


Measured memory_bytes: 7992
def solve(string):
    n, *a = map(int, string.split())
    m1, m2 = sorted(a)[-2:]
    index = a.index(m2)
    return "\n".join(map(str, [m1 if i == index else m2 for i in range(n)]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 26596
from string import ascii_lowercase
from itertools import accumulate


def solve(string):
    n = int(string)
    t = [0] + [len(ascii_lowercase)**i for i in range(1, 12)]
    *t, = accumulate(t)
    l = 0
    ans = ""
    while t[l] < n:
        l += 1
    n -= t[l - 1] + 1
    for i in range(l - 1):
        j, n = divmod(n, len(ascii_lowercase)**(l - i - 1))
        ans += ascii_lowercase[j]
    ans += ascii_lowercase[n]
    return ans


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9904
#include <stdio.h>
int main(void){
    int num=0,i,score=0,ans=0,n;
    while(1){
        scanf("%d",&num);
        if(num==0) break;
        n = num/4;
        for(i=0;i<n;i++){
            scanf("%d",&ans);
            score += ans;
        }
        printf("%d\n",score);
        score =0;
    }
    
}



Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
const int N=3010;
string s,t;
int f[N][N];
pair<int,int> g[N][N];
vector<int> ans;
int main()
{
    cin>>s>>t;
    int m=s.size();s=" "+s;
    int n=t.size();t=" "+t;
    for(int i=1;i<=m;++i) for(int j=1;j<=n;++j)
    {
        if(s[i]==t[j])
        {
            f[i][j]=f[i-1][j-1]+1;
            g[i][j]={i-1,j-1};
        }
        else 
        {
            if(f[i-1][j]>f[i][j-1])
            {
                f[i][j]=f[i-1][j];
                g[i][j]={i-1,j};
            }
            else 
            {
                f[i][j]=f[i][j-1];
                g[i][j]={i,j-1};
            }
        }
    }
    int x=m,y=n;
    int u,v;
    while(x || y)
    {
        if(s[x]==t[y]) ans.push_back(x);
        tie(u,v)=g[x][y];
        x=u;y=v;
    }
    reverse(ans.begin(),ans.end());
    for(auto i:ans) cout<<s[i];
}

Measured memory_bytes: 106368
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<cctype>
#include<string>
#include<bitset>
#include<vector>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<set>
#include<map>
#define INF 1000000000
#define ll long long
#define mod 10007
#define pb push_back
using namespace std;
char *fs,*ft,buf[1<<15];
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=200010;
int a[MAXN],sum[MAXN];
int ans,cnt;
int n,k;
int main()
{
	//freopen("1.in","r",stdin);
	n=read();k=read();
	for(int i=1;i<=n;++i)a[i]=read()+1;
	for(int i=1;i<=n;++i)
	{
		cnt+=a[i];
		if(i>=k)ans=max(ans,cnt);
		cnt-=a[i-k+1];
	}
	printf("%.7lf\n",ans*1.0/2);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string taro, hanako;
    int taro_score = 0, hanako_score = 0;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> taro >> hanako;
        if (taro > hanako) {
            taro_score += 3;
        } else if (taro < hanako) {
            hanako_score += 3;
        } else {
            taro_score ++;
            hanako_score ++;
        }
    }
    cout << taro_score << ' ' << hanako_score << endl;

    return 0;
}


Measured memory_bytes: 3140
#include<iostream>
#include<cstdio>
#define ll long long
#define maxn 400040
using namespace std;
const int mo=1000000007;

int n,a[maxn],b[maxn],c[maxn];
ll f[4040][4040],ans,p[maxn];

inline int ksm(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=(ll)ans*x%mo;
		x=(ll)x*x%mo;
		y>>=1;
	}
	return ans;
}

int main()
{
	scanf("%d",&n); int m=0;

	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		m=max(m,max(a[i],b[i]));
	}
	for(int i=1;i<=n;i++)f[m+a[i]][m+b[i]]++;

	c[0]=p[0]=1;
	for(int i=1;i<=m*4;i++) c[i]=(ll)c[i-1]*i%mo,p[i]=ksm(c[i],mo-2)%mo;

	for(int i=m*2;i>=0;i--)
		for(int j=m*2;j>=0;j--)
			f[i][j]=(f[i][j]+f[i+1][j]+f[i][j+1])%mo;

	for(int i=1;i<=n;i++) ans=(ans+f[m-a[i]][m-b[i]])%mo;
	for(int i=1;i<=n;i++) ans=(ans-(ll)c[a[i]*2+b[i]*2]*p[a[i]*2]%mo*p[b[i]*2])%mo;

	ans=(ans*ksm(2,mo-2))%mo;

	printf("%lld\n",(ans+mo)%mo);
}

Measured memory_bytes: 133376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string s;
  cin >> s;
  Yes_No((s[0] == s[1] && s[1] == s[2]) or (s[1] == s[2] && s[2] == s[3]));
}
int main(void) { solve(); }


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

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

    vector<int> num(n);
    for(int i = 0; i < n; i++){
        cin >> num[i];
    }
    sort(num.begin(), num.end());

    long long int tate, yoko;
    bool flag = true;
    for(int i = n - 1; i > -1 ; i--){
        //cout << num[i] << endl;
        if(num[i] == num[i - 1]){
            if(flag){
                tate = num[i];
                i -= 1;
                flag = false;
            }
            else{
                yoko = num[i];
                cout << tate * yoko << endl;
                return 0;
            }
        }
    }

    cout << "0" << endl;
    return 0;
}

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

    int a,b;cin>>a>>b;
    if(a==b)cout<<2*a<<endl;
    else if(a>b)cout<<2*a-1<<endl;
    else cout<<2*b-1<<endl; 
    return 0;
    
}

Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,a,b;
vector<pair<int,pair<int,int> > > v;
const int inf=999999999;
int dp[41][500][500];
                 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    int e,f,g;cin>>e>>f>>g;
    v.push_back(make_pair(e,make_pair(f,g)));
  }
  for(int i=0;i<41;i++)for(int j=0;j<500;j++)for(int k=0;k<500;k++)dp[i][j][k]=inf;
  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<400;j++){
      for(int k=0;k<400;k++){
        dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
        dp[i+1][j+v[i].fi][k+v[i].se.fi]=min(dp[i+1][j+v[i].fi][k+v[i].se.fi],dp[i][j][k]+v[i].se.se);
      }
    }
  }
  int ans=inf;
  for(int i=1;i<500;i++)for(int j=1;j<500;j++){
    if(i*b==j*a)ans=min(ans,dp[n][i][j]);
  }
  cout<<(ans==inf?-1:ans)<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 40320
#include <cstdio>

int main() {
	int N; scanf("%d", &N);
	long long numOfNodes = 0;
	for (int i = 1; i <= N; i++) {
		numOfNodes += ((long long)i) * (N - i + 1);
	}
	long long numOfEdges = 0;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (a > b) {
			int c = a;
			a = b;
			b = c;
		}
		numOfEdges += ((long long)a) * (N - b + 1);
	}
	printf("%lld", numOfNodes - numOfEdges);
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,x;
	cin >> N >> x;
	if(x==1 || x==(2*N-1)){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if(N==2){
		cout << "1\n2\n3\n";
		return 0;
	}
	vector<int> ans(2*N);
	queue<int> q;
	FOR(i,1,2*N){
		if(abs(x-i)>1)q.push(i);
	}
	FOR(i,1,2*N){
		if(i==N)cout<< x << endl;
		else if(i==N-1)cout << x+1 << endl;
		else if(i==N+1)cout << x-1 << endl;
		else{
			cout << q.front() << endl;
			q.pop();
		}
	}
}

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

int main(){
    ll a,b; cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int MAX = 510000;
const int MOD = 1000000007;
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();
    int N, K; cin >> N >> K;
    vector<vector<int>> G(N);
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    auto recur = [&](auto rec, int node, int parent) -> Int {
        Int ans = 0;
        if (parent == -1) {
            ans = K;
            int t = G[node].size();
            ans = ans * COM(K-1, t) % MOD * fac[t] % MOD;
        } else {
            ans = 1;
            int t = G[node].size() - 1;
            ans = ans * COM(K-2, t) % MOD * fac[t] % MOD;
        }
        for (auto child : G[node]) if (child != parent) {
            ans = ans * rec(rec, child, node) % MOD;
        }
        return ans;
    };
    cout << recur(recur, 0, -1) << endl;
    return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s,t;
set<string>st;
int dp[4444][4444];
int main(){
	while(cin>>s>>t){
		s="@"+s;
		t="@"+t;
		int ans=0;
		memset(dp,0,sizeof(dp));
		for(int i=1;i<s.size();i++){
			for(int j=1;j<t.size();j++){
				if(s[i]==t[j])dp[i][j]=dp[i-1][j-1]+1;
				ans=max(ans,dp[i][j]);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 80356
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	ll n;
	cin >> n;
	vector < ll > v(5);
	ll x = LINF;
	for (auto &el: v) {
		cin >> el;
		x = min(x, el);
	}
	ll ans = 0;
	for (int i = 0; i < 5; ++i) {
		ans = max(ans, i + (n + x - 1) / x);
	}
	cout << ans << "\n";
}

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;

int main() {
    int n;
    cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];

    int ans = 0;
    for (int i=0; i<=n-3; i++) {
        if (p[i] < p[i+1] && p[i+1] < p[i+2]) ++ans;
        if (p[i] > p[i+1] && p[i+1] > p[i+2]) ++ans;
    }

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

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

int main(){
 int a,x;
 a = 0;
 x = 1;

 while(x != 0){
 a = a + 1;
 cin >> x;
 if(x == 0) break;
 cout << "Case " << a << ": " << x << endl;
 }  

}


Measured memory_bytes: 3036