akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
int y[101], m[101], d[101];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int ans = 0;
		cin >> y[i] >> m[i] >> d[i];
		if ((y[i] - 1) % 3 == 0) {
			ans += 590 * (y[i] - 1) / 3;
		}
		else if ((y[i] - 1) % 3 == 1) {
			ans += 195;
			ans += 590 * (y[i] - 2) / 3;
		}
		else {
			ans += 590 * y[i] / 3;
			ans -= 200;
		}
		if (y[i] % 3 != 0) {
			if (m[i] % 2 == 0) {
				ans += m[i] * 10 + (m[i] / 2 - 1) * 19;
			}
			else {
				ans += m[i] / 2 * 20 + m[i] / 2 * 19;
			}
		}
		else {
			ans += (m[i] - 1) * 20;
		}
		ans += d[i];
		cout <<196471- ans << endl;
		}
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

long long lunlun(int k,long long temp){
  if(k==1){
    return temp;
  }else{
    string s = to_string(temp);
    if(temp%10-(temp/10)%10==1){
      int i = s.length()-1;
      while((s[i]-'0')-(s[i-1]-'0')==1&&i>0){
        i--;
      }
      s[i]++;
      for(i++;i<s.length();i++){
        s[i] = '0' + max((s[i-1]-'0')-1,0);
      }
      return lunlun(k-1,stoll(s));
    }else if(temp%10==9&&(temp/10)%10==9){ //99で終わるとき
      for(int i=s.length()-1;i>=0;i--){
        if(s[i]!='9'&&(i==0||(s[i]-'0')-(s[i-1]-'0')!=1)){
          s[i]++;
          for(i++;i<s.length();i++){
            s[i] = '0' + max((s[i-1]-'0')-1,0);
          }
          return lunlun(k-1,stoll(s));
        }
      }
    }
    return lunlun(k-1,temp+1);
  }
}

int main(){
  int k;
  cin >> k;
  cout << lunlun(k,1) << endl;
  return 0;
}

Measured memory_bytes: 17408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt() * 1000;
    int a = sc.nextInt() * 1000;
    int[] h = new int[n];
    for(int i = 0;i<n;i++){
      h[i] = sc.nextInt() * 6;
    }
    int[] abs = new int[n];
    int minpoint = -1;
    int min = 2000000000;
    for(int i = 0;i<n;i++){
      abs[i] =t-h[i]-a;
      if(abs[i]<0)abs[i]*=-1;
      if(min > abs[i]){
        min = abs[i];
        minpoint = i;
      }
    }
    System.out.println(minpoint+1);
  }
}


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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
typedef vector<int> vint;
#define fi first
#define se second

ll mod=1e9+7;

int main(){
    faster;

    int h,n;
    cin>>h>>n;

    ll sum=0;
    rep(i,n){
        int x;
        cin>>x;
        sum+=x;
    }

    if(sum>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a1,a2,a3,c;
    scanf("%d %d %d",&a1,&a2,&a3);
    c=a1+a2+a3;
    if (c>=22)
    {printf("bust\n");}
    else {
        printf("win\n");
    }
    
    
    return 0; }


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

using namespace std;

#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005

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


Measured memory_bytes: 256
dance = ["L","R","U","D"]

S = input()

for i in range(len(S)):
	if i%2 == 0 and S[i] == "L":
		print("No")
		exit(0)
	elif i%2 == 1 and S[i] == "R":
		print("No")
		exit(0)
	
print("Yes")


Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main()
{
    string s;
    int n, k;
    cin >> n >> s >> k;
    REP(i,n){
        if(s[i] != s[k-1]) s[i] = '*';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,i,j;
    cin>>n>>k;
  long long h[n];
  for(i=0;i<n;i++)
  {
     cin>>h[i];
  }
  long long vohan=10000000000000;
  long long b[n];
  for (i=0;i<n;i++)
  {
      b[i]=vohan;
  }
  b[0]=0;
  for(i=1;i<n;i++)
  {
      for(j=max(i-k,0);j<i;j++)
        {
			b[i] = min(b[i], b[j] + abs(h[j] - h[i]));
		}

  }
  cout<<b[n-1]<<endl;
}



Measured memory_bytes: 1792
import java.util.*
import java.io.PrintWriter


class P(idx: Int, x: Int) {
    val idx = idx
    val x = x
}

fun calc(l2: Int, l1: Int, r1: Int, r2: Int): Int {
    return (l2 - l1)*r1 + (r2 - r1)*(l1)
}
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val cout = PrintWriter(System.`out`)
    val n = cin.nextInt()
    val m : MutableList<P> = mutableListOf()
    for (i in 0..n-1) {
        m.add(P(i, cin.nextInt()))
    }
    val ms = m.sortedBy { it.x }

    val next = Array<Int>(n, { i -> i + 1 })
    val pre = Array<Int>(n, { i -> i - 1 })

    var ans : Long = 0L

    for (pp in ms) {
        val p = pp.idx
        val l1 = pre[p]
        val r1 = next[p]
        var l2 = pre[p]
        var r2 = next[p]
        if (next[p] < n) {
            r2 = next[next[p]]
            pre[next[p]] = pre[p]
        }
        if (pre[p] >= 0) {
            l2 = pre[pre[p]]
            next[pre[p]] = next[p]
        }
        ans += pp.x.toLong() * calc(p - l2, p - l1, r1 - p, r2 - p).toLong()
        
        
    }
    cout.println(ans)
    
    cout.flush()
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

Measured memory_bytes: 76700
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  map<ll,ll> m;
  sort(a,a+n);
  ll ans=0;
  rrep(i,n) {
    rrep(j,31) {
      ll x=1LL<<j;
      if(x-a[i]>=0&&m.count(x-a[i])&&m[x-a[i]]) {
        m[x-a[i]]--;
        ans++;
        goto next;
      }
    }
    m[a[i]]++;
  next:;
  }
  pr(ans);
}

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


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

using namespace std;

const ll Inf = 1e18;

ll Rec(ll l,ll r,bool Turn);

ll n;
ll a[3030];
ll Sum;

ll Dp[3030][3030][2];

int main()
{
    for(ll l=0;l<3030;l++)
        for(ll r=0;r<3030;r++)
            Dp[l][r][0] = Dp[l][r][1] = -Inf;

    cin>>n;

    for(ll i=0;i<n;i++) scanf("%I64d",a+i) , Sum += a[i];

    cout<<Rec(0,n-1,true);
}

ll Rec(ll l,ll r,bool Turn)
{
    if(l>r) return 0;

    if(Dp[l][r][Turn]+Inf)  return Dp[l][r][Turn];

    if(Turn)    return Dp[l][r][Turn] = max( a[l] + Rec(l+1,r,!Turn) , a[r] + Rec(l,r-1,!Turn) );
    else        return Dp[l][r][Turn] = min(-a[l] + Rec(l+1,r,!Turn) ,-a[r] + Rec(l,r-1,!Turn) );

}


Measured memory_bytes: 143872
from collections import Counter

while True:
    n = int(input())
    if n == 0:
        break
    counter = Counter()
    for _ in [0]*n:
        a, b, c = map(int, input().split())
        counter[a] += b*c
    result = [str(k) for k, v in counter.items() if v >= 1000000] or ["NA"]
    print("\n".join(result))
    


Measured memory_bytes: 6136
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define N 500001

typedef struct tree{
  int key;
  struct tree *parent;
  struct tree *left;
  struct tree *right;
} Tree;

Tree *createtree(int);
void insert(Tree *, int);
void find(Tree *, int);
void inorderwalk(Tree *);
void preorderwalk(Tree *);

Tree *root = NULL;

int main(){

  int m, x[N], i, j;
  char order[N][7];

  scanf("%d", &m);
  for(i = 0; i < m; i++){
    scanf(" %s", order[i]);
    if(order[i][0] != 'p') scanf("%d", &x[i]);
  }

  for(i = 0; i < m; i++){
    if(order[i][0] == 'i'){
      insert(root, x[i]);
    } 
    else if(order[i][0] == 'f'){
      find(root, x[i]);
    }
    else{
      assert(root!=NULL);
      inorderwalk(root);
      printf("\n");
      preorderwalk(root);
      printf("\n");
    }
   
  }

  return 0;
}

void insert(Tree *t, int v){
  Tree *x, *y, *z;
  z =  createtree(v);
  y = NULL;
  x = t;

  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;  
}

void find(Tree *t, int v){
  Tree *x;
  int flag = 0;

  x = t;

 while(x != NULL){
   if(v == x->key){
     flag = 1;
     break;
   }
   if(v < x->key) x = x->left;
   else x = x->right;
  }

 if(flag == 1) printf("yes\n");
 else printf("no\n");
}

void inorderwalk(Tree *x){
  if(x->left != NULL) inorderwalk(x->left);
  printf(" %d",x->key);
  if(x->right != NULL) inorderwalk(x->right);
}

void preorderwalk(Tree *x){
  printf(" %d",x->key);
  if(x->left != NULL) preorderwalk(x->left);
  if(x->right != NULL) preorderwalk(x->right);
}

Tree *createtree(int key){
  Tree *tree = (Tree *)malloc( sizeof(Tree) );
  tree->key = key;
  tree->parent = NULL;
  tree->left = NULL;
  tree->right = NULL;
  return tree;
}

Measured memory_bytes: 24736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
typedef pair<int,int> P;
#define INF 1e9

ll p[4000000];

int main(){
    ll n;
    while(cin>>n){
        if(n==0)break;
        memset(p,0,sizeof(p));
        ll nn = sqrt(2*n);
        p[1]=1;
        for(int i=2;i<=nn;i++){
            if(p[i]!=1){
                for(int j=i+i;j<=2*n;j+=i){
                    p[j]=1;
                }
            }
        }
        ll cnt=0;
        for(int i=n+1;i<=2*n;i++){
            if(p[i]==0){
                cnt++;
                //cout<<"p:"<<i<<endl;
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 34240
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int H[N];

	int max_ = 0;
	int count = 0;
	rep(i, N)
	{
		cin >> H[i];
		if (H[i] >= max_ )
		{
			count++;
		}
		max_ = max(H[i], max_);
	}

	cout << count << endl;

	
	return 0;
}


Measured memory_bytes: 256
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const ll INF = ll(1e18) + 1;
const int MOD = 1000000007;

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

   int n;
   ll k;
   cin >> n >> k;
   vector<ll> a(n);
   rep(i, 0, n) { cin >> a[i]; }
   sort(a.begin(), a.end());
   ll l = -INF, r = INF;
   while (l + 1 < r) {
      ll x = (l + r) / 2;
      bool ok = [&] {
         ll tot = 0;
         rep(i, 0, n) {
            if (a[i] < 0) {
               int l = -1, r = n;
               while (l + 1 < r) {
                  int mid = (l + r) / 2;
                  if (a[mid] * a[i] < x)
                     r = mid;
                  else
                     l = mid;
               }
               tot += n - r;
            } else {
               int l = -1, r = n;
               while (l + 1 < r) {
                  int mid = (l + r) / 2;
                  if (a[mid] * a[i] < x)
                     l = mid;
                  else
                     r = mid;
               }
               tot += r;
            }
            if (a[i] * a[i] < x)
               tot--;
         }
         tot /= 2;
         return tot < k;
      }();
      if (ok)
         l = x;
      else
         r = x;
   }
   cout << l << endl;
   return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int tb = (b-a)*(b-a+1)/2;
    System.out.println(tb-b);
    
  }
  

  
}

Measured memory_bytes: 21844
let input = readLine()!
let splitInput = input.split(separator: " ")
var x = Int(splitInput[0])!
var y = Int(splitInput[1])!
var z = Int(splitInput[2])!

var tempX = x
x = y
y = tempX

tempX = x
x = z
z = tempX

print(x, y, z)

Measured memory_bytes: 8228
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define rep(a,b,c) for(ll a=b;a<=c;a++)
#define per(a,b,c) for(ll a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 1e3 + 5;
const int M = 2e5 + 5;

int n;

int judge(int x){
    int cnt = 0;
    while(x > 0){
        cnt++;
        x/=10;
    }
    return cnt;
}

int main(){
    cin >> n;
    int ans = 0;
    rep(i,1,n){
        //printf("%d %d\n",i,judge(i));
        if(judge(i) % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define MAX 10000
#define NIL - 1

struct Node
{
	int parent;
	int left;
	int right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d)
{
	if (u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u)
{
	int h1 = 0, h2 = 0;
	if (T[u].left != NIL)
	{
		h1 = setHeight(T[u].left) + 1;
	}
	if (T[u].right != NIL)
	{
		h2 = setHeight(T[u].right) + 1;
	}
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u)
{
	if (T[u].parent == NIL) return NIL;
	if ( (T[T[u].parent].left != u) && (T[T[u].parent].left != NIL) ) return T[T[u].parent].left;
	if ((T[T[u].parent].right != u) && (T[T[u].parent].right != NIL)) return T[T[u].parent].right;
	return NIL;
}

void print(int u)
{
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if (T[u].left != NIL) deg++;
	if (T[u].right != NIL) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if (T[u].parent == NIL)
	{
		printf("root\n");
	}
	else if (T[u].left == NIL && T[u].right == NIL)
	{
		printf("leaf\n");
	}
	else
	{
		printf("internal node\n");
	}
}

int main()
{
	int v, l, r, root = 0;
	scanf("%d", &n);

	for (int i = 0; i < n; i++) T[i].parent = NIL;

	for (int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (l != NIL) T[l].parent = v;
		if (r != NIL) T[r].parent = v;
	}

	for (int i = 0; i < n; i++)
	{
		if (T[i].parent == NIL) root = i;
	}
	setDepth(root, 0);
	setHeight(root);

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


Measured memory_bytes: 2724
import java.lang.Math

val MOD: Int = 1000000000 + 7
val MODL: Long = MOD.toLong()

fun main(args: Array<String>)
{
    val n = read().toInt()
    val pl = mutableListOf<Pair<String, Int>>()
    for (i in 1..n) {
        val (s, t) = read().split(" ")
        pl.add(Pair<String, Int>(s, t.toInt()))
    }
    val x = read()

    var find = false
    var ans = 0
    for (i in 0 until n) {
       if (find) ans += pl[i].second
        if (pl[i].first == x) find = true
    }

    println(ans)
}

fun read(): String = readLine()!!


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

int main()
{
    long long n, m;
    cin >> n >> m;
    map<long long, long long> ab;
    for (long long i = 0; i < n; ++i)
    {
        long long a, b;
        cin >> a >> b;
        if (ab[a]) ab[a] += b;
        else ab[a] = b;
    }
    
    long long ans = 0;
    for (auto itr = ab.begin(); (itr != ab.end()) && (m > 0); ++itr)
    {
        if (itr -> second <= m)
        {
            ans += itr -> first * itr -> second;
            m -= itr -> second;
        }
        else
        {
            ans += itr -> first * m;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    int N,Q;
    vector <long long> l(1000000),r(1000000);
    vector <long long> s(1000000,0);    
    vector <long long> t(1000000,0);
    cin >> N >> Q >> S;
    for(int i=0;i<Q;i++){
        cin >>l.at(i)>>r.at(i);
    }
    for(int i=0;i<N-1;i++){
        if(S.at(i)=='A'&&S.at(i+1)=='C'){
            s.at(i)=1;
        }
    }
    for(int i=0;i<N-1;i++){
        t.at(i+1)=s.at(i)+t.at(i);
    }
    for(int i=0;i<Q;i++){
        cout << t.at(r.at(i)-1)-t.at(l.at(i)-1)<<endl;
    }
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
vector<int> zfunc(string s){
    int n=s.size();
    vector<int> z(n,0);
    int left=0,right=0;
    for(int i=1;i<n;++i){
        if(i<right)z[i]=min(z[i-left],right-i);
        while((s[z[i]]==s[i+z[i]])&&(i+z[i]<n))++z[i];
        if(i+z[i]>right)left=i,right=i+z[i];
    }
    return z;
}

int32_t main(){
    string s,t;
    cin>>s>>t;
    dbg(sz(s),sz(t));
    int ok=1;
    for(char c:s)ok&=c==s[0];
    for(char c:t)ok&=c==s[0];
    if(ok){
        cout<<"-1\n";
        return 0;
    }
    string ss=s;
    while(sz(s)<sz(t))s+=ss;
    s=s+s+s;
    auto z=zfunc(t+"#"+s);
    int q=sz(z);
    int f=-1;
    forn(i,q){
        if(z[i]==sz(t)){
            f=i-sz(t)-1;
            break;
        }
    }
    if(f>=0){
        ok=1;
        int j=0;
        forn(i,sz(s)){
            ok&=s[f]==t[j];
            f++;j++;
            if(f==sz(s))f=0;
            if(j==sz(t))j=0;
        }
        if(ok){
            cout<<"-1\n";
            return 0;
        }
    }
    int ans=0;
    vector<int> dp(q+1,0);
    for(int i=q-1;i>=0;--i){
        int h=z[i]==sz(t);
        if(h)dp[i]=dp[i+sz(t)]+1;
        upx(ans,dp[i]);
    }
    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 62784
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	string S;
	cin >> S;
	S += "0000000";
	vector<ll> g(S.size() + 5);
	g.at(0) = 0;
	g.at(1) = 1;
	if (S.at(0) == S.at(1)) {
		g.at(2) = 1;
	}
	else {
		g.at(2) = 2;
	}
	
	for (ll i = 3; i <= S.size(); i++) {
		if (S.at(i-1) == S.at(i-2)) {
			g.at(i) = g.at(i-3)+2;
		}
		else {
			g.at(i) = g.at(i - 1) + 1;
		}
		
	}
	
	cout << g.at(S.size()-7) << endl;
}


Measured memory_bytes: 5248
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

h1, m1, h2, m2, k = map(int, input().split())
time1 = h1 * 60 + m1
time2 = h2 * 60 + m2
print(time2 - k - time1)

Measured memory_bytes: 9320
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    D,N = map(int,input().split())
    if N != 100:
        ans = N * pow(100,D)
    else:
        ans = 101 * pow(100,D)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9140
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int A, B;

signed main()
{
	cin >> A >> B;
	cout << A * B << endl;
}




Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-6;
const ll MOD = 1000000007;
const ll INF = 1e15;

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (int i = 0;i < N;i++)
		cin >> a[i];
	ll r = 0;
	ll now = 0;
	ll ans = 0;
	for (ll l = 0;l < N;l++){
		while (r < N && (now ^ a[r]) == now + a[r]) {
			now ^= a[r];
			r++;
		}
		ans += r - l;
		now ^= a[l];
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if(s *t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<queue>
#include<bitset>
using namespace std; // 575

const int MAX = 200002;
int main() {
	int N, Q;
	static char t[MAX], d[MAX];
	string s;
	cin >> N >> Q >> s;
	for (int i = 0;i < Q;++ i) cin >> t[i] >> d[i];
	
	int l = -1, r = N;
	for (int i = Q - 1;i >= 0;-- i) {
		if (s[l + 1] == t[i] && d[i] == 'L') ++ l;
		if (0 <= l && s[l] == t[i] && d[i] == 'R') -- l;
		if (s[r - 1] == t[i] && d[i] == 'R') -- r;
		if (r < N && s[r] == t[i] && d[i] == 'L') ++ r;
		if (r - l <= 1) break;
	}
	cout << max(0, r - l - 1);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

逆順に考えれば良い
そうすれば左右から順に伸ばしていくだけになる
最後に、残った区間はその間なので一発で求まる
*/

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

int main() {
	string a,b,c,ans;
	cin >> a >> b >> c;
	char dif = 'A' - 'a';
	printf("%c%c%c\n", a[0] + dif, b[0] + dif, c[0] + dif);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }


int n,m,par[N],vis[N],vis1[N],dp[N];
vi adj[N];


void dfs(int u) {
	  vis[u]=1;
	  
	  for(auto to:adj[u]) {
		     if(vis[to]) continue;
		     par[to]=u;
		     dfs(to);
		  } 
	}



void solve() {
     cin>>n>>m;
     
     rep(i,0,m) {
		   int x,y;
		   cin>>x>>y;
		   adj[x].pb(y);
		   adj[y].pb(x);
		 }
		 
	dfs(1);
	int f=0,ind=0;
    rep1(i,1,n) {
		  if(!vis[i]) {
			  f=1;
			  ind=i;
		  }
 		}
 	//~ cout<<ind<<endl;	
    if(f) {
		  cout<<"No\n";
		  return;
		}
		
	vector<pi> vp;
	
	vis1[1]=1;
	queue<int> q;
	q.push(1);
	
	while(!q.empty()) {
		  int ver=q.front();
		  q.pop();
		  
		  
		  for(auto to:adj[ver]) {
			     if(!vis1[to]) {
					    dp[to]=ver;
					    vis1[to]=1;
					    q.push(to);
					 }
			  }		  
		}
	
	
	cout<<"Yes\n";
	rep1(i,2,n) {
		   cout<<dp[i]<<endl;
		}  				   
 }

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

return 0;	   
}


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

int main() {
	string unco;
	while(cin >> unco){
		int joi = 0, ioi = 0;
		for(int i= 2; i < unco.size(); i++){
			if(unco[i] == 'I' && unco[i - 1] == 'O'){
				if(unco[i - 2] == 'I'){
					ioi++;
				}	
				if(unco[i - 2] == 'J'){
					joi++;
				}
				
			}		
		}
	cout << joi << endl << ioi <<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < arr.size(); i++) {
        cin >> arr[i];
    }
    int ans = INT_MAX;
    for(int y = -100; y <= 100; y++) {
        int cur = 0;
        for(int x: arr) {
            cur += pow(x-y, 2);
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
    return 0;
}




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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,K;
int A[100010];

int gcd(int x , int y){
	return y == 0 ? x : gcd(y,x%y);
}

int main(){
	scanf("%d%d" , &N , &K);
	repp(i,0,N){
		scanf("%d" , A + i);
	}
	sort(A,A+N);
	if(A[N-1] < K){
		printf("IMPOSSIBLE\n");
		return 0;
	}
	int z = A[0];
	repp(i,1,N){
		z = gcd(z,A[i]);
	}
	printf("%s\n" , K%z == 0 ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int W, H, x, y, r;
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if(x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    int X, t;
    cin >> X >> t;
    if(X-t > 0)
        cout << X - t << '\n';
    else
        cout << 0 << '\n';
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    HashMap<String, Integer> map = new HashMap<>();

    int n = sc.nextInt();

    for (int i = 0; i < n; ++i) {
      String s = sc.next();
      map.put(s, map.getOrDefault(s, 0) + 1);
    }

    int m = sc.nextInt();

    for (int i = 0; i < m; ++i) {
      String t = sc.next();

      map.put(t, map.getOrDefault(t, 0) - 1);
    }

    int max = 0;

    for (int i : map.values()) {
      if (i > max)
        max = i;
    }

    System.out.println(max);
  }
}

Measured memory_bytes: 21844
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:a:as)=minimum$map(\f->fst$foldl' g(f 0 a)as)[fp,fn]
ft c b v=(c+abs(b-v),v)
fp c b=ft c b$max 1 b
fn c b=ft c b$min(-1)b
g(c,p)a
  |p<0=fp c$p+a
  |p>0=fn c$p+a

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

using namespace std;

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

    if(A==1){
        A+=13;
    }
    if(B==1){
        B+=13;
    }
    if(A==B){
        cout<<"Draw"<<endl;
    }else if(A<B){
        cout<<"Bob"<<endl;
    }else{
        cout<<"Alice"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin>>x;
    puts(x<30?"No":"Yes");
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		char[] S = sc.next().toCharArray();
		int a = 0;
		int b = 0;
		for (int i = 0; i < N; ++i) {
			boolean ok;
			if (S[i] == 'a') {
				ok = a + b < A + B;
				if (ok) ++a;
			} else if (S[i] == 'b') {
				ok = a + b < A + B && b < B;
				if (ok) ++b;
			} else {
				ok = false;
			}
			sb.append((ok ? "Yes" : "No") + "\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 29832
#include <iostream>
using namespace std;
int main()
{
    long long n, ans = 0, k = 10;
    cin >> n;
    if(n & 1){
        cout << 0 << endl;
        return 0;
    }
    while (k <= n) {
        ans += n / k;
        k *= 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    BN = 64
    B = [[0] * BN for _ in range(N+1)]
    for i, a in enumerate(A):
        for j in range(BN):
            B[i+1][j] = B[i][j] + ((a >> j) & 1)
    ans = 0
    for i in range(BN):
        b = 1 << i
        for j, a in enumerate(A):
            n = B[N][i] - B[j+1][i]
            if a & b:
                n = N - j  - n - 1
            ans = (ans + b * n % MOD) % MOD
    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 287688
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
double dp[3000+1][3000+1];
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<double> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i];
  }
  dp[0][0] = 1.0;
  for(int i=0; i<N; i++){
    for(int j=0; j<=i; j++){
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
    }
  }
  double res=0.0;
  for(int i=(N+1)/2; i<=N; i++){
    res += dp[N][i];
  }
  cout << fixed << setprecision(10) <<  res << endl;
  return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a <= c && c <= a + b){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl; 
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MOD = (int)1e9 + 7;

const int MAX_H = 1005;
const int MAX_W = 1005;

int dp[MAX_H][MAX_W];
char grid[MAX_H][MAX_W];
int main()
{
	rep (i, MAX_H) rep (j, MAX_W) dp[i][j] = 0, grid[i][j] = 0;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int H, W; cin >> H >> W;
	rep (i, H){
		rep (j, W){
			cin >> grid[i][j];
		} // end rep
	} // end rep

	rep (i, H){
		if (grid[i][0] == '.'){
			dp[i][0] = 1;
		}else
		if (grid[i][0] = '#'){
			break;
		} // end if
	} // end rep

	rep (j, W){
		if (grid[0][j] == '.'){
			dp[0][j] = 1;
		}else
		if (grid[0][j] == '#'){
			break;
		} // end if
	} // end rep

	for (int i = 1;i < H; ++i){
		for (int j = 1; j < W; ++j){
			if (grid[i][j] == '.'){
				dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
				dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
			} // end if
		} // end for
	} // end for

	int res = dp[H-1][W-1];
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int c[3][3];
int a[3], b[3];

int main(){
    rep(i,3) rep(j,3) cin>>c[i][j];

    string ans="No";
    for(int n=-100;n<=100;n++){
        a[0]=n;
        rep(j,3) b[j]=c[0][j]-a[0];
        rep(i,3) a[i]=c[i][0]-b[0];
        repn(i,2){
            repn(j,2){
                if(a[i]+b[j]!=c[i][j]) goto a;
            }
        }
        ans="Yes";
        break;
        a:;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
//#define DEBUG
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#else
#define s(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<",";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define ALL(v) v.begin(), v.end()

int main(){
    int N,M;ll X;
    cin>>N>>M>>X;
    vector<ll> C(N+10);
    vector<vector<ll>> A(N+10,vector<ll>(M+10));
    REP(i,N){
        cin>>C[i];
        REP(j,M)cin>>A[i][j];
    }
    
    vector<ll> w(pow(2,N),INF);
    REP(i,pow(2,N)-1){
        vector<ll> msum(M+10,0);
        ll csum=0;
        REP(j,N){
            if(((i>>(j-1))&1)==1){
                csum+=C[j];
                REP(m,M)msum[m]+=A[j][m];
            }
        }
        ll min=INF;
        REP(m,M){
            if(msum[m]<min)min=msum[m];
        }
        s(min)
        if(min>=X){
            w[i]=csum;
            s(csum)
        };
    }
    ll min = *min_element(ALL(w));
    if(min==INF)cout<<-1;else cout<<min;
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 4112
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
    sort(A.begin(),A.end());
}

int solve(){
    vector<ll> AS(N+1,0);
    for (int i = 0; i < N; i++)
    {
        AS[i+1] = AS[i]+A[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ll x = AS[i+1];
        int idx = 0;
        DBG(x)
        vector<ll>::iterator itr;
        while(idx<N){
            itr = upper_bound(A.begin(),A.end(),2*x);
            idx = itr-A.begin();
            DBG(idx)
            if(x==AS[idx]) break;
            x = AS[idx];
        }
        if(idx==N) ans++;
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1792
import sys,bisect
input = sys.stdin.readline
n,d,a = map(int,input().split())

def segfunc(x,y):
    return x+y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num


xh = []
dg = 10**10

for i in range(n):
    x,h = map(int,input().split())
    xh.append(x*dg+h)

xh.sort()

res = 0

for i in range(n):
    x,h = xh[i]//dg,xh[i]%dg
    k1 = bisect.bisect_left(xh,(x-2*d)*dg)
    
    r = query(k1,i)

    h -= r*a
    if h <= 0:
        continue

    if h%a == 0:
        res += h//a
        update(i,h//a)
    else:
        res += h//a+1
        update(i,h//a+1)
    
print(res)

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define dup(x,y) (((x)+(y)-1)/(y))
#define vecadd emplace_back

typedef long long ll;

int main(){
  string s;
  int k, num = 0;
  vector<int> count;
  
  cin >> s >> k;
  
  int temp = 0;
  char c_temp = ' ';
  rep(i, s.size()){
    if(c_temp == s[i]){
      temp++;
    }
    else{
      if(temp == 0){}
      else{
        count.push_back(temp);
      }
      temp = 1;
      c_temp = s[i];
    }
  }
  
  count.push_back(temp);
  
  ll ans = 0;
  rep(i, count.size()){
    ans += count[i] / 2;
  }
  
  ans *= k;
  
  if(count.size() == 1 && count[0] % 2 == 1){
    ans += k / 2;
  }
  else if(s.front() == s.back() &&
     count.front() % 2 == 1 &&
     count.back() % 2 == 1){
    ans += k - 1;
  }
  
  cout << ans;
  
  
  return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    if (s[0] == s[1] && s[2] == s[3]) ans++;
    if (s[0] == s[2] && s[1] == s[3]) ans++;
    if (s[0] == s[3] && s[1] == s[2]) ans++;
    if (ans && ans != 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL x; cin >> x;
    int cnt = 0;
    LL cur = 100;
    while (cur < x) {
        cur = cur * 1.01;
        cnt++;
    }
    cout << cnt << '\n';


}

Measured memory_bytes: 3608
from collections import*;n,*v=map(int,open(0).read().split());a,b=[Counter(v[i::2]).most_common()+[(0,0)]for i in(0,1)];i,x=a[0];j,y=b[0];print(n-[x+y,max(x+b[1][1],y+a[1][1])][i==j])

Measured memory_bytes: 20524
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
// 以下コピー
const int MAX_FACT = 2000000;
const int mod = 1000000000 + 7;
ll fact[MAX_FACT];

ll pow_mod(ll a,ll n){
  ll cur=1;
  ll mul=a;
  while(n){
    if(n%2)cur=(cur*mul)%mod;
    mul=(mul*mul)%mod;
    n/=2;
  }
  return cur;
}

ll div_mod(int a){
  return pow_mod(a,mod-2);
}

// factを前計算
void calcFact(){
  fact[0]=1;
  for(int i=1;i<MAX_FACT;i++)
    fact[i]=(fact[i-1]*i)%mod;
}

// aCbのmodを計算
// 計算量はO(log(fact[a])+log(fact[a-b]))程度
ll comb(ll a,ll b){
  if(a<0||b<0)return 0;
  else if(a<b)return 0;
  else if(b==0)return 1;
  ll res=fact[a];
  res=(res*div_mod(fact[b]))%mod;
  res=(res*div_mod(fact[a-b]))%mod;
  return res;
}


ll dcomb(int n, int r){
    if(n==0)return 1;
    if(r==0)return 1;
    return comb(n + r - 1, r);
}


int N, X;
int S[210];
ll dp[100010];

int dp2[100010];

int rec2(int x){
    if(dp2[x] >= 0) return dp2[x];
    int i = 0;
    // x以下となる最初の要素
    for(i = 0; i < N; i++){
        if(S[i] <= x){
            break;
        }
    }
    return dp2[x]= i;
}

ll rec(int x){
    if(dp[x] >= 0) return dp[x];
    ll res = 0;
    // xの要素以下となるところから選択可能
    int start = 0;
    for(start = 0; start < N; start++){
        if(S[start] <= x){
            break;
        }
    }
    if(start == N){
        res = x;
    }
    else{
        // i番目を選ぶ
        for(int i = start; i < N; i++){
            int nx = x % S[i];

            // nx以下となる最初の要素を見つけておく
            int last_sel = rec2(nx);

            // last_sel - start - 1 個は任意箇所に挿入可能
            // N - last_sel が残りの数
            ll f = (fact[last_sel - start - 1] * dcomb(N - last_sel + 1, last_sel - start - 1)) % mod;

            (res += (f * rec(nx)) % mod) %= mod;
        }
    }
    return dp[x] = res;
}

int main(){

    calcFact();
    memset(dp, -1, sizeof(dp));
    memset(dp2, -1, sizeof(dp2));
    cin >> N >> X;
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S, S + N, greater<int>());
    int start = 0;
    for(start = 0; start < N; start++){
        if(S[start] <= X){
            break;
        }
    }

    // start個は任意の場所に挿入可能
    ll ans = ((fact[start] * dcomb(N - start + 1, start)) % mod);

    ans *= rec(X);
    ans %= mod;

    cout << ans << endl;

    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

int main() {
  int X,Y;
  cin >> X >> Y;
  rep(a,X+1) {
    rep(b,X+1) {
      if( ( a + b ) != X ) continue;
      int v = 2 * a + 4 * b;
      if( v == Y ) {
	puts("Yes");
	return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 3616