akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x;
  x=nil->next;
  while (x!=nil && x->key!=key){
    x=x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next=t->next;
  t->next->prev=t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t=nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t;
  if((t=(listSearch(key)))!=NULL){
    if ( t == nil ) return;
    deleteNode(t);
  }
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 36040
#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>;

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


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a, b;
  cin >> a >> b;
  if(a=='H' && b=='H')cout << 'H';
  if(a=='H' && b=='D') cout << 'D';
  if(a=='D' && b=='H')cout<<'D';
  if(a=='D' && b=='D') cout<<'H';
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
S = [list(input()) for _ in range(N)]

edge = [[] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if S[i][j]=='1':
            edge[i].append(j)

ans = 0
import queue
for i in range(N):
    q = queue.Queue()
    q.put(i)
    nums = [-1]*N
    nums[i] = 1
    while not q.empty():
        v = q.get()
        flag = True
        for nv in edge[v]:
            if nums[nv] == -1:
                nums[nv] = nums[v] + 1
                q.put(nv)
            elif nums[nv]%2 != (nums[v]+1)%2:
                flag = False
                break
        if not flag:
            break
    if flag:
        ans = max(ans, max(nums))
print(ans) if ans != 0 else print(-1)

Measured memory_bytes: 49128
n = int(input())
a = list(map(int, input().split()))
x = ["*"]*n
x[0] = sum(a[::2])-sum(a)//2

for i in range(1,n):
    x[i] = a[i-1]-x[i-1]

for i in range(n):
    x[i] = str(2*x[i])

print(" ".join(x))


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

vector<vector<int>> makem(string s){
    vector<string> ss;
    string t="";
    for(int i=0;i<s.size();i++){
        if(s[i]=='/'){
            ss.push_back(t);
            t="";
            continue;
        }
        t+=s[i];
    }
    ss.push_back(t);
    int w=0;
    for(int i=0;i<ss[0].size();i++){
        if(ss[0][i]=='b'){
            w++;
        }else{
            w+=ss[0][i]-'0';
        }
    }
    int h=ss.size();
    vector<vector<int>> m(h,vector<int>(w,0));
    for(int i=0;i<h;i++){
        int mid=0;
        int sid=0;
        while(mid<w){
            if(ss[i][sid]=='b'){
                m[i][mid]=1;
                mid++;
            }else{
                mid+=ss[i][sid]-'0';
            }
            sid++;
        }
    }
    return m;
}

string enco(vector<vector<int>> m){
    vector<string> row(m.size(),"");
    for(int i=0;i<m.size();i++){
        int cnt=0;
        for(int j=0;j<m[i].size();j++){
            if(m[i][j]==0){
                cnt++;
            }else{
                if(cnt!=0){
                    row[i]+=to_string(cnt);
                    cnt=0;
                }
                row[i]+="b";
            }
            if(j==(int)m[i].size()-1&&cnt!=0){
                row[i]+=to_string(cnt);
            }
        }
    }
    string ans="";
    for(int i=0;i<(int)m.size()-1;i++){
        ans+=row[i]+"/";
    }ans+=row.back();
    return ans;
}

int main(){

    while(1){
        string s;
        cin >> s;
        if(s=="#")break;
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;c--;d--;
        vector<vector<int>> m;
        m=makem(s);
        m[a][b]=0;
        m[c][d]=1;
        string ans=enco(m);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3212
abc = gets.split.map(&:to_i)
i = 0
results = []
def change_abc(abc)
  a = abc[0]
  b = abc[1]
  c = abc[2]
  n = []
  n[0] = (b + c) / 2
  n[1] = (a + c) / 2
  n[2] = (b + a) / 2
  return n
end
while !abc.any?(&:odd?)
  if results.include?(abc)
    i = -1
    break
  end
  results << abc
  i += 1
  abc = change_abc(abc)
  break if i == 30
end
print i


Measured memory_bytes: 1788
a,b,c,d,e,f=map(int,input().split())
ans=0
s=0
t=0
for i in range(f//100+1):
    w=(f-100*a*i)//100
    for j in range(w+1):
        if i==0 and j==0:
            continue
        x=a*i+b*j
        for k in range(x*e//c+1):
            v=(x*e-c*k)//d
            for l in range(v+1):
                y=c*k+d*l
                if 100*x+y <=f:
                    p=100*y/(100*x+y)
                    if ans<=p:
                        s=100*x+y
                        t=y
                        ans=p
print(s,t)

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

int main(){
    int a,b;
    cin >> a >> b;
    int i,j,m,r,count = 0,sum = 0;
    int v[a][b];
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cin >> v[i][j];
        }
    }
    for(i=0;i<a;i++){
        for(m=0;m<a;m++){
            if(i<m){
            sum=0;
            for(j=0;j<b;j++){
                sum+=(v[i][j]-v[m][j])*(v[i][j]-v[m][j]);
            }
            for(r=1;r<20000;r++){
                    if(sum==r*r){
                        count++;
                        break;
                    }
                }
        }
    }
        }
    cout << count << endl;
}



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

typedef unsigned long long ull;

int dp[5001][5001];

int path(int x , int y){
  ull ret;
  if(dp[x][y] != 0){
    ret = dp[x][y];
  } else {
    if(x == 0 || y == 0) ret = 1;
    else ret = path(x - 1, y) + path(x, y - 1);
    ret %= 100000007;
    dp[x][y] = ret;
  }
  return ret;
}

int mod(int n , int a){
  int rtn = n%a;
  return n >= 0 ? rtn : (a + rtn)%a;
}

int main(){
  memset(dp,0,sizeof(dp));
  int r,c,a1,a2,b1,b2;
  cin >> r>>c>>a1>>a2>>b1>>b2;
  int dx1 = mod(a1 - b1, r);
  int dx2 = mod(-dx1, r);
  int dy1 = mod(a2 - b2, c);
  int dy2 = mod(-dy1, c);
  int dx = min(dx1,dx2);
  int dy = min(dy1,dy2);
  int rtn = path(dx , dy);
  if(dx1 == dx2 && a1 != b1) rtn = rtn * 2 % 100000007;
  if(dy1 == dy2 && a2 != b2) rtn = rtn * 2 % 100000007;

  cout << rtn << endl;
  return 0;
}

Measured memory_bytes: 98908
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

struct mi {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  mi(int v=0) : val(v) { if ((val %= MOD) < 0) val += MOD; }
  mi& operator += (const mi& b) { (val += b.val) %= MOD; return *this; }
  mi& operator -= (const mi& b) { return (*this) += MOD-b.val; }
  mi& operator *= (const mi& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
  mi& operator /= (const mi& b) { return (*this) *= b.pow(MOD-2); }
#define _op(op, op2) mi operator op (const mi& b) const { mi ans = *this; return ans op2 b; }
  _op(+, +=); _op(-, -=); _op(*, *=); _op(/, /=);
#undef _op
  mi pow(ll e) const { mi res(1), b(*this); for (; e>0; e/=2, b*=b) { if (e&1) res*=b; } return res; }
  int toInt() const { return val; }
};

struct bm {
  int v; bm(int val=0) : v(val) {}
  bool operator[](int i) const { return v & 1 << i; }
  bm set(int i) const { return bm(v | 1 << i); }
};

const int N = 22;
bool a[N][N];
mi dp[N][1 << N];
bool vis[N][1 << N];
int n;

mi solve(int i, bm mask) {
  if (i == n) return 1;
  if (!vis[i][mask.v]) {
    for (int j = 0; j < n; ++j) {
      if (a[i][j] && mask[j] == 0) {
        dp[i][mask.v] += solve(i+1, mask.set(j));
      }
    }
    vis[i][mask.v] = 1;
  }
  return dp[i][mask.v];
}

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  cout << solve(0, 0).toInt() << nl;

  return 0;
}



Measured memory_bytes: 428288
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


ans = B[0]
for i in range(1,N):
    ans += B[i]
    if A[i] == A[i-1] + 1:
        ans += C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    int x,y;
    cin>>n>>m>>x>>y;
    int a[n],b[m];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int k=0;k<m;k++){
        cin>>b[k];
    }
    a[n]=x;
    b[m]=y;
    sort(a,a+n+1);
    sort(b,b+m+1);
    if(a[n]>=b[0]){
        cout<<"War"<<endl;
    }
    else cout<<"No War"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

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

    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
        cout << s << endl;
    else
        cout << s.substr(0, k) << "..." << endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
unsigned int a,b,d,r;
double f;
 cin >> a >> b;
d=a/b;
r=a%b;
 f=((double)a)/b;
 printf("%d %d %.6f\n",d,r,f);
return 0;
}

Measured memory_bytes: 1192
l=1
for W in iter(input,'0'):
 W=int(W)
 D=[0,0]*W
 for p in[0]*int(input()):
  v,w=map(int,input().split(','))
  for i in range(W,w-1,-1):D[i]=max(D[i],D[i-w]+v)
 print(f'Case {l}:\n{D[W]}\n{D.index(D[W])}')
 l+=1


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

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

  if (a < b) {
    for (ll i = 0; i < b; i++) {
      cout << a;
    }
  } else {
    for (ll i = 0; i < a; i++) {
      cout << b;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias NN = Tuple!(int, int);

NN[10] MSS = [
    NN(0, int.max),
    NN(1, 2),
    NN(2, 5),
    NN(3, 5),
    NN(4, 4),
    NN(5, 5),
    NN(6, 6),
    NN(7, 3),
    NN(8, 7),
    NN(9, 6)
];

int[10^^4+1] MEMO;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    auto as = readln.split.to!(int[]);

    NN[] ms;
    foreach (a; as) ms ~= MSS[a];
    sort!"a[1] == b[1] ? a[0] > b[0] : a[1] < b[1]"(ms);

    bool[int] nn;
    NN[] MS;
    foreach (m; ms) {
        if (m[1] !in nn) {
            nn[m[1]] = true;
            MS ~= m;
        }
    }
    sort!"a[0] > b[0]"(MS);

    int solve(int n) {
        if (!n) return 0;
        if (MEMO[n]) return MEMO[n];
        auto r = int.min;
        foreach (m; MS) if (n - m[1] >= 0) {
            r = max(r, solve(n - m[1]) + 1);
        }
        return MEMO[n] = r;
    }

    auto k = solve(N);
    foreach (_; 0..k+1) {
        foreach (m; MS) {
            if (N - m[1] >= 0 && MEMO[N] == MEMO[N - m[1]] + 1) {
                N -= m[1];
                write(m[0]);
                break;
            }
        }
    }
    writeln("");
}

Measured memory_bytes: 380
N=int(input())
A=list(map(int,input().split()))
F=0
T=0
for i in A:
    if i%4==0:
        F+=1
    elif i%2==0:
        T+=1
    else:
        continue
if(N%2==0):
    if(F*2+T)>=N:
        print("Yes")
    else:
        print("No")
else:
    if(F*2+1+T)>=N:
        print("Yes")
    else:
        print("No")


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

namespace AOJ0058
{
    class Program
    {
        private const double Epsilon = 0.00000001;

        static void Main()
        {
            foreach(var data in ReadInputs())
            {
                var pA = new Point(data[0], data[1]);
                var pB = new Point(data[2], data[3]);
                var pC = new Point(data[4], data[5]);
                var pD = new Point(data[6], data[7]);
                // ReSharper disable InconsistentNaming
                var vAB = new Vector(pA, pB);
                var vCD = new Vector(pC, pD);
                // ReSharper restore InconsistentNaming
                Console.WriteLine(Math.Abs(vAB * vCD) < Epsilon ? "YES" : "NO");
            }
        }

        public static IEnumerable<double[]> ReadInputs()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                yield return line.Split(' ').Select(double.Parse).ToArray();
            }
        }
    }

    public class Point
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Z { get; set; }

        public Point(double x = 0, double y = 0, double z = 0)
        {
            X = x;
            Y = y;
            Z = z;
        }
    }

    public class Vector
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Z { get; set; }

        public Vector(double x = 0, double y = 0, double z = 0)
        {
            X = x;
            Y = y;
            Z = z;
        }

        public Vector(Point p1, Point p2)
            : this(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z)
        {
        }

        public Vector Cross(Vector other)
        {
            var x = Y * other.Z - Z * other.Y;
            var y = Z * other.X - X * other.Z;
            var z = X * other.Y - Y * other.X;

            return new Vector(x, y, z);
        }

        public static double operator *(Vector v1, Vector v2)
        {
            return v1.X*v2.X + v1.Y*v2.Y + v1.Z*v2.Z;
        }

        public static Vector operator *(Vector v, double a)
        {
            return new Vector(a*v.X, a*v.Y, a*v.Z);
        }

        public static Vector operator *(double a, Vector v)
        {
            return v*a;
        }
    }
}

Measured memory_bytes: 6112
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> // 

using namespace std;
using ll = long long;

ll dfs(ll x) {
    if (x <= 1) return x;
    return dfs(x / 2) * 2 + 1;
}


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

    ll H;
    cin >> H;
    ll res = dfs(H);
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
ll INF = 1e18;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int main(){
    ll N; cin >> N;
    ll a[N],b[N],c[N];
    for(ll i = 0; i < N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    ll dp[100100][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(ll i = 1; i < N; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    ll ans = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
    cout << ans << endl;
}


Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
A,B,Q = map(int,input().split())
S = []
for i in range(A):
  temp = int(input())
  S.append(temp)
#S.sort()
T = []
for i in range(B):
  temp = int(input())
  T.append(temp)
#T.sort()
#print(S,T)

def jinja(x): #移動距離、神社の位置を出力
  if x <= S[0]:
    ret = [S[0]-x,0]
  elif x >= S[-1]:
    ret = [x-S[-1],A-1]
  else:
    ok = 0
    ng = A
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - S[ok],ok,S[ng] - x,ng]
  return ret

def tera(x): #移動距離、神社の位置を出力
  if x <= T[0]:
    ret = [T[0]-x,0]
  elif x >= T[-1]:
    ret = [x-T[-1],B-1]
  else:
    ok = 0
    ng = B
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - T[ok],ok,T[ng] - x,ng]
  return ret
      

#P = tera(100)
#print(P)
for i in range(Q):
  INPUT = int(input())
  j = jinja(INPUT)
  #print(j)
  if len(j) == 2:
    x = j[0]; loc = S[j[1]]
    jt = tera(loc)
    if len(jt) == 2:
      x += jt[0]
    else:
      x += min(jt[0],jt[2])
  else:
    x1 = j[0]; loc1 = S[j[1]]; x2 = j[2]; loc2 = S[j[3]]
    jt1 = tera(loc1); jt2 = tera(loc2)
    if len(jt1) == 2:
      x1 += jt1[0]
    else:
      x1 += min(jt1[0],jt1[2])
    if len(jt2) == 2:
      x2 += jt2[0]
    else:
      x2 += min(jt2[0],jt2[2])
    x = min(x1, x2)
  t = tera(INPUT)
  #print(t)
  if len(t) == 2:
    y = t[0]; loc = T[t[1]]
    tj = jinja(loc)
    #print(y,loc,tj)
    if len(tj) == 2:
      y += tj[0]
    else:
      y += min(tj[0],tj[2])
  else:
    y1 = t[0]; loc1 = T[t[1]]; y2 = t[2]; loc2 = T[t[3]]
    tj1 = jinja(loc1); tj2 = jinja(loc2)
    if len(tj1) == 2:
      y1 += tj1[0]
    else:
      y1 += min(tj1[0],tj1[2])
    if len(tj2) == 2:
      y2 += tj2[0]
    else:
      y2 += min(tj2[0],tj2[2])
    y = min(y1, y2)
  #print(x,y)
  print(min(x,y))

Measured memory_bytes: 146368
#include<bits/stdc++.h>
using namespace std;
 int main()
{
	int a[100+5];
	memset(a,0,sizeof(a));
	int n,sum=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for (int j=1;j<=n;j++){
		if (a[j] % 2==1)  sum++;
		j++;
	}
	printf("%d",sum);
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	int n, m; std::cin >> n >> m;
	std::vector<std::vector<int>> nails; nails.reserve(n);
	for (auto i = 0; i < n; ++i) {
		nails.emplace_back(n - i, 0);
	}
	for (auto i = 0; i < m; ++i) {
		int a, b, x; std::cin >> a >> b >> x;
		nails[a - b][b - 1] = std::max(nails[a - b][b - 1], x + 1);
	}
	for (auto i = 1; i < n; ++i) {
		nails[i][0] = std::max(nails[i][0], nails[i - 1][0] - 1);
		nails[0][i] = std::max(nails[0][i], nails[0][i - 1] - 1);
	}
	for (auto i = 1; i < n; ++i) {
		for (auto j = 1; j < n - i; ++j) {
			nails[i][j] = std::max({ nails[i][j], nails[i][j - 1] - 1, nails[i - 1][j] - 1 });
		}
	}
	int count = 0;
	for (const auto& line : nails) count += std::count_if(line.begin(), line.end(), [](const int i) {return i > 0; });
	std::cout << count << std::endl;
}








Measured memory_bytes: 51948
#include<iostream>
#define DIM 10005
using namespace std;
int n, k, i, j, ok;
char s[DIM], a[DIM], sol[5005], minim;
void solve(){
    int i, ii, st, ok, nr;
    nr = 1;
    while(a[n - nr] == minim){
        nr++;
    }
    for(ii = 1; ii < k; ii++){
        for(i = 1; i <= n; i++){
            a[2 * n - i + 1] = a[i];
        }
        if(ii != k - 1){
            st = nr + 1;
        }
        else{
            st = n - nr + 1;
        }
        for(i = st; i < st + n; i++){
            a[i - st + 1] = a[i];
        }
        nr *= 2;
        if(nr >= n){
            for(i = 1; i <= n; i++){
                sol[i] = minim;
            }
            break;
        }
    }
    ok = 0;
    for(i = 1; i <= n; i++){
        if(a[i] != sol[i]){
            if(a[i] < sol[i]){
                ok = 1;
            }
            break;
        }
    }
    if(ok == 1){
        for(i = 1; i <= n; i++){
            sol[i] = a[i];
        }
    }
}
int main(){
    cin>> n >> k;
    cin>> s + 1;
    minim = 'z';
    for(i = 1; i <= n; i++){
        minim = min(minim, s[i]);
    }
    if(k > 20 || (1 << (k - 1) ) >= n){
        for(i = 1; i <= n; i++){
            cout<< minim;
        }
        return 0;
    }
    for(i = 1; i <= n; i++){
        sol[i] = 'z';
        s[n + n - i + 1] = s[i];
    }
    if(k == 1){
        for(i = n; i <= 2 * n; i++){
            for(j = i - n + 1; j <= i; j++){
                a[j - i + n] = s[j];
            }
            ok = 0;
            for(j = 1; j <= n; j++){
                if(a[j] != sol[j]){
                    if(a[j] < sol[j]){
                        ok = 1;
                    }
                    break;
                }
            }
            if(ok == 1){
                for(j = 1; j <= n; j++){
                    sol[j] = a[j];
                }
            }
        }
        cout<< sol + 1;
        return 0;
    }
    for(i = n; i <= 2 * n; i++){
        if(s[i] == minim){
            for(j = i - n + 1; j <= i; j++){
                a[j - i + n] = s[j];
            }
            solve();
        }
    }
    cout<< sol + 1;
}


Measured memory_bytes: 384
n,m = input().split()
n = int(n)
m = int(m)
mat = []
for i in range(n):
  mat.append([])
  for j in range(n):
    mat[-1].append(False)

for i in range(m):
  a,b = input().split()
  mat[int(a)-1][int(b)-1] = True
  mat[int(b)-1][int(a)-1] = True

def count(ar, s):
  if len(ar) == 1:
    return 1 if mat[s][ar[0]] else 0
  num = 0
  for s_next in ar:
    if mat[s][s_next]:
      num += count([x for x in ar if x != s_next], s_next)
  return num

total = 0
for i in range(n):
  ar = [j for j in range(n) if j != i]
  total += count(ar, i)
  break
print(total)



Measured memory_bytes: 3064
def main():
    n, x, y = list(map(int, input().split()))
    l = lambda i, j: min(abs(i - j), abs(i - x) + 1 + abs(y - j), abs(i - y) + 1 + abs(x - j)) - 1
    ans = [0] * (n - 1)
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            ans[l(i, j)] += 1
    [print(a) for a in ans]

if __name__ == '__main__':
    main()


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


int main()
{
	ll n,m,a,sum=0,cnt=0;
	cin>>n>>m;
	ll arr[n+10]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a;
		sum+=a;
		arr[i]=a;
	}
	for(int i=0;i<n;i++)
	{
		if(arr[i]>=((sum*1.0l)/(4*m)))cnt++;
	}
	if(cnt<m)cout<<"No\n";
	else cout<<"Yes\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,i,v,j,k;
  int A[1000];

  scanf("%d",&N);

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

  for(k=0; k < N; k++){
    printf("%d",A[k]);
    if(k < N-1){
      printf(" ");
    }
  }
  printf("\n");

  for(i=1; i < N; i++){
    v = A[i];
    j = i - 1;

    while(1){
      if(j >= 0 && A[j] > v){
	A[j+1] = A[j];
	j--;
	A[j+1] = v;
      } else {	
	break;
      }
    }
    
    for(k=0; k < N; k++){
      printf("%d",A[k]);
      if(k < N-1){
      printf(" ");
      }
    }
    printf("\n");
    
  }
}



Measured memory_bytes: 2084
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int A;
    set<int> st;
    rep(i, 3) {
        cin >> A;
        st.insert(A);
    }
    if (st.size() == 2) cout << "Yes\n";
    else cout << "No\n";
}

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


int main()
{
 long long  int H;
  cin>>H;
  
 long long int cur=1;
 long long int ans=0;
  while(H)
  {
    H=floor(H/2);
    ans=ans+cur;
    cur=cur*2;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = (1LL<<31)-1;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,ll)> P;
  ll n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(ll n_,F f,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>(),P p=[](E a,ll b){return a;}):
    f(f),g(g),h(h),d1(d1),d0(d0),p(p){
    init(n_);
    if(n_==(ll)v.size()) build(n_,v);
  }
  void init(ll n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(ll n_, vector<T> v){
    for(ll i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(ll i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(ll len,ll k){
    if(laz[k]==d0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=d0;
  }
  T update(ll a,ll b,E x,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(ll a,ll b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(ll a,ll b,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(ll a,ll b){
    return query(a,b,0,0,n);
  }
};
auto F = [](ll a, ll b) { return a + b; };
auto G=[](ll a, ll b) { return b == INF ? a : b; };
auto H = G;
SegmentTree<ll, ll> seg(MAX_N, F, G, H, 0, INF, vl(MAX_N, 0),multiplies<ll>());
int main() { cin >> n >> q; 
while(q--){
    cin >> x;
    if(x==0){
        cin >> a >> b >> c;
        seg.update(a, b + 1, c);
    }
    else{
        cin >> a >> b;
        cout << seg.query(a, b + 1)<<endl;
    }
}}




Measured memory_bytes: 27024
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double l = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
	cout << fixed << std::setprecision(6);
	cout << l << endl;
	return 0;
}



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

  cin >> s;
  
  int S = 0;

  for(int i=0;i<s.length();i++){
      S = (S+(int)(s[i]-'0'))%9;
  }
  
  if(S==0){
      printf("Yes\n");
  }else{
      printf("No\n");
  }

  return 0;
}

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

using namespace std;

//Single Source Shortest Path1:https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_A
//Bellman-Ford法で解く

const int inf = -1;

int main(){
    int V,E,r,s,t,d;
    bool update;
    cin >> V >> E >> r;
    vector<int> a(3,0), Score(V,inf);
    vector<vector<int> > Edges(E,a);
    for(int i = 0; i < E;i++){
        cin >> Edges[i][0] >> Edges[i][1] >> Edges[i][2];
    }
    Score[r] = 0;
    for(int i = 0;i < V-1;i++){
        update = false;
        for(int k = 0;k < E;k++){
            if(Score[Edges[k][0]] != -1){
                if(Score[Edges[k][1]] > Score[Edges[k][0]] + Edges[k][2] || Score[Edges[k][1]] == -1){
                    Score[Edges[k][1]] = Score[Edges[k][0]] + Edges[k][2];
                    update = true;
                }
            }
        }
        if(!update)break;
    }
    for(int i = 0;i < V;i++){
        if(Score[i] == -1){
            cout << "INF" << endl;
        }
        else cout << Score[i] << endl;
    }
}


Measured memory_bytes: 29892
#include <iostream>
#include <vector>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,q) for(int i = 0; q > i; i++)

int main(){
  int n;
  cin >> n;
  bool ok = false;
  int m = 2;
  while(n*2 >= m * (m+1)){
    if(m*(m+1) == n*2){
      ok = true;
      break;
    } else {
      m++;
    }
  }
  if(ok){
    cout << "Yes" << endl;
    cout << m+1 << endl;
    int DD[n * 2 / m][n * 2 / m];
    for(int i = 0; m > i; i++) DD[0][i] = i + 1;
    int mx = DD[0][m-1]+1;
    for(int i = 0; m+1 > i; i++){
      cout << n * 2 / m - 1;
      for(int j = 0; n * 2 / m - 1 > j; j++){
        cout << " ";
        if(i == 0){
          cout << DD[0][j];
        } else {
          if(i > j){
            cout << DD[j][i-1];
            DD[i][j] == DD[j][i-1];
          }else{
            cout << mx;
            DD[i][j] = mx;
            mx++;
          }
        }
      }
      cout << endl;
    }
  } else if(n == 1){
    cout << "Yes" << endl;
    cout << "2" << endl;
    cout << "1 1" << endl;
    cout << "1 1" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

    int a[26] = {};
    for (int i = 0; i < 26; i++) {
        a[i] = 50;
    }

    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;

        int b[26] = {};
        for (int j = 0; j < s.size(); j++) {
            b[s[j] - 'a']++;
        }

        for (int j = 0; j < 26; j++) {
            a[j] = min(a[j], b[j]);
        }
    }

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < a[i]; j++) {
            cout << (char)('a' + i);
        }
    }

    cout << endl;

    return 0;
}


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

int n,x;

int main(void){
    cin >> n >> x;
    string s;
    int l[n];
    for(int i=0;i<n;i++) cin >> l[i];

    int d = 0;
    int ans = 1;
    for(int i=0;i<n;i++){
        d = d+l[i];
        if(d > x) break;
        ans++;

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
p = p[:x]
q.sort(reverse=True)
q = q[:y]
r.sort(reverse=True)
apples = p + q + r
apples.sort(reverse=True)
ans = sum(apples[:x+y])

print(ans)


Measured memory_bytes: 112108
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int N, M, C;
	cin >> N >> M >> C;

	//長さMの配列を作る。要素を0で初期化する
	vector<int> B(M, 0);
	for (int i = 0; i < M; i++)
	{
		cin >> B[i];
	}

	//N×Mの配列を作る
	//Aは、vector<int>の長さNの配列
	//これを、vector<int>(M)で初期化（長さMの配列）
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> A[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int sum = 0;
		for (int j = 0; j < M; j++)
		{
			sum += A[i][j] * B[j];
		}
		sum += C;
		if (sum > 0) ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        double[] a = new double[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextDouble();
        }
        double ans = 0;
        for (int i = 0; i < n; i++) {
            ans += (1 / a[i]);
        }
        ans = 1 / ans;

        System.out.printf("%.5f%n", ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, w, num, c, a, M = 1e9 + 7, v[N], fc[N], iv[N];
ll po(ll p, ll q) {
	ll u = 1;
	for (;q; q /= 2, p = (p * p) % M) {
		if (q % 2) u = (u * p) % M;
	}
	return u;
}
int main()
{
	ll i, j;
	cin >> n;
	n++;
	for (i = 1; i <= n; i++) {
		scanf ("%lld", &a);
		if (v[a] != 0) w = i - v[a] + 1;
		v[a] = i;
	}
	fc[0] = 1;
	fc[1] = 1;
	for (i = 2; i <= n; i++) fc[i] = (fc[i - 1] * i) % M;
	iv[n] = po(fc[n], M - 2);
	for (i = n - 1; i >= 0; i--) {
		iv[i] = (iv[i + 1] * (i + 1)) % M;
	}
	cout << n - 1 << endl;
	for (i = 2; i <= n; i++) {
		num = ((fc[n] * iv[i]) % M * iv[n - i]) % M;
		if (n - w >= i - 1) {
			c = ((fc[n - w] * iv[i - 1]) % M * iv[n - w - i + 1]) % M;
		} else c = 0;
		num = (num - c + M) % M;
		printf("%lld\n", num);
	}
    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.nextLine();
		String T = in.nextLine();
		String[] S_arr = S.split("");
		String[] T_arr = T.split("");
		int total = 0;
		for (int i = 0; i<3;i++) {
			if(S_arr[i].compareTo(T_arr[i]) == 0) {
				total++;
			}
		
		}
		System.out.println(total);

	}

}


Measured memory_bytes: 21204
N = int(input())

a = list(map(int, input().split()))

ans = 1

now = a[0]

f = 0

for i in range(1, N):
    if now == a[i]:
        now = a[i]
    elif a[i]>now:
        if f == 0:
            f = 1
            now = a[i]
        elif f == 1:
            now = a[i]
        else:
            f = 0
            ans = ans + 1
            now = a[i]
    else:
        if f == 0:
            f = -1
            now = a[i]
        elif f == -1:
            now = a[i]
        else:
            f = 0
            ans = ans + 1
            now = a[i]

        

    
print(ans)

Measured memory_bytes: 14436
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = IntStream.range(0, n).mapToLong(i -> scanner.nextLong()).toArray();
			long[] sum = new long[n];
			sum[0] = a[0];
			IntStream.range(1, n).forEach(i -> sum[i] = (sum[i - 1] + a[i]) % MOD);
			long answer = 0L;
			for (int i = 0; i < n - 1; i++) {
				answer = (answer + a[i] * (sum[n - 1] - sum[i]) % MOD) % MOD;
			}
			System.out.println((answer + MOD) % MOD);
		}
	}
}


Measured memory_bytes: 62216
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n){
    cin>>t[i]>>x[i]>>y[i];
  }
  rep(i,n){
    int l;
    if(i==0){
      l=x[i]+y[i];
      if(l<=t[i]){
        if((t[i]-l)%2!=0){
          cout<<"No"<<endl;
          return 0;
        }
      }else{
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      l=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
      if(l<=t[i]-t[i-1]){
        if((t[i]-t[i-1]-l)%2!=0){
          cout<<"No"<<endl;
          return 0;
        }
      }else{
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
//使い方　インスタンス化(頂点数)　uniteつなぐ(双方向注意) same判定
int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < 4;i++){
        cout << s[i];
    }
    cout << " ";
    for (int i = 5; i < 13;i++){
        cout << s[i-1];
    }
    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        B[i] -= A[i]
        ans += A[i]
        if A[i+1] >= B[i]:
            A[i+1] -= B[i]
            ans += B[i]
        else:
            ans += A[i+1]
            A[i+1] = 0
print(ans)

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

using namespace std;
using ll = long long;
const int maxn = 1e5 + 14;

const int mod = 1e9 + 7;

ll dp[maxn][13];
int n;
string s;

long long binpow(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;
}

int solve(int idx, int rem){
    if (idx == n){
        if (rem == 5){
            return 1;
        }
        return 0;
    }
    if (dp[idx][rem] != -1) return dp[idx][rem];
    ll ans = 0;
    if (s[idx] != '?'){
        ans += solve(idx + 1, (rem + (s[idx] - '0') * binpow(10, n - idx - 1, 13)) % 13);
        ans %= mod;
    }
    else {
        for (int i = 0; i <= 9; i++){
            ans += solve(idx + 1, (rem + i * binpow(10, n - idx - 1, 13)) % 13);
            ans %= mod;
        }
    }
    return dp[idx][rem] = ans;
}

int main()
{
    cin >> s;
    n = s.length();
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 18432
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            int[] arr=new int[n];
            int ans=0;
            for(int i=0;i<n;i++){
                arr[i]=scan.nextInt();
                if ((i+1) % 2 != 0 && arr[i] % 2 != 0) {
                    ans++;
                }
            }
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 32464
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long
lli M=1e9+7;
 
#define MAXN  10000001 
lli power(lli x, lli y)  
{  
    lli res = 1;     // Initialize result  
  
    x = x % M; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % M;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % M;  
    }  
    return res;  
}
lli modInverse(int a, int m) 
{ 
    return power(a,m-2);
} 
 
int main()
{
    lli q=1;
    // cin>>q;
    time_t start, end;
    time(&start);
    for(lli tc=1;tc<=q;tc++)
    {
        lli n;
        string s;
        cin>>n;
        cin>>s;
        lli ans=1;
        lli d = power(26,n);
        lli f[n+1];
        f[0]=1;
        lli k = s.length();
        for(int i=1;i<=n;i++)
        {
            f[i] = ((f[i-1]*(i+k-1))%M*modInverse(i,M))%M;
        }
        ans = d;
        lli x = modInverse(26,M);
        for(int i=0;i<n;i++)
        {
            d = ((d*25)%M*x)%M;
            ans = (ans + (f[i+1]*d)%M)%M;
        }
        cout<<ans<<endl;
    }
    
    time(&end);
    //cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
    return 0;
}

Measured memory_bytes: 12072
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    vector<char> c(N);
    int red = 0;
    REP(i, N) {
        cin >> c[i];
        if (c[i] == 'R') red++;
    }
    
    int red_light = 0;
    // int red_light = 0;
    for(int i = 0; i < red; i++) {
        if (c[i] == 'R') red_light++;
    }


    cout << red - red_light << endl;

   return 0;
}   

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
bool ice[90][90];
int n,m;
int di[]={0,-1,0,1},dj[]={1,0,-1,0};

int serch(int now,int i,int j)
{
	int ans=0;
	ice[i][j]=0;
	for(int k=0;k<4;k++)if(i+di[k]>-1&&i+di[k]<m&&j+dj[k]>-1&&j+dj[k]<n&&ice[i+di[k]][j+dj[k]])ans=max(ans,serch(now+1,i+di[k],j+dj[k]));
	ice[i][j]=1;
	return max(ans,now);
}

int main() {
	while(cin>>n>>m,n,m){
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++)cin>>ice[i][j];
		}
		int ans=0;
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(ice[i][j]==1)ans=max(ans,serch(1,i,j));
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1168
#include"bits/stdc++.h"
using namespace std;
#define int int64_t
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a,v,b,w,t;cin>>a>>v>>b>>w>>t;
    int dis=abs(a-b);
    int rel=v-w;
    if(rel>0)
    {
        int time=dis/rel;
        if(dis%rel!=0)
            time++;
        if(time<=t)
        {
            cout<<"YES\n";
            return 0;
        }
    }
    cout<<"NO\n";
    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26)cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------//
    vector<int> t(d);
    rep(i, d){cin >> t[i]; t[i]--;}
    int ans = 0;
    vector<int> last(26, 0);
    rep(i, d){
        ans += s[i][t[i]];
        int sum = 0;
        rep(j, 26){
            if(t[i] == j)last[j] = i+1;
            ans -= c[j] * ((i+1)-last[j]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3676