akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const ll INF = 1e18;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<map<ll,ll>> dp(n+1);
    dp[0][0] = 0;
    for(int i=1;i<=n;i++){
        if(i==1){
            dp[i][0] = 0;
            dp[i][1] = a[0];
            continue;
        }
        dp[i][(i-1)/2] = dp[i][(i+1)/2] = -INF;
        if(i-1>=0){
            if(dp[i-1].find((i-1)/2) == dp[i-1].end()) dp[i-1][(i-1)/2] = -INF;
            if(dp[i-1].find((i+1)/2) == dp[i-1].end()) dp[i-1][(i+1)/2] = -INF;
            dp[i][(i-1)/2] = max(dp[i][(i-1)/2],dp[i-1][(i-1)/2]);
            dp[i][(i+1)/2] = max(dp[i][(i+1)/2],dp[i-1][(i+1)/2]);
        }if(i-2>=0){
            if(dp[i-2].find(((i-1)/2 - 1)) == dp[i-2].end()) dp[i-2][((i-1)/2 - 1)] = -INF;
            if(dp[i-2].find(((i+1)/2 - 1)) == dp[i-2].end()) dp[i-2][((i+1)/2 - 1)] = -INF;
            dp[i][(i-1)/2] = max(dp[i][(i-1)/2],dp[i-2][-1 + (i-1)/2] + a[i-1]);
            dp[i][(i+1)/2] = max(dp[i][(i+1)/2],dp[i-2][-1 + (i+1)/2] + a[i-1]);
        }
    }
    cout << dp[n][n/2] << endl;
    return 0;
}

Measured memory_bytes: 45512
#include<iostream>
#include<vector>
#include<queue>
#include<string>


int main(){
    std::vector<int> tiles;
    std::queue<int> unvisited_tile_q;
    int width, height, counter, pos;
    std::string line;

    while(true){
        std::cin >> width >> height;
        if( width == 0 && height == 0 ) break;
        tiles.resize(width*height);
        pos = 0;
        for( int h = 0; h < height; h++ ){
            std::cin >> line;
            for(std::string::iterator it = line.begin(); it != line.end(); ++it) {
                switch(*it){
                    case '#':
                        tiles[pos] = 0;
                        break;
                    case '@':
                        unvisited_tile_q.push(pos);
                    case '.':
                        tiles[pos] = 1;
                }
                pos++;
            }
        }

        counter = 0;
        while( !unvisited_tile_q.empty() ){
            pos = unvisited_tile_q.front();
            unvisited_tile_q.pop();
            if( tiles[pos] == 1 ){
                counter++;
                tiles[pos] = -1;
            } else continue;
            //left
            if ( pos - 1 >= 0 && pos % width > 0 && tiles[pos-1] == 1 ) unvisited_tile_q.push(pos-1); 
             //right
            if ( pos + 1 <= tiles.size() && pos % width < width - 1 && tiles[pos+1] == 1 ) unvisited_tile_q.push(pos+1);
            //up
            if ( pos - width >= 0 && tiles[pos-width] == 1 ) unvisited_tile_q.push(pos-width);
            //down
            if ( pos + width < tiles.size() && tiles[pos+width] == 1 ) unvisited_tile_q.push(pos+width);
        }
	    //output result
	    std::cout << counter << std::endl;
    }   
    return 0;
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;

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

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    //int tt; cin >> tt; while(tt--) {solve(); cout << "\n";}

    int n; cin >> n;

    vector <int> v(n);

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        if ((i + 1) % 2 == 1 && v[i] % 2 == 1)
            ++ans;
    }

    cout << ans;



}

/*
*/



Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] in = s.nextLine().split(" ");
        int a = Integer.parseInt(in[0]);
        int b = Integer.parseInt(in[1]);
        int r=0;
        for(int i=0;i<2;i++){
            if(a > b){
                r+=a;
                a--;
            }else{
                r+=b;
                b--;
            }
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int l,i,p[200],c,a[10000],an;
char s[200010],ch;
int main(){
    scanf("%s",&s);
    l=strlen(s);
    c=26;
    a[0]=l;
    an=1;
    for(i=l-1;i>=0;i--){
        if(!p[s[i]]){
            p[s[i]]=1;
            c--;
            if(c==0){
                memset(p,0,sizeof(p));
                c=26;
                a[an++]=i;
            }
        }
    }
    i=0;
    while(i<l){
        memset(p,0,sizeof(p));
        while(i<a[an-1]) p[s[i++]]=1;
        for(ch='a';ch<='z';ch++) if(!p[ch]) break;
        printf("%c",ch);
        while(i<l && s[i]!=ch) i++;
        i++;
        an--;
    }
    printf("\n");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  if(n>=10) cout<<a;
  else
  cout<<a+(100*(10-n));
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3560
# Here your code !
w,h,n = gets.chomp.split(" ").map{|u|u.to_i}
x = []
y = []
a = []
gx = 0
gy = 0
n.times do 
  x,y,a = gets.chomp.split(" ").map{|u|u.to_i}
  case a
  when 1 then
    gx = x if(x > gx)
  when 2 then
    w = x if(w > x)
  when 3 then
    gy = y if(y > gy)
  when 4 then
    h = y if(h > y)
  end
end
w = gx = 0 if (w < gx)
h = gy = 0 if (h < gy)

puts (w-gx)*(h-gy)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	char c[105];
	scanf("%d", &k);
	scanf("%s", &c);
	n = strlen(c);
	if(k >= n){
		printf("%s",c);
	}
	else {
		for(int i=0;i<k;i++)
		printf("%c",c[i]);
		printf("...");
	}
	return 0;
}

Measured memory_bytes: 3720
import sys
from itertools import permutations

a = [int(i) for i in sys.stdin]

b = [(list(map(int, str(k)))[-1], i) for i, k in enumerate(a)]

indexes = [i for i, (x, y)in enumerate(b) if x == 0]
d = 0
for i in sorted(indexes)[::-1]:
  d += a[i]
  b.pop(i)
b.sort()
c = b[::-1]

for i, k in c[:-1]:
  if i > 5:
    d += round(a[k], -1)
  else:
    d += (round(a[k], -1) + 10)
if c != []:
  d += a[c[-1][1]]
print(d)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
typedef long long LL;

int n, k;
LL w[100000];

bool check(LL P) {
    int i = 0;
    for (int j = 0; j < k; j++) {
        LL s = 0;
        while (s + w[i] <= P) {
            s += w[i++];
            if (i == n)
                return true;
        }
    }
    return false;
}

int solver() {
    LL left = 0, right = 100000 * 10000;
    LL mid;

    while (right > left) {
        mid = (left + right) / 2;
        if (check(mid))
            right = mid;
        else    
            left = mid + 1;
    }
    return right;
}

int main()
{
    cin >> n >> k;
 
    for (int i = 0; i < n; i++)
        cin >> w[i];
 
    cout << solver() << endl;

    return 0;
}

Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef long long ll;

int main(){
  int x; cin>>x;
  cout << !x << endl;
}

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

long long int a[128] = {2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, 4870847, 7881196, 12752043, 20633239, 33385282, 54018521, 87403803, 141422324, 228826127, 370248451, 599074578, 969323029, 1568397607, 2537720636, 4106118243, 6643838879, 10749957122, 17393796001, 28143753123, 45537549124, 73681302247, 119218851371, 192900153618, 312119004989, 505019158607, 817138163596, 1322157322203, 2139295485799, 3461452808002, 5600748293801, 9062201101803, 14662949395604, 23725150497407, 38388099893011, 62113250390418, 100501350283429, 162614600673847, 263115950957276, 425730551631123, 688846502588399, 1114577054219522, 1803423556807921, 2918000611027443, 4721424167835364, 7639424778862807, 12360848946698171, 20000273725560978, 32361122672259149, 52361396397820127, 84722519070079276, 137083915467899403, 221806434537978679, 358890350005878082, 580696784543856761, 939587134549734843, 1520283919093591604, 2459871053643326447, 3980154972736918051, 6440026026380244498};

int main(){
    scanf("%lld", a);
    cout << a[*a] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		int D = int.Parse(Console.ReadLine());
		var s = new StringBuilder("Christmas");
		while (D <= 24)
		{
			s.Append(" Eve");
			D++;
		}
		Console.WriteLine(s);
        
	}
}

Measured memory_bytes: 11092
/*---------------------------------------------*/
/*
    ABC174 D
 */
/*---------------------------------------------*/

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

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


    int64_t W = 0;
    int64_t R = 0;
    rep(i, n) {
        if (s[i] == 'W') W++;
        if (s[i] == 'R') R++;
    }

    int64_t ans = R;
    int64_t W_num = 0;
    rep(i, n) {
        if (s[i] == 'W') W_num++;
        if (s[i] == 'R') R--;

        chmin(ans, max(W_num, R));
    }
    chmin(ans, W);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3724
from collections import Counter
from math import sqrt
def fact(n):
    l = int(sqrt(n))
    a = []
    while not n%2:
        a.append(2)
        n //= 2
    for i in range(3,l+1,2):
        while not n%i:
            a.append(i)
            n //= i
    if n != 1:
        a.append(n)
    return Counter(a)


n = int(input())
c = Counter()
mod = 10**9 + 7
ans = 1
for j in range(1,n+1):
    c += fact(j)
for i in list(c.values()):
	ans = ans * (i+1)%mod
print(ans)


Measured memory_bytes: 3316
array = list(map(int, input().split(' ')))

K = int(input())

for i in range(K):
  if array[2] == max(array):
    if array[0] >= array[1]:
      array[1] = array[1] * 2
    else:
      array[2] = array [2] * 2
  else:
    array[2] = array[2] * 2

if array[0] < array[1] and array[1] < array[2]:
  print('Yes')
else:
  print('No')

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

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

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

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

// global variables

int main() {
  ll n,x;cin>>n>>x;
  ll a[n];
  rep(i,n){
    cin>>a[i];
  }

  ll l,r,d;

  ll res=0;
  rep(i, n-1){
    l = a[i];
    r = a[i+1];
    d = (l+r)-x;
    if (d <= 0){
      continue;
    }
    else if (d<=r){
      a[i+1] -= d;
      res += d;
    }
    else if (r<=d){
      a[i+1] = 0;
      a[i] = d-r;
      res += d;
    }
    else {
      assert (1 == 0);
    }
  }

  std::cout << res << std::endl;

  return 0;
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = ReadLine().Split(' ');
            if (ss[0] == "H" && ss[1] == "H" || ss[0] == "D" && ss[1] == "D")
            {
                WriteLine("H");
            }
            else
            {
                WriteLine("D");
            }
        }

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



Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[100000+10];
int main(void) {
  scanf("%s", buf);
  int len = strlen(buf);
  int res = len;
  REP(i, len-1) {
    if(buf[i] != buf[i+1]) {
      res = min(res, max(i+1, len-i-1));
    }
  }
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ls x << 1
#define rs x << 1 | 1
using namespace std;
const int N = 2e5 + 10;
int a[N], qz[N][2];
int mn[N << 2], tag[N << 2];

void down(int x) {
  if(tag[x]) {
    mn[ls] += tag[x];
    tag[ls] += tag[x];
    mn[rs] += tag[x];
    tag[rs] += tag[x];
    tag[x] = 0;
  }
}

void upd(int x, int l, int r, int L, int w) {
  if(l == r) {
    mn[x] = min(mn[x], w);
    return ;
  }
  down(x);
  int mid = (l + r) >> 1;
  if(L <= mid) upd(ls, l, mid, L, w);
  else upd(rs, mid + 1, r, L, w);
  mn[x] = min(mn[ls], mn[rs]);
}

void add(int x, int l, int r, int L, int R, int w) {
  if(L <= l && r <= R) {
    mn[x] += w;
    tag[x] += w;
    return ;
  }
  down(x);
  int mid = (l + r) >> 1;
  if(L <= mid) add(ls, l, mid, L, R, w);
  if(R > mid) add(rs, mid + 1, r, L, R, w);
  mn[x] = min(mn[ls], mn[rs]);
}

int get(int x, int l, int r, int L, int R) {
  if(L <= l && r <= R) {
    return mn[x];
  }
  down(x);
  int mid = (l + r) >> 1;
  if(R <= mid) return get(ls, l, mid, L, R);
  else if(L > mid) return get(rs, mid + 1, r, L, R);
  else {
    return min(get(ls, l, mid, L, R), get(rs, mid + 1, r, L, R));
  }
}

struct data {
  int l, r;
} q[N];

bool cmp(data A, data B) {
  return A.l == B.l ? A.r < B.r : A.l < B.l;
}


int main() {
  memset(mn, 0x3f, sizeof mn);
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    for(int j = 0; j < 2; ++j)
      qz[i][j] = qz[i - 1][j];
    scanf("%d", &a[i]);
    qz[i][a[i]]++;
  }
  upd(1, 0, n, 0, 0);
  int m;
  scanf("%d", &m);
  for(int i = 1; i <= m; ++i) {
    scanf("%d%d", &q[i].l, &q[i].r);
  }
  sort(q + 1, q + 1 + m, cmp);
  int lt = 1;
  for(int i = 1; i <= n; ++i) {
    for(; lt <= m && q[lt].l == i; ++lt)
      upd(1, 0, n, q[lt].r, get(1, 0, n, 0, q[lt].r));
    if(a[i])
      add(1, 0, n, 0, i - 1, 1);
    else 
      add(1, 0, n, 0, i - 1, -1);
  }
  printf("%d\n", get(1, 0, n, 0, n) + qz[n][0]);
  return 0;
}

Measured memory_bytes: 10496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Magatro
{
    static int H, W;
    static string[]A;
    static void Main()
    {
        Read();
        int q=0, w=0;
        AA(ref q, ref w);
        int posx = w, posy = q;
        bool[,] ed = new bool[H, W];
        while (true)
        {
            ed[posy, posx] = true;
            bool sita=false, migi=false;
            if (posy + 1 < H)
            {
                if (A[posy + 1][posx] == '#')
                {
                    if (!ed[posy + 1, posx])
                    {
                        sita = true;
                    }
                }
            }
            if (posx + 1 < W)
            {
                if (A[posy][posx + 1] == '#')
                {
                    if (!ed[posy, posx + 1])
                    {
                        migi = true;
                    }
                }
            }
            if (posx - 1 >= 0)
            {
                if (A[posy][posx - 1] == '#'&&!ed[posy,posx-1])
                {
                    Console.WriteLine("Impossible");
                    return;
                }
            }
            if (posy - 1 >= 0)
            {
                if (A[posy-1][posx] == '#'&&!ed[posy-1, posx])
                {
                    Console.WriteLine("Impossible");
                    return;
                }
            }
            if (sita && migi)
            {
                Console.WriteLine("Impossible");
                return;
            }
            if (sita)
            {
                posy++;
                continue;
            }
            if (migi)
            {
                posx++;
                continue;
            }
            if (!sita && !migi)
            {
                break;
            }
        }
        Console.WriteLine("Possible");
    }
    static void AA(ref int a,ref int b)
    {
        for (a = 0; a < H; a++)
        {
            for (b = 0; b < W; b++)
            {
                if (A[a][b] == '#')
                {
                    return;
                }
            }
        }
    }
    static void Read()
    {
        string[] s = Console.ReadLine().Split(' ');
        H = int.Parse(s[0]);
        W = int.Parse(s[1]);
        A = new string[H];
        for(int i = 0; i < H; i++)
        {
            A[i] = Console.ReadLine();
        }
    }
}


Measured memory_bytes: 2776
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x,int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
		return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
pair<int, int>a[114514]; int q,ans=0;
signed main() {
	int cnt[114514];
	cin >> q;
	for (int i = 0; i < q; i++)cin >> a[i].first>>a[i].second;
	for(int i=1;i<=99999;i+=2){
		if (prime(i) && prime((i + 1) / 2))ans++;
		cnt[i/2] = ans;
	}
	for (int j = 0; j < q; j++) {
		cout << cnt[a[j].second/2] - cnt[(a[j].first - 2)/2] << endl;
	}
	ll
}

Measured memory_bytes: 2560
D = int(input())
C = list(map(int, input().split()))
S = [[] for _ in range(D)]
for i in range(D):
    S[i] = list(map(int, input().split()))
T = [0 for _ in range(D)]
for i in range(D):
    T[i] = int(input())

last = [0 for _ in range(26)]
ans = 0
for i in range(D):
    contest = T[i] - 1
    ans += S[i][contest]
    d = i + 1
    last[contest] = d
    for x in range(26):
        ans -= C[x] * (d - last[x])
    print(ans)

Measured memory_bytes: 68612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    ld ans = 0;
    rep(i, n)
    {
        ld x; string s; cin >> x >> s;
        if (s == "JPY")
        {
            ans += x;
        }
        else
        {
            ans += x * 380000.0;
        }
    }

    cout << fixed << setprecision(5) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int x = 0;
  int N;
  string S;
  cin >> N >> S;
  vector<int> x_vec;
  rep(i,N){
    if(S.at(i) == 'I'){
      x++;
      x_vec.push_back(x);
    }
    if(S.at(i) == 'D'){
      x--;
      x_vec.push_back(x);
    }
  }
  int max_x = 0;
	rep(i,N){
      if(x_vec[i] > max_x){
        max_x = x_vec[i];
      }
    }
  	cout << max_x << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int r(int a){
	if(a%2==0)return -1;
	else return 1;
}

int main(){
	int n,i;
	long long a[100000],ans=0,ans2=0,tmp=0,tmp2=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	for(i=0;i<n;i++){
		tmp+=a[i];
		tmp2+=a[i];
		if(tmp*r(i)<=0){
			ans+=tmp*r(i+1)+1;
			tmp=r(i);
		}
		if(tmp2*r(1+i)<=0){
			ans2+=tmp2*r(i)+1;
			tmp2=r(i+1);
		}
	}
	printf("%lld\n",ans2<ans?ans2:ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
#define pf push_front
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	bool rev = false;
	string s;
	int q;
	cin >> s >> q;
	deque<char> dq;
	for (int i = 0; s[i]; i++) dq.pb(s[i]);
	for (int i = 0; i < q; i++) {
		int t, f;
		char c;
		cin >> t;
		if (t == 1) {
			rev = !rev;
		} else {
			cin >> f >> c;
			if (rev) {
				if (f == 1) dq.pb(c);
				else dq.pf(c);
			} else {
				if (f == 2) dq.pb(c);
				else dq.pf(c);
			}
		}
	}
	if (rev) {
		while (dq.size()) {
			putchar(dq.back());
			dq.pop_back();
		}
	} else {
		while (dq.size()) {
			putchar(dq.front());
			dq.pop_front();
		}
	}
	putchar('\n');
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  bool can=true;
  int t=0,tn;
  int x=0,y=0,xn,yn;
  for(int i=0;i<N;i++){
    cin >> tn >> xn >> yn;
    int man=tn-t-abs(xn-x)-abs(yn-y);
    if(man<0 || man%2==1)can=false;
    t=tn;
    x=xn;
    y=yn;
  }
  if(can)cout << "Yes";
  else cout << "No";
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;

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


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

int ar[3], tmp[6], u;

int main() {
	for (int i = 0; i < 3; i++)
		cin >> ar[i];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++) {
				if (i != j && i != k && j != k) {
					tmp[u] = abs(ar[j] - ar[i]) + abs(ar[k] - ar[j]);
					u++;
				}
			}
	sort(tmp, tmp + 6);
	cout << tmp[0];
}

Measured memory_bytes: 256
s = int(input())
a = []
a.append(s)
for s in a:
    if s%2 == 0:
        if s/2 in a:
            print(len(a)+1)
            exit()
        else:
            a.append(s/2)
    else:
        if 3*s+1 in a:
            print(len(a)+1)
            exit()
        else:
            a.append(3*s+1)
    

Measured memory_bytes: 3060
inf = (1 << 31) - 1

# 一点更新　区間取得　1-indexed
class SegmentTree:
    def __init__(self, n):
        tmp = 1
        while tmp < n:
            tmp <<= 1
        # self.N : 完全二分木の葉の数(N以上の最小の2べき)
        self.N = tmp
        # 2*self.N - 1 : 完全二分木のノード数
        # 1-indexedで管理するので１つ余分に設ける
        self.Data = [inf for _ in range(2*self.N)]

    # k (0-indexed)
    def update(self, k, x):
        #　インデックスを補正
        k += self.N
        # 指定ノードを更新
        self.Data[k] = x
        # kを含む区間ノードを更新していく
        while k != 1:
            k >>= 1
            self.Data[k] = min([self.Data[2*k], self.Data[2*k+1]])

    # [l, r) (0-indexed)
    def query(self, l, r):
        #　インデックスを補正
        l += self.N
        r += self.N
        # 返り値を初期化
        res = inf
        while l < r:
            # 右側なら右側を更新 右上に行く
            # 左側なら更新しない　上に行く
            if l & 1:
                res = min([res, self. Data[l]])
                l += 1
            # 右側なら左側を更新　上に行く
            # 左側なら更新しない 上に行く
            if r & 1:
                r -= 1
                res = min([res, self.Data[r]])
            l >>= 1; r >>= 1
        return res

N, Q = map(int,input().split())
st = SegmentTree(N)

for _ in range(Q):
    com, x, y = map(int,input().split())
    if com == 0:
        st.update(x, y)
    elif com == 1:
        y += 1
        print(st.query(x, y))


Measured memory_bytes: 9012
# def c():
#     n = int(input())
#     inp = {}
#     for i in range(n):
#         a = input()
#         if inp.get(a) is None:
#             inp[a] = 0
#         inp[a] += 1
#     print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
#     print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
#     print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
#     print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

# c()


h, w, k = [int(x) for x in input().split()]
ans = 0

grid = []

for i in range(h):
    grid.append(list(input()))

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1

print(ans)

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

typedef vector<vector<ll> > mat;

//行列累乗
// mat は vector<vectorのこと

// A*B　の　計算
mat mul( mat &A, mat &B){
 mat  C(A.size(), vector<ll>(B[0].size()));
 for(ll i = 0; i < A.size(); i++){
   for(ll k = 0; k < B.size(); k++){
     for(ll j = 0; j < B[0].size();j++){
       C[i][j] = (C[i][j]+A[i][k]*B[k][j]);
     }
   }
 }
return C;
}

// A^nの計算

mat pow(mat A, ll n){
  mat B(A.size(), vector<ll>(A.size()));
  
  for(int i = 0; i < A.size(); i++){
    B[i][i] = 1;}
 
  while( n > 0){
    if( n & 1){  
      B = mul(B,A);}
      A = mul(A,A);
      n >>= 1;
    }
    
    return B;
  }
  
  ll N;
  
int main(){
  cin >> N;
 
  mat A(2,vector<ll>(2));
  A[0][0] = 1LL; A[0][1] = 1LL; A[1][0] = 1LL; A[1][1] = 0LL;
  cout << pow(A,N+1)[1][0] << endl; return 0;}
  


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    int ans = INF;
    int tmp = 0;
    REP(i, N) tmp += A[i];
    ans = min(ans, tmp);
    tmp = 0;
    REP(i, N) tmp += B[i];
    ans = min(ans, tmp);

    vector<Pii> p(2 * N);
    REP(i, N){
        p[2 * i] = Pii(A[i], i);
        p[2 * i + 1] = Pii(B[i], i);
    }
    SORT(p);
    tmp = 0;
    vector<bool> used(N, false);
    bool f = false;
    REP(i, N){
        tmp += p[i].first;
        if(used[p[i].second]) f = true;
        used[p[i].second] = true;
    }
    if(!f){
        if(p[N].second != p[N - 1].second) tmp += p[N].first - p[N - 1].first;
        else tmp += min(p[N + 1].first - p[N - 1].first, p[N].first - p[N - 2].first);
    }
    ans = min(ans, tmp);
    cout << ans;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 4992
use List::Util 'min';
use List::Util 'max';

chomp($n = <>);
@s = split(/ /, <>);

$cnt = 0;
for $i (1 .. $n - 2){
	$cnt++ if((min($s[$i - 1], $s[$i + 1]) < $s[$i]) and ($s[$i] < max($s[$i - 1],$s[$i + 1])));
}

print "$cnt\n";



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const lli INF = 1e18L + 5;
vector<vector<int>> adj;
vector<int> dis;

int dfs(int u)
{

    if (adj[u].size() == 0)
        dis[u] = 0;
    if (dis[u] != -1)
        return dis[u];

    for (auto v : adj[u])
    {
        dis[u] = max(dis[u], dfs(v) + 1);
    }

    return dis[u];
}

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



    int n, m;
    cin >> n >> m;
    adj = vector<vector<int>>(n);
    dis = vector<int>(n, -1);
    for (int i = 0; i < m; ++i)
    {
        int x, y;
        cin >> x >> y, --x, --y;
        adj[x].push_back(y);
    }
    // for(int i = 0 ; i < n ; ++i){
    //     for(int j = 0 ; j < adj[i].size(); ++j){
    //         cout << adj[i][j] + 1 << " ";
    //     }
    //     cout << endl;
    // }
    for (int i = 0; i < n; ++i)
        dfs(i);
    int maxLen = 0;
    for (auto it : dis)
    {
        maxLen = max(maxLen, it);
        // cout << it << " ";
    }
    cout << maxLen << endl;

    return 0;
}

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

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

    int n;
    cin >> n;
    int cnt_4 = n / 4;
    for (int i = 0; i <= cnt_4; ++i) {
        if ((n - 4 * i) % 7 == 0) {
            cout << "Yes" << '\n';
            return 0;
        }
    }

    cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int a,b;
int main(){
    cin>>a>>b;
    if((a*b)%2==0)cout<<"No\n";
    else cout<<"Yes\n";


}



Measured memory_bytes: 256
import numpy as np

N = int(input())
S = [list(input()) for _ in range(N)]
S = np.array(S, dtype=object)

S = np.concatenate([S, S])
ans = 0
for B in range(N):
    T = S[B:B+N]
    if (T == T.T).all():
        ans += N
print(ans)

Measured memory_bytes: 16008
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

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

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, k, a, b, fact[MAXN], inv[MAXN];

ll C(ll r, ll n) {
    if (r > n || r < 0) return 0;
    return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

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

    fact[0] = 1;
    //for(ll i = 1 ; i < MAXN ; i++)  fact[i] = fact[i - 1] * i % MOD;
    //for(ll i = 0 ; i < MAXN ; i++)  inv[i] = poww(fact[i] , MOD - 2 , MOD);

    cin >> n >> a >> b;
    ll ans = poww(2, n, MOD) - 1, A = 1, B = 1;
    for (ll i = 0; i < a; i++) A = A * (n - i) % MOD * poww(i + 1, MOD - 2, MOD) % MOD;
    for (ll i = 0; i < b; i++) B = B * (n - i) % MOD * poww(i + 1, MOD - 2, MOD) % MOD;
    cout << (ans - A - B + MOD * 10) % MOD;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h> // double fmod(double x, double y);
 using namespace std;


 int main()
 {
   int a,b;
   cin >> a >> b;

   {
     long long k;
     k = (a + b);
     if(fmod(k, 2) == 0)
     {
       cout << k/2 << endl;
     }
     else
     {
       cout << "IMPOSSIBLE" << endl;
     }
   }
 }



Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

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


ll dp[(1<<12)+10];

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    rep(i, (1<<12)+10) dp[i] = 1e18;
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    LINE;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        int mask = 0;
        rep(j, b) {
            int c;
            cin >> c;
            mask |= (1<<(c-1));
        }
        dp[mask] = min(dp[mask], a);
    }
    dp[0] = 0;
    rep(mask, 1<<n) {
        rep(mask2,1<<n) {
            chmin(dp[mask|mask2], dp[mask] + dp[mask2]);
        }
    }
    ll ans = dp[(1<<n)-1];
    cout << (ans == 1e18?-1:ans) << '\n';
    // rep(i, 1<<n) {
    //     cout << bitset<5>(i) << " " << dp[i] << endl;
    // }
    return 0;
}

Measured memory_bytes: 256
// Problem : B - Golden Coins
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define vl vector<ll>


/*#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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...);
}*/


//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

using namespace __gnu_pbds;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

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


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n;
	x=n/500*1000;
	y=(n%500)/5*5;
	cout<<x+y;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int64_t MOD = 1e9 + 7;

int N, M;

vector<vector<vector<int64_t>>> DP(2, vector<vector<int64_t>>(3001, vector<int64_t>(3001, -1)));

int64_t f(bool bottle, int r, int steps) {
	if (steps == 0)
		return bottle;
	int64_t &ans = DP[bottle][r][steps];
	if (ans != -1)
		return ans;
	ans = 0;
	if (r > 0) {
		ans += f(bottle || r == 1, r - 1, steps - 1);
		ans += f(bottle || r == 1, r, steps - 1);
	}
	if (r < N) {
		ans += f(bottle || r == 0, r, steps - 1);
		ans += f(bottle || r == 0, r+1, steps - 1);
	}
	ans %= MOD;
	return ans;
}

int main() {
	cin >> N >> M;
	int64_t ways = 0;
	for (int r = 0; r <= N; ++r) {
		ways += f(0, r, M);
		ways %= MOD;
	}
	cout << ways << endl;
	cin >> ws;
}

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

int main(void){
	bool t[3] = {true,false,false};
	char x,y,ch;

	while(cin>>x>>ch>>y){
		int idxX = x - 'A';
		int idxY = y - 'A';
		swap(t[idxX],t[idxY]);
	}
	if(t[0]) cout<<"A\n";
	if(t[1]) cout<<"B\n";
	if(t[2]) cout<<"C\n";

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int B[M];
    for(int i=0;i<M;i++)cin >> B[i];
    int A[N][M];
    int tmp;
    int ans=0;
    for(int i=0;i<N;i++){
        tmp=C;
        for(int j=0;j<M;j++){
            cin >> A[i][j];
            tmp += A[i][j]*B[j];
        }
    if(tmp>0)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,a,b,c;
    scanf("%d",&n);
    a = n/100;
    n = n%100;
    b = n/10;
    c = n%10;

    if(a==7 || b==7 || c==7)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    
    if(a+b>c){
      System.out.println("No");
      return;
    }
    
    if(4*a*b < (c-a-b)*(c-a-b)) System.out.println("Yes");
    else System.out.println("No");

  }
}

Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;

int t, b, u, d, l, r;
int main() {
    int a, b;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b << endl;
    }else{
        cout << b-a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4+5;
const int mod = 1e9+7;
typedef long long ll;
int memo[maxn][100],M;
int solve(int pos,int rem){
    if (!pos&& !rem)return 1;
    if (!pos)return 0;
    int &ans = memo[pos][rem];
    if (ans != -1)return ans;
    ans =0;
    for(int i = 0; i < 10;i++)
        ans = (ans+solve(pos-1,(rem+i) % M)) % mod;
    return ans;
}
int solve(string s){
    int sol =0;
    int rem =0;
    int len = s.size();
    for (int i =0; i < len;i++){
        int d = s[i]-'0';
        for (int j=0; j < d;j++){
            sol = (sol+solve(len-i-1,(rem+j) % M)) % mod;
        }
        rem = (rem+d)% M;
    }
    if (!rem)sol = (sol+1)% mod;
    return sol;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(".in","r",stdin);
    string s;
    cin >> s >> M;
    memset(memo,-1,sizeof memo);
    cout << (solve(s)-1+mod) % mod;
    return 0;
}


Measured memory_bytes: 4864
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    Sum = sum(A)
    NN = N*(N+1)//2
    if Sum%NN != 0:
        return False
    k = Sum//NN
    cnt = 0
    for i in range(N):
        a = A[i]-A[i-1]
        if (k-a)%N != 0:
            return False
        cnt += (k-a)//N 
        if cnt > k:
            return False
    if cnt != k:
        return False
    for i in range(N):
        if A[i]<k:
            return False
    return True
if solve():
    print('YES')
else:
    print('NO')

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B;
    cin >> A >> B;

    if (A >= 10 || B >= 10) {
        cout << -1 << endl;
    } else {
        cout << A*B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
snacks = [0] * n
for i in range(k):
    d = int(input())
    a = map(int, input().split())
    for item in a:
        snacks[item-1] += 1

ans = 0
for i in range(n):
    if snacks[i] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 67576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k,mx,c[101],cnt=0;
  cin >> a >> b >> k;
  mx = min(a,b);
  for(int i=1;i<=mx;i++){
    if(a % i == 0 && b % i == 0){
      c[cnt++] = i;
    }
  }
  //for(int i=0;i<cnt;i++)cout << c[i] <<" ";
  cout << c[cnt - (k)] <<endl;
  return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = 0x1fffffffffffffff;
int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    string a;
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            for(ll k=0;k<10;k++){
              a=to_string(i*100+j*10+k);
              if(i==0){
                if(j==0)a="00"+a;
                else a="0"+a;
              }
              //cout<<a<<" "<<i<<j<<k<<endl;
                bool a1,a2,a3;
                a1=a2=false;
                for(ll i=0;i<n;i++){
                    if(!a1){
                        if(s[i]==a[0])a1=true;
                    }else{
                        if(!a2){
                            if(s[i]==a[1])a2=true;
                        }else{
                            if(s[i]==a[2]){
                                a3=true;
                                ans++;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256