akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = II()
    s = input()
    print(s if a >= 3200 else "red")
    return

#B
def B():
    II()
    a = LI()
    ans = 0
    for ai in a:
        ans += 1 / ai
    print(1/ans)
    return

#C
def C():
    n = II()
    v = LI()
    q = []
    for vi in v:
        heappush(q, vi)
    while 1:
        a = heappop(q)
        if q:
            b = heappop(q)
            heappush(q, (a + b) / 2)
        else:
            print(a)
            return

#D
def D():
    n, q = LI()
    tree = [[] for i in range(n)]
    for _ in range(n - 1):
        a, b = LI_()
        tree[a].append(b)
        tree[b].append(a)
    ans = [0] * n
    c = defaultdict(int)
    def dfs(now):
        for nex in tree[now]:
            if c[nex]:
                continue
            c[nex] += 1
            ans[nex] += ans[now]
            dfs(nex)
    for _ in range(q):
        p, x = LI_()
        x += 1
        ans[p] += x
    c[0] = 1
    dfs(0)
    print(*ans)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39152
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <iomanip>

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

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> t(N), v(N), time(N + 1);
	for (int i = 0; i < N; i++) cin >> t[i];
	for (int i = 0; i < N; i++) cin >> v[i];
	for (int i = 0; i < N; i++) time[i + 1] = t[i] + time[i];
	int time_end = time.back();

	vector<int> speed(2 * time_end + 1);
	for (int i = 0; i < time_end; i++) speed[i] = i;
	for (int i = time_end; i <= 2 * time_end; i++) speed[i] = 2 * time_end - i;

	for (int i = 0; i <= 2 * time_end; i++) {
		for (int j = 0; j < N; j++) {
			if (2 * time[j] <= i && i < 2 * time[j + 1]) speed[i] = min(speed[i], 2 * v[j]);
			else if (i < 2 * time[j]) speed[i] = min(speed[i], 2 * time[j] - i + 2 * v[j]);
			else speed[i] = min(speed[i], i - 2 * time[j + 1] + 2 * v[j]);
		}
	}

	int ans = 0;
	for (int i = 0; i < 2 * time_end; i++) {
		ans += speed[i] + speed[i + 1];
	}
	cout << fixed << setprecision(20) << ans / 8.0 << "\n";

	return 0;
}

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

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<vector<int>> card(K, vector<int>(N/2));
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < N/2; j++) {
            cin >> card[i][j];
            card[i][j]--;
        }
    }
    
    random_device rd;
    mt19937 mt(rd());
    bool finished = 0;
    while (!finished) {
        finished = 1;
        
        vector<int> seq(N);
        for (int i = 0; i < N; i++) {
            seq[i] = mt() % 2;
        }
        
        for (int i = 0; i < K; i++) {
            int sum = 0;
            for (int j = 0; j < N/2; j++) {
                sum += seq[card[i][j]];
            }
            if (sum < N/8 || sum > 3*N/8) {
                finished = 0;
                break;
            }
        }

        if (finished) {
            for (int i = 0; i < N; i++) {
                cout << seq[i];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
int GCD(int a, int b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
 
    int main(){
      int n;
      cin >> n;
      int count=0;
      int p=11;
      while(count<n){
        if(IsPrime(p) && count==n-1){
         count++;
          cout << p << endl;
        }
        else if(IsPrime(p) && count<n-1){
         count++;
          cout << p << ' ';
        }
        p+=10;
      }
      return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;

int main(){
  int N;
  string S;
  int Q;
  cin >>N>>Q>>S;
  vector<int>cnt(N);
  cnt[0]=0;
  for(int i=0;i<N-1;i++){
  	if(S[i]=='A'&&S[i+1]=='C'){
    	cnt[i+1]=cnt[i]+1;
    }
    else{cnt[i+1]=cnt[i];}
  }
  rep(i,Q){
  	int a,b;cin >>a>>b;a--;b--;
    	cout<<cnt[b]-cnt[a]<<endl;
  }
}

Measured memory_bytes: 1408
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

A,B,C,D = mint()

def f(x):
    return B//x-(A-1)//x

print(f(1)-f(C)-f(D)+f(lcm(C,D)))

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

int main(void)
{
    int N;
    cin >> N;

    int temp = N;
    int sum = 0;
    for (int i = 0; i < 10; i++)
    {
        sum += temp % 10;
        temp /= 10;
    }
    // cout << sum << endl;
    // cout << N % sum << endl;
    if (N % sum == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return (0);
}

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

using namespace std;

int main()
{
	int W,H,x,y,r;
	
	cin >> W >> H >> x >> y >> r ;
	
	if( 0 <= x-r && x+r <= W && 0 <= y - r && y + r <= H){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>

int main() {
  int h, n, a;
  char buf[1024];
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d\n", &h, &n);

  int tmp;
  for (tmp=0; tmp<n; tmp++) {
    scanf("%d", &a);
    h -= a;
  }

  if (h > 0) printf("No\n");
  else printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){

	int n = 0;
	int num[10000] = { 0 };
	long long int sum = 0;
	int min = 1000000;
	int max = -1000000;

	cin >> n;

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

		cin >> num[i];

	}

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

		if (min > num[i]) {

			min = num[i];

		}

		if (max < num[i]) {

			max = num[i];

		}

		sum += num[i];

	}

	cout << min << " " << max << " " << sum << endl;

	return 0;

}



Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	print(min(a, b) + min(c, d));



	return 0;
}

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

using namespace std;

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

  long long int A[n];
  long long int MOD=1000000007;
  long long int ans=0;
  long long int sum=0;
  for(int i=0; i<n; i++) cin>>A[i];

  for(int i=0; i<n; i++){
    sum +=A[i];
    sum %= MOD;
  }

  for(int i=0; i<n-1; i++){
    sum = sum- A[i];
    if(sum<0) sum+=MOD;
    ans+=sum*A[i];
    ans%=MOD;
  }

  cout<<ans<<endl;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long X){
    long long x = 100;
    rep(i,1,1e10) {
        x = (long long)((long double)x * 1.01);
        if (x >= X) {
            cout << i << endl;
            return;
        }
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {

    int N;
    long x;
    cin >> N;
    cin >> x;
    vector<long> as;
    for (int i = 0; i < N; i++) {
        long a;
        cin >> a;
        as.push_back(a);
    }

    sort(as.begin(), as.end());

    int k = 0;
    long sum = 0;

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

        sum += as[i];
        if (sum <= x) {
            k += 1;
        } else {
            break;
        }
    }

    if ((k == N) and ((x - sum) > 0)) {
        k -= 1;
    }

    cout << k << "\n";


    return 0;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[100005];
int sign(int a){
  if(a>0) return 1;
  return -1;
}
int main(){
  cin>>n;
  REP(i,n) scanf("%d",&ar[i]);
  n=unique(ar,ar+n)-ar;

  int res=0;
  REP(i,n){
    ++res;
    if(i==n-1) break;

    int j=i+1;
    while(j<n && sign(ar[j]-ar[j-1])==sign(ar[i+1]-ar[i])) ++j;
    i=j-1;
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
  int k, x;

  scanf("%d %d", &k, &x);
  for (int i = x - k + 1; i < x + k; i++) {
    if (i != x - k + 1) printf(" ");
    printf("%d", i);
  }
  printf("\n");

  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static int[] march;

        static void Main(string[] args)
        {
            //[summary]C - Lower
            int N = int.Parse(Console.ReadLine());
            var H = ReadLine();
            
            int max = 0;
            int i = 0;
            int move = 0;

            while (i < N - 1)
            {
                if (H[i] >= H[i + 1])
                {
                    move++;
                }
                else
                {
                    max = Math.Max(max, move);
                    move = 0;
                }

                i++;
            }

            Console.WriteLine(Math.Max(max, move));
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 27868
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define rep(i, N) for(int i = 0; i < N; ++i)

using namespace std;
int main() {
    int N; cin >> N;
    string w[N]; rep(i, N) cin >> w[i];
    map<string, bool> ww;
    ww[w[0]] = true;
    for (int i = 1; i < N; ++i) {
        if (ww.count(w[i])) {
            cout << "No" << endl;
            return 0;
        }
        if(w[i-1][w[i-1].size()-1] != w[i][0]) {
            cout << "No" << endl;
            return 0;
        }
        ww[w[i]] = true;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public static class Program
{
    public static void Main()
    {
        new Solve().Run();
    }
}

public class Solve
{
    int[] a;
    int[] query;
    int n;

    public void Run()
    {
        Console.ReadLine();
        a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        n = a.Length;
        Console.ReadLine();
        query = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        foreach (var m in query)
        {
            Console.WriteLine(Func(0, m) ? "yes" : "no");
        }
    }

    public bool Func(int i, int m)
    {
        if (i == n)
        {
            return m == 0;
        }
        return Func(i + 1, m) || Func(i + 1, m - a[i]);
    }
}




Measured memory_bytes: 9460
"use strict"

function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
var stdout = [];
function input(){return stdin.pop()};
function print(x){stdout.push(x)};
function mapint(x){return x.map(n=>parseInt(n))};


var tmp = mapint(input().split(" "))
var n = tmp[0]
var m = tmp[1]
var c = tmp[2]
var b = mapint(input().split(" "))
var ans = 0


for (var i = 0; i < n; i++){
    var ai = mapint(input().split(" "))
    var s = c
    for (var j = 0; j < m; j++){ s += ai[j] * b[j] }
    if (s > 0){ ans++ }
}

print(ans)






stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7500
x,n=map(int,input().split())
l=list(map(int,input().split()))
a=0
for i in range(100):
    if x-i not in l:
        ans=x-i
        a=i+1
        break
for i in range(100):
    if x+i not in l:
        ansb=x+i
        ab=i+1
        break
if a>ab:
    print(ansb)
else:
    print(ans)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    string s;
    cin>>n>>s;
    int need_left=0;
    int pointer=0;
    rep(i,n){
        if(s[i]=='(') pointer++;
        else{
            if(pointer==0) need_left++;
            else pointer--;
        }
    }

    int need_right=pointer;
    string res="";
    rep(i,need_left) res+='(';
    res+=s;
    rep(i,need_right) res+=')';
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef struct node
{
	int b,c;
	bool operator < (const struct node & n)const
	{
		return c>n.c;
	}
}NODE,*PNODE;
NODE v[100001];
priority_queue<int,vector<int>,greater<int> > pq;
int main()
{
	int n,m,i,j,a;
	long long ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		pq.push(a);
	}
	for(i=1;i<=m;i++)
		scanf("%d%d",&v[i].b,&v[i].c);
	sort(v+1,v+1+m);
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=v[i].b;j++)
		{
			if(pq.top()>=v[i].c)
				break;
			pq.pop();
			pq.push(v[i].c);
		}
	}
	for(i=1;i<=n;i++)
	{
		ans+=pq.top();
		pq.pop();
	}
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1528
import math
def cmb(n, r):
        if r > n: 
                return 0
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


import collections
N = int(input())
s= [input() for i in range(N)]
ans=0
#各文字列文字列をソート
s=list(map(sorted,s))

s.sort()        #リストをソート
s=list(map(''.join,s))  #リストになっていたものを文字列に変換
clist = collections.Counter(s) #リスト内の各要素の数を数え上げ
kaisu=list(clist.values())

for i in kaisu:
        ans += cmb(i,2)

print(ans)

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

int main() {
  string s;
  cin >> s;

  vector<int> v(s.size() + 1);

  int c;
  c = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '<')
      v[i + 1] = ++c;
    else
      c = 0;
  }
  c = 0;
  for (int i = s.size() - 1; i >= 0; --i) {
    if (s[i] == '>')
      v[i] = max(v[i], ++c);
    else
      c = 0;
  }

  long long cnt = 0;
  for (auto e : v)
    cnt += e;
  cout << cnt << endl;
}

Measured memory_bytes: 2820
N = int(input())
a = list(map(int,input().split()))
m_list = []
m_num = 0

ans_ls = [0]*N
for i in range(N):
    temp = 0
    num = N - i
    j = 1
    while num*j <= N:
        temp += ans_ls[num*j-1]
        j += 1
    if (temp + a[num-1])%2 == 1:
        ans_ls[num-1] = 1
        m_list.append(str(num))
        m_num += 1
m_list.sort()

print(m_num)
print(' '.join(m_list))



Measured memory_bytes: 96832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int N;
    cin >> N;

    int64_t ans = 0;
    for(int A=1; A<=N; A++) {
        ans += (N-1) / A;
    }

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


Measured memory_bytes: 3636
fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn main() {
    let n: u8 = input_one().unwrap();
    let s: String = input_one().unwrap();

    println!("{}", s.chars().map(|c| (((c as u8 + n - 65) % 26) + 65) as char).collect::<String>());
}


Measured memory_bytes: 2124
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = InputNumList();
            WriteLine(a[1] - a[0] == a[2] - a[1] ? "YES" : "NO");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll> 
#define vv vector<v>
#define p pair<ll,ll>
#define arrayinput int n; int m; cin>>n>>m; v arr (n+1,-1); for (int i=0; i<n; i++){int temp; cin>>temp;arr[i]=temp;}
#define vp vector<pair<int,p> >
int LIM=2e5+10;
ll MOD=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int ans=0;
    for (int i=0; i<s.length(); i++)
        ans+=(s[i]==t[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
*H, = map(int, input().split())
X = [0]
for i in range(1, n):
    x = 1 << 30
    for j in range(1, min(i, k)+1):
        x = min(x, X[i-j]+abs(H[i]-H[i-j]))
    X.append(x)
print(X[n-1])


Measured memory_bytes: 61024
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }

    val groupby = readLine()!!.split(" ").map { it.toInt() }
            .groupBy {
                when {
                    b < it -> 1
                    a < it -> 0
                    else -> -1
                }
            }

    if (groupby.size != 3) {
        println(0)
    } else {
        println(groupby.map { it.value.size }.min()!!)
    }
}

Measured memory_bytes: 37992
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b,c,d,e,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

bool ok(ll ret,ll ce){
    ll le,ri;
    le=a[ret-1];
    ri=a[ce-1]-a[ret-1];
    if(ri>=le)return true;
    else return false;
}

void solve1(ll ce){
    ll le=1,ri=ce-1,mid;
    while(ri-le>1){
        mid=(le+ri)/2;
        if(ok(mid,ce)){
            le=mid;
        }
        else{
            ri=mid;
        }
    }
    tmp=LINF;
    rrep(i,max(1LL,le),min(ce,ri+1)){
        if(tmp>=abs(a[i-1]-(a[ce-1]-a[i-1]))){
            tmp=abs(a[i-1]-(a[ce-1]-a[i-1]));
            b=a[i-1];
            c=a[ce-1]-a[i-1];
        }
    }
    return;
}

bool ok1(ll ret,ll ce){
    ll le,ri;
    le=a[ret-1]-a[ce-1];
    ri=a[n-1]-a[ret-1];
    if(ri>=le)return true;
    else return false;
}

void solve2(ll ce){
    ll le=ce+1,ri=n-1,mid;
    while(ri-le>1){
        mid=(le+ri)/2;
        if(ok1(mid,ce)){
            le=mid;
        }
        else{
            ri=mid;
        }
    }
    tmp=LINF;
    rrep(i,max(ce+1,le),min(n,ri+1)){
        if(tmp>=abs((a[i-1]-a[ce-1])-(a[n-1]-a[i-1]))){
            tmp=abs((a[i-1]-a[ce-1])-(a[n-1]-a[i-1]));
            d=a[i-1]-a[ce-1];
            e=a[n-1]-a[i-1];
        }
    }
    return;
}

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

    cin>>n;
    rep(i,n)cin>>a[i];
    rrep(i,1,n)a[i]+=a[i-1];
    ans=LINF;
    rrep(ce,2,n-1){
        b=0;c=LINF;d=0;e=LINF;
        solve1(ce);
        solve2(ce);
        ans=min(ans,max({b,c,d,e})-min({b,c,d,e}));
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
m = [[int(i) for i in input().split()] for j in range(n)]
dp = [[0]*3 for i in range(n)]

dp[0][0] = m[0][0]
dp[0][1] = m[0][1]
dp[0][2] = m[0][2]

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1]+m[i][0],dp[i-1][2]+m[i][0])
    dp[i][1] = max(dp[i-1][0]+m[i][1],dp[i-1][2]+m[i][1])
    dp[i][2] = max(dp[i-1][0]+m[i][2],dp[i-1][1]+m[i][2])

print(max(dp[n-1]))


Measured memory_bytes: 74712
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N, M;
  cin >> N >> M;
  pair<ll, ll> d[N];
  REP(i, N) { cin >> d[i].first >> d[i].second; }
  sort(d, d + N);

  ll sum = 0, cnt = 0;
  REP(i, N) {
    if (cnt + d[i].second < M) {
      cnt += d[i].second;
      sum += d[i].first * d[i].second;
    } else {
      sum += d[i].first * (M - cnt);
      break;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n;
PII e[N];
int ptr;

void add(int u, int v)
{
	e[ptr++] = {u, v};
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n;
	if (__builtin_popcount(n) == 1)
	{
		cout << "No";
		return 0;
	}
	
	cout << "Yes" << endl;
	
	for(int i = 2; i <= n - 1; i += 2)
	{
		add(1, i);
		add(i, i + 1);
		add(1, n + i + 1);
		add(n + i + 1, n + i);
	}
	
	add(n + 1, n + 2);
	
	if (n % 2 == 0)
	{
		int ksor = n ^ (n - 1);
		add(2 * n, 2 * n - 1);
		add(n, ksor - 1);
	}
	
	assert(ptr == 2 * n - 1);	
	FOR(i, 0, ptr)
		cout << e[i].X << ' ' << e[i].Y << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 3968
import numpy as np
H,W=map(int,input().split())
a=[list(map(str,list(input()))) for i in range(H)]
f=np.empty((H+2,W+2))
f=f.tolist()
#print(f)
#print(a)

for i in range(H+2):
    for j in range(W+2):
        if (i==0)or(i==H+1)or(j==0)or(j==W+1):
            f[i][j]='#'
            #print("#")
        elif (i>0)and(j>0):
            f[i][j]=a[i-1][j-1]
            #print(a[i-1][j-1])
for i in f:print(*i, sep='')

Measured memory_bytes: 13940
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 1e6 + 69;
const int base = 311;

// dung igt thay cho gt luc tinh giai thua
// 3
// cach tao hoan vi tu n so : n*(n+1)/2;

ll s[e];
int a, b, n;


int main()
{
    ll n;
    string s;
    cin >> n;
    cin >> s;
    string thanhdink;
    ll cur = 0;
    for(int i=0; i<n; i++)
    {
        if(s[i] == ')')
        {
            if(cur - 1 < 0)
            {
                thanhdink += '(';
            }
            cur = max(cur - 1, 0LL);
        }
        else
        {
            cur ++;
        }
    }
    s = thanhdink + s;
    for(int i=1; i<=cur; i++)
    {
        s += ')';
    }
    cout << s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#define mt make_tuple
#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cin >> vec[i];}
#define printVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
//#define PI 3.1415926535897932384626
 
using namespace std;
 //using namespace __gnu_pbds;
 //template <typename T>
 //using ordered_set =
    //tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
/*
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 */
//----------------------------------------------------------------------------------------------------------------------
 
void swap(int & a, int & b){
    auto temp = a;
    a = b;
    b = temp;
}
 
const ll MOD = 1e9 + 7;
 
ll inf = 1LL*1e17;
 
void no(){
    cout <<"NO" << endl;
   //exit(0);
}
 
void yes(){
    cout <<"YES" << endl; //exit(0);
}
 
const ll md = 998244353;


void sl(){
	int n;
	 cin >> n;
	 vector< int > arr(n); scanVec(arr);
	 sort(all(arr));
	 for(int i = 1;i < n;i++){
		 if(arr[i] == arr[i - 1]){
			 cout << "NO" << endl;
			 return;
		 }
	 }
	 cout << "YES" << endl;
}
 
 
int main(){
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int ts = 0;
    if(ts == 1) cin >> ts;
    else ts = 1;
    while(ts--) sl(); 
    return 0;
} 


Measured memory_bytes: 1024
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
result = 0
count = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        count += 1
    else:
        if count % 2 == 1:
            result += 1
        count = 1
if count % 2 == 1:
    result += 1
print(result)

Measured memory_bytes: 50264
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int age = sc.nextInt(), value = sc.nextInt();
        
        if(age >= 13){
            System.out.println(value);
        }else if(age <= 5){
            System.out.println(0);
        }else{
            System.out.println(value/2);
        }
        
    }
}


Measured memory_bytes: 22996
#include <cstdio>
#include <vector>
using namespace std;

#define MOD 1000000007

typedef long long int LLI;
typedef vector<vector<LLI> > Mat;
typedef vector<vector<Mat> > MatMat;

int n;
int k;
int c;
int T;
Mat one;
Mat zero;
Mat G[7];
MatMat m;
MatMat m_zero;
MatMat ans;

Mat mul(Mat &a, Mat &b) {
    Mat ret(zero);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            for (int k=0; k<n; k++) {
                ret[i][j] += a[i][k] * b[k][j] % MOD;
                ret[i][j] %= MOD;
            }
        }
    }
    return ret;
}

Mat add(Mat &a, Mat &b) {
    Mat ret(zero);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            ret[i][j] = (a[i][j] + b[i][j]) % MOD;
        }
    }
    return ret;
}

MatMat mul(MatMat &a, MatMat &b) {
    MatMat ret(m_zero);
    for (int i=0; i<5; i++) {
        for (int j=0; j<5; j++) {
            for (int k=0; k<5; k++) {
                Mat s = mul(a[i][k], b[k][j]);
                ret[i][j] = add(ret[i][j], s);
            }
        }
    }
    return ret;
}

int main() {
    scanf("%d%d%d%d", &n, &k, &c, &T);
    zero = Mat(n, vector<LLI>(n));
    one = Mat(zero);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            zero[i][j] = 0;
            one[i][j] = 0;
        }
        one[i][i] = 1;
    }

    for (int i=0; i<7; i++) {
        G[i] = Mat(zero);
    }

    for (int i=0; i<k; i++) {
        int a, b, t;
        scanf("%d%d%d", &a, &b, &t);
        --a;
        for (int j=0; j<a; j++) {
            G[t][j][b+j]++;
        }

        for (int j=0; j<b; j++) {
            G[t][a+j][j]++;
        }

        for (int j=a+b; j<n; j++) {
            G[t][j][j]++;
        }
    }

    m_zero = vector<vector<Mat> >(5, vector<Mat>(5, zero));
    ans = vector<vector<Mat> >(m_zero);
    m = vector<vector<Mat> >(m_zero);
    for (int i=0; i<5; i++) {
        m[0][i] = G[i+1];
        if (i < 4) m[i+1][i] = one;
        ans[i][i] = one;
    }

    while (T > 0) {
        if (T&1) {
            ans = mul(ans, m);
        }
        m = mul(m, m);
        T >>= 1;
    }
    printf("%lld\n", ans[0][0][c-1][0]);
}

Measured memory_bytes: 2596
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		int a = sc.nextInt(), b = sc.nextInt();
		String u = sc.next();
		sc.close();
		if (u.equals(s))
			a--;
		else if (u.equals(t))
			b--;
		System.out.println(a + " " + b);
	}
}


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

#define pb push_back
#define ppp pop_back
#define fi first
#define se second
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
    int a,b;
    cin >> a >> b;
    if (a+b == 15) cout << "+";
    else if (a*b == 15) cout << "*";
    else cout << "x";
}


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

const int mod = 1000000007;

long long dp[100100];

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> stairs(N + 1, true);
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        stairs[a] = false;
    }

    for (int i = 0; i < 100100; i++) dp[i] = 0;
    dp[0] = 1;
    if (stairs[1]) dp[1] = 1;

    for (int i = 2; i <= N; i++) {
        if (!stairs[i]) continue;
        dp[i] += (dp[i - 2] + dp[i - 1]) % mod;
        dp[i] %= mod;
    }

    cout << dp[N] << endl;
}

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

int main(){
    int64_t l, r;
    cin >> l >> r;
    if(r-l >= 2019) cout << 0 << endl;
    else{
        int ans = 2019;
        for(int i=l;i<=r;++i){
            for(int j=i+1;j<=r;++j){
                ans = min(ans, (i%2019)*(j%2019)%2019);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

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

    int check=0;

    if(A+B+C==17){
        if(A==5){
            if(B==5||B==7){
                check=1;
            }
        }
        else if(A==7 && B==5){
            check=1;
        }
    }

    if(check==1){
        cout << "YES" <<endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	cout << min(N*M, K) << endl;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	auto a = vector<int>(n);
	long long int sum = 0;
	for(auto&& aa : a){
		cin >> aa;
		sum += aa;
	}
	sort(a.begin(), a.end());
	auto cb = vector<pair<int, int>>(m);
	for(auto&& d : cb){
		cin >> d.second >> d.first;
	}
	sort(cb.begin(), cb.end(), greater<pair<int, int>>());
	int p = 0;
	bool over = false;
	for(auto d : cb){
		for(auto i = 0; i < d.second; ++i){
			if(p >= n || a[p] >= d.first){
				over = true;
				break;
			}
			sum += d.first - a[p++];
		}
		if(over) break;
	}
	cout << sum << endl;
	return 0;
}

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

class Solution
{
    static long Calc(long[] array)
    {
        long sum = 0;

        var i = 0;
        var j = array.Length - 1;
        var left = array[i];
        var right = array[i];
        i++;
        while (i <= j)
        {
            sum += Math.Abs(left - array[j]);
            left = array[j];
            j--;
            if (i > j)
            {
                break;
            }

            sum += Math.Abs(right - array[j]);
            right = array[j];
            j--;
            if (i > j)
            {
                break;
            }

            sum += Math.Abs(left - array[i]);
            left = array[i];
            i++;
            if (i > j)
            {
                break;
            }

            sum += Math.Abs(right - array[i]);
            right = array[i];
            i++;
            if (i > j)
            {
                break;
            }
        }

        return sum;
    }

    static void Main()
    {
        var input = Console.In.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.None).Where(s => s != "").Select(long.Parse).ToArray();
        var N = input[0];
        var A = input.Skip(1).ToArray();

        Array.Sort(A);
        var a = Calc(A);
        var b = Calc(A.AsEnumerable().Reverse().ToArray());

        var sum = Math.Max(a, b);
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 30944
N = int(input())
march_dict = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0
}
for i in range(N):
    S = input()
    s_head = S[0]
    if march_dict.get(s_head) is not None:
        march_dict[s_head] += 1

march_candidate = [key for key, val in march_dict.items() if val != 0]

import itertools

ans = 0
for C in itertools.combinations(march_candidate, 3):
    a = march_dict[C[0]]
    b = march_dict[C[1]]
    c = march_dict[C[2]]
    ans += a * b * c
    #print(ans)
    #print(march_candidate)
print(ans)


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

int main() {
  int N,K,t,m;
  cin >> N >> K;
  for (int i = N; i <= K; i++) {
    if (i / 10000 == i % 10) {
      t = i - (i / 10000) * 10000;
      t /= 10;
      if (t / 100 == t % 10) {
        m++;
      }
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << (abs(a-c)<=d || abs(a-b)<=d && abs(b-c)<=d ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map &:to_i
lm = []
m.times {
    _, *s =  gets.split.map &:to_i
    lm << s
}
p = gets.split.map &:to_i
ans = 0
(0..2**n - 1).each{ |e|
    sum = Array.new(m, 0)
    (0..n-1).each{ |i|
        if e[i] == 1
            (0..m-1).each{ |j|
                if lm[j].include? i+1
                    sum[j] += 1
                end
            }
        end
    }
    s = true
    (0..m-1).each{ |i|
        s &= p[i] == sum[i] % 2
    }
    ans += 1 if s
}

puts ans

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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	ll ans = 1e18;
	bool x = true;
	for (int i = 0; i < 2; i++) {
		ll res = 0;
		ll sig = 0;
		for (int j = 0; j < n; j++) {
			if (x) {
				sig += a.at(j);
				x = false;
				if (sig > 0)continue;
				else {
					res += abs(1 - sig);
					sig = 1;
				}
			}
			else {
				sig += a.at(j); 
				x = true;
				if (sig < 0)continue;
				else {
					res += abs(-1 - sig);
					sig = -1;
				}
			}
		}
		x = false;
		ans = min(ans, res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3772
#include<stdio.h>

int main(){
    char word[1000];
    scanf("%s", word);
    int len=0;
    for (int i=0;word[i]!='\0';i++){
        len++;
    }
    int flag=0,cOccur=0,upCase;
    if (word[0]!='A'){
        printf("WA\n");
        return 0;
    }
    for (int j=2;j<len-1;j++){
        if (word[j]=='C'){
            cOccur++;
        }
    }
    if (cOccur!=1){
        printf("WA\n");
        return 0;
    }
    if (word[1]>='A' && word[1]<='Z'){
        printf("WA\n");
        return 0;
    }
    for (int j=2;j<len-1;j++){
        if (word[j]!='C'){
            if (word[j]>='A' && word[j]<='Z'){
            printf("WA\n");
            return 0;
            }
        }
    }
    if (word[len-1]>='A' && word[len-1]<='Z'){
        printf("WA\n");
        return 0;
    }
    printf("AC\n");
    return 0;
}





Measured memory_bytes: 128
n = int(input())
a = 0
w = 0
t = 0
r = 0
for _ in range(n):
    s = str(input())
    if s == 'AC':
        a += 1
    elif s == 'WA':
        w += 1
    elif s == 'TLE':
        t += 1
    else:
        r += 1
print('AC x', a)
print('WA x', w)
print('TLE x', t)
print('RE x', r)

Measured memory_bytes: 9208
#include<stdio.h>

long int count_of_2(long int n){
    long int count=0;
    while(n%2==0){
        count++;
        n = n/2;
    }
    return count;
}

int main(void){
    int N;
    scanf("%d",&N);
    long int a = 0;
    long int sum = 0;
    for(int i=0;i<N;i++){
        scanf("%ld",&a);    
        sum += count_of_2(a);
    }
    printf("%ld",sum);
    return 0;
}

Measured memory_bytes: 128
o=->a,n{n<1?1:a**n[0]*o[a,n/2]**2%M}
eval'N,A,B,C='+`dd`.split*?,
a=o[A*=t=o[A+B,-2+M=10**9+7],N]
b=o[B*=t,N]
f=f=1,*(1..2*N).map{|i|f=f*i%M}
N.times{|i|$.=($.+(N+i)*f[N+i-1]*o[f[N-1]*f[i],M-2]*(a+b))%M
a=a*B%M
b=b*A%M}
p$.*100*o[100-C,M-2]%M

Measured memory_bytes: 5128
#include <stdio.h>

int main()
{
    int a, b;

    scanf("%d %d",&a, &b);

    if (a >= 13)
    {
        printf("%d",b);
    }
    else if (a <= 5)
    {
        printf("0");
    }
    else
    {
        printf("%d",b / 2);
    }
    
    
}

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N),B(N);

    for(ll i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        A[i] = tmp;
        B[i] = tmp;
    }

    sort(A.begin(),A.end());
    ll left = A[(N-2)/2];
    ll right = A[N/2];

    for(ll i = 0; i < N; i++)
    {
        if(B[i] <= left)cout << right << endl;
        else if(B[i] >= right)cout << left << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
n= int(input())
x = list(map(int, input().split()))

sum = 0
ans = 0

round=lambda x:(x*2+1)//2

for i in range(n):
    sum += x[i]

avg = round(sum/n)

for i in range(n):
    ans += (x[i]-avg)*(x[i]-avg)

print(int(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();++i){
  	if(s[i]=='?'){
      	s[i]='D';
      }
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3380
s = input()
left, right = [0,], [0,]
a, b = 0, 0
for i in range(len(s)):
    a = a+1 if s[i] == '<' else 0
    left.append(a)
    b = b+1 if s[-1*(i+1)] == '>' else 0
    right.append(b)

right.reverse()
ans = sum(max(x, y) for x, y in zip(left, right))
print(ans)

Measured memory_bytes: 32992
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 200005;

int N;
int a[MaxN + 5];

int main()
{
	while(scanf("%d", &N) != EOF)
	{
		for(int i = 1; i <= N; i++)
			scanf("%d", &a[i]);
		sort(a + 1, a + N + 1);
		int MIN = inf;
		int ans = 0;
		for(int i = 1; i < N; i++) {
			if(abs(a[i] - ((a[N] + 1) / 2)) < MIN) {
				MIN = abs(a[i] - ((a[N] + 1) / 2));
				ans = a[i];
			}
		}
		printf("%d %d\n", a[N], ans);
	}
	return 0;
}

Measured memory_bytes: 512
X,N = gets.strip.split(nil).map(&:to_i)
if N == 0 then
  m = X
else
  numbers = gets.strip.split(nil).map(&:to_i)
  z = 0
  numbers.each do |x|
    if x == X then
      z += 1
    end
  end
  if z != 0 then
    i = 1
  else
    i = 0
    m = X
  end
  while i >= 1 do
    hokaku = numbers.select{|x| (x-X).abs == i}
      if hokaku.size == 2
        i += 1
      elsif hokaku.size == 1
        if hokaku[0] == X-i then
          m = X+i
        else
          m = X-i
        end
        break
      else
        m = X-i
        break
      end
  end
end
puts m

Measured memory_bytes: 14356
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
ll x, y, f, t;
vector<ll> vec[2];
bool dpx[8100][16100], dpy[8100][16100];
string str;
int main(void){
    // Your code here!
    cin >> str >> x >> y;
    for (ll i = 0; i < str.length(); i++) {
        if (str[i] == 'T') {
            if (t) {
                if (f) vec[t % 2].push_back(f);
            } else {
                x -= f;
            }
            f = 0, t++;
        } else {
            f++;
        }
    }
    if (f) {
        if (t) {
            vec[t % 2].push_back(f);
        } else {
            x -= f;
        }
    }
    memset(dpx, 0, sizeof(dpx));
    memset(dpy, 0, sizeof(dpy));
    dpx[0][8000] = true, dpy[0][8000] = true;
    for (ll i = 0; i < vec[0].size(); i++) {
        for (ll j = 0; j <= 16000; j++) {
            if (16000 - vec[0][i] >= j)dpx[i + 1][j] |= dpx[i][j + vec[0][i]];
            if (vec[0][i] <= j)dpx[i + 1][j] |= dpx[i][j - vec[0][i]];
        }
    }
    for (ll i = 0; i < vec[1].size(); i++) {
        for (ll j = 0; j <= 16000; j++) {
            if (16000 - vec[1][i] >= j)dpy[i + 1][j] |= dpy[i][j + vec[1][i]];
            if (vec[1][i] <= j)dpy[i + 1][j] |= dpy[i][j - vec[1][i]];
        }
    }
    if (dpx[vec[0].size()][x + 8000] && dpy[vec[1].size()][y + 8000]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 254976